mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2025-11-30 15:33:39 +00:00
692 lines
30 KiB
Objective-C
692 lines
30 KiB
Objective-C
#import "SWGWordApi.h"
|
|
#import "SWGFile.h"
|
|
#import "SWGApiClient.h"
|
|
#import "SWGFrequencySummary.h"
|
|
#import "SWGBigram.h"
|
|
#import "SWGWordObject.h"
|
|
#import "SWGExampleSearchResults.h"
|
|
#import "SWGExample.h"
|
|
#import "SWGScrabbleScoreResult.h"
|
|
#import "SWGTextPron.h"
|
|
#import "SWGSyllable.h"
|
|
#import "SWGRelated.h"
|
|
#import "SWGDefinition.h"
|
|
#import "SWGAudioFile.h"
|
|
|
|
|
|
|
|
|
|
@implementation SWGWordApi
|
|
static NSString * basePath = @"http://api.wordnik.com/v4";
|
|
|
|
+(SWGWordApi*) apiWithHeader:(NSString*)headerValue key:(NSString*)key {
|
|
static SWGWordApi* singletonAPI = nil;
|
|
|
|
if (singletonAPI == nil) {
|
|
singletonAPI = [[SWGWordApi alloc] init];
|
|
[singletonAPI addHeader:headerValue forKey:key];
|
|
}
|
|
return singletonAPI;
|
|
}
|
|
|
|
+(void) setBasePath:(NSString*)path {
|
|
basePath = path;
|
|
}
|
|
|
|
+(NSString*) getBasePath {
|
|
return basePath;
|
|
}
|
|
|
|
-(SWGApiClient*) apiClient {
|
|
return [SWGApiClient sharedClientFromPool:basePath];
|
|
}
|
|
|
|
-(void) addHeader:(NSString*)value forKey:(NSString*)key {
|
|
[[self apiClient] setHeaderValue:value forKey:key];
|
|
}
|
|
|
|
-(id) init {
|
|
self = [super init];
|
|
[self apiClient];
|
|
return self;
|
|
}
|
|
|
|
-(void) setHeaderValue:(NSString*) value
|
|
forKey:(NSString*)key {
|
|
[[self apiClient] setHeaderValue:value forKey:key];
|
|
}
|
|
|
|
-(unsigned long) requestQueueSize {
|
|
return [SWGApiClient requestQueueSize];
|
|
}
|
|
|
|
|
|
-(NSNumber*) getExamplesWithCompletionBlock:(NSString*) word
|
|
includeDuplicates:(NSString*) includeDuplicates
|
|
useCanonical:(NSString*) useCanonical
|
|
skip:(NSNumber*) skip
|
|
limit:(NSNumber*) limit
|
|
completionHandler: (void (^)(SWGExampleSearchResults* output, NSError* error))completionBlock{
|
|
|
|
NSMutableString* requestUrl = [NSMutableString stringWithFormat:@"%@/word.{format}/{word}/examples", basePath];
|
|
|
|
// remove format in URL if needed
|
|
if ([requestUrl rangeOfString:@".{format}"].location != NSNotFound)
|
|
[requestUrl replaceCharactersInRange: [requestUrl rangeOfString:@".{format}"] withString:@".json"];
|
|
|
|
[requestUrl replaceCharactersInRange: [requestUrl rangeOfString:[NSString stringWithFormat:@"%@%@%@", @"{", @"word", @"}"]] withString: [SWGApiClient escape:word]];
|
|
NSString* requestContentType = @"application/json";
|
|
NSString* responseContentType = @"application/json";
|
|
|
|
NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init];
|
|
if(includeDuplicates != nil)
|
|
queryParams[@"includeDuplicates"] = includeDuplicates;
|
|
if(useCanonical != nil)
|
|
queryParams[@"useCanonical"] = useCanonical;
|
|
if(skip != nil)
|
|
queryParams[@"skip"] = skip;
|
|
if(limit != nil)
|
|
queryParams[@"limit"] = limit;
|
|
NSMutableDictionary* headerParams = [[NSMutableDictionary alloc] init];
|
|
id bodyDictionary = nil;
|
|
if(word == nil) {
|
|
// error
|
|
}
|
|
SWGApiClient* client = [SWGApiClient sharedClientFromPool:basePath];
|
|
|
|
return [client dictionary:requestUrl
|
|
method:@"GET"
|
|
queryParams:queryParams
|
|
body:bodyDictionary
|
|
headerParams:headerParams
|
|
requestContentType:requestContentType
|
|
responseContentType:responseContentType
|
|
completionBlock:^(NSDictionary *data, NSError *error) {
|
|
if (error) {
|
|
completionBlock(nil, error);return;
|
|
}
|
|
SWGExampleSearchResults *result = nil;
|
|
if (data) {
|
|
result = [[SWGExampleSearchResults alloc]initWithValues: data];
|
|
}
|
|
completionBlock(result , nil);}];
|
|
|
|
|
|
}
|
|
|
|
-(NSNumber*) getWordWithCompletionBlock:(NSString*) word
|
|
useCanonical:(NSString*) useCanonical
|
|
includeSuggestions:(NSString*) includeSuggestions
|
|
completionHandler: (void (^)(SWGWordObject* output, NSError* error))completionBlock{
|
|
|
|
NSMutableString* requestUrl = [NSMutableString stringWithFormat:@"%@/word.{format}/{word}", basePath];
|
|
|
|
// remove format in URL if needed
|
|
if ([requestUrl rangeOfString:@".{format}"].location != NSNotFound)
|
|
[requestUrl replaceCharactersInRange: [requestUrl rangeOfString:@".{format}"] withString:@".json"];
|
|
|
|
[requestUrl replaceCharactersInRange: [requestUrl rangeOfString:[NSString stringWithFormat:@"%@%@%@", @"{", @"word", @"}"]] withString: [SWGApiClient escape:word]];
|
|
NSString* requestContentType = @"application/json";
|
|
NSString* responseContentType = @"application/json";
|
|
|
|
NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init];
|
|
if(useCanonical != nil)
|
|
queryParams[@"useCanonical"] = useCanonical;
|
|
if(includeSuggestions != nil)
|
|
queryParams[@"includeSuggestions"] = includeSuggestions;
|
|
NSMutableDictionary* headerParams = [[NSMutableDictionary alloc] init];
|
|
id bodyDictionary = nil;
|
|
if(word == nil) {
|
|
// error
|
|
}
|
|
SWGApiClient* client = [SWGApiClient sharedClientFromPool:basePath];
|
|
|
|
return [client dictionary:requestUrl
|
|
method:@"GET"
|
|
queryParams:queryParams
|
|
body:bodyDictionary
|
|
headerParams:headerParams
|
|
requestContentType:requestContentType
|
|
responseContentType:responseContentType
|
|
completionBlock:^(NSDictionary *data, NSError *error) {
|
|
if (error) {
|
|
completionBlock(nil, error);return;
|
|
}
|
|
SWGWordObject *result = nil;
|
|
if (data) {
|
|
result = [[SWGWordObject alloc]initWithValues: data];
|
|
}
|
|
completionBlock(result , nil);}];
|
|
|
|
|
|
}
|
|
|
|
-(NSNumber*) getDefinitionsWithCompletionBlock:(NSString*) word
|
|
partOfSpeech:(NSString*) partOfSpeech
|
|
sourceDictionaries:(NSString*) sourceDictionaries
|
|
limit:(NSNumber*) limit
|
|
includeRelated:(NSString*) includeRelated
|
|
useCanonical:(NSString*) useCanonical
|
|
includeTags:(NSString*) includeTags
|
|
completionHandler: (void (^)(NSArray* output, NSError* error))completionBlock{
|
|
|
|
NSMutableString* requestUrl = [NSMutableString stringWithFormat:@"%@/word.{format}/{word}/definitions", basePath];
|
|
|
|
// remove format in URL if needed
|
|
if ([requestUrl rangeOfString:@".{format}"].location != NSNotFound)
|
|
[requestUrl replaceCharactersInRange: [requestUrl rangeOfString:@".{format}"] withString:@".json"];
|
|
|
|
[requestUrl replaceCharactersInRange: [requestUrl rangeOfString:[NSString stringWithFormat:@"%@%@%@", @"{", @"word", @"}"]] withString: [SWGApiClient escape:word]];
|
|
NSString* requestContentType = @"application/json";
|
|
NSString* responseContentType = @"application/json";
|
|
|
|
NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init];
|
|
if(limit != nil)
|
|
queryParams[@"limit"] = limit;
|
|
if(partOfSpeech != nil)
|
|
queryParams[@"partOfSpeech"] = partOfSpeech;
|
|
if(includeRelated != nil)
|
|
queryParams[@"includeRelated"] = includeRelated;
|
|
if(sourceDictionaries != nil)
|
|
queryParams[@"sourceDictionaries"] = sourceDictionaries;
|
|
if(useCanonical != nil)
|
|
queryParams[@"useCanonical"] = useCanonical;
|
|
if(includeTags != nil)
|
|
queryParams[@"includeTags"] = includeTags;
|
|
NSMutableDictionary* headerParams = [[NSMutableDictionary alloc] init];
|
|
id bodyDictionary = nil;
|
|
if(word == nil) {
|
|
// error
|
|
}
|
|
SWGApiClient* client = [SWGApiClient sharedClientFromPool:basePath];
|
|
|
|
return [client dictionary: requestUrl
|
|
method: @"GET"
|
|
queryParams: queryParams
|
|
body: bodyDictionary
|
|
headerParams: headerParams
|
|
requestContentType: requestContentType
|
|
responseContentType: responseContentType
|
|
completionBlock: ^(NSDictionary *data, NSError *error) {
|
|
if (error) {
|
|
completionBlock(nil, error);return;
|
|
}
|
|
|
|
if([data isKindOfClass:[NSArray class]]){
|
|
NSMutableArray * objs = [[NSMutableArray alloc] initWithCapacity:[data count]];
|
|
for (NSDictionary* dict in (NSArray*)data) {
|
|
SWGDefinition* d = [[SWGDefinition alloc]initWithValues: dict];
|
|
[objs addObject:d];
|
|
}
|
|
completionBlock(objs, nil);
|
|
}
|
|
}];
|
|
|
|
|
|
}
|
|
|
|
-(NSNumber*) getTopExampleWithCompletionBlock:(NSString*) word
|
|
useCanonical:(NSString*) useCanonical
|
|
completionHandler: (void (^)(SWGExample* output, NSError* error))completionBlock{
|
|
|
|
NSMutableString* requestUrl = [NSMutableString stringWithFormat:@"%@/word.{format}/{word}/topExample", basePath];
|
|
|
|
// remove format in URL if needed
|
|
if ([requestUrl rangeOfString:@".{format}"].location != NSNotFound)
|
|
[requestUrl replaceCharactersInRange: [requestUrl rangeOfString:@".{format}"] withString:@".json"];
|
|
|
|
[requestUrl replaceCharactersInRange: [requestUrl rangeOfString:[NSString stringWithFormat:@"%@%@%@", @"{", @"word", @"}"]] withString: [SWGApiClient escape:word]];
|
|
NSString* requestContentType = @"application/json";
|
|
NSString* responseContentType = @"application/json";
|
|
|
|
NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init];
|
|
if(useCanonical != nil)
|
|
queryParams[@"useCanonical"] = useCanonical;
|
|
NSMutableDictionary* headerParams = [[NSMutableDictionary alloc] init];
|
|
id bodyDictionary = nil;
|
|
if(word == nil) {
|
|
// error
|
|
}
|
|
SWGApiClient* client = [SWGApiClient sharedClientFromPool:basePath];
|
|
|
|
return [client dictionary:requestUrl
|
|
method:@"GET"
|
|
queryParams:queryParams
|
|
body:bodyDictionary
|
|
headerParams:headerParams
|
|
requestContentType:requestContentType
|
|
responseContentType:responseContentType
|
|
completionBlock:^(NSDictionary *data, NSError *error) {
|
|
if (error) {
|
|
completionBlock(nil, error);return;
|
|
}
|
|
SWGExample *result = nil;
|
|
if (data) {
|
|
result = [[SWGExample alloc]initWithValues: data];
|
|
}
|
|
completionBlock(result , nil);}];
|
|
|
|
|
|
}
|
|
|
|
-(NSNumber*) getRelatedWordsWithCompletionBlock:(NSString*) word
|
|
relationshipTypes:(NSString*) relationshipTypes
|
|
useCanonical:(NSString*) useCanonical
|
|
limitPerRelationshipType:(NSNumber*) limitPerRelationshipType
|
|
completionHandler: (void (^)(NSArray* output, NSError* error))completionBlock{
|
|
|
|
NSMutableString* requestUrl = [NSMutableString stringWithFormat:@"%@/word.{format}/{word}/relatedWords", basePath];
|
|
|
|
// remove format in URL if needed
|
|
if ([requestUrl rangeOfString:@".{format}"].location != NSNotFound)
|
|
[requestUrl replaceCharactersInRange: [requestUrl rangeOfString:@".{format}"] withString:@".json"];
|
|
|
|
[requestUrl replaceCharactersInRange: [requestUrl rangeOfString:[NSString stringWithFormat:@"%@%@%@", @"{", @"word", @"}"]] withString: [SWGApiClient escape:word]];
|
|
NSString* requestContentType = @"application/json";
|
|
NSString* responseContentType = @"application/json";
|
|
|
|
NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init];
|
|
if(useCanonical != nil)
|
|
queryParams[@"useCanonical"] = useCanonical;
|
|
if(relationshipTypes != nil)
|
|
queryParams[@"relationshipTypes"] = relationshipTypes;
|
|
if(limitPerRelationshipType != nil)
|
|
queryParams[@"limitPerRelationshipType"] = limitPerRelationshipType;
|
|
NSMutableDictionary* headerParams = [[NSMutableDictionary alloc] init];
|
|
id bodyDictionary = nil;
|
|
if(word == nil) {
|
|
// error
|
|
}
|
|
SWGApiClient* client = [SWGApiClient sharedClientFromPool:basePath];
|
|
|
|
return [client dictionary: requestUrl
|
|
method: @"GET"
|
|
queryParams: queryParams
|
|
body: bodyDictionary
|
|
headerParams: headerParams
|
|
requestContentType: requestContentType
|
|
responseContentType: responseContentType
|
|
completionBlock: ^(NSDictionary *data, NSError *error) {
|
|
if (error) {
|
|
completionBlock(nil, error);return;
|
|
}
|
|
|
|
if([data isKindOfClass:[NSArray class]]){
|
|
NSMutableArray * objs = [[NSMutableArray alloc] initWithCapacity:[data count]];
|
|
for (NSDictionary* dict in (NSArray*)data) {
|
|
SWGRelated* d = [[SWGRelated alloc]initWithValues: dict];
|
|
[objs addObject:d];
|
|
}
|
|
completionBlock(objs, nil);
|
|
}
|
|
}];
|
|
|
|
|
|
}
|
|
|
|
-(NSNumber*) getTextPronunciationsWithCompletionBlock:(NSString*) word
|
|
sourceDictionary:(NSString*) sourceDictionary
|
|
typeFormat:(NSString*) typeFormat
|
|
useCanonical:(NSString*) useCanonical
|
|
limit:(NSNumber*) limit
|
|
completionHandler: (void (^)(NSArray* output, NSError* error))completionBlock{
|
|
|
|
NSMutableString* requestUrl = [NSMutableString stringWithFormat:@"%@/word.{format}/{word}/pronunciations", basePath];
|
|
|
|
// remove format in URL if needed
|
|
if ([requestUrl rangeOfString:@".{format}"].location != NSNotFound)
|
|
[requestUrl replaceCharactersInRange: [requestUrl rangeOfString:@".{format}"] withString:@".json"];
|
|
|
|
[requestUrl replaceCharactersInRange: [requestUrl rangeOfString:[NSString stringWithFormat:@"%@%@%@", @"{", @"word", @"}"]] withString: [SWGApiClient escape:word]];
|
|
NSString* requestContentType = @"application/json";
|
|
NSString* responseContentType = @"application/json";
|
|
|
|
NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init];
|
|
if(useCanonical != nil)
|
|
queryParams[@"useCanonical"] = useCanonical;
|
|
if(sourceDictionary != nil)
|
|
queryParams[@"sourceDictionary"] = sourceDictionary;
|
|
if(typeFormat != nil)
|
|
queryParams[@"typeFormat"] = typeFormat;
|
|
if(limit != nil)
|
|
queryParams[@"limit"] = limit;
|
|
NSMutableDictionary* headerParams = [[NSMutableDictionary alloc] init];
|
|
id bodyDictionary = nil;
|
|
if(word == nil) {
|
|
// error
|
|
}
|
|
SWGApiClient* client = [SWGApiClient sharedClientFromPool:basePath];
|
|
|
|
return [client dictionary: requestUrl
|
|
method: @"GET"
|
|
queryParams: queryParams
|
|
body: bodyDictionary
|
|
headerParams: headerParams
|
|
requestContentType: requestContentType
|
|
responseContentType: responseContentType
|
|
completionBlock: ^(NSDictionary *data, NSError *error) {
|
|
if (error) {
|
|
completionBlock(nil, error);return;
|
|
}
|
|
|
|
if([data isKindOfClass:[NSArray class]]){
|
|
NSMutableArray * objs = [[NSMutableArray alloc] initWithCapacity:[data count]];
|
|
for (NSDictionary* dict in (NSArray*)data) {
|
|
SWGTextPron* d = [[SWGTextPron alloc]initWithValues: dict];
|
|
[objs addObject:d];
|
|
}
|
|
completionBlock(objs, nil);
|
|
}
|
|
}];
|
|
|
|
|
|
}
|
|
|
|
-(NSNumber*) getHyphenationWithCompletionBlock:(NSString*) word
|
|
sourceDictionary:(NSString*) sourceDictionary
|
|
useCanonical:(NSString*) useCanonical
|
|
limit:(NSNumber*) limit
|
|
completionHandler: (void (^)(NSArray* output, NSError* error))completionBlock{
|
|
|
|
NSMutableString* requestUrl = [NSMutableString stringWithFormat:@"%@/word.{format}/{word}/hyphenation", basePath];
|
|
|
|
// remove format in URL if needed
|
|
if ([requestUrl rangeOfString:@".{format}"].location != NSNotFound)
|
|
[requestUrl replaceCharactersInRange: [requestUrl rangeOfString:@".{format}"] withString:@".json"];
|
|
|
|
[requestUrl replaceCharactersInRange: [requestUrl rangeOfString:[NSString stringWithFormat:@"%@%@%@", @"{", @"word", @"}"]] withString: [SWGApiClient escape:word]];
|
|
NSString* requestContentType = @"application/json";
|
|
NSString* responseContentType = @"application/json";
|
|
|
|
NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init];
|
|
if(useCanonical != nil)
|
|
queryParams[@"useCanonical"] = useCanonical;
|
|
if(sourceDictionary != nil)
|
|
queryParams[@"sourceDictionary"] = sourceDictionary;
|
|
if(limit != nil)
|
|
queryParams[@"limit"] = limit;
|
|
NSMutableDictionary* headerParams = [[NSMutableDictionary alloc] init];
|
|
id bodyDictionary = nil;
|
|
if(word == nil) {
|
|
// error
|
|
}
|
|
SWGApiClient* client = [SWGApiClient sharedClientFromPool:basePath];
|
|
|
|
return [client dictionary: requestUrl
|
|
method: @"GET"
|
|
queryParams: queryParams
|
|
body: bodyDictionary
|
|
headerParams: headerParams
|
|
requestContentType: requestContentType
|
|
responseContentType: responseContentType
|
|
completionBlock: ^(NSDictionary *data, NSError *error) {
|
|
if (error) {
|
|
completionBlock(nil, error);return;
|
|
}
|
|
|
|
if([data isKindOfClass:[NSArray class]]){
|
|
NSMutableArray * objs = [[NSMutableArray alloc] initWithCapacity:[data count]];
|
|
for (NSDictionary* dict in (NSArray*)data) {
|
|
SWGSyllable* d = [[SWGSyllable alloc]initWithValues: dict];
|
|
[objs addObject:d];
|
|
}
|
|
completionBlock(objs, nil);
|
|
}
|
|
}];
|
|
|
|
|
|
}
|
|
|
|
-(NSNumber*) getWordFrequencyWithCompletionBlock:(NSString*) word
|
|
useCanonical:(NSString*) useCanonical
|
|
startYear:(NSNumber*) startYear
|
|
endYear:(NSNumber*) endYear
|
|
completionHandler: (void (^)(SWGFrequencySummary* output, NSError* error))completionBlock{
|
|
|
|
NSMutableString* requestUrl = [NSMutableString stringWithFormat:@"%@/word.{format}/{word}/frequency", basePath];
|
|
|
|
// remove format in URL if needed
|
|
if ([requestUrl rangeOfString:@".{format}"].location != NSNotFound)
|
|
[requestUrl replaceCharactersInRange: [requestUrl rangeOfString:@".{format}"] withString:@".json"];
|
|
|
|
[requestUrl replaceCharactersInRange: [requestUrl rangeOfString:[NSString stringWithFormat:@"%@%@%@", @"{", @"word", @"}"]] withString: [SWGApiClient escape:word]];
|
|
NSString* requestContentType = @"application/json";
|
|
NSString* responseContentType = @"application/json";
|
|
|
|
NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init];
|
|
if(useCanonical != nil)
|
|
queryParams[@"useCanonical"] = useCanonical;
|
|
if(startYear != nil)
|
|
queryParams[@"startYear"] = startYear;
|
|
if(endYear != nil)
|
|
queryParams[@"endYear"] = endYear;
|
|
NSMutableDictionary* headerParams = [[NSMutableDictionary alloc] init];
|
|
id bodyDictionary = nil;
|
|
if(word == nil) {
|
|
// error
|
|
}
|
|
SWGApiClient* client = [SWGApiClient sharedClientFromPool:basePath];
|
|
|
|
return [client dictionary:requestUrl
|
|
method:@"GET"
|
|
queryParams:queryParams
|
|
body:bodyDictionary
|
|
headerParams:headerParams
|
|
requestContentType:requestContentType
|
|
responseContentType:responseContentType
|
|
completionBlock:^(NSDictionary *data, NSError *error) {
|
|
if (error) {
|
|
completionBlock(nil, error);return;
|
|
}
|
|
SWGFrequencySummary *result = nil;
|
|
if (data) {
|
|
result = [[SWGFrequencySummary alloc]initWithValues: data];
|
|
}
|
|
completionBlock(result , nil);}];
|
|
|
|
|
|
}
|
|
|
|
-(NSNumber*) getPhrasesWithCompletionBlock:(NSString*) word
|
|
limit:(NSNumber*) limit
|
|
wlmi:(NSNumber*) wlmi
|
|
useCanonical:(NSString*) useCanonical
|
|
completionHandler: (void (^)(NSArray* output, NSError* error))completionBlock{
|
|
|
|
NSMutableString* requestUrl = [NSMutableString stringWithFormat:@"%@/word.{format}/{word}/phrases", basePath];
|
|
|
|
// remove format in URL if needed
|
|
if ([requestUrl rangeOfString:@".{format}"].location != NSNotFound)
|
|
[requestUrl replaceCharactersInRange: [requestUrl rangeOfString:@".{format}"] withString:@".json"];
|
|
|
|
[requestUrl replaceCharactersInRange: [requestUrl rangeOfString:[NSString stringWithFormat:@"%@%@%@", @"{", @"word", @"}"]] withString: [SWGApiClient escape:word]];
|
|
NSString* requestContentType = @"application/json";
|
|
NSString* responseContentType = @"application/json";
|
|
|
|
NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init];
|
|
if(limit != nil)
|
|
queryParams[@"limit"] = limit;
|
|
if(wlmi != nil)
|
|
queryParams[@"wlmi"] = wlmi;
|
|
if(useCanonical != nil)
|
|
queryParams[@"useCanonical"] = useCanonical;
|
|
NSMutableDictionary* headerParams = [[NSMutableDictionary alloc] init];
|
|
id bodyDictionary = nil;
|
|
if(word == nil) {
|
|
// error
|
|
}
|
|
SWGApiClient* client = [SWGApiClient sharedClientFromPool:basePath];
|
|
|
|
return [client dictionary: requestUrl
|
|
method: @"GET"
|
|
queryParams: queryParams
|
|
body: bodyDictionary
|
|
headerParams: headerParams
|
|
requestContentType: requestContentType
|
|
responseContentType: responseContentType
|
|
completionBlock: ^(NSDictionary *data, NSError *error) {
|
|
if (error) {
|
|
completionBlock(nil, error);return;
|
|
}
|
|
|
|
if([data isKindOfClass:[NSArray class]]){
|
|
NSMutableArray * objs = [[NSMutableArray alloc] initWithCapacity:[data count]];
|
|
for (NSDictionary* dict in (NSArray*)data) {
|
|
SWGBigram* d = [[SWGBigram alloc]initWithValues: dict];
|
|
[objs addObject:d];
|
|
}
|
|
completionBlock(objs, nil);
|
|
}
|
|
}];
|
|
|
|
|
|
}
|
|
|
|
-(NSNumber*) getEtymologiesWithCompletionBlock:(NSString*) word
|
|
useCanonical:(NSString*) useCanonical
|
|
completionHandler: (void (^)(NSArray* output, NSError* error))completionBlock{
|
|
|
|
NSMutableString* requestUrl = [NSMutableString stringWithFormat:@"%@/word.{format}/{word}/etymologies", basePath];
|
|
|
|
// remove format in URL if needed
|
|
if ([requestUrl rangeOfString:@".{format}"].location != NSNotFound)
|
|
[requestUrl replaceCharactersInRange: [requestUrl rangeOfString:@".{format}"] withString:@".json"];
|
|
|
|
[requestUrl replaceCharactersInRange: [requestUrl rangeOfString:[NSString stringWithFormat:@"%@%@%@", @"{", @"word", @"}"]] withString: [SWGApiClient escape:word]];
|
|
NSString* requestContentType = @"application/json";
|
|
NSString* responseContentType = @"application/json";
|
|
|
|
NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init];
|
|
if(useCanonical != nil)
|
|
queryParams[@"useCanonical"] = useCanonical;
|
|
NSMutableDictionary* headerParams = [[NSMutableDictionary alloc] init];
|
|
id bodyDictionary = nil;
|
|
if(word == nil) {
|
|
// error
|
|
}
|
|
SWGApiClient* client = [SWGApiClient sharedClientFromPool:basePath];
|
|
|
|
return [client dictionary: requestUrl
|
|
method: @"GET"
|
|
queryParams: queryParams
|
|
body: bodyDictionary
|
|
headerParams: headerParams
|
|
requestContentType: requestContentType
|
|
responseContentType: responseContentType
|
|
completionBlock: ^(NSDictionary *data, NSError *error) {
|
|
if (error) {
|
|
completionBlock(nil, error);return;
|
|
}
|
|
|
|
if([data isKindOfClass:[NSArray class]]){
|
|
NSMutableArray * objs = [[NSMutableArray alloc] initWithCapacity:[data count]];
|
|
for (NSDictionary* dict in (NSArray*)data) {
|
|
// NSString
|
|
|
|
NSString* d = [[NSString alloc]initWithString: data];
|
|
[objs addObject:d];
|
|
}
|
|
completionBlock(objs, nil);
|
|
}
|
|
}];
|
|
|
|
|
|
}
|
|
|
|
-(NSNumber*) getAudioWithCompletionBlock:(NSString*) word
|
|
useCanonical:(NSString*) useCanonical
|
|
limit:(NSNumber*) limit
|
|
completionHandler: (void (^)(NSArray* output, NSError* error))completionBlock{
|
|
|
|
NSMutableString* requestUrl = [NSMutableString stringWithFormat:@"%@/word.{format}/{word}/audio", basePath];
|
|
|
|
// remove format in URL if needed
|
|
if ([requestUrl rangeOfString:@".{format}"].location != NSNotFound)
|
|
[requestUrl replaceCharactersInRange: [requestUrl rangeOfString:@".{format}"] withString:@".json"];
|
|
|
|
[requestUrl replaceCharactersInRange: [requestUrl rangeOfString:[NSString stringWithFormat:@"%@%@%@", @"{", @"word", @"}"]] withString: [SWGApiClient escape:word]];
|
|
NSString* requestContentType = @"application/json";
|
|
NSString* responseContentType = @"application/json";
|
|
|
|
NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init];
|
|
if(useCanonical != nil)
|
|
queryParams[@"useCanonical"] = useCanonical;
|
|
if(limit != nil)
|
|
queryParams[@"limit"] = limit;
|
|
NSMutableDictionary* headerParams = [[NSMutableDictionary alloc] init];
|
|
id bodyDictionary = nil;
|
|
if(word == nil) {
|
|
// error
|
|
}
|
|
SWGApiClient* client = [SWGApiClient sharedClientFromPool:basePath];
|
|
|
|
return [client dictionary: requestUrl
|
|
method: @"GET"
|
|
queryParams: queryParams
|
|
body: bodyDictionary
|
|
headerParams: headerParams
|
|
requestContentType: requestContentType
|
|
responseContentType: responseContentType
|
|
completionBlock: ^(NSDictionary *data, NSError *error) {
|
|
if (error) {
|
|
completionBlock(nil, error);return;
|
|
}
|
|
|
|
if([data isKindOfClass:[NSArray class]]){
|
|
NSMutableArray * objs = [[NSMutableArray alloc] initWithCapacity:[data count]];
|
|
for (NSDictionary* dict in (NSArray*)data) {
|
|
SWGAudioFile* d = [[SWGAudioFile alloc]initWithValues: dict];
|
|
[objs addObject:d];
|
|
}
|
|
completionBlock(objs, nil);
|
|
}
|
|
}];
|
|
|
|
|
|
}
|
|
|
|
-(NSNumber*) getScrabbleScoreWithCompletionBlock:(NSString*) word
|
|
completionHandler: (void (^)(SWGScrabbleScoreResult* output, NSError* error))completionBlock{
|
|
|
|
NSMutableString* requestUrl = [NSMutableString stringWithFormat:@"%@/word.{format}/{word}/scrabbleScore", basePath];
|
|
|
|
// remove format in URL if needed
|
|
if ([requestUrl rangeOfString:@".{format}"].location != NSNotFound)
|
|
[requestUrl replaceCharactersInRange: [requestUrl rangeOfString:@".{format}"] withString:@".json"];
|
|
|
|
[requestUrl replaceCharactersInRange: [requestUrl rangeOfString:[NSString stringWithFormat:@"%@%@%@", @"{", @"word", @"}"]] withString: [SWGApiClient escape:word]];
|
|
NSString* requestContentType = @"application/json";
|
|
NSString* responseContentType = @"application/json";
|
|
|
|
NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init];
|
|
NSMutableDictionary* headerParams = [[NSMutableDictionary alloc] init];
|
|
id bodyDictionary = nil;
|
|
if(word == nil) {
|
|
// error
|
|
}
|
|
SWGApiClient* client = [SWGApiClient sharedClientFromPool:basePath];
|
|
|
|
return [client dictionary:requestUrl
|
|
method:@"GET"
|
|
queryParams:queryParams
|
|
body:bodyDictionary
|
|
headerParams:headerParams
|
|
requestContentType:requestContentType
|
|
responseContentType:responseContentType
|
|
completionBlock:^(NSDictionary *data, NSError *error) {
|
|
if (error) {
|
|
completionBlock(nil, error);return;
|
|
}
|
|
SWGScrabbleScoreResult *result = nil;
|
|
if (data) {
|
|
result = [[SWGScrabbleScoreResult alloc]initWithValues: data];
|
|
}
|
|
completionBlock(result , nil);}];
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
@end
|