PageRenderTime 4ms CodeModel.GetById 3ms app.highlight 219ms RepoModel.GetById 2ms app.codeStats 0ms

/samples/client/wordnik-api/objc/client/NIKWordApi.m

https://github.com/sforce100/swagger-codegen
Objective C | 1088 lines | 815 code | 152 blank | 121 comment | 285 complexity | 0e351b9c9ad5b293632761ad430a8f62 MD5 | raw file
   1#import "NIKWordApi.h"
   2#import "NIKDefinition.h"
   3#import "NIKTextPron.h"
   4#import "NIKExample.h"
   5#import "NIKSyllable.h"
   6#import "NIKAudioFile.h"
   7#import "NIKExampleSearchResults.h"
   8#import "NIKWordObject.h"
   9#import "NIKBigram.h"
  10#import "NIKRelated.h"
  11#import "NIKFrequencySummary.h"
  12
  13
  14
  15@implementation NIKWordApi
  16static NSString * basePath = @"http://api.wordnik.com/v4";
  17
  18@synthesize queue = _queue;
  19@synthesize api = _api;
  20
  21- (id) init {
  22    self = [super init];
  23    _queue = [[NSOperationQueue alloc] init];
  24    _api = [[NIKApiInvoker alloc] init];
  25
  26    return self;
  27}
  28
  29-(void) addHeader:(NSString*) value
  30           forKey:(NSString*)key {
  31    [_api addHeader:value forKey:key];
  32}
  33
  34/**
  35 * 
  36 * returnTypeIsPrimitive: 
  37 * returnBaseType: NIKExampleSearchResults
  38 * returnContainer: 
  39 * 
  40 **/
  41-(void) getExamplesWithCompletionBlock :(NSString*) word includeDuplicates:(NSString*) includeDuplicates useCanonical:(NSString*) useCanonical skip:(NSNumber*) skip limit:(NSNumber*) limit 
  42        completionHandler:(void (^)(NIKExampleSearchResults*, NSError *))completionBlock{
  43
  44    NSMutableString* requestUrl = [NSMutableString stringWithFormat:@"%@/word.{format}/{word}/examples", basePath];
  45
  46    // remove format in URL if needed
  47    if ([requestUrl rangeOfString:@".{format}"].location != NSNotFound)
  48        [requestUrl replaceCharactersInRange: [requestUrl rangeOfString:@".{format}"] withString:@".json"];
  49
  50    [requestUrl replaceCharactersInRange: [requestUrl rangeOfString:[NSString stringWithFormat:@"%@%@%@", @"{", @"word", @"}"]] withString: [_api escapeString:word]];
  51    NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init];
  52    if(includeDuplicates != nil)
  53        [queryParams setValue:includeDuplicates forKey:@"includeDuplicates"];
  54    if(useCanonical != nil)
  55        [queryParams setValue:useCanonical forKey:@"useCanonical"];
  56    if(skip != nil)
  57        [queryParams setValue:skip forKey:@"skip"];
  58    if(limit != nil)
  59        [queryParams setValue:limit forKey:@"limit"];
  60    NSMutableDictionary* headerParams = [[NSMutableDictionary alloc] init];
  61    id bodyDictionary = nil;
  62        if(word == nil) {
  63        // error
  64    }
  65    [_api dictionaryWithCompletionBlock: requestUrl 
  66                                 method: @"GET" 
  67                            queryParams: queryParams 
  68                                   body: bodyDictionary 
  69                           headerParams: headerParams
  70                      completionHandler: ^(NSDictionary *data, NSError *error) {
  71        if (error) {
  72            completionBlock(nil, error);return;
  73        }
  74        
  75        completionBlock( [[NIKExampleSearchResults alloc]initWithValues: data], nil);}];
  76    
  77}
  78
  79/**
  80 * 
  81 * returnTypeIsPrimitive: 
  82 * returnBaseType: NIKWordObject
  83 * returnContainer: 
  84 * 
  85 **/
  86-(void) getWordWithCompletionBlock :(NSString*) word useCanonical:(NSString*) useCanonical includeSuggestions:(NSString*) includeSuggestions 
  87        completionHandler:(void (^)(NIKWordObject*, NSError *))completionBlock{
  88
  89    NSMutableString* requestUrl = [NSMutableString stringWithFormat:@"%@/word.{format}/{word}", basePath];
  90
  91    // remove format in URL if needed
  92    if ([requestUrl rangeOfString:@".{format}"].location != NSNotFound)
  93        [requestUrl replaceCharactersInRange: [requestUrl rangeOfString:@".{format}"] withString:@".json"];
  94
  95    [requestUrl replaceCharactersInRange: [requestUrl rangeOfString:[NSString stringWithFormat:@"%@%@%@", @"{", @"word", @"}"]] withString: [_api escapeString:word]];
  96    NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init];
  97    if(useCanonical != nil)
  98        [queryParams setValue:useCanonical forKey:@"useCanonical"];
  99    if(includeSuggestions != nil)
 100        [queryParams setValue:includeSuggestions forKey:@"includeSuggestions"];
 101    NSMutableDictionary* headerParams = [[NSMutableDictionary alloc] init];
 102    id bodyDictionary = nil;
 103        if(word == nil) {
 104        // error
 105    }
 106    [_api dictionaryWithCompletionBlock: requestUrl 
 107                                 method: @"GET" 
 108                            queryParams: queryParams 
 109                                   body: bodyDictionary 
 110                           headerParams: headerParams
 111                      completionHandler: ^(NSDictionary *data, NSError *error) {
 112        if (error) {
 113            completionBlock(nil, error);return;
 114        }
 115        
 116        completionBlock( [[NIKWordObject alloc]initWithValues: data], nil);}];
 117    
 118}
 119
 120/**
 121 * 
 122 * returnTypeIsPrimitive: 
 123 * returnBaseType: NIKDefinition
 124 * returnContainer: List
 125 * 
 126 **/
 127-(void) getDefinitionsWithCompletionBlock :(NSString*) word partOfSpeech:(NSString*) partOfSpeech sourceDictionaries:(NSString*) sourceDictionaries limit:(NSNumber*) limit includeRelated:(NSString*) includeRelated useCanonical:(NSString*) useCanonical includeTags:(NSString*) includeTags 
 128        completionHandler:(void (^)(NSArray*, NSError *))completionBlock{
 129
 130    NSMutableString* requestUrl = [NSMutableString stringWithFormat:@"%@/word.{format}/{word}/definitions", basePath];
 131
 132    // remove format in URL if needed
 133    if ([requestUrl rangeOfString:@".{format}"].location != NSNotFound)
 134        [requestUrl replaceCharactersInRange: [requestUrl rangeOfString:@".{format}"] withString:@".json"];
 135
 136    [requestUrl replaceCharactersInRange: [requestUrl rangeOfString:[NSString stringWithFormat:@"%@%@%@", @"{", @"word", @"}"]] withString: [_api escapeString:word]];
 137    NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init];
 138    if(limit != nil)
 139        [queryParams setValue:limit forKey:@"limit"];
 140    if(partOfSpeech != nil)
 141        [queryParams setValue:partOfSpeech forKey:@"partOfSpeech"];
 142    if(includeRelated != nil)
 143        [queryParams setValue:includeRelated forKey:@"includeRelated"];
 144    if(sourceDictionaries != nil)
 145        [queryParams setValue:sourceDictionaries forKey:@"sourceDictionaries"];
 146    if(useCanonical != nil)
 147        [queryParams setValue:useCanonical forKey:@"useCanonical"];
 148    if(includeTags != nil)
 149        [queryParams setValue:includeTags forKey:@"includeTags"];
 150    NSMutableDictionary* headerParams = [[NSMutableDictionary alloc] init];
 151    id bodyDictionary = nil;
 152        if(word == nil) {
 153        // error
 154    }
 155    [_api dictionaryWithCompletionBlock: requestUrl 
 156                                 method: @"GET" 
 157                            queryParams: queryParams 
 158                                   body: bodyDictionary 
 159                           headerParams: headerParams
 160                      completionHandler: ^(NSDictionary *data, NSError *error) {
 161        if (error) {
 162            completionBlock(nil, error);return;
 163        }
 164        
 165        if([data isKindOfClass:[NSArray class]]){
 166            NSMutableArray * objs = [[NSMutableArray alloc] initWithCapacity:[data count]];
 167            for (NSDictionary* dict in (NSArray*)data) {
 168                NIKDefinition* d = [[NIKDefinition alloc]initWithValues: dict];
 169                [objs addObject:d];
 170            }
 171            completionBlock(objs, nil);
 172        }
 173        }];
 174    
 175}
 176
 177/**
 178 * 
 179 * returnTypeIsPrimitive: 
 180 * returnBaseType: NIKExample
 181 * returnContainer: 
 182 * 
 183 **/
 184-(void) getTopExampleWithCompletionBlock :(NSString*) word useCanonical:(NSString*) useCanonical 
 185        completionHandler:(void (^)(NIKExample*, NSError *))completionBlock{
 186
 187    NSMutableString* requestUrl = [NSMutableString stringWithFormat:@"%@/word.{format}/{word}/topExample", basePath];
 188
 189    // remove format in URL if needed
 190    if ([requestUrl rangeOfString:@".{format}"].location != NSNotFound)
 191        [requestUrl replaceCharactersInRange: [requestUrl rangeOfString:@".{format}"] withString:@".json"];
 192
 193    [requestUrl replaceCharactersInRange: [requestUrl rangeOfString:[NSString stringWithFormat:@"%@%@%@", @"{", @"word", @"}"]] withString: [_api escapeString:word]];
 194    NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init];
 195    if(useCanonical != nil)
 196        [queryParams setValue:useCanonical forKey:@"useCanonical"];
 197    NSMutableDictionary* headerParams = [[NSMutableDictionary alloc] init];
 198    id bodyDictionary = nil;
 199        if(word == nil) {
 200        // error
 201    }
 202    [_api dictionaryWithCompletionBlock: requestUrl 
 203                                 method: @"GET" 
 204                            queryParams: queryParams 
 205                                   body: bodyDictionary 
 206                           headerParams: headerParams
 207                      completionHandler: ^(NSDictionary *data, NSError *error) {
 208        if (error) {
 209            completionBlock(nil, error);return;
 210        }
 211        
 212        completionBlock( [[NIKExample alloc]initWithValues: data], nil);}];
 213    
 214}
 215
 216/**
 217 * 
 218 * returnTypeIsPrimitive: 
 219 * returnBaseType: NIKRelated
 220 * returnContainer: List
 221 * 
 222 **/
 223-(void) getRelatedWordsWithCompletionBlock :(NSString*) word relationshipTypes:(NSString*) relationshipTypes useCanonical:(NSString*) useCanonical limitPerRelationshipType:(NSNumber*) limitPerRelationshipType 
 224        completionHandler:(void (^)(NSArray*, NSError *))completionBlock{
 225
 226    NSMutableString* requestUrl = [NSMutableString stringWithFormat:@"%@/word.{format}/{word}/relatedWords", basePath];
 227
 228    // remove format in URL if needed
 229    if ([requestUrl rangeOfString:@".{format}"].location != NSNotFound)
 230        [requestUrl replaceCharactersInRange: [requestUrl rangeOfString:@".{format}"] withString:@".json"];
 231
 232    [requestUrl replaceCharactersInRange: [requestUrl rangeOfString:[NSString stringWithFormat:@"%@%@%@", @"{", @"word", @"}"]] withString: [_api escapeString:word]];
 233    NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init];
 234    if(useCanonical != nil)
 235        [queryParams setValue:useCanonical forKey:@"useCanonical"];
 236    if(relationshipTypes != nil)
 237        [queryParams setValue:relationshipTypes forKey:@"relationshipTypes"];
 238    if(limitPerRelationshipType != nil)
 239        [queryParams setValue:limitPerRelationshipType forKey:@"limitPerRelationshipType"];
 240    NSMutableDictionary* headerParams = [[NSMutableDictionary alloc] init];
 241    id bodyDictionary = nil;
 242        if(word == nil) {
 243        // error
 244    }
 245    [_api dictionaryWithCompletionBlock: requestUrl 
 246                                 method: @"GET" 
 247                            queryParams: queryParams 
 248                                   body: bodyDictionary 
 249                           headerParams: headerParams
 250                      completionHandler: ^(NSDictionary *data, NSError *error) {
 251        if (error) {
 252            completionBlock(nil, error);return;
 253        }
 254        
 255        if([data isKindOfClass:[NSArray class]]){
 256            NSMutableArray * objs = [[NSMutableArray alloc] initWithCapacity:[data count]];
 257            for (NSDictionary* dict in (NSArray*)data) {
 258                NIKRelated* d = [[NIKRelated alloc]initWithValues: dict];
 259                [objs addObject:d];
 260            }
 261            completionBlock(objs, nil);
 262        }
 263        }];
 264    
 265}
 266
 267/**
 268 * 
 269 * returnTypeIsPrimitive: 
 270 * returnBaseType: NIKTextPron
 271 * returnContainer: List
 272 * 
 273 **/
 274-(void) getTextPronunciationsWithCompletionBlock :(NSString*) word sourceDictionary:(NSString*) sourceDictionary typeFormat:(NSString*) typeFormat useCanonical:(NSString*) useCanonical limit:(NSNumber*) limit 
 275        completionHandler:(void (^)(NSArray*, NSError *))completionBlock{
 276
 277    NSMutableString* requestUrl = [NSMutableString stringWithFormat:@"%@/word.{format}/{word}/pronunciations", basePath];
 278
 279    // remove format in URL if needed
 280    if ([requestUrl rangeOfString:@".{format}"].location != NSNotFound)
 281        [requestUrl replaceCharactersInRange: [requestUrl rangeOfString:@".{format}"] withString:@".json"];
 282
 283    [requestUrl replaceCharactersInRange: [requestUrl rangeOfString:[NSString stringWithFormat:@"%@%@%@", @"{", @"word", @"}"]] withString: [_api escapeString:word]];
 284    NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init];
 285    if(useCanonical != nil)
 286        [queryParams setValue:useCanonical forKey:@"useCanonical"];
 287    if(sourceDictionary != nil)
 288        [queryParams setValue:sourceDictionary forKey:@"sourceDictionary"];
 289    if(typeFormat != nil)
 290        [queryParams setValue:typeFormat forKey:@"typeFormat"];
 291    if(limit != nil)
 292        [queryParams setValue:limit forKey:@"limit"];
 293    NSMutableDictionary* headerParams = [[NSMutableDictionary alloc] init];
 294    id bodyDictionary = nil;
 295        if(word == nil) {
 296        // error
 297    }
 298    [_api dictionaryWithCompletionBlock: requestUrl 
 299                                 method: @"GET" 
 300                            queryParams: queryParams 
 301                                   body: bodyDictionary 
 302                           headerParams: headerParams
 303                      completionHandler: ^(NSDictionary *data, NSError *error) {
 304        if (error) {
 305            completionBlock(nil, error);return;
 306        }
 307        
 308        if([data isKindOfClass:[NSArray class]]){
 309            NSMutableArray * objs = [[NSMutableArray alloc] initWithCapacity:[data count]];
 310            for (NSDictionary* dict in (NSArray*)data) {
 311                NIKTextPron* d = [[NIKTextPron alloc]initWithValues: dict];
 312                [objs addObject:d];
 313            }
 314            completionBlock(objs, nil);
 315        }
 316        }];
 317    
 318}
 319
 320/**
 321 * 
 322 * returnTypeIsPrimitive: 
 323 * returnBaseType: NIKSyllable
 324 * returnContainer: List
 325 * 
 326 **/
 327-(void) getHyphenationWithCompletionBlock :(NSString*) word sourceDictionary:(NSString*) sourceDictionary useCanonical:(NSString*) useCanonical limit:(NSNumber*) limit 
 328        completionHandler:(void (^)(NSArray*, NSError *))completionBlock{
 329
 330    NSMutableString* requestUrl = [NSMutableString stringWithFormat:@"%@/word.{format}/{word}/hyphenation", basePath];
 331
 332    // remove format in URL if needed
 333    if ([requestUrl rangeOfString:@".{format}"].location != NSNotFound)
 334        [requestUrl replaceCharactersInRange: [requestUrl rangeOfString:@".{format}"] withString:@".json"];
 335
 336    [requestUrl replaceCharactersInRange: [requestUrl rangeOfString:[NSString stringWithFormat:@"%@%@%@", @"{", @"word", @"}"]] withString: [_api escapeString:word]];
 337    NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init];
 338    if(useCanonical != nil)
 339        [queryParams setValue:useCanonical forKey:@"useCanonical"];
 340    if(sourceDictionary != nil)
 341        [queryParams setValue:sourceDictionary forKey:@"sourceDictionary"];
 342    if(limit != nil)
 343        [queryParams setValue:limit forKey:@"limit"];
 344    NSMutableDictionary* headerParams = [[NSMutableDictionary alloc] init];
 345    id bodyDictionary = nil;
 346        if(word == nil) {
 347        // error
 348    }
 349    [_api dictionaryWithCompletionBlock: requestUrl 
 350                                 method: @"GET" 
 351                            queryParams: queryParams 
 352                                   body: bodyDictionary 
 353                           headerParams: headerParams
 354                      completionHandler: ^(NSDictionary *data, NSError *error) {
 355        if (error) {
 356            completionBlock(nil, error);return;
 357        }
 358        
 359        if([data isKindOfClass:[NSArray class]]){
 360            NSMutableArray * objs = [[NSMutableArray alloc] initWithCapacity:[data count]];
 361            for (NSDictionary* dict in (NSArray*)data) {
 362                NIKSyllable* d = [[NIKSyllable alloc]initWithValues: dict];
 363                [objs addObject:d];
 364            }
 365            completionBlock(objs, nil);
 366        }
 367        }];
 368    
 369}
 370
 371/**
 372 * 
 373 * returnTypeIsPrimitive: 
 374 * returnBaseType: NIKFrequencySummary
 375 * returnContainer: 
 376 * 
 377 **/
 378-(void) getWordFrequencyWithCompletionBlock :(NSString*) word useCanonical:(NSString*) useCanonical startYear:(NSNumber*) startYear endYear:(NSNumber*) endYear 
 379        completionHandler:(void (^)(NIKFrequencySummary*, NSError *))completionBlock{
 380
 381    NSMutableString* requestUrl = [NSMutableString stringWithFormat:@"%@/word.{format}/{word}/frequency", basePath];
 382
 383    // remove format in URL if needed
 384    if ([requestUrl rangeOfString:@".{format}"].location != NSNotFound)
 385        [requestUrl replaceCharactersInRange: [requestUrl rangeOfString:@".{format}"] withString:@".json"];
 386
 387    [requestUrl replaceCharactersInRange: [requestUrl rangeOfString:[NSString stringWithFormat:@"%@%@%@", @"{", @"word", @"}"]] withString: [_api escapeString:word]];
 388    NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init];
 389    if(useCanonical != nil)
 390        [queryParams setValue:useCanonical forKey:@"useCanonical"];
 391    if(startYear != nil)
 392        [queryParams setValue:startYear forKey:@"startYear"];
 393    if(endYear != nil)
 394        [queryParams setValue:endYear forKey:@"endYear"];
 395    NSMutableDictionary* headerParams = [[NSMutableDictionary alloc] init];
 396    id bodyDictionary = nil;
 397        if(word == nil) {
 398        // error
 399    }
 400    [_api dictionaryWithCompletionBlock: requestUrl 
 401                                 method: @"GET" 
 402                            queryParams: queryParams 
 403                                   body: bodyDictionary 
 404                           headerParams: headerParams
 405                      completionHandler: ^(NSDictionary *data, NSError *error) {
 406        if (error) {
 407            completionBlock(nil, error);return;
 408        }
 409        
 410        completionBlock( [[NIKFrequencySummary alloc]initWithValues: data], nil);}];
 411    
 412}
 413
 414/**
 415 * 
 416 * returnTypeIsPrimitive: 
 417 * returnBaseType: NIKBigram
 418 * returnContainer: List
 419 * 
 420 **/
 421-(void) getPhrasesWithCompletionBlock :(NSString*) word limit:(NSNumber*) limit wlmi:(NSNumber*) wlmi useCanonical:(NSString*) useCanonical 
 422        completionHandler:(void (^)(NSArray*, NSError *))completionBlock{
 423
 424    NSMutableString* requestUrl = [NSMutableString stringWithFormat:@"%@/word.{format}/{word}/phrases", basePath];
 425
 426    // remove format in URL if needed
 427    if ([requestUrl rangeOfString:@".{format}"].location != NSNotFound)
 428        [requestUrl replaceCharactersInRange: [requestUrl rangeOfString:@".{format}"] withString:@".json"];
 429
 430    [requestUrl replaceCharactersInRange: [requestUrl rangeOfString:[NSString stringWithFormat:@"%@%@%@", @"{", @"word", @"}"]] withString: [_api escapeString:word]];
 431    NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init];
 432    if(limit != nil)
 433        [queryParams setValue:limit forKey:@"limit"];
 434    if(wlmi != nil)
 435        [queryParams setValue:wlmi forKey:@"wlmi"];
 436    if(useCanonical != nil)
 437        [queryParams setValue:useCanonical forKey:@"useCanonical"];
 438    NSMutableDictionary* headerParams = [[NSMutableDictionary alloc] init];
 439    id bodyDictionary = nil;
 440        if(word == nil) {
 441        // error
 442    }
 443    [_api dictionaryWithCompletionBlock: requestUrl 
 444                                 method: @"GET" 
 445                            queryParams: queryParams 
 446                                   body: bodyDictionary 
 447                           headerParams: headerParams
 448                      completionHandler: ^(NSDictionary *data, NSError *error) {
 449        if (error) {
 450            completionBlock(nil, error);return;
 451        }
 452        
 453        if([data isKindOfClass:[NSArray class]]){
 454            NSMutableArray * objs = [[NSMutableArray alloc] initWithCapacity:[data count]];
 455            for (NSDictionary* dict in (NSArray*)data) {
 456                NIKBigram* d = [[NIKBigram alloc]initWithValues: dict];
 457                [objs addObject:d];
 458            }
 459            completionBlock(objs, nil);
 460        }
 461        }];
 462    
 463}
 464
 465/**
 466 * 
 467 * returnTypeIsPrimitive: true
 468 * returnBaseType: NSString
 469 * returnContainer: List
 470 * 
 471 **/
 472-(void) getEtymologiesWithCompletionBlock :(NSString*) word useCanonical:(NSString*) useCanonical 
 473        completionHandler:(void (^)(NSArray*, NSError *))completionBlock{
 474
 475    NSMutableString* requestUrl = [NSMutableString stringWithFormat:@"%@/word.{format}/{word}/etymologies", basePath];
 476
 477    // remove format in URL if needed
 478    if ([requestUrl rangeOfString:@".{format}"].location != NSNotFound)
 479        [requestUrl replaceCharactersInRange: [requestUrl rangeOfString:@".{format}"] withString:@".json"];
 480
 481    [requestUrl replaceCharactersInRange: [requestUrl rangeOfString:[NSString stringWithFormat:@"%@%@%@", @"{", @"word", @"}"]] withString: [_api escapeString:word]];
 482    NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init];
 483    if(useCanonical != nil)
 484        [queryParams setValue:useCanonical forKey:@"useCanonical"];
 485    NSMutableDictionary* headerParams = [[NSMutableDictionary alloc] init];
 486    id bodyDictionary = nil;
 487        if(word == nil) {
 488        // error
 489    }
 490    [_api dictionaryWithCompletionBlock: requestUrl 
 491                                 method: @"GET" 
 492                            queryParams: queryParams 
 493                                   body: bodyDictionary 
 494                           headerParams: headerParams
 495                      completionHandler: ^(NSDictionary *data, NSError *error) {
 496        if (error) {
 497            completionBlock(nil, error);return;
 498        }
 499        
 500        if([data isKindOfClass:[NSArray class]]){
 501            NSMutableArray * objs = [[NSMutableArray alloc] initWithCapacity:[data count]];
 502            for (NSDictionary* dict in (NSArray*)data) {
 503                NSString* d = [[NSString alloc]initWithString: data];
 504                [objs addObject:d];
 505            }
 506            completionBlock(objs, nil);
 507        }
 508        }];
 509    
 510}
 511
 512/**
 513 * 
 514 * returnTypeIsPrimitive: 
 515 * returnBaseType: NIKAudioFile
 516 * returnContainer: List
 517 * 
 518 **/
 519-(void) getAudioWithCompletionBlock :(NSString*) word useCanonical:(NSString*) useCanonical limit:(NSNumber*) limit 
 520        completionHandler:(void (^)(NSArray*, NSError *))completionBlock{
 521
 522    NSMutableString* requestUrl = [NSMutableString stringWithFormat:@"%@/word.{format}/{word}/audio", basePath];
 523
 524    // remove format in URL if needed
 525    if ([requestUrl rangeOfString:@".{format}"].location != NSNotFound)
 526        [requestUrl replaceCharactersInRange: [requestUrl rangeOfString:@".{format}"] withString:@".json"];
 527
 528    [requestUrl replaceCharactersInRange: [requestUrl rangeOfString:[NSString stringWithFormat:@"%@%@%@", @"{", @"word", @"}"]] withString: [_api escapeString:word]];
 529    NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init];
 530    if(useCanonical != nil)
 531        [queryParams setValue:useCanonical forKey:@"useCanonical"];
 532    if(limit != nil)
 533        [queryParams setValue:limit forKey:@"limit"];
 534    NSMutableDictionary* headerParams = [[NSMutableDictionary alloc] init];
 535    id bodyDictionary = nil;
 536        if(word == nil) {
 537        // error
 538    }
 539    [_api dictionaryWithCompletionBlock: requestUrl 
 540                                 method: @"GET" 
 541                            queryParams: queryParams 
 542                                   body: bodyDictionary 
 543                           headerParams: headerParams
 544                      completionHandler: ^(NSDictionary *data, NSError *error) {
 545        if (error) {
 546            completionBlock(nil, error);return;
 547        }
 548        
 549        if([data isKindOfClass:[NSArray class]]){
 550            NSMutableArray * objs = [[NSMutableArray alloc] initWithCapacity:[data count]];
 551            for (NSDictionary* dict in (NSArray*)data) {
 552                NIKAudioFile* d = [[NIKAudioFile alloc]initWithValues: dict];
 553                [objs addObject:d];
 554            }
 555            completionBlock(objs, nil);
 556        }
 557        }];
 558    
 559}
 560
 561-(void) getExamplesAsJsonWithCompletionBlock :(NSString*) word includeDuplicates:(NSString*) includeDuplicates useCanonical:(NSString*) useCanonical skip:(NSNumber*) skip limit:(NSNumber*) limit 
 562        completionHandler:(void (^)(NSString*, NSError *))completionBlock{
 563
 564    NSMutableString* requestUrl = [NSMutableString stringWithFormat:@"%@/word.{format}/{word}/examples", basePath];
 565
 566    // remove format in URL if needed
 567    if ([requestUrl rangeOfString:@".{format}"].location != NSNotFound)
 568        [requestUrl replaceCharactersInRange: [requestUrl rangeOfString:@".{format}"] withString:@""];
 569
 570    [requestUrl replaceCharactersInRange: [requestUrl rangeOfString:[NSString stringWithFormat:@"%@%@%@", @"{", @"word", @"}"]] withString: [_api escapeString:word]];
 571    NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init];
 572    if(includeDuplicates != nil)
 573        [queryParams setValue:includeDuplicates forKey:@"includeDuplicates"];
 574    if(useCanonical != nil)
 575        [queryParams setValue:useCanonical forKey:@"useCanonical"];
 576    if(skip != nil)
 577        [queryParams setValue:skip forKey:@"skip"];
 578    if(limit != nil)
 579        [queryParams setValue:limit forKey:@"limit"];
 580    NSMutableDictionary* headerParams = [[NSMutableDictionary alloc] init];
 581    id bodyDictionary = nil;
 582    if(word == nil) {
 583        // error
 584    }
 585    [_api dictionaryWithCompletionBlock: requestUrl 
 586                                 method: @"GET" 
 587                            queryParams: queryParams 
 588                                   body: bodyDictionary 
 589                           headerParams: headerParams
 590                      completionHandler: ^(NSDictionary *data, NSError *error) {
 591        if (error) {
 592            completionBlock(nil, error);return;
 593        }
 594
 595        NSData * responseData = nil;
 596            if([data isKindOfClass:[NSDictionary class]]){
 597                responseData = [NSJSONSerialization dataWithJSONObject:data
 598                                                               options:kNilOptions error:&error];
 599            }
 600            else if ([data isKindOfClass:[NSArray class]]){
 601                responseData = [NSJSONSerialization dataWithJSONObject:data
 602                                                               options:kNilOptions error:&error];
 603            }
 604            NSString * json = [[NSString alloc]initWithData:responseData encoding:NSUTF8StringEncoding];
 605            completionBlock(json, nil);
 606        
 607    }];
 608
 609}
 610
 611-(void) getWordAsJsonWithCompletionBlock :(NSString*) word useCanonical:(NSString*) useCanonical includeSuggestions:(NSString*) includeSuggestions 
 612        completionHandler:(void (^)(NSString*, NSError *))completionBlock{
 613
 614    NSMutableString* requestUrl = [NSMutableString stringWithFormat:@"%@/word.{format}/{word}", basePath];
 615
 616    // remove format in URL if needed
 617    if ([requestUrl rangeOfString:@".{format}"].location != NSNotFound)
 618        [requestUrl replaceCharactersInRange: [requestUrl rangeOfString:@".{format}"] withString:@""];
 619
 620    [requestUrl replaceCharactersInRange: [requestUrl rangeOfString:[NSString stringWithFormat:@"%@%@%@", @"{", @"word", @"}"]] withString: [_api escapeString:word]];
 621    NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init];
 622    if(useCanonical != nil)
 623        [queryParams setValue:useCanonical forKey:@"useCanonical"];
 624    if(includeSuggestions != nil)
 625        [queryParams setValue:includeSuggestions forKey:@"includeSuggestions"];
 626    NSMutableDictionary* headerParams = [[NSMutableDictionary alloc] init];
 627    id bodyDictionary = nil;
 628    if(word == nil) {
 629        // error
 630    }
 631    [_api dictionaryWithCompletionBlock: requestUrl 
 632                                 method: @"GET" 
 633                            queryParams: queryParams 
 634                                   body: bodyDictionary 
 635                           headerParams: headerParams
 636                      completionHandler: ^(NSDictionary *data, NSError *error) {
 637        if (error) {
 638            completionBlock(nil, error);return;
 639        }
 640
 641        NSData * responseData = nil;
 642            if([data isKindOfClass:[NSDictionary class]]){
 643                responseData = [NSJSONSerialization dataWithJSONObject:data
 644                                                               options:kNilOptions error:&error];
 645            }
 646            else if ([data isKindOfClass:[NSArray class]]){
 647                responseData = [NSJSONSerialization dataWithJSONObject:data
 648                                                               options:kNilOptions error:&error];
 649            }
 650            NSString * json = [[NSString alloc]initWithData:responseData encoding:NSUTF8StringEncoding];
 651            completionBlock(json, nil);
 652        
 653    }];
 654
 655}
 656
 657-(void) getDefinitionsAsJsonWithCompletionBlock :(NSString*) word partOfSpeech:(NSString*) partOfSpeech sourceDictionaries:(NSString*) sourceDictionaries limit:(NSNumber*) limit includeRelated:(NSString*) includeRelated useCanonical:(NSString*) useCanonical includeTags:(NSString*) includeTags 
 658        completionHandler:(void (^)(NSString*, NSError *))completionBlock{
 659
 660    NSMutableString* requestUrl = [NSMutableString stringWithFormat:@"%@/word.{format}/{word}/definitions", basePath];
 661
 662    // remove format in URL if needed
 663    if ([requestUrl rangeOfString:@".{format}"].location != NSNotFound)
 664        [requestUrl replaceCharactersInRange: [requestUrl rangeOfString:@".{format}"] withString:@""];
 665
 666    [requestUrl replaceCharactersInRange: [requestUrl rangeOfString:[NSString stringWithFormat:@"%@%@%@", @"{", @"word", @"}"]] withString: [_api escapeString:word]];
 667    NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init];
 668    if(limit != nil)
 669        [queryParams setValue:limit forKey:@"limit"];
 670    if(partOfSpeech != nil)
 671        [queryParams setValue:partOfSpeech forKey:@"partOfSpeech"];
 672    if(includeRelated != nil)
 673        [queryParams setValue:includeRelated forKey:@"includeRelated"];
 674    if(sourceDictionaries != nil)
 675        [queryParams setValue:sourceDictionaries forKey:@"sourceDictionaries"];
 676    if(useCanonical != nil)
 677        [queryParams setValue:useCanonical forKey:@"useCanonical"];
 678    if(includeTags != nil)
 679        [queryParams setValue:includeTags forKey:@"includeTags"];
 680    NSMutableDictionary* headerParams = [[NSMutableDictionary alloc] init];
 681    id bodyDictionary = nil;
 682    if(word == nil) {
 683        // error
 684    }
 685    [_api dictionaryWithCompletionBlock: requestUrl 
 686                                 method: @"GET" 
 687                            queryParams: queryParams 
 688                                   body: bodyDictionary 
 689                           headerParams: headerParams
 690                      completionHandler: ^(NSDictionary *data, NSError *error) {
 691        if (error) {
 692            completionBlock(nil, error);return;
 693        }
 694
 695        NSData * responseData = nil;
 696            if([data isKindOfClass:[NSDictionary class]]){
 697                responseData = [NSJSONSerialization dataWithJSONObject:data
 698                                                               options:kNilOptions error:&error];
 699            }
 700            else if ([data isKindOfClass:[NSArray class]]){
 701                responseData = [NSJSONSerialization dataWithJSONObject:data
 702                                                               options:kNilOptions error:&error];
 703            }
 704            NSString * json = [[NSString alloc]initWithData:responseData encoding:NSUTF8StringEncoding];
 705            completionBlock(json, nil);
 706        
 707    }];
 708
 709}
 710
 711-(void) getTopExampleAsJsonWithCompletionBlock :(NSString*) word useCanonical:(NSString*) useCanonical 
 712        completionHandler:(void (^)(NSString*, NSError *))completionBlock{
 713
 714    NSMutableString* requestUrl = [NSMutableString stringWithFormat:@"%@/word.{format}/{word}/topExample", basePath];
 715
 716    // remove format in URL if needed
 717    if ([requestUrl rangeOfString:@".{format}"].location != NSNotFound)
 718        [requestUrl replaceCharactersInRange: [requestUrl rangeOfString:@".{format}"] withString:@""];
 719
 720    [requestUrl replaceCharactersInRange: [requestUrl rangeOfString:[NSString stringWithFormat:@"%@%@%@", @"{", @"word", @"}"]] withString: [_api escapeString:word]];
 721    NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init];
 722    if(useCanonical != nil)
 723        [queryParams setValue:useCanonical forKey:@"useCanonical"];
 724    NSMutableDictionary* headerParams = [[NSMutableDictionary alloc] init];
 725    id bodyDictionary = nil;
 726    if(word == nil) {
 727        // error
 728    }
 729    [_api dictionaryWithCompletionBlock: requestUrl 
 730                                 method: @"GET" 
 731                            queryParams: queryParams 
 732                                   body: bodyDictionary 
 733                           headerParams: headerParams
 734                      completionHandler: ^(NSDictionary *data, NSError *error) {
 735        if (error) {
 736            completionBlock(nil, error);return;
 737        }
 738
 739        NSData * responseData = nil;
 740            if([data isKindOfClass:[NSDictionary class]]){
 741                responseData = [NSJSONSerialization dataWithJSONObject:data
 742                                                               options:kNilOptions error:&error];
 743            }
 744            else if ([data isKindOfClass:[NSArray class]]){
 745                responseData = [NSJSONSerialization dataWithJSONObject:data
 746                                                               options:kNilOptions error:&error];
 747            }
 748            NSString * json = [[NSString alloc]initWithData:responseData encoding:NSUTF8StringEncoding];
 749            completionBlock(json, nil);
 750        
 751    }];
 752
 753}
 754
 755-(void) getRelatedWordsAsJsonWithCompletionBlock :(NSString*) word relationshipTypes:(NSString*) relationshipTypes useCanonical:(NSString*) useCanonical limitPerRelationshipType:(NSNumber*) limitPerRelationshipType 
 756        completionHandler:(void (^)(NSString*, NSError *))completionBlock{
 757
 758    NSMutableString* requestUrl = [NSMutableString stringWithFormat:@"%@/word.{format}/{word}/relatedWords", basePath];
 759
 760    // remove format in URL if needed
 761    if ([requestUrl rangeOfString:@".{format}"].location != NSNotFound)
 762        [requestUrl replaceCharactersInRange: [requestUrl rangeOfString:@".{format}"] withString:@""];
 763
 764    [requestUrl replaceCharactersInRange: [requestUrl rangeOfString:[NSString stringWithFormat:@"%@%@%@", @"{", @"word", @"}"]] withString: [_api escapeString:word]];
 765    NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init];
 766    if(useCanonical != nil)
 767        [queryParams setValue:useCanonical forKey:@"useCanonical"];
 768    if(relationshipTypes != nil)
 769        [queryParams setValue:relationshipTypes forKey:@"relationshipTypes"];
 770    if(limitPerRelationshipType != nil)
 771        [queryParams setValue:limitPerRelationshipType forKey:@"limitPerRelationshipType"];
 772    NSMutableDictionary* headerParams = [[NSMutableDictionary alloc] init];
 773    id bodyDictionary = nil;
 774    if(word == nil) {
 775        // error
 776    }
 777    [_api dictionaryWithCompletionBlock: requestUrl 
 778                                 method: @"GET" 
 779                            queryParams: queryParams 
 780                                   body: bodyDictionary 
 781                           headerParams: headerParams
 782                      completionHandler: ^(NSDictionary *data, NSError *error) {
 783        if (error) {
 784            completionBlock(nil, error);return;
 785        }
 786
 787        NSData * responseData = nil;
 788            if([data isKindOfClass:[NSDictionary class]]){
 789                responseData = [NSJSONSerialization dataWithJSONObject:data
 790                                                               options:kNilOptions error:&error];
 791            }
 792            else if ([data isKindOfClass:[NSArray class]]){
 793                responseData = [NSJSONSerialization dataWithJSONObject:data
 794                                                               options:kNilOptions error:&error];
 795            }
 796            NSString * json = [[NSString alloc]initWithData:responseData encoding:NSUTF8StringEncoding];
 797            completionBlock(json, nil);
 798        
 799    }];
 800
 801}
 802
 803-(void) getTextPronunciationsAsJsonWithCompletionBlock :(NSString*) word sourceDictionary:(NSString*) sourceDictionary typeFormat:(NSString*) typeFormat useCanonical:(NSString*) useCanonical limit:(NSNumber*) limit 
 804        completionHandler:(void (^)(NSString*, NSError *))completionBlock{
 805
 806    NSMutableString* requestUrl = [NSMutableString stringWithFormat:@"%@/word.{format}/{word}/pronunciations", basePath];
 807
 808    // remove format in URL if needed
 809    if ([requestUrl rangeOfString:@".{format}"].location != NSNotFound)
 810        [requestUrl replaceCharactersInRange: [requestUrl rangeOfString:@".{format}"] withString:@""];
 811
 812    [requestUrl replaceCharactersInRange: [requestUrl rangeOfString:[NSString stringWithFormat:@"%@%@%@", @"{", @"word", @"}"]] withString: [_api escapeString:word]];
 813    NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init];
 814    if(useCanonical != nil)
 815        [queryParams setValue:useCanonical forKey:@"useCanonical"];
 816    if(sourceDictionary != nil)
 817        [queryParams setValue:sourceDictionary forKey:@"sourceDictionary"];
 818    if(typeFormat != nil)
 819        [queryParams setValue:typeFormat forKey:@"typeFormat"];
 820    if(limit != nil)
 821        [queryParams setValue:limit forKey:@"limit"];
 822    NSMutableDictionary* headerParams = [[NSMutableDictionary alloc] init];
 823    id bodyDictionary = nil;
 824    if(word == nil) {
 825        // error
 826    }
 827    [_api dictionaryWithCompletionBlock: requestUrl 
 828                                 method: @"GET" 
 829                            queryParams: queryParams 
 830                                   body: bodyDictionary 
 831                           headerParams: headerParams
 832                      completionHandler: ^(NSDictionary *data, NSError *error) {
 833        if (error) {
 834            completionBlock(nil, error);return;
 835        }
 836
 837        NSData * responseData = nil;
 838            if([data isKindOfClass:[NSDictionary class]]){
 839                responseData = [NSJSONSerialization dataWithJSONObject:data
 840                                                               options:kNilOptions error:&error];
 841            }
 842            else if ([data isKindOfClass:[NSArray class]]){
 843                responseData = [NSJSONSerialization dataWithJSONObject:data
 844                                                               options:kNilOptions error:&error];
 845            }
 846            NSString * json = [[NSString alloc]initWithData:responseData encoding:NSUTF8StringEncoding];
 847            completionBlock(json, nil);
 848        
 849    }];
 850
 851}
 852
 853-(void) getHyphenationAsJsonWithCompletionBlock :(NSString*) word sourceDictionary:(NSString*) sourceDictionary useCanonical:(NSString*) useCanonical limit:(NSNumber*) limit 
 854        completionHandler:(void (^)(NSString*, NSError *))completionBlock{
 855
 856    NSMutableString* requestUrl = [NSMutableString stringWithFormat:@"%@/word.{format}/{word}/hyphenation", basePath];
 857
 858    // remove format in URL if needed
 859    if ([requestUrl rangeOfString:@".{format}"].location != NSNotFound)
 860        [requestUrl replaceCharactersInRange: [requestUrl rangeOfString:@".{format}"] withString:@""];
 861
 862    [requestUrl replaceCharactersInRange: [requestUrl rangeOfString:[NSString stringWithFormat:@"%@%@%@", @"{", @"word", @"}"]] withString: [_api escapeString:word]];
 863    NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init];
 864    if(useCanonical != nil)
 865        [queryParams setValue:useCanonical forKey:@"useCanonical"];
 866    if(sourceDictionary != nil)
 867        [queryParams setValue:sourceDictionary forKey:@"sourceDictionary"];
 868    if(limit != nil)
 869        [queryParams setValue:limit forKey:@"limit"];
 870    NSMutableDictionary* headerParams = [[NSMutableDictionary alloc] init];
 871    id bodyDictionary = nil;
 872    if(word == nil) {
 873        // error
 874    }
 875    [_api dictionaryWithCompletionBlock: requestUrl 
 876                                 method: @"GET" 
 877                            queryParams: queryParams 
 878                                   body: bodyDictionary 
 879                           headerParams: headerParams
 880                      completionHandler: ^(NSDictionary *data, NSError *error) {
 881        if (error) {
 882            completionBlock(nil, error);return;
 883        }
 884
 885        NSData * responseData = nil;
 886            if([data isKindOfClass:[NSDictionary class]]){
 887                responseData = [NSJSONSerialization dataWithJSONObject:data
 888                                                               options:kNilOptions error:&error];
 889            }
 890            else if ([data isKindOfClass:[NSArray class]]){
 891                responseData = [NSJSONSerialization dataWithJSONObject:data
 892                                                               options:kNilOptions error:&error];
 893            }
 894            NSString * json = [[NSString alloc]initWithData:responseData encoding:NSUTF8StringEncoding];
 895            completionBlock(json, nil);
 896        
 897    }];
 898
 899}
 900
 901-(void) getWordFrequencyAsJsonWithCompletionBlock :(NSString*) word useCanonical:(NSString*) useCanonical startYear:(NSNumber*) startYear endYear:(NSNumber*) endYear 
 902        completionHandler:(void (^)(NSString*, NSError *))completionBlock{
 903
 904    NSMutableString* requestUrl = [NSMutableString stringWithFormat:@"%@/word.{format}/{word}/frequency", basePath];
 905
 906    // remove format in URL if needed
 907    if ([requestUrl rangeOfString:@".{format}"].location != NSNotFound)
 908        [requestUrl replaceCharactersInRange: [requestUrl rangeOfString:@".{format}"] withString:@""];
 909
 910    [requestUrl replaceCharactersInRange: [requestUrl rangeOfString:[NSString stringWithFormat:@"%@%@%@", @"{", @"word", @"}"]] withString: [_api escapeString:word]];
 911    NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init];
 912    if(useCanonical != nil)
 913        [queryParams setValue:useCanonical forKey:@"useCanonical"];
 914    if(startYear != nil)
 915        [queryParams setValue:startYear forKey:@"startYear"];
 916    if(endYear != nil)
 917        [queryParams setValue:endYear forKey:@"endYear"];
 918    NSMutableDictionary* headerParams = [[NSMutableDictionary alloc] init];
 919    id bodyDictionary = nil;
 920    if(word == nil) {
 921        // error
 922    }
 923    [_api dictionaryWithCompletionBlock: requestUrl 
 924                                 method: @"GET" 
 925                            queryParams: queryParams 
 926                                   body: bodyDictionary 
 927                           headerParams: headerParams
 928                      completionHandler: ^(NSDictionary *data, NSError *error) {
 929        if (error) {
 930            completionBlock(nil, error);return;
 931        }
 932
 933        NSData * responseData = nil;
 934            if([data isKindOfClass:[NSDictionary class]]){
 935                responseData = [NSJSONSerialization dataWithJSONObject:data
 936                                                               options:kNilOptions error:&error];
 937            }
 938            else if ([data isKindOfClass:[NSArray class]]){
 939                responseData = [NSJSONSerialization dataWithJSONObject:data
 940                                                               options:kNilOptions error:&error];
 941            }
 942            NSString * json = [[NSString alloc]initWithData:responseData encoding:NSUTF8StringEncoding];
 943            completionBlock(json, nil);
 944        
 945    }];
 946
 947}
 948
 949-(void) getPhrasesAsJsonWithCompletionBlock :(NSString*) word limit:(NSNumber*) limit wlmi:(NSNumber*) wlmi useCanonical:(NSString*) useCanonical 
 950        completionHandler:(void (^)(NSString*, NSError *))completionBlock{
 951
 952    NSMutableString* requestUrl = [NSMutableString stringWithFormat:@"%@/word.{format}/{word}/phrases", basePath];
 953
 954    // remove format in URL if needed
 955    if ([requestUrl rangeOfString:@".{format}"].location != NSNotFound)
 956        [requestUrl replaceCharactersInRange: [requestUrl rangeOfString:@".{format}"] withString:@""];
 957
 958    [requestUrl replaceCharactersInRange: [requestUrl rangeOfString:[NSString stringWithFormat:@"%@%@%@", @"{", @"word", @"}"]] withString: [_api escapeString:word]];
 959    NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init];
 960    if(limit != nil)
 961        [queryParams setValue:limit forKey:@"limit"];
 962    if(wlmi != nil)
 963        [queryParams setValue:wlmi forKey:@"wlmi"];
 964    if(useCanonical != nil)
 965        [queryParams setValue:useCanonical forKey:@"useCanonical"];
 966    NSMutableDictionary* headerParams = [[NSMutableDictionary alloc] init];
 967    id bodyDictionary = nil;
 968    if(word == nil) {
 969        // error
 970    }
 971    [_api dictionaryWithCompletionBlock: requestUrl 
 972                                 method: @"GET" 
 973                            queryParams: queryParams 
 974                                   body: bodyDictionary 
 975                           headerParams: headerParams
 976                      completionHandler: ^(NSDictionary *data, NSError *error) {
 977        if (error) {
 978            completionBlock(nil, error);return;
 979        }
 980
 981        NSData * responseData = nil;
 982            if([data isKindOfClass:[NSDictionary class]]){
 983                responseData = [NSJSONSerialization dataWithJSONObject:data
 984                                                               options:kNilOptions error:&error];
 985            }
 986            else if ([data isKindOfClass:[NSArray class]]){
 987                responseData = [NSJSONSerialization dataWithJSONObject:data
 988                                                               options:kNilOptions error:&error];
 989            }
 990            NSString * json = [[NSString alloc]initWithData:responseData encoding:NSUTF8StringEncoding];
 991            completionBlock(json, nil);
 992        
 993    }];
 994
 995}
 996
 997-(void) getEtymologiesAsJsonWithCompletionBlock :(NSString*) word useCanonical:(NSString*) useCanonical 
 998        completionHandler:(void (^)(NSString*, NSError *))completionBlock{
 999
1000    NSMutableString* requestUrl = [NSMutableString stringWithFormat:@"%@/word.{format}/{word}/etymologies", basePath];
1001
1002    // remove format in URL if needed
1003    if ([requestUrl rangeOfString:@".{format}"].location != NSNotFound)
1004        [requestUrl replaceCharactersInRange: [requestUrl rangeOfString:@".{format}"] withString:@""];
1005
1006    [requestUrl replaceCharactersInRange: [requestUrl rangeOfString:[NSString stringWithFormat:@"%@%@%@", @"{", @"word", @"}"]] withString: [_api escapeString:word]];
1007    NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init];
1008    if(useCanonical != nil)
1009        [queryParams setValue:useCanonical forKey:@"useCanonical"];
1010    NSMutableDictionary* headerParams = [[NSMutableDictionary alloc] init];
1011    id bodyDictionary = nil;
1012    if(word == nil) {
1013        // error
1014    }
1015    [_api dictionaryWithCompletionBlock: requestUrl 
1016                                 method: @"GET" 
1017                            queryParams: queryParams 
1018                                   body: bodyDictionary 
1019                           headerParams: headerParams
1020                      completionHandler: ^(NSDictionary *data, NSError *error) {
1021        if (error) {
1022            completionBlock(nil, error);return;
1023        }
1024
1025        NSData * responseData = nil;
1026            if([data isKindOfClass:[NSDictionary class]]){
1027                responseData = [NSJSONSerialization dataWithJSONObject:data
1028                                                               options:kNilOptions error:&error];
1029            }
1030            else if ([data isKindOfClass:[NSArray class]]){
1031                responseData = [NSJSONSerialization dataWithJSONObject:data
1032                                                               options:kNilOptions error:&error];
1033            }
1034            NSString * json = [[NSString alloc]initWithData:responseData encoding:NSUTF8StringEncoding];
1035            completionBlock(json, nil);
1036        
1037    }];
1038
1039}
1040
1041-(void) getAudioAsJsonWithCompletionBlock :(NSString*) word useCanonical:(NSString*) useCanonical limit:(NSNumber*) limit 
1042        completionHandler:(void (^)(NSString*, NSError *))completionBlock{
1043
1044    NSMutableString* requestUrl = [NSMutableString stringWithFormat:@"%@/word.{format}/{word}/audio", basePath];
1045
1046    // remove format in URL if needed
1047    if ([requestUrl rangeOfString:@".{format}"].location != NSNotFound)
1048        [requestUrl replaceCharactersInRange: [requestUrl rangeOfString:@".{format}"] withString:@""];
1049
1050    [requestUrl replaceCharactersInRange: [requestUrl rangeOfString:[NSString stringWithFormat:@"%@%@%@", @"{", @"word", @"}"]] withString: [_api escapeString:word]];
1051    NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init];
1052    if(useCanonical != nil)
1053        [queryParams setValue:useCanonical forKey:@"useCanonical"];
1054    if(limit != nil)
1055        [queryParams setValue:limit forKey:@"limit"];
1056    NSMutableDictionary* headerParams = [[NSMutableDictionary alloc] init];
1057    id bodyDictionary = nil;
1058    if(word == nil) {
1059        // error
1060    }
1061    [_api dictionaryWithCompletionBlock: requestUrl 
1062                                 method: @"GET" 
1063                            queryParams: queryParams 
1064                                   body: bodyDictionary 
1065                           headerParams: headerParams
1066                      completionHandler: ^(NSDictionary *data, NSError *error) {
1067        if (error) {
1068            completionBlock(nil, error);return;
1069        }
1070
1071        NSData * responseData = nil;
1072            if([data isKindOfClass:[NSDictionary class]]){
1073                responseData = [NSJSONSerialization dataWithJSONObject:data
1074                                                               options:kNilOptions error:&error];
1075            }
1076            else if ([data isKindOfClass:[NSArray class]]){
1077                responseData = [NSJSONSerialization dataWithJSONObject:data
1078                                                               options:kNilOptions error:&error];
1079            }
1080            NSString * json = [[NSString alloc]initWithData:responseData encoding:NSUTF8StringEncoding];
1081            completionBlock(json, nil);
1082        
1083    }];
1084
1085}
1086
1087
1088@end