From b4efa892a1c4ee14fe5e494268c4378c65c58b4a Mon Sep 17 00:00:00 2001 From: Tony Tam Date: Wed, 26 Sep 2012 22:15:16 -0700 Subject: [PATCH] added objc wordnik sample --- .../objc/ObjcWordnikApiCodegen.scala | 36 + .../project.pbxproj | 4 - .../contents.xcworkspacedata | 7 + .../UserInterfaceState.xcuserstate | Bin 0 -> 37269 bytes .../xcdebugger/Breakpoints.xcbkptlist | 72 ++ .../xcschemes/WordnikApiClient.xcscheme | 86 ++ .../xcschemes/WordnikApiClientTests.xcscheme | 53 + .../xcschemes/xcschememanagement.plist | 32 + .../en.lproj/InfoPlist.strings | 2 + .../wordnik-api/objc/client/NIKAccountApi.h | 31 + .../wordnik-api/objc/client/NIKAccountApi.m | 505 ++++++++ .../wordnik-api/objc/client/NIKApiInvoker.h | 32 + .../wordnik-api/objc/client/NIKApiInvoker.m | 222 ++++ .../objc/client/NIKApiTokenStatus.h | 34 + .../objc/client/NIKApiTokenStatus.m | 58 + .../wordnik-api/objc/client/NIKAudioFile.h | 59 + .../wordnik-api/objc/client/NIKAudioFile.m | 124 ++ .../objc/client/NIKAuthenticationToken.h | 25 + .../objc/client/NIKAuthenticationToken.m | 40 + .../wordnik-api/objc/client/NIKBigram.h | 31 + .../wordnik-api/objc/client/NIKBigram.m | 52 + .../wordnik-api/objc/client/NIKCitation.h | 22 + .../wordnik-api/objc/client/NIKCitation.m | 34 + .../objc/client/NIKContentProvider.h | 22 + .../objc/client/NIKContentProvider.m | 34 + .../client/wordnik-api/objc/client/NIKDate.h | 13 + .../client/wordnik-api/objc/client/NIKDate.m | 34 + .../wordnik-api/objc/client/NIKDefinition.h | 70 ++ .../wordnik-api/objc/client/NIKDefinition.m | 280 +++++ .../objc/client/NIKDefinitionSearchResults.h | 23 + .../objc/client/NIKDefinitionSearchResults.m | 61 + .../wordnik-api/objc/client/NIKExample.h | 55 + .../wordnik-api/objc/client/NIKExample.m | 148 +++ .../objc/client/NIKExampleSearchResults.h | 24 + .../objc/client/NIKExampleSearchResults.m | 88 ++ .../wordnik-api/objc/client/NIKExampleUsage.h | 19 + .../wordnik-api/objc/client/NIKExampleUsage.m | 28 + .../client/wordnik-api/objc/client/NIKFacet.h | 23 + .../client/wordnik-api/objc/client/NIKFacet.m | 61 + .../wordnik-api/objc/client/NIKFacetValue.h | 22 + .../wordnik-api/objc/client/NIKFacetValue.m | 34 + .../wordnik-api/objc/client/NIKFrequency.h | 22 + .../wordnik-api/objc/client/NIKFrequency.m | 34 + .../objc/client/NIKFrequencySummary.h | 32 + .../objc/client/NIKFrequencySummary.m | 79 ++ .../client/wordnik-api/objc/client/NIKLabel.h | 22 + .../client/wordnik-api/objc/client/NIKLabel.m | 34 + .../client/wordnik-api/objc/client/NIKNote.h | 28 + .../client/wordnik-api/objc/client/NIKNote.m | 46 + .../wordnik-api/objc/client/NIKRelated.h | 37 + .../wordnik-api/objc/client/NIKRelated.m | 64 + .../wordnik-api/objc/client/NIKScoredWord.h | 49 + .../wordnik-api/objc/client/NIKScoredWord.m | 88 ++ .../wordnik-api/objc/client/NIKSentence.h | 35 + .../wordnik-api/objc/client/NIKSentence.m | 85 ++ .../objc/client/NIKSimpleDefinition.h | 28 + .../objc/client/NIKSimpleDefinition.m | 46 + .../objc/client/NIKSimpleExample.h | 28 + .../objc/client/NIKSimpleExample.m | 46 + .../wordnik-api/objc/client/NIKStringValue.h | 19 + .../wordnik-api/objc/client/NIKStringValue.m | 28 + .../objc/client/NIKSwaggerObject.h | 6 + .../objc/client/NIKSwaggerObject.m | 10 + .../wordnik-api/objc/client/NIKSyllable.h | 25 + .../wordnik-api/objc/client/NIKSyllable.m | 40 + .../wordnik-api/objc/client/NIKTextPron.h | 25 + .../wordnik-api/objc/client/NIKTextPron.m | 40 + .../client/wordnik-api/objc/client/NIKUser.h | 40 + .../client/wordnik-api/objc/client/NIKUser.m | 70 ++ .../wordnik-api/objc/client/NIKWordApi.h | 49 + .../wordnik-api/objc/client/NIKWordApi.m | 1100 +++++++++++++++++ .../wordnik-api/objc/client/NIKWordList.h | 50 + .../wordnik-api/objc/client/NIKWordList.m | 142 +++ .../wordnik-api/objc/client/NIKWordListApi.h | 32 + .../wordnik-api/objc/client/NIKWordListApi.m | 684 ++++++++++ .../wordnik-api/objc/client/NIKWordListWord.h | 38 + .../wordnik-api/objc/client/NIKWordListWord.m | 82 ++ .../wordnik-api/objc/client/NIKWordListsApi.h | 20 + .../wordnik-api/objc/client/NIKWordListsApi.m | 152 +++ .../wordnik-api/objc/client/NIKWordObject.h | 34 + .../wordnik-api/objc/client/NIKWordObject.m | 58 + .../wordnik-api/objc/client/NIKWordOfTheDay.h | 56 + .../wordnik-api/objc/client/NIKWordOfTheDay.m | 202 +++ .../objc/client/NIKWordSearchResult.h | 25 + .../objc/client/NIKWordSearchResult.m | 40 + .../objc/client/NIKWordSearchResults.h | 23 + .../objc/client/NIKWordSearchResults.m | 61 + .../wordnik-api/objc/client/NIKWordsApi.h | 31 + .../wordnik-api/objc/client/NIKWordsApi.m | 607 +++++++++ .../tests/WordnikApiClientTests-Info.plist | 22 + .../tests/WordnikApiClientTests-Prefix.pch | 7 + .../scala/ScalaWordnikApiCodegen.scala | 16 + 92 files changed, 7233 insertions(+), 4 deletions(-) create mode 100644 samples/client/wordnik-api/objc/ObjcWordnikApiCodegen.scala create mode 100644 samples/client/wordnik-api/objc/WordnikApiClient/WordnikApiClient.xcodeproj/project.xcworkspace/contents.xcworkspacedata create mode 100644 samples/client/wordnik-api/objc/WordnikApiClient/WordnikApiClient.xcodeproj/project.xcworkspace/xcuserdata/tony.xcuserdatad/UserInterfaceState.xcuserstate create mode 100644 samples/client/wordnik-api/objc/WordnikApiClient/WordnikApiClient.xcodeproj/xcuserdata/tony.xcuserdatad/xcdebugger/Breakpoints.xcbkptlist create mode 100644 samples/client/wordnik-api/objc/WordnikApiClient/WordnikApiClient.xcodeproj/xcuserdata/tony.xcuserdatad/xcschemes/WordnikApiClient.xcscheme create mode 100644 samples/client/wordnik-api/objc/WordnikApiClient/WordnikApiClient.xcodeproj/xcuserdata/tony.xcuserdatad/xcschemes/WordnikApiClientTests.xcscheme create mode 100644 samples/client/wordnik-api/objc/WordnikApiClient/WordnikApiClient.xcodeproj/xcuserdata/tony.xcuserdatad/xcschemes/xcschememanagement.plist create mode 100644 samples/client/wordnik-api/objc/WordnikApiClient/en.lproj/InfoPlist.strings create mode 100644 samples/client/wordnik-api/objc/client/NIKAccountApi.h create mode 100644 samples/client/wordnik-api/objc/client/NIKAccountApi.m create mode 100644 samples/client/wordnik-api/objc/client/NIKApiInvoker.h create mode 100644 samples/client/wordnik-api/objc/client/NIKApiInvoker.m create mode 100644 samples/client/wordnik-api/objc/client/NIKApiTokenStatus.h create mode 100644 samples/client/wordnik-api/objc/client/NIKApiTokenStatus.m create mode 100644 samples/client/wordnik-api/objc/client/NIKAudioFile.h create mode 100644 samples/client/wordnik-api/objc/client/NIKAudioFile.m create mode 100644 samples/client/wordnik-api/objc/client/NIKAuthenticationToken.h create mode 100644 samples/client/wordnik-api/objc/client/NIKAuthenticationToken.m create mode 100644 samples/client/wordnik-api/objc/client/NIKBigram.h create mode 100644 samples/client/wordnik-api/objc/client/NIKBigram.m create mode 100644 samples/client/wordnik-api/objc/client/NIKCitation.h create mode 100644 samples/client/wordnik-api/objc/client/NIKCitation.m create mode 100644 samples/client/wordnik-api/objc/client/NIKContentProvider.h create mode 100644 samples/client/wordnik-api/objc/client/NIKContentProvider.m create mode 100644 samples/client/wordnik-api/objc/client/NIKDate.h create mode 100644 samples/client/wordnik-api/objc/client/NIKDate.m create mode 100644 samples/client/wordnik-api/objc/client/NIKDefinition.h create mode 100644 samples/client/wordnik-api/objc/client/NIKDefinition.m create mode 100644 samples/client/wordnik-api/objc/client/NIKDefinitionSearchResults.h create mode 100644 samples/client/wordnik-api/objc/client/NIKDefinitionSearchResults.m create mode 100644 samples/client/wordnik-api/objc/client/NIKExample.h create mode 100644 samples/client/wordnik-api/objc/client/NIKExample.m create mode 100644 samples/client/wordnik-api/objc/client/NIKExampleSearchResults.h create mode 100644 samples/client/wordnik-api/objc/client/NIKExampleSearchResults.m create mode 100644 samples/client/wordnik-api/objc/client/NIKExampleUsage.h create mode 100644 samples/client/wordnik-api/objc/client/NIKExampleUsage.m create mode 100644 samples/client/wordnik-api/objc/client/NIKFacet.h create mode 100644 samples/client/wordnik-api/objc/client/NIKFacet.m create mode 100644 samples/client/wordnik-api/objc/client/NIKFacetValue.h create mode 100644 samples/client/wordnik-api/objc/client/NIKFacetValue.m create mode 100644 samples/client/wordnik-api/objc/client/NIKFrequency.h create mode 100644 samples/client/wordnik-api/objc/client/NIKFrequency.m create mode 100644 samples/client/wordnik-api/objc/client/NIKFrequencySummary.h create mode 100644 samples/client/wordnik-api/objc/client/NIKFrequencySummary.m create mode 100644 samples/client/wordnik-api/objc/client/NIKLabel.h create mode 100644 samples/client/wordnik-api/objc/client/NIKLabel.m create mode 100644 samples/client/wordnik-api/objc/client/NIKNote.h create mode 100644 samples/client/wordnik-api/objc/client/NIKNote.m create mode 100644 samples/client/wordnik-api/objc/client/NIKRelated.h create mode 100644 samples/client/wordnik-api/objc/client/NIKRelated.m create mode 100644 samples/client/wordnik-api/objc/client/NIKScoredWord.h create mode 100644 samples/client/wordnik-api/objc/client/NIKScoredWord.m create mode 100644 samples/client/wordnik-api/objc/client/NIKSentence.h create mode 100644 samples/client/wordnik-api/objc/client/NIKSentence.m create mode 100644 samples/client/wordnik-api/objc/client/NIKSimpleDefinition.h create mode 100644 samples/client/wordnik-api/objc/client/NIKSimpleDefinition.m create mode 100644 samples/client/wordnik-api/objc/client/NIKSimpleExample.h create mode 100644 samples/client/wordnik-api/objc/client/NIKSimpleExample.m create mode 100644 samples/client/wordnik-api/objc/client/NIKStringValue.h create mode 100644 samples/client/wordnik-api/objc/client/NIKStringValue.m create mode 100644 samples/client/wordnik-api/objc/client/NIKSwaggerObject.h create mode 100644 samples/client/wordnik-api/objc/client/NIKSwaggerObject.m create mode 100644 samples/client/wordnik-api/objc/client/NIKSyllable.h create mode 100644 samples/client/wordnik-api/objc/client/NIKSyllable.m create mode 100644 samples/client/wordnik-api/objc/client/NIKTextPron.h create mode 100644 samples/client/wordnik-api/objc/client/NIKTextPron.m create mode 100644 samples/client/wordnik-api/objc/client/NIKUser.h create mode 100644 samples/client/wordnik-api/objc/client/NIKUser.m create mode 100644 samples/client/wordnik-api/objc/client/NIKWordApi.h create mode 100644 samples/client/wordnik-api/objc/client/NIKWordApi.m create mode 100644 samples/client/wordnik-api/objc/client/NIKWordList.h create mode 100644 samples/client/wordnik-api/objc/client/NIKWordList.m create mode 100644 samples/client/wordnik-api/objc/client/NIKWordListApi.h create mode 100644 samples/client/wordnik-api/objc/client/NIKWordListApi.m create mode 100644 samples/client/wordnik-api/objc/client/NIKWordListWord.h create mode 100644 samples/client/wordnik-api/objc/client/NIKWordListWord.m create mode 100644 samples/client/wordnik-api/objc/client/NIKWordListsApi.h create mode 100644 samples/client/wordnik-api/objc/client/NIKWordListsApi.m create mode 100644 samples/client/wordnik-api/objc/client/NIKWordObject.h create mode 100644 samples/client/wordnik-api/objc/client/NIKWordObject.m create mode 100644 samples/client/wordnik-api/objc/client/NIKWordOfTheDay.h create mode 100644 samples/client/wordnik-api/objc/client/NIKWordOfTheDay.m create mode 100644 samples/client/wordnik-api/objc/client/NIKWordSearchResult.h create mode 100644 samples/client/wordnik-api/objc/client/NIKWordSearchResult.m create mode 100644 samples/client/wordnik-api/objc/client/NIKWordSearchResults.h create mode 100644 samples/client/wordnik-api/objc/client/NIKWordSearchResults.m create mode 100644 samples/client/wordnik-api/objc/client/NIKWordsApi.h create mode 100644 samples/client/wordnik-api/objc/client/NIKWordsApi.m create mode 100644 samples/client/wordnik-api/objc/tests/WordnikApiClientTests-Info.plist create mode 100644 samples/client/wordnik-api/objc/tests/WordnikApiClientTests-Prefix.pch diff --git a/samples/client/wordnik-api/objc/ObjcWordnikApiCodegen.scala b/samples/client/wordnik-api/objc/ObjcWordnikApiCodegen.scala new file mode 100644 index 00000000000..0e1c241544f --- /dev/null +++ b/samples/client/wordnik-api/objc/ObjcWordnikApiCodegen.scala @@ -0,0 +1,36 @@ +/** + * Copyright 2012 Wordnik, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import com.wordnik.swagger.codegen.BasicObjcGenerator + +import com.wordnik.swagger.core._ + +object ObjcWordnikApiCodegen extends BasicObjcGenerator { + def main(args: Array[String]) = generateClient(args) + + // where to write generated code + override def destinationDir = "samples/client/wordnik-api/objc/client" + + // supporting classes + override def supportingFiles = + List( + ("NIKSwaggerObject.h", destinationDir, "NIKSwaggerObject.h"), + ("NIKSwaggerObject.m", destinationDir, "NIKSwaggerObject.m"), + ("NIKApiInvoker.h", destinationDir, "NIKApiInvoker.h"), + ("NIKApiInvoker.m", destinationDir, "NIKApiInvoker.m"), + ("NIKDate.h", destinationDir, "NIKDate.h"), + ("NIKDate.m", destinationDir, "NIKDate.m")) +} diff --git a/samples/client/wordnik-api/objc/WordnikApiClient/WordnikApiClient.xcodeproj/project.pbxproj b/samples/client/wordnik-api/objc/WordnikApiClient/WordnikApiClient.xcodeproj/project.pbxproj index 32dd2c779e9..db2f2dd9aac 100644 --- a/samples/client/wordnik-api/objc/WordnikApiClient/WordnikApiClient.xcodeproj/project.pbxproj +++ b/samples/client/wordnik-api/objc/WordnikApiClient/WordnikApiClient.xcodeproj/project.pbxproj @@ -242,8 +242,6 @@ EA5A02A21613AC66003B3E41 /* NIKWordSearchResults.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = NIKWordSearchResults.m; path = ../client/NIKWordSearchResults.m; sourceTree = ""; }; EA5A02CD1613AD47003B3E41 /* WordnikApiClientTests-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = "WordnikApiClientTests-Info.plist"; path = "../tests/WordnikApiClientTests-Info.plist"; sourceTree = ""; }; EA5A02CE1613AD47003B3E41 /* WordnikApiClientTests-Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "WordnikApiClientTests-Prefix.pch"; path = "../tests/WordnikApiClientTests-Prefix.pch"; sourceTree = ""; }; - EA5A02CF1613AD47003B3E41 /* WordnikApiClientTests.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WordnikApiClientTests.h; path = ../tests/WordnikApiClientTests.h; sourceTree = ""; }; - EA5A02D01613AD47003B3E41 /* WordnikApiClientTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = WordnikApiClientTests.m; path = ../tests/WordnikApiClientTests.m; sourceTree = ""; }; EA5A02E41614017E003B3E41 /* WordApiTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WordApiTest.h; path = ../tests/WordApiTest.h; sourceTree = ""; }; EA5A02E51614017E003B3E41 /* WordApiTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = WordApiTest.m; path = ../tests/WordApiTest.m; sourceTree = ""; }; /* End PBXFileReference section */ @@ -333,8 +331,6 @@ children = ( EA5A02CD1613AD47003B3E41 /* WordnikApiClientTests-Info.plist */, EA5A02CE1613AD47003B3E41 /* WordnikApiClientTests-Prefix.pch */, - EA5A02CF1613AD47003B3E41 /* WordnikApiClientTests.h */, - EA5A02D01613AD47003B3E41 /* WordnikApiClientTests.m */, EA5A02E41614017E003B3E41 /* WordApiTest.h */, EA5A02E51614017E003B3E41 /* WordApiTest.m */, ); diff --git a/samples/client/wordnik-api/objc/WordnikApiClient/WordnikApiClient.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/samples/client/wordnik-api/objc/WordnikApiClient/WordnikApiClient.xcodeproj/project.xcworkspace/contents.xcworkspacedata new file mode 100644 index 00000000000..34f8a86f517 --- /dev/null +++ b/samples/client/wordnik-api/objc/WordnikApiClient/WordnikApiClient.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/samples/client/wordnik-api/objc/WordnikApiClient/WordnikApiClient.xcodeproj/project.xcworkspace/xcuserdata/tony.xcuserdatad/UserInterfaceState.xcuserstate b/samples/client/wordnik-api/objc/WordnikApiClient/WordnikApiClient.xcodeproj/project.xcworkspace/xcuserdata/tony.xcuserdatad/UserInterfaceState.xcuserstate new file mode 100644 index 0000000000000000000000000000000000000000..02b8faaa0539bf26f1aaeee1f2cbff7872024716 GIT binary patch literal 37269 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 + + + + + + + + + + + + + + diff --git a/samples/client/wordnik-api/objc/WordnikApiClient/WordnikApiClient.xcodeproj/xcuserdata/tony.xcuserdatad/xcschemes/WordnikApiClient.xcscheme b/samples/client/wordnik-api/objc/WordnikApiClient/WordnikApiClient.xcodeproj/xcuserdata/tony.xcuserdatad/xcschemes/WordnikApiClient.xcscheme new file mode 100644 index 00000000000..e6c96f60765 --- /dev/null +++ b/samples/client/wordnik-api/objc/WordnikApiClient/WordnikApiClient.xcodeproj/xcuserdata/tony.xcuserdatad/xcschemes/WordnikApiClient.xcscheme @@ -0,0 +1,86 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/samples/client/wordnik-api/objc/WordnikApiClient/WordnikApiClient.xcodeproj/xcuserdata/tony.xcuserdatad/xcschemes/WordnikApiClientTests.xcscheme b/samples/client/wordnik-api/objc/WordnikApiClient/WordnikApiClient.xcodeproj/xcuserdata/tony.xcuserdatad/xcschemes/WordnikApiClientTests.xcscheme new file mode 100644 index 00000000000..dbc5c6a29d6 --- /dev/null +++ b/samples/client/wordnik-api/objc/WordnikApiClient/WordnikApiClient.xcodeproj/xcuserdata/tony.xcuserdatad/xcschemes/WordnikApiClientTests.xcscheme @@ -0,0 +1,53 @@ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/samples/client/wordnik-api/objc/WordnikApiClient/WordnikApiClient.xcodeproj/xcuserdata/tony.xcuserdatad/xcschemes/xcschememanagement.plist b/samples/client/wordnik-api/objc/WordnikApiClient/WordnikApiClient.xcodeproj/xcuserdata/tony.xcuserdatad/xcschemes/xcschememanagement.plist new file mode 100644 index 00000000000..f2695389746 --- /dev/null +++ b/samples/client/wordnik-api/objc/WordnikApiClient/WordnikApiClient.xcodeproj/xcuserdata/tony.xcuserdatad/xcschemes/xcschememanagement.plist @@ -0,0 +1,32 @@ + + + + + SchemeUserState + + WordnikApiClient.xcscheme + + orderHint + 0 + + WordnikApiClientTests.xcscheme + + orderHint + 1 + + + SuppressBuildableAutocreation + + EA224CFC1613ABE700129740 + + primary + + + EA224D131613ABFA00129740 + + primary + + + + + diff --git a/samples/client/wordnik-api/objc/WordnikApiClient/en.lproj/InfoPlist.strings b/samples/client/wordnik-api/objc/WordnikApiClient/en.lproj/InfoPlist.strings new file mode 100644 index 00000000000..477b28ff8f8 --- /dev/null +++ b/samples/client/wordnik-api/objc/WordnikApiClient/en.lproj/InfoPlist.strings @@ -0,0 +1,2 @@ +/* Localized versions of Info.plist keys */ + diff --git a/samples/client/wordnik-api/objc/client/NIKAccountApi.h b/samples/client/wordnik-api/objc/client/NIKAccountApi.h new file mode 100644 index 00000000000..b7e8d198d47 --- /dev/null +++ b/samples/client/wordnik-api/objc/client/NIKAccountApi.h @@ -0,0 +1,31 @@ +#import +#import "NIKApiInvoker.h" +#import "NIKApiTokenStatus.h" +#import "NIKWordList.h" +#import "NIKUser.h" +#import "NIKAuthenticationToken.h" + + +@interface NIKAccountApi: NSObject { + +@private + NSOperationQueue *_queue; + NIKApiInvoker * _api; +} +@property(nonatomic, readonly) NSOperationQueue* queue; +@property(nonatomic, readonly) NIKApiInvoker* api; + +-(void) addHeader:(NSString*) value + forKey:(NSString*)key; + +-(void) authenticateWithCompletionBlock :(NSString*) username password:(NSString*) password + completionHandler:(void (^)(NIKAuthenticationToken*, NSError *))completionBlock; +-(void) authenticatePostWithCompletionBlock :(NSString*) username body:(NSString*) body + completionHandler:(void (^)(NIKAuthenticationToken*, NSError *))completionBlock; +-(void) getWordListsForLoggedInUserWithCompletionBlock :(NSString*) auth_token skip:(NSNumber*) skip limit:(NSNumber*) limit + completionHandler:(void (^)(NSArray*, NSError *))completionBlock; +-(void) getApiTokenStatusWithCompletionBlock :(NSString*) api_key + completionHandler:(void (^)(NIKApiTokenStatus*, NSError *))completionBlock; +-(void) getLoggedInUserWithCompletionBlock :(NSString*) auth_token + completionHandler:(void (^)(NIKUser*, NSError *))completionBlock; +@end diff --git a/samples/client/wordnik-api/objc/client/NIKAccountApi.m b/samples/client/wordnik-api/objc/client/NIKAccountApi.m new file mode 100644 index 00000000000..b8059cefed6 --- /dev/null +++ b/samples/client/wordnik-api/objc/client/NIKAccountApi.m @@ -0,0 +1,505 @@ +#import "NIKAccountApi.h" +#import "NIKApiTokenStatus.h" +#import "NIKWordList.h" +#import "NIKUser.h" +#import "NIKAuthenticationToken.h" + + + +@implementation NIKAccountApi +static NSString * basePath = @"http://api.wordnik.com/v4"; + +@synthesize queue = _queue; +@synthesize api = _api; + +- (id) init { + self = [super init]; + _queue = [[NSOperationQueue alloc] init]; + _api = [[NIKApiInvoker alloc] init]; + + return self; +} + +-(void) addHeader:(NSString*) value + forKey:(NSString*)key { + [_api addHeader:value forKey:key]; +} + +/** + * + * returnTypeIsPrimitive: + * returnBaseType: NIKAuthenticationToken + * returnContainer: + * + **/ +-(void) authenticateWithCompletionBlock :(NSString*) username password:(NSString*) password + completionHandler:(void (^)(NIKAuthenticationToken*, NSError *))completionBlock{ + + NSMutableString* requestUrl = [NSMutableString stringWithFormat:@"%@/account.{format}/authenticate/{username}", 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:@"%@%@%@", @"{", @"username", @"}"]] withString: [_api escapeString:username]]; + NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init]; + if(password != nil) + [queryParams setValue:password forKey:@"password"]; + NSMutableDictionary* headerParams = [[NSMutableDictionary alloc] init]; + id bodyDictionary = nil; + if(username == nil) { + // error + } + if(password == nil) { + // error + } + // not a return container + [_api dictionaryWithCompletionBlock: requestUrl + method: @"GET" + queryParams: queryParams + body: bodyDictionary + headerParams: headerParams + completionHandler: ^(NSDictionary *data, NSError *error) { + if (error) { + completionBlock(nil, error);return; + } + + completionBlock( [[NIKAuthenticationToken alloc]initWithValues: data], nil);}]; + +} + +/** + * + * returnTypeIsPrimitive: + * returnBaseType: NIKAuthenticationToken + * returnContainer: + * + **/ +-(void) authenticatePostWithCompletionBlock :(NSString*) username body:(NSString*) body + completionHandler:(void (^)(NIKAuthenticationToken*, NSError *))completionBlock{ + + NSMutableString* requestUrl = [NSMutableString stringWithFormat:@"%@/account.{format}/authenticate/{username}", 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:@"%@%@%@", @"{", @"username", @"}"]] withString: [_api escapeString:username]]; + NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init]; + NSMutableDictionary* headerParams = [[NSMutableDictionary alloc] init]; + id bodyDictionary = nil; + if(body != nil && [body isKindOfClass:[NSArray class]]){ + NSMutableArray * objs = [[NSMutableArray alloc] init]; + for (id dict in (NSArray*)body) { + if([dict respondsToSelector:@selector(asDictionary)]) { + [objs addObject:[(NIKSwaggerObject*)dict asDictionary]]; + } + else{ + [objs addObject:dict]; + } + } + bodyDictionary = objs; + } + else if([body respondsToSelector:@selector(asDictionary)]) { + bodyDictionary = [(NIKSwaggerObject*)body asDictionary]; + } + else if([body isKindOfClass:[NSString class]]) { + bodyDictionary = body; + } + else{ + NSLog(@"don't know what to do with %@", body); + } + + if(username == nil) { + // error + } + if(body == nil) { + // error + } + // not a return container + [_api dictionaryWithCompletionBlock: requestUrl + method: @"POST" + queryParams: queryParams + body: bodyDictionary + headerParams: headerParams + completionHandler: ^(NSDictionary *data, NSError *error) { + if (error) { + completionBlock(nil, error);return; + } + + completionBlock( [[NIKAuthenticationToken alloc]initWithValues: data], nil);}]; + +} + +/** + * + * returnTypeIsPrimitive: + * returnBaseType: NIKWordList + * returnContainer: List + * + **/ +-(void) getWordListsForLoggedInUserWithCompletionBlock :(NSString*) auth_token skip:(NSNumber*) skip limit:(NSNumber*) limit + completionHandler:(void (^)(NSArray*, NSError *))completionBlock{ + + NSMutableString* requestUrl = [NSMutableString stringWithFormat:@"%@/account.{format}/wordLists", basePath]; + + // remove format in URL if needed + if ([requestUrl rangeOfString:@".{format}"].location != NSNotFound) + [requestUrl replaceCharactersInRange: [requestUrl rangeOfString:@".{format}"] withString:@".json"]; + + NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init]; + if(skip != nil) + [queryParams setValue:skip forKey:@"skip"]; + if(limit != nil) + [queryParams setValue:limit forKey:@"limit"]; + NSMutableDictionary* headerParams = [[NSMutableDictionary alloc] init]; + if(auth_token != nil) + [headerParams setValue:auth_token forKey:@"auth_token"]; + id bodyDictionary = nil; + if(auth_token == nil) { + // error + } + // it's a returnContainer + [_api dictionaryWithCompletionBlock: requestUrl + method: @"GET" + queryParams: queryParams + body: bodyDictionary + headerParams: headerParams + completionHandler: ^(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) { + NIKWordList* d = [[NIKWordList alloc]initWithValues: dict]; + [objs addObject:d]; + } + completionBlock(objs, nil); + } + }]; + +} + +/** + * + * returnTypeIsPrimitive: + * returnBaseType: NIKApiTokenStatus + * returnContainer: + * + **/ +-(void) getApiTokenStatusWithCompletionBlock :(NSString*) api_key + completionHandler:(void (^)(NIKApiTokenStatus*, NSError *))completionBlock{ + + NSMutableString* requestUrl = [NSMutableString stringWithFormat:@"%@/account.{format}/apiTokenStatus", basePath]; + + // remove format in URL if needed + if ([requestUrl rangeOfString:@".{format}"].location != NSNotFound) + [requestUrl replaceCharactersInRange: [requestUrl rangeOfString:@".{format}"] withString:@".json"]; + + NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init]; + NSMutableDictionary* headerParams = [[NSMutableDictionary alloc] init]; + if(api_key != nil) + [headerParams setValue:api_key forKey:@"api_key"]; + id bodyDictionary = nil; + // not a return container + [_api dictionaryWithCompletionBlock: requestUrl + method: @"GET" + queryParams: queryParams + body: bodyDictionary + headerParams: headerParams + completionHandler: ^(NSDictionary *data, NSError *error) { + if (error) { + completionBlock(nil, error);return; + } + + completionBlock( [[NIKApiTokenStatus alloc]initWithValues: data], nil);}]; + +} + +/** + * + * returnTypeIsPrimitive: + * returnBaseType: NIKUser + * returnContainer: + * + **/ +-(void) getLoggedInUserWithCompletionBlock :(NSString*) auth_token + completionHandler:(void (^)(NIKUser*, NSError *))completionBlock{ + + NSMutableString* requestUrl = [NSMutableString stringWithFormat:@"%@/account.{format}/user", basePath]; + + // remove format in URL if needed + if ([requestUrl rangeOfString:@".{format}"].location != NSNotFound) + [requestUrl replaceCharactersInRange: [requestUrl rangeOfString:@".{format}"] withString:@".json"]; + + NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init]; + NSMutableDictionary* headerParams = [[NSMutableDictionary alloc] init]; + if(auth_token != nil) + [headerParams setValue:auth_token forKey:@"auth_token"]; + id bodyDictionary = nil; + if(auth_token == nil) { + // error + } + // not a return container + [_api dictionaryWithCompletionBlock: requestUrl + method: @"GET" + queryParams: queryParams + body: bodyDictionary + headerParams: headerParams + completionHandler: ^(NSDictionary *data, NSError *error) { + if (error) { + completionBlock(nil, error);return; + } + + completionBlock( [[NIKUser alloc]initWithValues: data], nil);}]; + +} + +-(void) authenticateAsJsonWithCompletionBlock :(NSString*) username password:(NSString*) password + completionHandler:(void (^)(NSString*, NSError *))completionBlock{ + + NSMutableString* requestUrl = [NSMutableString stringWithFormat:@"%@/account.{format}/authenticate/{username}", basePath]; + + // remove format in URL if needed + if ([requestUrl rangeOfString:@".{format}"].location != NSNotFound) + [requestUrl replaceCharactersInRange: [requestUrl rangeOfString:@".{format}"] withString:@""]; + + [requestUrl replaceCharactersInRange: [requestUrl rangeOfString:[NSString stringWithFormat:@"%@%@%@", @"{", @"username", @"}"]] withString: [_api escapeString:username]]; + NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init]; + if(password != nil) + [queryParams setValue:password forKey:@"password"]; + NSMutableDictionary* headerParams = [[NSMutableDictionary alloc] init]; + id bodyDictionary = nil; + if(username == nil) { + // error + } + if(password == nil) { + // error + } + [_api dictionaryWithCompletionBlock: requestUrl + method: @"GET" + queryParams: queryParams + body: bodyDictionary + headerParams: headerParams + completionHandler: ^(NSDictionary *data, NSError *error) { + if (error) { + completionBlock(nil, error);return; + } + + NSData * responseData = nil; + if([data isKindOfClass:[NSDictionary class]]){ + responseData = [NSJSONSerialization dataWithJSONObject:data + options:kNilOptions error:&error]; + } + else if ([data isKindOfClass:[NSArray class]]){ + responseData = [NSJSONSerialization dataWithJSONObject:data + options:kNilOptions error:&error]; + } + NSString * json = [[NSString alloc]initWithData:responseData encoding:NSUTF8StringEncoding]; + completionBlock(json, nil); + + }]; + +} + +-(void) authenticatePostAsJsonWithCompletionBlock :(NSString*) username body:(NSString*) body + completionHandler:(void (^)(NSString*, NSError *))completionBlock{ + + NSMutableString* requestUrl = [NSMutableString stringWithFormat:@"%@/account.{format}/authenticate/{username}", basePath]; + + // remove format in URL if needed + if ([requestUrl rangeOfString:@".{format}"].location != NSNotFound) + [requestUrl replaceCharactersInRange: [requestUrl rangeOfString:@".{format}"] withString:@""]; + + [requestUrl replaceCharactersInRange: [requestUrl rangeOfString:[NSString stringWithFormat:@"%@%@%@", @"{", @"username", @"}"]] withString: [_api escapeString:username]]; + NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init]; + NSMutableDictionary* headerParams = [[NSMutableDictionary alloc] init]; + id bodyDictionary = nil; + if(body != nil && [body isKindOfClass:[NSArray class]]){ + NSMutableArray * objs = [[NSMutableArray alloc] init]; + for (id dict in (NSArray*)body) { + if([dict respondsToSelector:@selector(asDictionary)]) { + [objs addObject:[(NIKSwaggerObject*)dict asDictionary]]; + } + else{ + [objs addObject:dict]; + } + } + bodyDictionary = objs; + } + else if([body respondsToSelector:@selector(asDictionary)]) { + bodyDictionary = [(NIKSwaggerObject*)body asDictionary]; + } + else if([body isKindOfClass:[NSString class]]) { + bodyDictionary = body; + } + else{ + NSLog(@"don't know what to do with %@", body); + } + + if(username == nil) { + // error + } + if(body == nil) { + // error + } + [_api dictionaryWithCompletionBlock: requestUrl + method: @"POST" + queryParams: queryParams + body: bodyDictionary + headerParams: headerParams + completionHandler: ^(NSDictionary *data, NSError *error) { + if (error) { + completionBlock(nil, error);return; + } + + NSData * responseData = nil; + if([data isKindOfClass:[NSDictionary class]]){ + responseData = [NSJSONSerialization dataWithJSONObject:data + options:kNilOptions error:&error]; + } + else if ([data isKindOfClass:[NSArray class]]){ + responseData = [NSJSONSerialization dataWithJSONObject:data + options:kNilOptions error:&error]; + } + NSString * json = [[NSString alloc]initWithData:responseData encoding:NSUTF8StringEncoding]; + completionBlock(json, nil); + + }]; + +} + +-(void) getWordListsForLoggedInUserAsJsonWithCompletionBlock :(NSString*) auth_token skip:(NSNumber*) skip limit:(NSNumber*) limit + completionHandler:(void (^)(NSString*, NSError *))completionBlock{ + + NSMutableString* requestUrl = [NSMutableString stringWithFormat:@"%@/account.{format}/wordLists", basePath]; + + // remove format in URL if needed + if ([requestUrl rangeOfString:@".{format}"].location != NSNotFound) + [requestUrl replaceCharactersInRange: [requestUrl rangeOfString:@".{format}"] withString:@""]; + + NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init]; + if(skip != nil) + [queryParams setValue:skip forKey:@"skip"]; + if(limit != nil) + [queryParams setValue:limit forKey:@"limit"]; + NSMutableDictionary* headerParams = [[NSMutableDictionary alloc] init]; + if(auth_token != nil) + [headerParams setValue:auth_token forKey:@"auth_token"]; + id bodyDictionary = nil; + if(auth_token == nil) { + // error + } + [_api dictionaryWithCompletionBlock: requestUrl + method: @"GET" + queryParams: queryParams + body: bodyDictionary + headerParams: headerParams + completionHandler: ^(NSDictionary *data, NSError *error) { + if (error) { + completionBlock(nil, error);return; + } + + NSData * responseData = nil; + if([data isKindOfClass:[NSDictionary class]]){ + responseData = [NSJSONSerialization dataWithJSONObject:data + options:kNilOptions error:&error]; + } + else if ([data isKindOfClass:[NSArray class]]){ + responseData = [NSJSONSerialization dataWithJSONObject:data + options:kNilOptions error:&error]; + } + NSString * json = [[NSString alloc]initWithData:responseData encoding:NSUTF8StringEncoding]; + completionBlock(json, nil); + + }]; + +} + +-(void) getApiTokenStatusAsJsonWithCompletionBlock :(NSString*) api_key + completionHandler:(void (^)(NSString*, NSError *))completionBlock{ + + NSMutableString* requestUrl = [NSMutableString stringWithFormat:@"%@/account.{format}/apiTokenStatus", basePath]; + + // remove format in URL if needed + if ([requestUrl rangeOfString:@".{format}"].location != NSNotFound) + [requestUrl replaceCharactersInRange: [requestUrl rangeOfString:@".{format}"] withString:@""]; + + NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init]; + NSMutableDictionary* headerParams = [[NSMutableDictionary alloc] init]; + if(api_key != nil) + [headerParams setValue:api_key forKey:@"api_key"]; + id bodyDictionary = nil; + [_api dictionaryWithCompletionBlock: requestUrl + method: @"GET" + queryParams: queryParams + body: bodyDictionary + headerParams: headerParams + completionHandler: ^(NSDictionary *data, NSError *error) { + if (error) { + completionBlock(nil, error);return; + } + + NSData * responseData = nil; + if([data isKindOfClass:[NSDictionary class]]){ + responseData = [NSJSONSerialization dataWithJSONObject:data + options:kNilOptions error:&error]; + } + else if ([data isKindOfClass:[NSArray class]]){ + responseData = [NSJSONSerialization dataWithJSONObject:data + options:kNilOptions error:&error]; + } + NSString * json = [[NSString alloc]initWithData:responseData encoding:NSUTF8StringEncoding]; + completionBlock(json, nil); + + }]; + +} + +-(void) getLoggedInUserAsJsonWithCompletionBlock :(NSString*) auth_token + completionHandler:(void (^)(NSString*, NSError *))completionBlock{ + + NSMutableString* requestUrl = [NSMutableString stringWithFormat:@"%@/account.{format}/user", basePath]; + + // remove format in URL if needed + if ([requestUrl rangeOfString:@".{format}"].location != NSNotFound) + [requestUrl replaceCharactersInRange: [requestUrl rangeOfString:@".{format}"] withString:@""]; + + NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init]; + NSMutableDictionary* headerParams = [[NSMutableDictionary alloc] init]; + if(auth_token != nil) + [headerParams setValue:auth_token forKey:@"auth_token"]; + id bodyDictionary = nil; + if(auth_token == nil) { + // error + } + [_api dictionaryWithCompletionBlock: requestUrl + method: @"GET" + queryParams: queryParams + body: bodyDictionary + headerParams: headerParams + completionHandler: ^(NSDictionary *data, NSError *error) { + if (error) { + completionBlock(nil, error);return; + } + + NSData * responseData = nil; + if([data isKindOfClass:[NSDictionary class]]){ + responseData = [NSJSONSerialization dataWithJSONObject:data + options:kNilOptions error:&error]; + } + else if ([data isKindOfClass:[NSArray class]]){ + responseData = [NSJSONSerialization dataWithJSONObject:data + options:kNilOptions error:&error]; + } + NSString * json = [[NSString alloc]initWithData:responseData encoding:NSUTF8StringEncoding]; + completionBlock(json, nil); + + }]; + +} + + +@end diff --git a/samples/client/wordnik-api/objc/client/NIKApiInvoker.h b/samples/client/wordnik-api/objc/client/NIKApiInvoker.h new file mode 100644 index 00000000000..1e1c28aef37 --- /dev/null +++ b/samples/client/wordnik-api/objc/client/NIKApiInvoker.h @@ -0,0 +1,32 @@ +#import + +@interface NIKApiInvoker : NSObject { + +@private + NSOperationQueue *_queue; + NSMutableDictionary * _defaultHeaders; +} +@property(nonatomic, readonly) NSOperationQueue* queue; +@property(nonatomic, readonly) NSMutableDictionary * defaultHeaders; + + +-(void) addHeader:(NSString*) value + forKey:(NSString*)key; + +-(NSString*) escapeString:(NSString*) string; + +-(id) dictionaryWithCompletionBlock:(NSString*) path + method:(NSString*) method + queryParams:(NSDictionary*) queryParams + body:(id)body + headerParams:(NSDictionary*) headerParams + completionHandler:(void (^)(NSDictionary*, NSError *))completionBlock; + +-(id) stringWithCompletionBlock:(NSString*) path + method:(NSString*) method + queryParams:(NSDictionary*) queryParams + body:(id)body + headerParams:(NSDictionary*) headerParams + completionHandler:(void (^)(NSString*, NSError *))completionBlock; + +@end diff --git a/samples/client/wordnik-api/objc/client/NIKApiInvoker.m b/samples/client/wordnik-api/objc/client/NIKApiInvoker.m new file mode 100644 index 00000000000..62962375a06 --- /dev/null +++ b/samples/client/wordnik-api/objc/client/NIKApiInvoker.m @@ -0,0 +1,222 @@ +#import "NIKApiInvoker.h" + +@implementation NIKApiInvoker + +@synthesize queue = _queue; +@synthesize defaultHeaders = _defaultHeaders; + +- (id) init { + self = [super init]; + _queue = [[NSOperationQueue alloc] init]; + _defaultHeaders = [[NSMutableDictionary alloc] init]; + return self; +} + +-(void) addHeader:(NSString*) value + forKey:(NSString*)key { + [_defaultHeaders setValue:value forKey:key]; +} + +-(NSString*) escapeString:(NSString *)unescaped { + return (NSString *)CFBridgingRelease(CFURLCreateStringByAddingPercentEscapes( + NULL, + (__bridge CFStringRef) unescaped, + NULL, + (CFStringRef)@"!*'();:@&=+$,/?%#[]", + kCFStringEncodingUTF8)); +} + +-(id) dictionaryWithCompletionBlock:(NSString*) path + method:(NSString*) method + queryParams:(NSDictionary*) queryParams + body:(id) body + headerParams:(NSDictionary*) headerParams + completionHandler:(void (^)(NSDictionary*, NSError *))completionBlock +{ + NSMutableString * requestUrl = [NSMutableString stringWithFormat:@"%@", path]; + NSString * separator = nil; + int counter = 0; + if(queryParams != nil){ + for(NSString * key in [queryParams keyEnumerator]){ + if(counter == 0) separator = @"?"; + else separator = @"&"; + NSString * value; + if([[queryParams valueForKey:key] isKindOfClass:[NSString class]]){ + value = [self escapeString:[queryParams valueForKey:key]]; + } + else { + value = [NSString stringWithFormat:@"%@", [queryParams valueForKey:key]]; + } + [requestUrl appendString:[NSString stringWithFormat:@"%@%@=%@", separator, + [self escapeString:key], value]]; + counter += 1; + } + } + NSLog(@"request url: %@", requestUrl); + + NSURL* URL = [NSURL URLWithString:requestUrl]; + + NSMutableURLRequest* request = [[NSMutableURLRequest alloc] init]; + [request setURL:URL]; + [request setCachePolicy:NSURLRequestReloadIgnoringLocalCacheData]; + [request setTimeoutInterval:30]; + + for(NSString * key in [_defaultHeaders keyEnumerator]){ + [request setValue:[_defaultHeaders valueForKey:key] forHTTPHeaderField:key]; + } + if(headerParams != nil){ + for(NSString * key in [headerParams keyEnumerator]){ + [request setValue:[headerParams valueForKey:key] forHTTPHeaderField:key]; + } + } + [request setHTTPMethod:method]; + if(body != nil) { + NSError * error = [NSError new]; + NSData * data = nil; + if([body isKindOfClass:[NSDictionary class]]){ + data = [NSJSONSerialization dataWithJSONObject:body + options:kNilOptions error:&error]; + } + else if ([body isKindOfClass:[NSArray class]]){ + data = [NSJSONSerialization dataWithJSONObject:body + options:kNilOptions error:&error]; + } + else { + data = [body dataUsingEncoding:NSUTF8StringEncoding]; + } + NSString *postLength = [NSString stringWithFormat:@"%ld", [data length]]; + [request setValue:postLength forHTTPHeaderField:@"Content-Length"]; + [request setHTTPBody:data]; + + [request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"]; + [request setCachePolicy:NSURLRequestReloadIgnoringLocalCacheData]; + + NSLog(@"request: %@", request); + } + + [NSURLConnection sendAsynchronousRequest:request queue:_queue completionHandler: + ^(NSURLResponse *response, NSData *data, NSError *error) { + long statusCode = [(NSHTTPURLResponse*)response statusCode]; + + if (error) { + completionBlock(nil, error); + return; + } + else if (!NSLocationInRange(statusCode, NSMakeRange(200, 99))){ + error = [NSError errorWithDomain:@"swagger" + code:statusCode + userInfo:[NSJSONSerialization JSONObjectWithData:data + options:kNilOptions + error:&error]]; + completionBlock(nil, error); + return; + } + else { + NSDictionary* results = [NSJSONSerialization JSONObjectWithData:data + options:kNilOptions + error:&error]; + completionBlock(results, nil); + } + }]; + return nil; +} + +-(id) stringWithCompletionBlock:(NSString*) path + method:(NSString*) method + queryParams:(NSDictionary*) queryParams + body:(id) body + headerParams:(NSDictionary*) headerParams + completionHandler:(void (^)(NSString*, NSError *))completionBlock +{ + NSMutableString * requestUrl = [NSMutableString stringWithFormat:@"%@", path]; + NSString * separator = nil; + int counter = 0; + if(queryParams != nil){ + for(NSString * key in [queryParams keyEnumerator]){ + if(counter == 0) separator = @"?"; + else separator = @"&"; + NSString * value; + if([[queryParams valueForKey:key] isKindOfClass:[NSString class]]){ + value = [self escapeString:[queryParams valueForKey:key]]; + } + else { + value = [NSString stringWithFormat:@"%@", [queryParams valueForKey:key]]; + } + [requestUrl appendFormat:[NSString stringWithFormat:@"%@%@=%@", separator, + [self escapeString:key], value]]; + counter += 1; + } + } + NSLog(@"request url: %@", requestUrl); + + NSURL* URL = [NSURL URLWithString:requestUrl]; + + NSMutableURLRequest* request = [[NSMutableURLRequest alloc] init]; + [request setURL:URL]; + [request setCachePolicy:NSURLRequestReloadIgnoringLocalCacheData]; + [request setTimeoutInterval:30]; + + for(NSString * key in [_defaultHeaders keyEnumerator]){ + [request setValue:[_defaultHeaders valueForKey:key] forHTTPHeaderField:key]; + } + if(headerParams != nil){ + for(NSString * key in [headerParams keyEnumerator]){ + [request setValue:[headerParams valueForKey:key] forHTTPHeaderField:key]; + } + } + [request setHTTPMethod:method]; + if(body != nil) { + NSError * error = [NSError new]; + NSData * data = nil; + if([body isKindOfClass:[NSDictionary class]]){ + data = [NSJSONSerialization dataWithJSONObject:body + options:kNilOptions error:&error]; + } + else if ([body isKindOfClass:[NSArray class]]){ + data = [NSJSONSerialization dataWithJSONObject:body + options:kNilOptions error:&error]; + } + else { + data = [body dataUsingEncoding:NSUTF8StringEncoding]; + } + NSString *postLength = [NSString stringWithFormat:@"%d", [data length]]; + [request setValue:postLength forHTTPHeaderField:@"Content-Length"]; + [request setHTTPBody:data]; + + [request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"]; + [request setCachePolicy:NSURLRequestReloadIgnoringLocalCacheData]; + + NSLog(@"request: %@", request); + } + + [NSURLConnection sendAsynchronousRequest:request queue:_queue completionHandler: + ^(NSURLResponse *response, NSData *data, NSError *error) { + int statusCode = [(NSHTTPURLResponse*)response statusCode]; + + if (error) { + completionBlock(nil, error); + return; + } + else if (!NSLocationInRange(statusCode, NSMakeRange(200, 99))){ + error = [NSError errorWithDomain:@"swagger" + code:statusCode + userInfo:[NSJSONSerialization JSONObjectWithData:data + options:kNilOptions + error:&error]]; + completionBlock(nil, error); + return; + } + else { + NSString* results = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]; + + if(results && [results length] >= 2) { + if(([results characterAtIndex:0] == '\"') && ([results characterAtIndex:([results length] - 1) == '\"'])){ + results = [results substringWithRange:NSMakeRange(1, [results length] -2)]; + } + } + completionBlock(results, nil); + } + }]; + return nil; +} +@end \ No newline at end of file diff --git a/samples/client/wordnik-api/objc/client/NIKApiTokenStatus.h b/samples/client/wordnik-api/objc/client/NIKApiTokenStatus.h new file mode 100644 index 00000000000..709238fd549 --- /dev/null +++ b/samples/client/wordnik-api/objc/client/NIKApiTokenStatus.h @@ -0,0 +1,34 @@ +#import +#import "NIKSwaggerObject.h" + +@interface NIKApiTokenStatus : NIKSwaggerObject { +@private + NSNumber* _valid; //NSNumber + NSString* _token; //NSString + NSNumber* _resetsInMillis; //NSNumber + NSNumber* _remainingCalls; //NSNumber + NSNumber* _expiresInMillis; //NSNumber + NSNumber* _totalRequests; //NSNumber + } + + + +@property(nonatomic) NSNumber* valid; +@property(nonatomic) NSString* token; +@property(nonatomic) NSNumber* resetsInMillis; +@property(nonatomic) NSNumber* remainingCalls; +@property(nonatomic) NSNumber* expiresInMillis; +@property(nonatomic) NSNumber* totalRequests; +- (id) valid: (NSNumber*) valid + token: (NSString*) token + resetsInMillis: (NSNumber*) resetsInMillis + remainingCalls: (NSNumber*) remainingCalls + expiresInMillis: (NSNumber*) expiresInMillis + totalRequests: (NSNumber*) totalRequests; + +- (id) initWithValues: (NSDictionary*)dict; +- (NSDictionary*) asDictionary; + + +@end + diff --git a/samples/client/wordnik-api/objc/client/NIKApiTokenStatus.m b/samples/client/wordnik-api/objc/client/NIKApiTokenStatus.m new file mode 100644 index 00000000000..81641866daa --- /dev/null +++ b/samples/client/wordnik-api/objc/client/NIKApiTokenStatus.m @@ -0,0 +1,58 @@ +#import "NIKDate.h" +#import "NIKApiTokenStatus.h" + +@implementation NIKApiTokenStatus + +@synthesize valid = _valid; +@synthesize token = _token; +@synthesize resetsInMillis = _resetsInMillis; +@synthesize remainingCalls = _remainingCalls; +@synthesize expiresInMillis = _expiresInMillis; +@synthesize totalRequests = _totalRequests; +- (id) valid: (NSNumber*) valid + token: (NSString*) token + resetsInMillis: (NSNumber*) resetsInMillis + remainingCalls: (NSNumber*) remainingCalls + expiresInMillis: (NSNumber*) expiresInMillis + totalRequests: (NSNumber*) totalRequests + { + _valid = valid; + _token = token; + _resetsInMillis = resetsInMillis; + _remainingCalls = remainingCalls; + _expiresInMillis = expiresInMillis; + _totalRequests = totalRequests; + return self; + } + +- (id) initWithValues: (NSDictionary*)dict +{ + /* isContainer: , baseType: NSNumber, complexType: */ + _valid = [dict objectForKey:@"valid"]; + /* isContainer: , baseType: NSString, complexType: */ + _token = [dict objectForKey:@"token"]; + /* isContainer: , baseType: NSNumber, complexType: */ + _resetsInMillis = [dict objectForKey:@"resetsInMillis"]; + /* isContainer: , baseType: NSNumber, complexType: */ + _remainingCalls = [dict objectForKey:@"remainingCalls"]; + /* isContainer: , baseType: NSNumber, complexType: */ + _expiresInMillis = [dict objectForKey:@"expiresInMillis"]; + /* isContainer: , baseType: NSNumber, complexType: */ + _totalRequests = [dict objectForKey:@"totalRequests"]; + return self; +} + +-(NSDictionary*) asDictionary { + NSMutableDictionary* dict = [[NSMutableDictionary alloc] init]; + if(_valid != nil) [dict setObject:_valid forKey:@"valid"]; + if(_token != nil) [dict setObject:_token forKey:@"token"]; + if(_resetsInMillis != nil) [dict setObject:_resetsInMillis forKey:@"resetsInMillis"]; + if(_remainingCalls != nil) [dict setObject:_remainingCalls forKey:@"remainingCalls"]; + if(_expiresInMillis != nil) [dict setObject:_expiresInMillis forKey:@"expiresInMillis"]; + if(_totalRequests != nil) [dict setObject:_totalRequests forKey:@"totalRequests"]; + NSDictionary* output = [dict copy]; + return output; +} + +@end + diff --git a/samples/client/wordnik-api/objc/client/NIKAudioFile.h b/samples/client/wordnik-api/objc/client/NIKAudioFile.h new file mode 100644 index 00000000000..eb66e05a06b --- /dev/null +++ b/samples/client/wordnik-api/objc/client/NIKAudioFile.h @@ -0,0 +1,59 @@ +#import +#import "NIKSwaggerObject.h" +#import "NIKDate.h" + +@interface NIKAudioFile : NIKSwaggerObject { +@private + NSString* _attributionUrl; //NSString + NSNumber* _commentCount; //NSNumber + NSNumber* _voteCount; //NSNumber + NSString* _fileUrl; //NSString + NSString* _audioType; //NSString + NSNumber* __id; //NSNumber + NSNumber* _duration; //NSNumber + NSString* _attributionText; //NSString + NSString* _createdBy; //NSString + NSString* _description; //NSString + NIKDate* _createdAt; //NIKDate + NSNumber* _voteWeightedAverage; //NSNumber + NSNumber* _voteAverage; //NSNumber + NSString* _word; //NSString + } + + + +@property(nonatomic) NSString* attributionUrl; +@property(nonatomic) NSNumber* commentCount; +@property(nonatomic) NSNumber* voteCount; +@property(nonatomic) NSString* fileUrl; +@property(nonatomic) NSString* audioType; +@property(nonatomic) NSNumber* _id; +@property(nonatomic) NSNumber* duration; +@property(nonatomic) NSString* attributionText; +@property(nonatomic) NSString* createdBy; +@property(nonatomic) NSString* description; +@property(nonatomic) NIKDate* createdAt; +@property(nonatomic) NSNumber* voteWeightedAverage; +@property(nonatomic) NSNumber* voteAverage; +@property(nonatomic) NSString* word; +- (id) attributionUrl: (NSString*) attributionUrl + commentCount: (NSNumber*) commentCount + voteCount: (NSNumber*) voteCount + fileUrl: (NSString*) fileUrl + audioType: (NSString*) audioType + _id: (NSNumber*) _id + duration: (NSNumber*) duration + attributionText: (NSString*) attributionText + createdBy: (NSString*) createdBy + description: (NSString*) description + createdAt: (NIKDate*) createdAt + voteWeightedAverage: (NSNumber*) voteWeightedAverage + voteAverage: (NSNumber*) voteAverage + word: (NSString*) word; + +- (id) initWithValues: (NSDictionary*)dict; +- (NSDictionary*) asDictionary; + + +@end + diff --git a/samples/client/wordnik-api/objc/client/NIKAudioFile.m b/samples/client/wordnik-api/objc/client/NIKAudioFile.m new file mode 100644 index 00000000000..c9e4c84c69b --- /dev/null +++ b/samples/client/wordnik-api/objc/client/NIKAudioFile.m @@ -0,0 +1,124 @@ +#import "NIKDate.h" +#import "NIKAudioFile.h" + +@implementation NIKAudioFile + +@synthesize attributionUrl = _attributionUrl; +@synthesize commentCount = _commentCount; +@synthesize voteCount = _voteCount; +@synthesize fileUrl = _fileUrl; +@synthesize audioType = _audioType; +@synthesize _id = __id; +@synthesize duration = _duration; +@synthesize attributionText = _attributionText; +@synthesize createdBy = _createdBy; +@synthesize description = _description; +@synthesize createdAt = _createdAt; +@synthesize voteWeightedAverage = _voteWeightedAverage; +@synthesize voteAverage = _voteAverage; +@synthesize word = _word; +- (id) attributionUrl: (NSString*) attributionUrl + commentCount: (NSNumber*) commentCount + voteCount: (NSNumber*) voteCount + fileUrl: (NSString*) fileUrl + audioType: (NSString*) audioType + _id: (NSNumber*) _id + duration: (NSNumber*) duration + attributionText: (NSString*) attributionText + createdBy: (NSString*) createdBy + description: (NSString*) description + createdAt: (NIKDate*) createdAt + voteWeightedAverage: (NSNumber*) voteWeightedAverage + voteAverage: (NSNumber*) voteAverage + word: (NSString*) word + { + _attributionUrl = attributionUrl; + _commentCount = commentCount; + _voteCount = voteCount; + _fileUrl = fileUrl; + _audioType = audioType; + __id = _id; + _duration = duration; + _attributionText = attributionText; + _createdBy = createdBy; + _description = description; + _createdAt = createdAt; + _voteWeightedAverage = voteWeightedAverage; + _voteAverage = voteAverage; + _word = word; + return self; + } + +- (id) initWithValues: (NSDictionary*)dict +{ + /* isContainer: , baseType: NSString, complexType: */ + _attributionUrl = [dict objectForKey:@"attributionUrl"]; + /* isContainer: , baseType: NSNumber, complexType: */ + _commentCount = [dict objectForKey:@"commentCount"]; + /* isContainer: , baseType: NSNumber, complexType: */ + _voteCount = [dict objectForKey:@"voteCount"]; + /* isContainer: , baseType: NSString, complexType: */ + _fileUrl = [dict objectForKey:@"fileUrl"]; + /* isContainer: , baseType: NSString, complexType: */ + _audioType = [dict objectForKey:@"audioType"]; + /* isContainer: , baseType: NSNumber, complexType: */ + __id = [dict objectForKey:@"id"]; + /* isContainer: , baseType: NSNumber, complexType: */ + _duration = [dict objectForKey:@"duration"]; + /* isContainer: , baseType: NSString, complexType: */ + _attributionText = [dict objectForKey:@"attributionText"]; + /* isContainer: , baseType: NSString, complexType: */ + _createdBy = [dict objectForKey:@"createdBy"]; + /* isContainer: , baseType: NSString, complexType: */ + _description = [dict objectForKey:@"description"]; + /* isContainer: , baseType: NIKDate, complexType: NIKDate */ + id createdAt_dict = [dict objectForKey:@"createdAt"]; + _createdAt = [[NIKDate alloc]initWithValues:createdAt_dict]; + /* isContainer: , baseType: NSNumber, complexType: */ + _voteWeightedAverage = [dict objectForKey:@"voteWeightedAverage"]; + /* isContainer: , baseType: NSNumber, complexType: */ + _voteAverage = [dict objectForKey:@"voteAverage"]; + /* isContainer: , baseType: NSString, complexType: */ + _word = [dict objectForKey:@"word"]; + return self; +} + +-(NSDictionary*) asDictionary { + NSMutableDictionary* dict = [[NSMutableDictionary alloc] init]; + if(_attributionUrl != nil) [dict setObject:_attributionUrl forKey:@"attributionUrl"]; + if(_commentCount != nil) [dict setObject:_commentCount forKey:@"commentCount"]; + if(_voteCount != nil) [dict setObject:_voteCount forKey:@"voteCount"]; + if(_fileUrl != nil) [dict setObject:_fileUrl forKey:@"fileUrl"]; + if(_audioType != nil) [dict setObject:_audioType forKey:@"audioType"]; + if(__id != nil) [dict setObject:__id forKey:@"id"]; + if(_duration != nil) [dict setObject:_duration forKey:@"duration"]; + if(_attributionText != nil) [dict setObject:_attributionText forKey:@"attributionText"]; + if(_createdBy != nil) [dict setObject:_createdBy forKey:@"createdBy"]; + if(_description != nil) [dict setObject:_description forKey:@"description"]; + if(_createdAt != nil){ + if([_createdAt isKindOfClass:[NSArray class]]){ + NSMutableArray * array = [[NSMutableArray alloc] init]; + for( NIKDate * createdAt in (NSArray*)_createdAt) { + [array addObject:[(NIKSwaggerObject*)createdAt asDictionary]]; + } + [dict setObject:array forKey:@"createdAt"]; + } + else if(_createdAt && [_createdAt isKindOfClass:[NIKDate class]]) { + NSString * dateString = [(NIKDate*)_createdAt toString]; + if(dateString){ + [dict setObject:dateString forKey:@"createdAt"]; + } + } + } + else { + if(_createdAt != nil) [dict setObject:[(NIKSwaggerObject*)_createdAt asDictionary]forKey:@"createdAt"]; + } + if(_voteWeightedAverage != nil) [dict setObject:_voteWeightedAverage forKey:@"voteWeightedAverage"]; + if(_voteAverage != nil) [dict setObject:_voteAverage forKey:@"voteAverage"]; + if(_word != nil) [dict setObject:_word forKey:@"word"]; + NSDictionary* output = [dict copy]; + return output; +} + +@end + diff --git a/samples/client/wordnik-api/objc/client/NIKAuthenticationToken.h b/samples/client/wordnik-api/objc/client/NIKAuthenticationToken.h new file mode 100644 index 00000000000..e2f993e09a8 --- /dev/null +++ b/samples/client/wordnik-api/objc/client/NIKAuthenticationToken.h @@ -0,0 +1,25 @@ +#import +#import "NIKSwaggerObject.h" + +@interface NIKAuthenticationToken : NIKSwaggerObject { +@private + NSString* _token; //NSString + NSNumber* _userId; //NSNumber + NSString* _userSignature; //NSString + } + + + +@property(nonatomic) NSString* token; +@property(nonatomic) NSNumber* userId; +@property(nonatomic) NSString* userSignature; +- (id) token: (NSString*) token + userId: (NSNumber*) userId + userSignature: (NSString*) userSignature; + +- (id) initWithValues: (NSDictionary*)dict; +- (NSDictionary*) asDictionary; + + +@end + diff --git a/samples/client/wordnik-api/objc/client/NIKAuthenticationToken.m b/samples/client/wordnik-api/objc/client/NIKAuthenticationToken.m new file mode 100644 index 00000000000..88d03aa986f --- /dev/null +++ b/samples/client/wordnik-api/objc/client/NIKAuthenticationToken.m @@ -0,0 +1,40 @@ +#import "NIKDate.h" +#import "NIKAuthenticationToken.h" + +@implementation NIKAuthenticationToken + +@synthesize token = _token; +@synthesize userId = _userId; +@synthesize userSignature = _userSignature; +- (id) token: (NSString*) token + userId: (NSNumber*) userId + userSignature: (NSString*) userSignature + { + _token = token; + _userId = userId; + _userSignature = userSignature; + return self; + } + +- (id) initWithValues: (NSDictionary*)dict +{ + /* isContainer: , baseType: NSString, complexType: */ + _token = [dict objectForKey:@"token"]; + /* isContainer: , baseType: NSNumber, complexType: */ + _userId = [dict objectForKey:@"userId"]; + /* isContainer: , baseType: NSString, complexType: */ + _userSignature = [dict objectForKey:@"userSignature"]; + return self; +} + +-(NSDictionary*) asDictionary { + NSMutableDictionary* dict = [[NSMutableDictionary alloc] init]; + if(_token != nil) [dict setObject:_token forKey:@"token"]; + if(_userId != nil) [dict setObject:_userId forKey:@"userId"]; + if(_userSignature != nil) [dict setObject:_userSignature forKey:@"userSignature"]; + NSDictionary* output = [dict copy]; + return output; +} + +@end + diff --git a/samples/client/wordnik-api/objc/client/NIKBigram.h b/samples/client/wordnik-api/objc/client/NIKBigram.h new file mode 100644 index 00000000000..e21267949fe --- /dev/null +++ b/samples/client/wordnik-api/objc/client/NIKBigram.h @@ -0,0 +1,31 @@ +#import +#import "NIKSwaggerObject.h" + +@interface NIKBigram : NIKSwaggerObject { +@private + NSNumber* _count; //NSNumber + NSString* _gram2; //NSString + NSString* _gram1; //NSString + NSNumber* _wlmi; //NSNumber + NSNumber* _mi; //NSNumber + } + + + +@property(nonatomic) NSNumber* count; +@property(nonatomic) NSString* gram2; +@property(nonatomic) NSString* gram1; +@property(nonatomic) NSNumber* wlmi; +@property(nonatomic) NSNumber* mi; +- (id) count: (NSNumber*) count + gram2: (NSString*) gram2 + gram1: (NSString*) gram1 + wlmi: (NSNumber*) wlmi + mi: (NSNumber*) mi; + +- (id) initWithValues: (NSDictionary*)dict; +- (NSDictionary*) asDictionary; + + +@end + diff --git a/samples/client/wordnik-api/objc/client/NIKBigram.m b/samples/client/wordnik-api/objc/client/NIKBigram.m new file mode 100644 index 00000000000..ce33f44ebef --- /dev/null +++ b/samples/client/wordnik-api/objc/client/NIKBigram.m @@ -0,0 +1,52 @@ +#import "NIKDate.h" +#import "NIKBigram.h" + +@implementation NIKBigram + +@synthesize count = _count; +@synthesize gram2 = _gram2; +@synthesize gram1 = _gram1; +@synthesize wlmi = _wlmi; +@synthesize mi = _mi; +- (id) count: (NSNumber*) count + gram2: (NSString*) gram2 + gram1: (NSString*) gram1 + wlmi: (NSNumber*) wlmi + mi: (NSNumber*) mi + { + _count = count; + _gram2 = gram2; + _gram1 = gram1; + _wlmi = wlmi; + _mi = mi; + return self; + } + +- (id) initWithValues: (NSDictionary*)dict +{ + /* isContainer: , baseType: NSNumber, complexType: */ + _count = [dict objectForKey:@"count"]; + /* isContainer: , baseType: NSString, complexType: */ + _gram2 = [dict objectForKey:@"gram2"]; + /* isContainer: , baseType: NSString, complexType: */ + _gram1 = [dict objectForKey:@"gram1"]; + /* isContainer: , baseType: NSNumber, complexType: */ + _wlmi = [dict objectForKey:@"wlmi"]; + /* isContainer: , baseType: NSNumber, complexType: */ + _mi = [dict objectForKey:@"mi"]; + return self; +} + +-(NSDictionary*) asDictionary { + NSMutableDictionary* dict = [[NSMutableDictionary alloc] init]; + if(_count != nil) [dict setObject:_count forKey:@"count"]; + if(_gram2 != nil) [dict setObject:_gram2 forKey:@"gram2"]; + if(_gram1 != nil) [dict setObject:_gram1 forKey:@"gram1"]; + if(_wlmi != nil) [dict setObject:_wlmi forKey:@"wlmi"]; + if(_mi != nil) [dict setObject:_mi forKey:@"mi"]; + NSDictionary* output = [dict copy]; + return output; +} + +@end + diff --git a/samples/client/wordnik-api/objc/client/NIKCitation.h b/samples/client/wordnik-api/objc/client/NIKCitation.h new file mode 100644 index 00000000000..344aa998216 --- /dev/null +++ b/samples/client/wordnik-api/objc/client/NIKCitation.h @@ -0,0 +1,22 @@ +#import +#import "NIKSwaggerObject.h" + +@interface NIKCitation : NIKSwaggerObject { +@private + NSString* _cite; //NSString + NSString* _source; //NSString + } + + + +@property(nonatomic) NSString* cite; +@property(nonatomic) NSString* source; +- (id) cite: (NSString*) cite + source: (NSString*) source; + +- (id) initWithValues: (NSDictionary*)dict; +- (NSDictionary*) asDictionary; + + +@end + diff --git a/samples/client/wordnik-api/objc/client/NIKCitation.m b/samples/client/wordnik-api/objc/client/NIKCitation.m new file mode 100644 index 00000000000..e3ff0b4d330 --- /dev/null +++ b/samples/client/wordnik-api/objc/client/NIKCitation.m @@ -0,0 +1,34 @@ +#import "NIKDate.h" +#import "NIKCitation.h" + +@implementation NIKCitation + +@synthesize cite = _cite; +@synthesize source = _source; +- (id) cite: (NSString*) cite + source: (NSString*) source + { + _cite = cite; + _source = source; + return self; + } + +- (id) initWithValues: (NSDictionary*)dict +{ + /* isContainer: , baseType: NSString, complexType: */ + _cite = [dict objectForKey:@"cite"]; + /* isContainer: , baseType: NSString, complexType: */ + _source = [dict objectForKey:@"source"]; + return self; +} + +-(NSDictionary*) asDictionary { + NSMutableDictionary* dict = [[NSMutableDictionary alloc] init]; + if(_cite != nil) [dict setObject:_cite forKey:@"cite"]; + if(_source != nil) [dict setObject:_source forKey:@"source"]; + NSDictionary* output = [dict copy]; + return output; +} + +@end + diff --git a/samples/client/wordnik-api/objc/client/NIKContentProvider.h b/samples/client/wordnik-api/objc/client/NIKContentProvider.h new file mode 100644 index 00000000000..4087c0d28fa --- /dev/null +++ b/samples/client/wordnik-api/objc/client/NIKContentProvider.h @@ -0,0 +1,22 @@ +#import +#import "NIKSwaggerObject.h" + +@interface NIKContentProvider : NIKSwaggerObject { +@private + NSNumber* __id; //NSNumber + NSString* _name; //NSString + } + + + +@property(nonatomic) NSNumber* _id; +@property(nonatomic) NSString* name; +- (id) _id: (NSNumber*) _id + name: (NSString*) name; + +- (id) initWithValues: (NSDictionary*)dict; +- (NSDictionary*) asDictionary; + + +@end + diff --git a/samples/client/wordnik-api/objc/client/NIKContentProvider.m b/samples/client/wordnik-api/objc/client/NIKContentProvider.m new file mode 100644 index 00000000000..88ddac8b770 --- /dev/null +++ b/samples/client/wordnik-api/objc/client/NIKContentProvider.m @@ -0,0 +1,34 @@ +#import "NIKDate.h" +#import "NIKContentProvider.h" + +@implementation NIKContentProvider + +@synthesize _id = __id; +@synthesize name = _name; +- (id) _id: (NSNumber*) _id + name: (NSString*) name + { + __id = _id; + _name = name; + return self; + } + +- (id) initWithValues: (NSDictionary*)dict +{ + /* isContainer: , baseType: NSNumber, complexType: */ + __id = [dict objectForKey:@"id"]; + /* isContainer: , baseType: NSString, complexType: */ + _name = [dict objectForKey:@"name"]; + return self; +} + +-(NSDictionary*) asDictionary { + NSMutableDictionary* dict = [[NSMutableDictionary alloc] init]; + if(__id != nil) [dict setObject:__id forKey:@"id"]; + if(_name != nil) [dict setObject:_name forKey:@"name"]; + NSDictionary* output = [dict copy]; + return output; +} + +@end + diff --git a/samples/client/wordnik-api/objc/client/NIKDate.h b/samples/client/wordnik-api/objc/client/NIKDate.h new file mode 100644 index 00000000000..b72c7dc5479 --- /dev/null +++ b/samples/client/wordnik-api/objc/client/NIKDate.h @@ -0,0 +1,13 @@ +#import +#import "NIKSwaggerObject.h" + +@interface NIKDate : NIKSwaggerObject { +@private + NSDate *_date; +} +@property(nonatomic, readonly) NSDate* date; + +- (id) initWithValues: (NSString*)input; +-(NSString*) toString; +@end + diff --git a/samples/client/wordnik-api/objc/client/NIKDate.m b/samples/client/wordnik-api/objc/client/NIKDate.m new file mode 100644 index 00000000000..c1f9a163deb --- /dev/null +++ b/samples/client/wordnik-api/objc/client/NIKDate.m @@ -0,0 +1,34 @@ +#import "NIKDate.h" + +@implementation NIKDate + +@synthesize date = _date; + +- (id) initWithValues:(NSString*)input { + if([input isKindOfClass:[NSString class]]){ + NSDateFormatter* df = [NSDateFormatter new]; + NSLocale *locale = [[NSLocale new] + initWithLocaleIdentifier:@"en_US_POSIX"]; + [df setLocale:locale]; + [df setDateFormat:@"yyyy-MM-dd'T'HH:mm:ss.SSSZ"]; + + _date = [df dateFromString:input]; + } + else if([input isKindOfClass:[NSNumber class]]) { + NSTimeInterval interval = [input doubleValue]; + _date = [[NSDate alloc] initWithTimeIntervalSince1970:interval]; + } + return self; +} + +-(NSString*) toString { + NSDateFormatter* df = [NSDateFormatter new]; + NSLocale *locale = [[NSLocale new] + initWithLocaleIdentifier:@"en_US_POSIX"]; + [df setLocale:locale]; + [df setDateFormat:@"yyyy-MM-dd'T'HH:mm:ss.SSSZ"]; + + return [df stringFromDate:_date]; +} + +@end \ No newline at end of file diff --git a/samples/client/wordnik-api/objc/client/NIKDefinition.h b/samples/client/wordnik-api/objc/client/NIKDefinition.h new file mode 100644 index 00000000000..ad722c690a7 --- /dev/null +++ b/samples/client/wordnik-api/objc/client/NIKDefinition.h @@ -0,0 +1,70 @@ +#import +#import "NIKSwaggerObject.h" +#import "NIKExampleUsage.h" +#import "NIKNote.h" +#import "NIKCitation.h" +#import "NIKTextPron.h" +#import "NIKLabel.h" +#import "NIKRelated.h" + +@interface NIKDefinition : NIKSwaggerObject { +@private + NSString* _extendedText; //NSString + NSString* _text; //NSString + NSString* _sourceDictionary; //NSString + NSArray* _citations; //Citation + NSArray* _labels; //Label + NSNumber* _score; //NSNumber + NSArray* _exampleUses; //ExampleUsage + NSString* _attributionUrl; //NSString + NSString* _seqString; //NSString + NSString* _attributionText; //NSString + NSArray* _relatedWords; //Related + NSString* _sequence; //NSString + NSString* _word; //NSString + NSArray* _textProns; //TextPron + NSArray* _notes; //Note + NSString* _partOfSpeech; //NSString + } + + + +@property(nonatomic) NSString* extendedText; +@property(nonatomic) NSString* text; +@property(nonatomic) NSString* sourceDictionary; +@property(nonatomic) NSArray* citations; +@property(nonatomic) NSArray* labels; +@property(nonatomic) NSNumber* score; +@property(nonatomic) NSArray* exampleUses; +@property(nonatomic) NSString* attributionUrl; +@property(nonatomic) NSString* seqString; +@property(nonatomic) NSString* attributionText; +@property(nonatomic) NSArray* relatedWords; +@property(nonatomic) NSString* sequence; +@property(nonatomic) NSString* word; +@property(nonatomic) NSArray* textProns; +@property(nonatomic) NSArray* notes; +@property(nonatomic) NSString* partOfSpeech; +- (id) extendedText: (NSString*) extendedText + text: (NSString*) text + sourceDictionary: (NSString*) sourceDictionary + citations: (NSArray*) citations + labels: (NSArray*) labels + score: (NSNumber*) score + exampleUses: (NSArray*) exampleUses + attributionUrl: (NSString*) attributionUrl + seqString: (NSString*) seqString + attributionText: (NSString*) attributionText + relatedWords: (NSArray*) relatedWords + sequence: (NSString*) sequence + word: (NSString*) word + textProns: (NSArray*) textProns + notes: (NSArray*) notes + partOfSpeech: (NSString*) partOfSpeech; + +- (id) initWithValues: (NSDictionary*)dict; +- (NSDictionary*) asDictionary; + + +@end + diff --git a/samples/client/wordnik-api/objc/client/NIKDefinition.m b/samples/client/wordnik-api/objc/client/NIKDefinition.m new file mode 100644 index 00000000000..e98ed0d79c4 --- /dev/null +++ b/samples/client/wordnik-api/objc/client/NIKDefinition.m @@ -0,0 +1,280 @@ +#import "NIKDate.h" +#import "NIKDefinition.h" + +@implementation NIKDefinition + +@synthesize extendedText = _extendedText; +@synthesize text = _text; +@synthesize sourceDictionary = _sourceDictionary; +@synthesize citations = _citations; +@synthesize labels = _labels; +@synthesize score = _score; +@synthesize exampleUses = _exampleUses; +@synthesize attributionUrl = _attributionUrl; +@synthesize seqString = _seqString; +@synthesize attributionText = _attributionText; +@synthesize relatedWords = _relatedWords; +@synthesize sequence = _sequence; +@synthesize word = _word; +@synthesize textProns = _textProns; +@synthesize notes = _notes; +@synthesize partOfSpeech = _partOfSpeech; +- (id) extendedText: (NSString*) extendedText + text: (NSString*) text + sourceDictionary: (NSString*) sourceDictionary + citations: (NSArray*) citations + labels: (NSArray*) labels + score: (NSNumber*) score + exampleUses: (NSArray*) exampleUses + attributionUrl: (NSString*) attributionUrl + seqString: (NSString*) seqString + attributionText: (NSString*) attributionText + relatedWords: (NSArray*) relatedWords + sequence: (NSString*) sequence + word: (NSString*) word + textProns: (NSArray*) textProns + notes: (NSArray*) notes + partOfSpeech: (NSString*) partOfSpeech + { + _extendedText = extendedText; + _text = text; + _sourceDictionary = sourceDictionary; + _citations = citations; + _labels = labels; + _score = score; + _exampleUses = exampleUses; + _attributionUrl = attributionUrl; + _seqString = seqString; + _attributionText = attributionText; + _relatedWords = relatedWords; + _sequence = sequence; + _word = word; + _textProns = textProns; + _notes = notes; + _partOfSpeech = partOfSpeech; + return self; + } + +- (id) initWithValues: (NSDictionary*)dict +{ + /* isContainer: , baseType: NSString, complexType: */ + _extendedText = [dict objectForKey:@"extendedText"]; + /* isContainer: , baseType: NSString, complexType: */ + _text = [dict objectForKey:@"text"]; + /* isContainer: , baseType: NSString, complexType: */ + _sourceDictionary = [dict objectForKey:@"sourceDictionary"]; + /* isContainer: true, baseType: Citation, complexType: NIKCitation */ + id citations_dict = [dict objectForKey:@"citations"]; + if([citations_dict isKindOfClass:[NSArray class]]) { + if([(NSArray*)citations_dict count] > 0) { + NSMutableArray * objs = [[NSMutableArray alloc] initWithCapacity:[(NSArray*)citations_dict count]]; + for (NSDictionary* dict in (NSArray*)citations_dict) { + NIKCitation* d = [[NIKCitation alloc]initWithValues:dict]; + [objs addObject:d]; + } + _citations = [[NSArray alloc] initWithArray:objs]; + } + } + /* isContainer: true, baseType: Label, complexType: NIKLabel */ + id labels_dict = [dict objectForKey:@"labels"]; + if([labels_dict isKindOfClass:[NSArray class]]) { + if([(NSArray*)labels_dict count] > 0) { + NSMutableArray * objs = [[NSMutableArray alloc] initWithCapacity:[(NSArray*)labels_dict count]]; + for (NSDictionary* dict in (NSArray*)labels_dict) { + NIKLabel* d = [[NIKLabel alloc]initWithValues:dict]; + [objs addObject:d]; + } + _labels = [[NSArray alloc] initWithArray:objs]; + } + } + /* isContainer: , baseType: NSNumber, complexType: */ + _score = [dict objectForKey:@"score"]; + /* isContainer: true, baseType: ExampleUsage, complexType: NIKExampleUsage */ + id exampleUses_dict = [dict objectForKey:@"exampleUses"]; + if([exampleUses_dict isKindOfClass:[NSArray class]]) { + if([(NSArray*)exampleUses_dict count] > 0) { + NSMutableArray * objs = [[NSMutableArray alloc] initWithCapacity:[(NSArray*)exampleUses_dict count]]; + for (NSDictionary* dict in (NSArray*)exampleUses_dict) { + NIKExampleUsage* d = [[NIKExampleUsage alloc]initWithValues:dict]; + [objs addObject:d]; + } + _exampleUses = [[NSArray alloc] initWithArray:objs]; + } + } + /* isContainer: , baseType: NSString, complexType: */ + _attributionUrl = [dict objectForKey:@"attributionUrl"]; + /* isContainer: , baseType: NSString, complexType: */ + _seqString = [dict objectForKey:@"seqString"]; + /* isContainer: , baseType: NSString, complexType: */ + _attributionText = [dict objectForKey:@"attributionText"]; + /* isContainer: true, baseType: Related, complexType: NIKRelated */ + id relatedWords_dict = [dict objectForKey:@"relatedWords"]; + if([relatedWords_dict isKindOfClass:[NSArray class]]) { + if([(NSArray*)relatedWords_dict count] > 0) { + NSMutableArray * objs = [[NSMutableArray alloc] initWithCapacity:[(NSArray*)relatedWords_dict count]]; + for (NSDictionary* dict in (NSArray*)relatedWords_dict) { + NIKRelated* d = [[NIKRelated alloc]initWithValues:dict]; + [objs addObject:d]; + } + _relatedWords = [[NSArray alloc] initWithArray:objs]; + } + } + /* isContainer: , baseType: NSString, complexType: */ + _sequence = [dict objectForKey:@"sequence"]; + /* isContainer: , baseType: NSString, complexType: */ + _word = [dict objectForKey:@"word"]; + /* isContainer: true, baseType: TextPron, complexType: NIKTextPron */ + id textProns_dict = [dict objectForKey:@"textProns"]; + if([textProns_dict isKindOfClass:[NSArray class]]) { + if([(NSArray*)textProns_dict count] > 0) { + NSMutableArray * objs = [[NSMutableArray alloc] initWithCapacity:[(NSArray*)textProns_dict count]]; + for (NSDictionary* dict in (NSArray*)textProns_dict) { + NIKTextPron* d = [[NIKTextPron alloc]initWithValues:dict]; + [objs addObject:d]; + } + _textProns = [[NSArray alloc] initWithArray:objs]; + } + } + /* isContainer: true, baseType: Note, complexType: NIKNote */ + id notes_dict = [dict objectForKey:@"notes"]; + if([notes_dict isKindOfClass:[NSArray class]]) { + if([(NSArray*)notes_dict count] > 0) { + NSMutableArray * objs = [[NSMutableArray alloc] initWithCapacity:[(NSArray*)notes_dict count]]; + for (NSDictionary* dict in (NSArray*)notes_dict) { + NIKNote* d = [[NIKNote alloc]initWithValues:dict]; + [objs addObject:d]; + } + _notes = [[NSArray alloc] initWithArray:objs]; + } + } + /* isContainer: , baseType: NSString, complexType: */ + _partOfSpeech = [dict objectForKey:@"partOfSpeech"]; + return self; +} + +-(NSDictionary*) asDictionary { + NSMutableDictionary* dict = [[NSMutableDictionary alloc] init]; + if(_extendedText != nil) [dict setObject:_extendedText forKey:@"extendedText"]; + if(_text != nil) [dict setObject:_text forKey:@"text"]; + if(_sourceDictionary != nil) [dict setObject:_sourceDictionary forKey:@"sourceDictionary"]; + if(_citations != nil){ + if([_citations isKindOfClass:[NSArray class]]){ + NSMutableArray * array = [[NSMutableArray alloc] init]; + for( NIKCitation * citations in (NSArray*)_citations) { + [array addObject:[(NIKSwaggerObject*)citations asDictionary]]; + } + [dict setObject:array forKey:@"citations"]; + } + else if(_citations && [_citations isKindOfClass:[NIKDate class]]) { + NSString * dateString = [(NIKDate*)_citations toString]; + if(dateString){ + [dict setObject:dateString forKey:@"citations"]; + } + } + } + else { + if(_citations != nil) [dict setObject:[(NIKSwaggerObject*)_citations asDictionary]forKey:@"citations"]; + } + if(_labels != nil){ + if([_labels isKindOfClass:[NSArray class]]){ + NSMutableArray * array = [[NSMutableArray alloc] init]; + for( NIKLabel * labels in (NSArray*)_labels) { + [array addObject:[(NIKSwaggerObject*)labels asDictionary]]; + } + [dict setObject:array forKey:@"labels"]; + } + else if(_labels && [_labels isKindOfClass:[NIKDate class]]) { + NSString * dateString = [(NIKDate*)_labels toString]; + if(dateString){ + [dict setObject:dateString forKey:@"labels"]; + } + } + } + else { + if(_labels != nil) [dict setObject:[(NIKSwaggerObject*)_labels asDictionary]forKey:@"labels"]; + } + if(_score != nil) [dict setObject:_score forKey:@"score"]; + if(_exampleUses != nil){ + if([_exampleUses isKindOfClass:[NSArray class]]){ + NSMutableArray * array = [[NSMutableArray alloc] init]; + for( NIKExampleUsage * exampleUses in (NSArray*)_exampleUses) { + [array addObject:[(NIKSwaggerObject*)exampleUses asDictionary]]; + } + [dict setObject:array forKey:@"exampleUses"]; + } + else if(_exampleUses && [_exampleUses isKindOfClass:[NIKDate class]]) { + NSString * dateString = [(NIKDate*)_exampleUses toString]; + if(dateString){ + [dict setObject:dateString forKey:@"exampleUses"]; + } + } + } + else { + if(_exampleUses != nil) [dict setObject:[(NIKSwaggerObject*)_exampleUses asDictionary]forKey:@"exampleUses"]; + } + if(_attributionUrl != nil) [dict setObject:_attributionUrl forKey:@"attributionUrl"]; + if(_seqString != nil) [dict setObject:_seqString forKey:@"seqString"]; + if(_attributionText != nil) [dict setObject:_attributionText forKey:@"attributionText"]; + if(_relatedWords != nil){ + if([_relatedWords isKindOfClass:[NSArray class]]){ + NSMutableArray * array = [[NSMutableArray alloc] init]; + for( NIKRelated * relatedWords in (NSArray*)_relatedWords) { + [array addObject:[(NIKSwaggerObject*)relatedWords asDictionary]]; + } + [dict setObject:array forKey:@"relatedWords"]; + } + else if(_relatedWords && [_relatedWords isKindOfClass:[NIKDate class]]) { + NSString * dateString = [(NIKDate*)_relatedWords toString]; + if(dateString){ + [dict setObject:dateString forKey:@"relatedWords"]; + } + } + } + else { + if(_relatedWords != nil) [dict setObject:[(NIKSwaggerObject*)_relatedWords asDictionary]forKey:@"relatedWords"]; + } + if(_sequence != nil) [dict setObject:_sequence forKey:@"sequence"]; + if(_word != nil) [dict setObject:_word forKey:@"word"]; + if(_textProns != nil){ + if([_textProns isKindOfClass:[NSArray class]]){ + NSMutableArray * array = [[NSMutableArray alloc] init]; + for( NIKTextPron * textProns in (NSArray*)_textProns) { + [array addObject:[(NIKSwaggerObject*)textProns asDictionary]]; + } + [dict setObject:array forKey:@"textProns"]; + } + else if(_textProns && [_textProns isKindOfClass:[NIKDate class]]) { + NSString * dateString = [(NIKDate*)_textProns toString]; + if(dateString){ + [dict setObject:dateString forKey:@"textProns"]; + } + } + } + else { + if(_textProns != nil) [dict setObject:[(NIKSwaggerObject*)_textProns asDictionary]forKey:@"textProns"]; + } + if(_notes != nil){ + if([_notes isKindOfClass:[NSArray class]]){ + NSMutableArray * array = [[NSMutableArray alloc] init]; + for( NIKNote * notes in (NSArray*)_notes) { + [array addObject:[(NIKSwaggerObject*)notes asDictionary]]; + } + [dict setObject:array forKey:@"notes"]; + } + else if(_notes && [_notes isKindOfClass:[NIKDate class]]) { + NSString * dateString = [(NIKDate*)_notes toString]; + if(dateString){ + [dict setObject:dateString forKey:@"notes"]; + } + } + } + else { + if(_notes != nil) [dict setObject:[(NIKSwaggerObject*)_notes asDictionary]forKey:@"notes"]; + } + if(_partOfSpeech != nil) [dict setObject:_partOfSpeech forKey:@"partOfSpeech"]; + NSDictionary* output = [dict copy]; + return output; +} + +@end + diff --git a/samples/client/wordnik-api/objc/client/NIKDefinitionSearchResults.h b/samples/client/wordnik-api/objc/client/NIKDefinitionSearchResults.h new file mode 100644 index 00000000000..635faf7ebc1 --- /dev/null +++ b/samples/client/wordnik-api/objc/client/NIKDefinitionSearchResults.h @@ -0,0 +1,23 @@ +#import +#import "NIKSwaggerObject.h" +#import "NIKDefinition.h" + +@interface NIKDefinitionSearchResults : NIKSwaggerObject { +@private + NSArray* _results; //Definition + NSNumber* _totalResults; //NSNumber + } + + + +@property(nonatomic) NSArray* results; +@property(nonatomic) NSNumber* totalResults; +- (id) results: (NSArray*) results + totalResults: (NSNumber*) totalResults; + +- (id) initWithValues: (NSDictionary*)dict; +- (NSDictionary*) asDictionary; + + +@end + diff --git a/samples/client/wordnik-api/objc/client/NIKDefinitionSearchResults.m b/samples/client/wordnik-api/objc/client/NIKDefinitionSearchResults.m new file mode 100644 index 00000000000..ebf2996c9cd --- /dev/null +++ b/samples/client/wordnik-api/objc/client/NIKDefinitionSearchResults.m @@ -0,0 +1,61 @@ +#import "NIKDate.h" +#import "NIKDefinitionSearchResults.h" + +@implementation NIKDefinitionSearchResults + +@synthesize results = _results; +@synthesize totalResults = _totalResults; +- (id) results: (NSArray*) results + totalResults: (NSNumber*) totalResults + { + _results = results; + _totalResults = totalResults; + return self; + } + +- (id) initWithValues: (NSDictionary*)dict +{ + /* isContainer: true, baseType: Definition, complexType: NIKDefinition */ + id results_dict = [dict objectForKey:@"results"]; + if([results_dict isKindOfClass:[NSArray class]]) { + if([(NSArray*)results_dict count] > 0) { + NSMutableArray * objs = [[NSMutableArray alloc] initWithCapacity:[(NSArray*)results_dict count]]; + for (NSDictionary* dict in (NSArray*)results_dict) { + NIKDefinition* d = [[NIKDefinition alloc]initWithValues:dict]; + [objs addObject:d]; + } + _results = [[NSArray alloc] initWithArray:objs]; + } + } + /* isContainer: , baseType: NSNumber, complexType: */ + _totalResults = [dict objectForKey:@"totalResults"]; + return self; +} + +-(NSDictionary*) asDictionary { + NSMutableDictionary* dict = [[NSMutableDictionary alloc] init]; + if(_results != nil){ + if([_results isKindOfClass:[NSArray class]]){ + NSMutableArray * array = [[NSMutableArray alloc] init]; + for( NIKDefinition * results in (NSArray*)_results) { + [array addObject:[(NIKSwaggerObject*)results asDictionary]]; + } + [dict setObject:array forKey:@"results"]; + } + else if(_results && [_results isKindOfClass:[NIKDate class]]) { + NSString * dateString = [(NIKDate*)_results toString]; + if(dateString){ + [dict setObject:dateString forKey:@"results"]; + } + } + } + else { + if(_results != nil) [dict setObject:[(NIKSwaggerObject*)_results asDictionary]forKey:@"results"]; + } + if(_totalResults != nil) [dict setObject:_totalResults forKey:@"totalResults"]; + NSDictionary* output = [dict copy]; + return output; +} + +@end + diff --git a/samples/client/wordnik-api/objc/client/NIKExample.h b/samples/client/wordnik-api/objc/client/NIKExample.h new file mode 100644 index 00000000000..ed725fc08c9 --- /dev/null +++ b/samples/client/wordnik-api/objc/client/NIKExample.h @@ -0,0 +1,55 @@ +#import +#import "NIKSwaggerObject.h" +#import "NIKSentence.h" +#import "NIKScoredWord.h" +#import "NIKContentProvider.h" + +@interface NIKExample : NIKSwaggerObject { +@private + NSNumber* __id; //NSNumber + NSString* _text; //NSString + NSString* _title; //NSString + NSNumber* _exampleId; //NSNumber + NIKScoredWord* _score; //ScoredWord + NIKSentence* _sentence; //Sentence + NSNumber* _year; //NSNumber + NIKContentProvider* _provider; //ContentProvider + NSString* _word; //NSString + NSNumber* _rating; //NSNumber + NSString* _url; //NSString + NSNumber* _documentId; //NSNumber + } + + + +@property(nonatomic) NSNumber* _id; +@property(nonatomic) NSString* text; +@property(nonatomic) NSString* title; +@property(nonatomic) NSNumber* exampleId; +@property(nonatomic) NIKScoredWord* score; +@property(nonatomic) NIKSentence* sentence; +@property(nonatomic) NSNumber* year; +@property(nonatomic) NIKContentProvider* provider; +@property(nonatomic) NSString* word; +@property(nonatomic) NSNumber* rating; +@property(nonatomic) NSString* url; +@property(nonatomic) NSNumber* documentId; +- (id) _id: (NSNumber*) _id + text: (NSString*) text + title: (NSString*) title + exampleId: (NSNumber*) exampleId + score: (NIKScoredWord*) score + sentence: (NIKSentence*) sentence + year: (NSNumber*) year + provider: (NIKContentProvider*) provider + word: (NSString*) word + rating: (NSNumber*) rating + url: (NSString*) url + documentId: (NSNumber*) documentId; + +- (id) initWithValues: (NSDictionary*)dict; +- (NSDictionary*) asDictionary; + + +@end + diff --git a/samples/client/wordnik-api/objc/client/NIKExample.m b/samples/client/wordnik-api/objc/client/NIKExample.m new file mode 100644 index 00000000000..e686a804ecc --- /dev/null +++ b/samples/client/wordnik-api/objc/client/NIKExample.m @@ -0,0 +1,148 @@ +#import "NIKDate.h" +#import "NIKExample.h" + +@implementation NIKExample + +@synthesize _id = __id; +@synthesize text = _text; +@synthesize title = _title; +@synthesize exampleId = _exampleId; +@synthesize score = _score; +@synthesize sentence = _sentence; +@synthesize year = _year; +@synthesize provider = _provider; +@synthesize word = _word; +@synthesize rating = _rating; +@synthesize url = _url; +@synthesize documentId = _documentId; +- (id) _id: (NSNumber*) _id + text: (NSString*) text + title: (NSString*) title + exampleId: (NSNumber*) exampleId + score: (NIKScoredWord*) score + sentence: (NIKSentence*) sentence + year: (NSNumber*) year + provider: (NIKContentProvider*) provider + word: (NSString*) word + rating: (NSNumber*) rating + url: (NSString*) url + documentId: (NSNumber*) documentId + { + __id = _id; + _text = text; + _title = title; + _exampleId = exampleId; + _score = score; + _sentence = sentence; + _year = year; + _provider = provider; + _word = word; + _rating = rating; + _url = url; + _documentId = documentId; + return self; + } + +- (id) initWithValues: (NSDictionary*)dict +{ + /* isContainer: , baseType: NSNumber, complexType: */ + __id = [dict objectForKey:@"id"]; + /* isContainer: , baseType: NSString, complexType: */ + _text = [dict objectForKey:@"text"]; + /* isContainer: , baseType: NSString, complexType: */ + _title = [dict objectForKey:@"title"]; + /* isContainer: , baseType: NSNumber, complexType: */ + _exampleId = [dict objectForKey:@"exampleId"]; + /* isContainer: , baseType: ScoredWord, complexType: NIKScoredWord */ + id score_dict = [dict objectForKey:@"score"]; + _score = [[NIKScoredWord alloc]initWithValues:score_dict]; + /* isContainer: , baseType: Sentence, complexType: NIKSentence */ + id sentence_dict = [dict objectForKey:@"sentence"]; + _sentence = [[NIKSentence alloc]initWithValues:sentence_dict]; + /* isContainer: , baseType: NSNumber, complexType: */ + _year = [dict objectForKey:@"year"]; + /* isContainer: , baseType: ContentProvider, complexType: NIKContentProvider */ + id provider_dict = [dict objectForKey:@"provider"]; + _provider = [[NIKContentProvider alloc]initWithValues:provider_dict]; + /* isContainer: , baseType: NSString, complexType: */ + _word = [dict objectForKey:@"word"]; + /* isContainer: , baseType: NSNumber, complexType: */ + _rating = [dict objectForKey:@"rating"]; + /* isContainer: , baseType: NSString, complexType: */ + _url = [dict objectForKey:@"url"]; + /* isContainer: , baseType: NSNumber, complexType: */ + _documentId = [dict objectForKey:@"documentId"]; + return self; +} + +-(NSDictionary*) asDictionary { + NSMutableDictionary* dict = [[NSMutableDictionary alloc] init]; + if(__id != nil) [dict setObject:__id forKey:@"id"]; + if(_text != nil) [dict setObject:_text forKey:@"text"]; + if(_title != nil) [dict setObject:_title forKey:@"title"]; + if(_exampleId != nil) [dict setObject:_exampleId forKey:@"exampleId"]; + if(_score != nil){ + if([_score isKindOfClass:[NSArray class]]){ + NSMutableArray * array = [[NSMutableArray alloc] init]; + for( NIKScoredWord * score in (NSArray*)_score) { + [array addObject:[(NIKSwaggerObject*)score asDictionary]]; + } + [dict setObject:array forKey:@"score"]; + } + else if(_score && [_score isKindOfClass:[NIKDate class]]) { + NSString * dateString = [(NIKDate*)_score toString]; + if(dateString){ + [dict setObject:dateString forKey:@"score"]; + } + } + } + else { + if(_score != nil) [dict setObject:[(NIKSwaggerObject*)_score asDictionary]forKey:@"score"]; + } + if(_sentence != nil){ + if([_sentence isKindOfClass:[NSArray class]]){ + NSMutableArray * array = [[NSMutableArray alloc] init]; + for( NIKSentence * sentence in (NSArray*)_sentence) { + [array addObject:[(NIKSwaggerObject*)sentence asDictionary]]; + } + [dict setObject:array forKey:@"sentence"]; + } + else if(_sentence && [_sentence isKindOfClass:[NIKDate class]]) { + NSString * dateString = [(NIKDate*)_sentence toString]; + if(dateString){ + [dict setObject:dateString forKey:@"sentence"]; + } + } + } + else { + if(_sentence != nil) [dict setObject:[(NIKSwaggerObject*)_sentence asDictionary]forKey:@"sentence"]; + } + if(_year != nil) [dict setObject:_year forKey:@"year"]; + if(_provider != nil){ + if([_provider isKindOfClass:[NSArray class]]){ + NSMutableArray * array = [[NSMutableArray alloc] init]; + for( NIKContentProvider * provider in (NSArray*)_provider) { + [array addObject:[(NIKSwaggerObject*)provider asDictionary]]; + } + [dict setObject:array forKey:@"provider"]; + } + else if(_provider && [_provider isKindOfClass:[NIKDate class]]) { + NSString * dateString = [(NIKDate*)_provider toString]; + if(dateString){ + [dict setObject:dateString forKey:@"provider"]; + } + } + } + else { + if(_provider != nil) [dict setObject:[(NIKSwaggerObject*)_provider asDictionary]forKey:@"provider"]; + } + if(_word != nil) [dict setObject:_word forKey:@"word"]; + if(_rating != nil) [dict setObject:_rating forKey:@"rating"]; + if(_url != nil) [dict setObject:_url forKey:@"url"]; + if(_documentId != nil) [dict setObject:_documentId forKey:@"documentId"]; + NSDictionary* output = [dict copy]; + return output; +} + +@end + diff --git a/samples/client/wordnik-api/objc/client/NIKExampleSearchResults.h b/samples/client/wordnik-api/objc/client/NIKExampleSearchResults.h new file mode 100644 index 00000000000..420c5c97e70 --- /dev/null +++ b/samples/client/wordnik-api/objc/client/NIKExampleSearchResults.h @@ -0,0 +1,24 @@ +#import +#import "NIKSwaggerObject.h" +#import "NIKFacet.h" +#import "NIKExample.h" + +@interface NIKExampleSearchResults : NIKSwaggerObject { +@private + NSArray* _facets; //Facet + NSArray* _examples; //Example + } + + + +@property(nonatomic) NSArray* facets; +@property(nonatomic) NSArray* examples; +- (id) facets: (NSArray*) facets + examples: (NSArray*) examples; + +- (id) initWithValues: (NSDictionary*)dict; +- (NSDictionary*) asDictionary; + + +@end + diff --git a/samples/client/wordnik-api/objc/client/NIKExampleSearchResults.m b/samples/client/wordnik-api/objc/client/NIKExampleSearchResults.m new file mode 100644 index 00000000000..08ad6fbc41f --- /dev/null +++ b/samples/client/wordnik-api/objc/client/NIKExampleSearchResults.m @@ -0,0 +1,88 @@ +#import "NIKDate.h" +#import "NIKExampleSearchResults.h" + +@implementation NIKExampleSearchResults + +@synthesize facets = _facets; +@synthesize examples = _examples; +- (id) facets: (NSArray*) facets + examples: (NSArray*) examples + { + _facets = facets; + _examples = examples; + return self; + } + +- (id) initWithValues: (NSDictionary*)dict +{ + /* isContainer: true, baseType: Facet, complexType: NIKFacet */ + id facets_dict = [dict objectForKey:@"facets"]; + if([facets_dict isKindOfClass:[NSArray class]]) { + if([(NSArray*)facets_dict count] > 0) { + NSMutableArray * objs = [[NSMutableArray alloc] initWithCapacity:[(NSArray*)facets_dict count]]; + for (NSDictionary* dict in (NSArray*)facets_dict) { + NIKFacet* d = [[NIKFacet alloc]initWithValues:dict]; + [objs addObject:d]; + } + _facets = [[NSArray alloc] initWithArray:objs]; + } + } + /* isContainer: true, baseType: Example, complexType: NIKExample */ + id examples_dict = [dict objectForKey:@"examples"]; + if([examples_dict isKindOfClass:[NSArray class]]) { + if([(NSArray*)examples_dict count] > 0) { + NSMutableArray * objs = [[NSMutableArray alloc] initWithCapacity:[(NSArray*)examples_dict count]]; + for (NSDictionary* dict in (NSArray*)examples_dict) { + NIKExample* d = [[NIKExample alloc]initWithValues:dict]; + [objs addObject:d]; + } + _examples = [[NSArray alloc] initWithArray:objs]; + } + } + return self; +} + +-(NSDictionary*) asDictionary { + NSMutableDictionary* dict = [[NSMutableDictionary alloc] init]; + if(_facets != nil){ + if([_facets isKindOfClass:[NSArray class]]){ + NSMutableArray * array = [[NSMutableArray alloc] init]; + for( NIKFacet * facets in (NSArray*)_facets) { + [array addObject:[(NIKSwaggerObject*)facets asDictionary]]; + } + [dict setObject:array forKey:@"facets"]; + } + else if(_facets && [_facets isKindOfClass:[NIKDate class]]) { + NSString * dateString = [(NIKDate*)_facets toString]; + if(dateString){ + [dict setObject:dateString forKey:@"facets"]; + } + } + } + else { + if(_facets != nil) [dict setObject:[(NIKSwaggerObject*)_facets asDictionary]forKey:@"facets"]; + } + if(_examples != nil){ + if([_examples isKindOfClass:[NSArray class]]){ + NSMutableArray * array = [[NSMutableArray alloc] init]; + for( NIKExample * examples in (NSArray*)_examples) { + [array addObject:[(NIKSwaggerObject*)examples asDictionary]]; + } + [dict setObject:array forKey:@"examples"]; + } + else if(_examples && [_examples isKindOfClass:[NIKDate class]]) { + NSString * dateString = [(NIKDate*)_examples toString]; + if(dateString){ + [dict setObject:dateString forKey:@"examples"]; + } + } + } + else { + if(_examples != nil) [dict setObject:[(NIKSwaggerObject*)_examples asDictionary]forKey:@"examples"]; + } + NSDictionary* output = [dict copy]; + return output; +} + +@end + diff --git a/samples/client/wordnik-api/objc/client/NIKExampleUsage.h b/samples/client/wordnik-api/objc/client/NIKExampleUsage.h new file mode 100644 index 00000000000..955a859d90f --- /dev/null +++ b/samples/client/wordnik-api/objc/client/NIKExampleUsage.h @@ -0,0 +1,19 @@ +#import +#import "NIKSwaggerObject.h" + +@interface NIKExampleUsage : NIKSwaggerObject { +@private + NSString* _text; //NSString + } + + + +@property(nonatomic) NSString* text; +- (id) text: (NSString*) text; + +- (id) initWithValues: (NSDictionary*)dict; +- (NSDictionary*) asDictionary; + + +@end + diff --git a/samples/client/wordnik-api/objc/client/NIKExampleUsage.m b/samples/client/wordnik-api/objc/client/NIKExampleUsage.m new file mode 100644 index 00000000000..84359f00a87 --- /dev/null +++ b/samples/client/wordnik-api/objc/client/NIKExampleUsage.m @@ -0,0 +1,28 @@ +#import "NIKDate.h" +#import "NIKExampleUsage.h" + +@implementation NIKExampleUsage + +@synthesize text = _text; +- (id) text: (NSString*) text + { + _text = text; + return self; + } + +- (id) initWithValues: (NSDictionary*)dict +{ + /* isContainer: , baseType: NSString, complexType: */ + _text = [dict objectForKey:@"text"]; + return self; +} + +-(NSDictionary*) asDictionary { + NSMutableDictionary* dict = [[NSMutableDictionary alloc] init]; + if(_text != nil) [dict setObject:_text forKey:@"text"]; + NSDictionary* output = [dict copy]; + return output; +} + +@end + diff --git a/samples/client/wordnik-api/objc/client/NIKFacet.h b/samples/client/wordnik-api/objc/client/NIKFacet.h new file mode 100644 index 00000000000..9c0d71ad4ab --- /dev/null +++ b/samples/client/wordnik-api/objc/client/NIKFacet.h @@ -0,0 +1,23 @@ +#import +#import "NIKSwaggerObject.h" +#import "NIKFacetValue.h" + +@interface NIKFacet : NIKSwaggerObject { +@private + NSArray* _facetValues; //FacetValue + NSString* _name; //NSString + } + + + +@property(nonatomic) NSArray* facetValues; +@property(nonatomic) NSString* name; +- (id) facetValues: (NSArray*) facetValues + name: (NSString*) name; + +- (id) initWithValues: (NSDictionary*)dict; +- (NSDictionary*) asDictionary; + + +@end + diff --git a/samples/client/wordnik-api/objc/client/NIKFacet.m b/samples/client/wordnik-api/objc/client/NIKFacet.m new file mode 100644 index 00000000000..5786839ad39 --- /dev/null +++ b/samples/client/wordnik-api/objc/client/NIKFacet.m @@ -0,0 +1,61 @@ +#import "NIKDate.h" +#import "NIKFacet.h" + +@implementation NIKFacet + +@synthesize facetValues = _facetValues; +@synthesize name = _name; +- (id) facetValues: (NSArray*) facetValues + name: (NSString*) name + { + _facetValues = facetValues; + _name = name; + return self; + } + +- (id) initWithValues: (NSDictionary*)dict +{ + /* isContainer: true, baseType: FacetValue, complexType: NIKFacetValue */ + id facetValues_dict = [dict objectForKey:@"facetValues"]; + if([facetValues_dict isKindOfClass:[NSArray class]]) { + if([(NSArray*)facetValues_dict count] > 0) { + NSMutableArray * objs = [[NSMutableArray alloc] initWithCapacity:[(NSArray*)facetValues_dict count]]; + for (NSDictionary* dict in (NSArray*)facetValues_dict) { + NIKFacetValue* d = [[NIKFacetValue alloc]initWithValues:dict]; + [objs addObject:d]; + } + _facetValues = [[NSArray alloc] initWithArray:objs]; + } + } + /* isContainer: , baseType: NSString, complexType: */ + _name = [dict objectForKey:@"name"]; + return self; +} + +-(NSDictionary*) asDictionary { + NSMutableDictionary* dict = [[NSMutableDictionary alloc] init]; + if(_facetValues != nil){ + if([_facetValues isKindOfClass:[NSArray class]]){ + NSMutableArray * array = [[NSMutableArray alloc] init]; + for( NIKFacetValue * facetValues in (NSArray*)_facetValues) { + [array addObject:[(NIKSwaggerObject*)facetValues asDictionary]]; + } + [dict setObject:array forKey:@"facetValues"]; + } + else if(_facetValues && [_facetValues isKindOfClass:[NIKDate class]]) { + NSString * dateString = [(NIKDate*)_facetValues toString]; + if(dateString){ + [dict setObject:dateString forKey:@"facetValues"]; + } + } + } + else { + if(_facetValues != nil) [dict setObject:[(NIKSwaggerObject*)_facetValues asDictionary]forKey:@"facetValues"]; + } + if(_name != nil) [dict setObject:_name forKey:@"name"]; + NSDictionary* output = [dict copy]; + return output; +} + +@end + diff --git a/samples/client/wordnik-api/objc/client/NIKFacetValue.h b/samples/client/wordnik-api/objc/client/NIKFacetValue.h new file mode 100644 index 00000000000..92f1a3159a3 --- /dev/null +++ b/samples/client/wordnik-api/objc/client/NIKFacetValue.h @@ -0,0 +1,22 @@ +#import +#import "NIKSwaggerObject.h" + +@interface NIKFacetValue : NIKSwaggerObject { +@private + NSNumber* _count; //NSNumber + NSString* _value; //NSString + } + + + +@property(nonatomic) NSNumber* count; +@property(nonatomic) NSString* value; +- (id) count: (NSNumber*) count + value: (NSString*) value; + +- (id) initWithValues: (NSDictionary*)dict; +- (NSDictionary*) asDictionary; + + +@end + diff --git a/samples/client/wordnik-api/objc/client/NIKFacetValue.m b/samples/client/wordnik-api/objc/client/NIKFacetValue.m new file mode 100644 index 00000000000..a8f86f18541 --- /dev/null +++ b/samples/client/wordnik-api/objc/client/NIKFacetValue.m @@ -0,0 +1,34 @@ +#import "NIKDate.h" +#import "NIKFacetValue.h" + +@implementation NIKFacetValue + +@synthesize count = _count; +@synthesize value = _value; +- (id) count: (NSNumber*) count + value: (NSString*) value + { + _count = count; + _value = value; + return self; + } + +- (id) initWithValues: (NSDictionary*)dict +{ + /* isContainer: , baseType: NSNumber, complexType: */ + _count = [dict objectForKey:@"count"]; + /* isContainer: , baseType: NSString, complexType: */ + _value = [dict objectForKey:@"value"]; + return self; +} + +-(NSDictionary*) asDictionary { + NSMutableDictionary* dict = [[NSMutableDictionary alloc] init]; + if(_count != nil) [dict setObject:_count forKey:@"count"]; + if(_value != nil) [dict setObject:_value forKey:@"value"]; + NSDictionary* output = [dict copy]; + return output; +} + +@end + diff --git a/samples/client/wordnik-api/objc/client/NIKFrequency.h b/samples/client/wordnik-api/objc/client/NIKFrequency.h new file mode 100644 index 00000000000..dab3a40a783 --- /dev/null +++ b/samples/client/wordnik-api/objc/client/NIKFrequency.h @@ -0,0 +1,22 @@ +#import +#import "NIKSwaggerObject.h" + +@interface NIKFrequency : NIKSwaggerObject { +@private + NSNumber* _count; //NSNumber + NSNumber* _year; //NSNumber + } + + + +@property(nonatomic) NSNumber* count; +@property(nonatomic) NSNumber* year; +- (id) count: (NSNumber*) count + year: (NSNumber*) year; + +- (id) initWithValues: (NSDictionary*)dict; +- (NSDictionary*) asDictionary; + + +@end + diff --git a/samples/client/wordnik-api/objc/client/NIKFrequency.m b/samples/client/wordnik-api/objc/client/NIKFrequency.m new file mode 100644 index 00000000000..fd0a5233023 --- /dev/null +++ b/samples/client/wordnik-api/objc/client/NIKFrequency.m @@ -0,0 +1,34 @@ +#import "NIKDate.h" +#import "NIKFrequency.h" + +@implementation NIKFrequency + +@synthesize count = _count; +@synthesize year = _year; +- (id) count: (NSNumber*) count + year: (NSNumber*) year + { + _count = count; + _year = year; + return self; + } + +- (id) initWithValues: (NSDictionary*)dict +{ + /* isContainer: , baseType: NSNumber, complexType: */ + _count = [dict objectForKey:@"count"]; + /* isContainer: , baseType: NSNumber, complexType: */ + _year = [dict objectForKey:@"year"]; + return self; +} + +-(NSDictionary*) asDictionary { + NSMutableDictionary* dict = [[NSMutableDictionary alloc] init]; + if(_count != nil) [dict setObject:_count forKey:@"count"]; + if(_year != nil) [dict setObject:_year forKey:@"year"]; + NSDictionary* output = [dict copy]; + return output; +} + +@end + diff --git a/samples/client/wordnik-api/objc/client/NIKFrequencySummary.h b/samples/client/wordnik-api/objc/client/NIKFrequencySummary.h new file mode 100644 index 00000000000..943903c23b0 --- /dev/null +++ b/samples/client/wordnik-api/objc/client/NIKFrequencySummary.h @@ -0,0 +1,32 @@ +#import +#import "NIKSwaggerObject.h" +#import "NIKFrequency.h" + +@interface NIKFrequencySummary : NIKSwaggerObject { +@private + NSNumber* _unknownYearCount; //NSNumber + NSNumber* _totalCount; //NSNumber + NSString* _frequencyString; //NSString + NSString* _word; //NSString + NSArray* _frequency; //Frequency + } + + + +@property(nonatomic) NSNumber* unknownYearCount; +@property(nonatomic) NSNumber* totalCount; +@property(nonatomic) NSString* frequencyString; +@property(nonatomic) NSString* word; +@property(nonatomic) NSArray* frequency; +- (id) unknownYearCount: (NSNumber*) unknownYearCount + totalCount: (NSNumber*) totalCount + frequencyString: (NSString*) frequencyString + word: (NSString*) word + frequency: (NSArray*) frequency; + +- (id) initWithValues: (NSDictionary*)dict; +- (NSDictionary*) asDictionary; + + +@end + diff --git a/samples/client/wordnik-api/objc/client/NIKFrequencySummary.m b/samples/client/wordnik-api/objc/client/NIKFrequencySummary.m new file mode 100644 index 00000000000..27e1ea05888 --- /dev/null +++ b/samples/client/wordnik-api/objc/client/NIKFrequencySummary.m @@ -0,0 +1,79 @@ +#import "NIKDate.h" +#import "NIKFrequencySummary.h" + +@implementation NIKFrequencySummary + +@synthesize unknownYearCount = _unknownYearCount; +@synthesize totalCount = _totalCount; +@synthesize frequencyString = _frequencyString; +@synthesize word = _word; +@synthesize frequency = _frequency; +- (id) unknownYearCount: (NSNumber*) unknownYearCount + totalCount: (NSNumber*) totalCount + frequencyString: (NSString*) frequencyString + word: (NSString*) word + frequency: (NSArray*) frequency + { + _unknownYearCount = unknownYearCount; + _totalCount = totalCount; + _frequencyString = frequencyString; + _word = word; + _frequency = frequency; + return self; + } + +- (id) initWithValues: (NSDictionary*)dict +{ + /* isContainer: , baseType: NSNumber, complexType: */ + _unknownYearCount = [dict objectForKey:@"unknownYearCount"]; + /* isContainer: , baseType: NSNumber, complexType: */ + _totalCount = [dict objectForKey:@"totalCount"]; + /* isContainer: , baseType: NSString, complexType: */ + _frequencyString = [dict objectForKey:@"frequencyString"]; + /* isContainer: , baseType: NSString, complexType: */ + _word = [dict objectForKey:@"word"]; + /* isContainer: true, baseType: Frequency, complexType: NIKFrequency */ + id frequency_dict = [dict objectForKey:@"frequency"]; + if([frequency_dict isKindOfClass:[NSArray class]]) { + if([(NSArray*)frequency_dict count] > 0) { + NSMutableArray * objs = [[NSMutableArray alloc] initWithCapacity:[(NSArray*)frequency_dict count]]; + for (NSDictionary* dict in (NSArray*)frequency_dict) { + NIKFrequency* d = [[NIKFrequency alloc]initWithValues:dict]; + [objs addObject:d]; + } + _frequency = [[NSArray alloc] initWithArray:objs]; + } + } + return self; +} + +-(NSDictionary*) asDictionary { + NSMutableDictionary* dict = [[NSMutableDictionary alloc] init]; + if(_unknownYearCount != nil) [dict setObject:_unknownYearCount forKey:@"unknownYearCount"]; + if(_totalCount != nil) [dict setObject:_totalCount forKey:@"totalCount"]; + if(_frequencyString != nil) [dict setObject:_frequencyString forKey:@"frequencyString"]; + if(_word != nil) [dict setObject:_word forKey:@"word"]; + if(_frequency != nil){ + if([_frequency isKindOfClass:[NSArray class]]){ + NSMutableArray * array = [[NSMutableArray alloc] init]; + for( NIKFrequency * frequency in (NSArray*)_frequency) { + [array addObject:[(NIKSwaggerObject*)frequency asDictionary]]; + } + [dict setObject:array forKey:@"frequency"]; + } + else if(_frequency && [_frequency isKindOfClass:[NIKDate class]]) { + NSString * dateString = [(NIKDate*)_frequency toString]; + if(dateString){ + [dict setObject:dateString forKey:@"frequency"]; + } + } + } + else { + if(_frequency != nil) [dict setObject:[(NIKSwaggerObject*)_frequency asDictionary]forKey:@"frequency"]; + } + NSDictionary* output = [dict copy]; + return output; +} + +@end + diff --git a/samples/client/wordnik-api/objc/client/NIKLabel.h b/samples/client/wordnik-api/objc/client/NIKLabel.h new file mode 100644 index 00000000000..6879e717c50 --- /dev/null +++ b/samples/client/wordnik-api/objc/client/NIKLabel.h @@ -0,0 +1,22 @@ +#import +#import "NIKSwaggerObject.h" + +@interface NIKLabel : NIKSwaggerObject { +@private + NSString* _text; //NSString + NSString* _type; //NSString + } + + + +@property(nonatomic) NSString* text; +@property(nonatomic) NSString* type; +- (id) text: (NSString*) text + type: (NSString*) type; + +- (id) initWithValues: (NSDictionary*)dict; +- (NSDictionary*) asDictionary; + + +@end + diff --git a/samples/client/wordnik-api/objc/client/NIKLabel.m b/samples/client/wordnik-api/objc/client/NIKLabel.m new file mode 100644 index 00000000000..ffd0659d9ab --- /dev/null +++ b/samples/client/wordnik-api/objc/client/NIKLabel.m @@ -0,0 +1,34 @@ +#import "NIKDate.h" +#import "NIKLabel.h" + +@implementation NIKLabel + +@synthesize text = _text; +@synthesize type = _type; +- (id) text: (NSString*) text + type: (NSString*) type + { + _text = text; + _type = type; + return self; + } + +- (id) initWithValues: (NSDictionary*)dict +{ + /* isContainer: , baseType: NSString, complexType: */ + _text = [dict objectForKey:@"text"]; + /* isContainer: , baseType: NSString, complexType: */ + _type = [dict objectForKey:@"type"]; + return self; +} + +-(NSDictionary*) asDictionary { + NSMutableDictionary* dict = [[NSMutableDictionary alloc] init]; + if(_text != nil) [dict setObject:_text forKey:@"text"]; + if(_type != nil) [dict setObject:_type forKey:@"type"]; + NSDictionary* output = [dict copy]; + return output; +} + +@end + diff --git a/samples/client/wordnik-api/objc/client/NIKNote.h b/samples/client/wordnik-api/objc/client/NIKNote.h new file mode 100644 index 00000000000..f3abb33ee7f --- /dev/null +++ b/samples/client/wordnik-api/objc/client/NIKNote.h @@ -0,0 +1,28 @@ +#import +#import "NIKSwaggerObject.h" + +@interface NIKNote : NIKSwaggerObject { +@private + NSString* _noteType; //NSString + NSArray* _appliesTo; //NSString + NSString* _value; //NSString + NSNumber* _pos; //NSNumber + } + + + +@property(nonatomic) NSString* noteType; +@property(nonatomic) NSArray* appliesTo; +@property(nonatomic) NSString* value; +@property(nonatomic) NSNumber* pos; +- (id) noteType: (NSString*) noteType + appliesTo: (NSArray*) appliesTo + value: (NSString*) value + pos: (NSNumber*) pos; + +- (id) initWithValues: (NSDictionary*)dict; +- (NSDictionary*) asDictionary; + + +@end + diff --git a/samples/client/wordnik-api/objc/client/NIKNote.m b/samples/client/wordnik-api/objc/client/NIKNote.m new file mode 100644 index 00000000000..030da937644 --- /dev/null +++ b/samples/client/wordnik-api/objc/client/NIKNote.m @@ -0,0 +1,46 @@ +#import "NIKDate.h" +#import "NIKNote.h" + +@implementation NIKNote + +@synthesize noteType = _noteType; +@synthesize appliesTo = _appliesTo; +@synthesize value = _value; +@synthesize pos = _pos; +- (id) noteType: (NSString*) noteType + appliesTo: (NSArray*) appliesTo + value: (NSString*) value + pos: (NSNumber*) pos + { + _noteType = noteType; + _appliesTo = appliesTo; + _value = value; + _pos = pos; + return self; + } + +- (id) initWithValues: (NSDictionary*)dict +{ + /* isContainer: , baseType: NSString, complexType: */ + _noteType = [dict objectForKey:@"noteType"]; + /* isContainer: true, baseType: NSString, complexType: */ + _appliesTo = [dict objectForKey:@"appliesTo"]; + /* isContainer: , baseType: NSString, complexType: */ + _value = [dict objectForKey:@"value"]; + /* isContainer: , baseType: NSNumber, complexType: */ + _pos = [dict objectForKey:@"pos"]; + return self; +} + +-(NSDictionary*) asDictionary { + NSMutableDictionary* dict = [[NSMutableDictionary alloc] init]; + if(_noteType != nil) [dict setObject:_noteType forKey:@"noteType"]; + if(_appliesTo != nil) [dict setObject:_appliesTo forKey:@"appliesTo"]; + if(_value != nil) [dict setObject:_value forKey:@"value"]; + if(_pos != nil) [dict setObject:_pos forKey:@"pos"]; + NSDictionary* output = [dict copy]; + return output; +} + +@end + diff --git a/samples/client/wordnik-api/objc/client/NIKRelated.h b/samples/client/wordnik-api/objc/client/NIKRelated.h new file mode 100644 index 00000000000..3b47ba6fbba --- /dev/null +++ b/samples/client/wordnik-api/objc/client/NIKRelated.h @@ -0,0 +1,37 @@ +#import +#import "NIKSwaggerObject.h" + +@interface NIKRelated : NIKSwaggerObject { +@private + NSString* _label1; //NSString + NSString* _label2; //NSString + NSString* _relationshipType; //NSString + NSString* _label3; //NSString + NSArray* _words; //NSString + NSString* _label4; //NSString + NSString* _gram; //NSString + } + + + +@property(nonatomic) NSString* label1; +@property(nonatomic) NSString* label2; +@property(nonatomic) NSString* relationshipType; +@property(nonatomic) NSString* label3; +@property(nonatomic) NSArray* words; +@property(nonatomic) NSString* label4; +@property(nonatomic) NSString* gram; +- (id) label1: (NSString*) label1 + label2: (NSString*) label2 + relationshipType: (NSString*) relationshipType + label3: (NSString*) label3 + words: (NSArray*) words + label4: (NSString*) label4 + gram: (NSString*) gram; + +- (id) initWithValues: (NSDictionary*)dict; +- (NSDictionary*) asDictionary; + + +@end + diff --git a/samples/client/wordnik-api/objc/client/NIKRelated.m b/samples/client/wordnik-api/objc/client/NIKRelated.m new file mode 100644 index 00000000000..7d38fd1021f --- /dev/null +++ b/samples/client/wordnik-api/objc/client/NIKRelated.m @@ -0,0 +1,64 @@ +#import "NIKDate.h" +#import "NIKRelated.h" + +@implementation NIKRelated + +@synthesize label1 = _label1; +@synthesize label2 = _label2; +@synthesize relationshipType = _relationshipType; +@synthesize label3 = _label3; +@synthesize words = _words; +@synthesize label4 = _label4; +@synthesize gram = _gram; +- (id) label1: (NSString*) label1 + label2: (NSString*) label2 + relationshipType: (NSString*) relationshipType + label3: (NSString*) label3 + words: (NSArray*) words + label4: (NSString*) label4 + gram: (NSString*) gram + { + _label1 = label1; + _label2 = label2; + _relationshipType = relationshipType; + _label3 = label3; + _words = words; + _label4 = label4; + _gram = gram; + return self; + } + +- (id) initWithValues: (NSDictionary*)dict +{ + /* isContainer: , baseType: NSString, complexType: */ + _label1 = [dict objectForKey:@"label1"]; + /* isContainer: , baseType: NSString, complexType: */ + _label2 = [dict objectForKey:@"label2"]; + /* isContainer: , baseType: NSString, complexType: */ + _relationshipType = [dict objectForKey:@"relationshipType"]; + /* isContainer: , baseType: NSString, complexType: */ + _label3 = [dict objectForKey:@"label3"]; + /* isContainer: true, baseType: NSString, complexType: */ + _words = [dict objectForKey:@"words"]; + /* isContainer: , baseType: NSString, complexType: */ + _label4 = [dict objectForKey:@"label4"]; + /* isContainer: , baseType: NSString, complexType: */ + _gram = [dict objectForKey:@"gram"]; + return self; +} + +-(NSDictionary*) asDictionary { + NSMutableDictionary* dict = [[NSMutableDictionary alloc] init]; + if(_label1 != nil) [dict setObject:_label1 forKey:@"label1"]; + if(_label2 != nil) [dict setObject:_label2 forKey:@"label2"]; + if(_relationshipType != nil) [dict setObject:_relationshipType forKey:@"relationshipType"]; + if(_label3 != nil) [dict setObject:_label3 forKey:@"label3"]; + if(_words != nil) [dict setObject:_words forKey:@"words"]; + if(_label4 != nil) [dict setObject:_label4 forKey:@"label4"]; + if(_gram != nil) [dict setObject:_gram forKey:@"gram"]; + NSDictionary* output = [dict copy]; + return output; +} + +@end + diff --git a/samples/client/wordnik-api/objc/client/NIKScoredWord.h b/samples/client/wordnik-api/objc/client/NIKScoredWord.h new file mode 100644 index 00000000000..4f3ad2e534b --- /dev/null +++ b/samples/client/wordnik-api/objc/client/NIKScoredWord.h @@ -0,0 +1,49 @@ +#import +#import "NIKSwaggerObject.h" + +@interface NIKScoredWord : NIKSwaggerObject { +@private + NSNumber* __id; //NSNumber + NSNumber* _position; //NSNumber + NSString* _lemma; //NSString + NSNumber* _docTermCount; //NSNumber + NSString* _wordType; //NSString + NSNumber* _score; //NSNumber + NSString* _word; //NSString + NSNumber* _sentenceId; //NSNumber + NSNumber* _stopword; //NSNumber + NSNumber* _baseWordScore; //NSNumber + NSString* _partOfSpeech; //NSString + } + + + +@property(nonatomic) NSNumber* _id; +@property(nonatomic) NSNumber* position; +@property(nonatomic) NSString* lemma; +@property(nonatomic) NSNumber* docTermCount; +@property(nonatomic) NSString* wordType; +@property(nonatomic) NSNumber* score; +@property(nonatomic) NSString* word; +@property(nonatomic) NSNumber* sentenceId; +@property(nonatomic) NSNumber* stopword; +@property(nonatomic) NSNumber* baseWordScore; +@property(nonatomic) NSString* partOfSpeech; +- (id) _id: (NSNumber*) _id + position: (NSNumber*) position + lemma: (NSString*) lemma + docTermCount: (NSNumber*) docTermCount + wordType: (NSString*) wordType + score: (NSNumber*) score + word: (NSString*) word + sentenceId: (NSNumber*) sentenceId + stopword: (NSNumber*) stopword + baseWordScore: (NSNumber*) baseWordScore + partOfSpeech: (NSString*) partOfSpeech; + +- (id) initWithValues: (NSDictionary*)dict; +- (NSDictionary*) asDictionary; + + +@end + diff --git a/samples/client/wordnik-api/objc/client/NIKScoredWord.m b/samples/client/wordnik-api/objc/client/NIKScoredWord.m new file mode 100644 index 00000000000..5314a671255 --- /dev/null +++ b/samples/client/wordnik-api/objc/client/NIKScoredWord.m @@ -0,0 +1,88 @@ +#import "NIKDate.h" +#import "NIKScoredWord.h" + +@implementation NIKScoredWord + +@synthesize _id = __id; +@synthesize position = _position; +@synthesize lemma = _lemma; +@synthesize docTermCount = _docTermCount; +@synthesize wordType = _wordType; +@synthesize score = _score; +@synthesize word = _word; +@synthesize sentenceId = _sentenceId; +@synthesize stopword = _stopword; +@synthesize baseWordScore = _baseWordScore; +@synthesize partOfSpeech = _partOfSpeech; +- (id) _id: (NSNumber*) _id + position: (NSNumber*) position + lemma: (NSString*) lemma + docTermCount: (NSNumber*) docTermCount + wordType: (NSString*) wordType + score: (NSNumber*) score + word: (NSString*) word + sentenceId: (NSNumber*) sentenceId + stopword: (NSNumber*) stopword + baseWordScore: (NSNumber*) baseWordScore + partOfSpeech: (NSString*) partOfSpeech + { + __id = _id; + _position = position; + _lemma = lemma; + _docTermCount = docTermCount; + _wordType = wordType; + _score = score; + _word = word; + _sentenceId = sentenceId; + _stopword = stopword; + _baseWordScore = baseWordScore; + _partOfSpeech = partOfSpeech; + return self; + } + +- (id) initWithValues: (NSDictionary*)dict +{ + /* isContainer: , baseType: NSNumber, complexType: */ + __id = [dict objectForKey:@"id"]; + /* isContainer: , baseType: NSNumber, complexType: */ + _position = [dict objectForKey:@"position"]; + /* isContainer: , baseType: NSString, complexType: */ + _lemma = [dict objectForKey:@"lemma"]; + /* isContainer: , baseType: NSNumber, complexType: */ + _docTermCount = [dict objectForKey:@"docTermCount"]; + /* isContainer: , baseType: NSString, complexType: */ + _wordType = [dict objectForKey:@"wordType"]; + /* isContainer: , baseType: NSNumber, complexType: */ + _score = [dict objectForKey:@"score"]; + /* isContainer: , baseType: NSString, complexType: */ + _word = [dict objectForKey:@"word"]; + /* isContainer: , baseType: NSNumber, complexType: */ + _sentenceId = [dict objectForKey:@"sentenceId"]; + /* isContainer: , baseType: NSNumber, complexType: */ + _stopword = [dict objectForKey:@"stopword"]; + /* isContainer: , baseType: NSNumber, complexType: */ + _baseWordScore = [dict objectForKey:@"baseWordScore"]; + /* isContainer: , baseType: NSString, complexType: */ + _partOfSpeech = [dict objectForKey:@"partOfSpeech"]; + return self; +} + +-(NSDictionary*) asDictionary { + NSMutableDictionary* dict = [[NSMutableDictionary alloc] init]; + if(__id != nil) [dict setObject:__id forKey:@"id"]; + if(_position != nil) [dict setObject:_position forKey:@"position"]; + if(_lemma != nil) [dict setObject:_lemma forKey:@"lemma"]; + if(_docTermCount != nil) [dict setObject:_docTermCount forKey:@"docTermCount"]; + if(_wordType != nil) [dict setObject:_wordType forKey:@"wordType"]; + if(_score != nil) [dict setObject:_score forKey:@"score"]; + if(_word != nil) [dict setObject:_word forKey:@"word"]; + if(_sentenceId != nil) [dict setObject:_sentenceId forKey:@"sentenceId"]; + if(_stopword != nil) [dict setObject:_stopword forKey:@"stopword"]; + if(_baseWordScore != nil) [dict setObject:_baseWordScore forKey:@"baseWordScore"]; + if(_partOfSpeech != nil) [dict setObject:_partOfSpeech forKey:@"partOfSpeech"]; + NSDictionary* output = [dict copy]; + return output; +} + +@end + diff --git a/samples/client/wordnik-api/objc/client/NIKSentence.h b/samples/client/wordnik-api/objc/client/NIKSentence.h new file mode 100644 index 00000000000..478bdd2f969 --- /dev/null +++ b/samples/client/wordnik-api/objc/client/NIKSentence.h @@ -0,0 +1,35 @@ +#import +#import "NIKSwaggerObject.h" +#import "NIKScoredWord.h" + +@interface NIKSentence : NIKSwaggerObject { +@private + NSNumber* __id; //NSNumber + NSNumber* _hasScoredWords; //NSNumber + NSArray* _scoredWords; //ScoredWord + NSString* _display; //NSString + NSNumber* _rating; //NSNumber + NSNumber* _documentMetadataId; //NSNumber + } + + + +@property(nonatomic) NSNumber* _id; +@property(nonatomic) NSNumber* hasScoredWords; +@property(nonatomic) NSArray* scoredWords; +@property(nonatomic) NSString* display; +@property(nonatomic) NSNumber* rating; +@property(nonatomic) NSNumber* documentMetadataId; +- (id) _id: (NSNumber*) _id + hasScoredWords: (NSNumber*) hasScoredWords + scoredWords: (NSArray*) scoredWords + display: (NSString*) display + rating: (NSNumber*) rating + documentMetadataId: (NSNumber*) documentMetadataId; + +- (id) initWithValues: (NSDictionary*)dict; +- (NSDictionary*) asDictionary; + + +@end + diff --git a/samples/client/wordnik-api/objc/client/NIKSentence.m b/samples/client/wordnik-api/objc/client/NIKSentence.m new file mode 100644 index 00000000000..49214a4d7bb --- /dev/null +++ b/samples/client/wordnik-api/objc/client/NIKSentence.m @@ -0,0 +1,85 @@ +#import "NIKDate.h" +#import "NIKSentence.h" + +@implementation NIKSentence + +@synthesize _id = __id; +@synthesize hasScoredWords = _hasScoredWords; +@synthesize scoredWords = _scoredWords; +@synthesize display = _display; +@synthesize rating = _rating; +@synthesize documentMetadataId = _documentMetadataId; +- (id) _id: (NSNumber*) _id + hasScoredWords: (NSNumber*) hasScoredWords + scoredWords: (NSArray*) scoredWords + display: (NSString*) display + rating: (NSNumber*) rating + documentMetadataId: (NSNumber*) documentMetadataId + { + __id = _id; + _hasScoredWords = hasScoredWords; + _scoredWords = scoredWords; + _display = display; + _rating = rating; + _documentMetadataId = documentMetadataId; + return self; + } + +- (id) initWithValues: (NSDictionary*)dict +{ + /* isContainer: , baseType: NSNumber, complexType: */ + __id = [dict objectForKey:@"id"]; + /* isContainer: , baseType: NSNumber, complexType: */ + _hasScoredWords = [dict objectForKey:@"hasScoredWords"]; + /* isContainer: true, baseType: ScoredWord, complexType: NIKScoredWord */ + id scoredWords_dict = [dict objectForKey:@"scoredWords"]; + if([scoredWords_dict isKindOfClass:[NSArray class]]) { + if([(NSArray*)scoredWords_dict count] > 0) { + NSMutableArray * objs = [[NSMutableArray alloc] initWithCapacity:[(NSArray*)scoredWords_dict count]]; + for (NSDictionary* dict in (NSArray*)scoredWords_dict) { + NIKScoredWord* d = [[NIKScoredWord alloc]initWithValues:dict]; + [objs addObject:d]; + } + _scoredWords = [[NSArray alloc] initWithArray:objs]; + } + } + /* isContainer: , baseType: NSString, complexType: */ + _display = [dict objectForKey:@"display"]; + /* isContainer: , baseType: NSNumber, complexType: */ + _rating = [dict objectForKey:@"rating"]; + /* isContainer: , baseType: NSNumber, complexType: */ + _documentMetadataId = [dict objectForKey:@"documentMetadataId"]; + return self; +} + +-(NSDictionary*) asDictionary { + NSMutableDictionary* dict = [[NSMutableDictionary alloc] init]; + if(__id != nil) [dict setObject:__id forKey:@"id"]; + if(_hasScoredWords != nil) [dict setObject:_hasScoredWords forKey:@"hasScoredWords"]; + if(_scoredWords != nil){ + if([_scoredWords isKindOfClass:[NSArray class]]){ + NSMutableArray * array = [[NSMutableArray alloc] init]; + for( NIKScoredWord * scoredWords in (NSArray*)_scoredWords) { + [array addObject:[(NIKSwaggerObject*)scoredWords asDictionary]]; + } + [dict setObject:array forKey:@"scoredWords"]; + } + else if(_scoredWords && [_scoredWords isKindOfClass:[NIKDate class]]) { + NSString * dateString = [(NIKDate*)_scoredWords toString]; + if(dateString){ + [dict setObject:dateString forKey:@"scoredWords"]; + } + } + } + else { + if(_scoredWords != nil) [dict setObject:[(NIKSwaggerObject*)_scoredWords asDictionary]forKey:@"scoredWords"]; + } + if(_display != nil) [dict setObject:_display forKey:@"display"]; + if(_rating != nil) [dict setObject:_rating forKey:@"rating"]; + if(_documentMetadataId != nil) [dict setObject:_documentMetadataId forKey:@"documentMetadataId"]; + NSDictionary* output = [dict copy]; + return output; +} + +@end + diff --git a/samples/client/wordnik-api/objc/client/NIKSimpleDefinition.h b/samples/client/wordnik-api/objc/client/NIKSimpleDefinition.h new file mode 100644 index 00000000000..331a39f0c37 --- /dev/null +++ b/samples/client/wordnik-api/objc/client/NIKSimpleDefinition.h @@ -0,0 +1,28 @@ +#import +#import "NIKSwaggerObject.h" + +@interface NIKSimpleDefinition : NIKSwaggerObject { +@private + NSString* _text; //NSString + NSString* _source; //NSString + NSString* _note; //NSString + NSString* _partOfSpeech; //NSString + } + + + +@property(nonatomic) NSString* text; +@property(nonatomic) NSString* source; +@property(nonatomic) NSString* note; +@property(nonatomic) NSString* partOfSpeech; +- (id) text: (NSString*) text + source: (NSString*) source + note: (NSString*) note + partOfSpeech: (NSString*) partOfSpeech; + +- (id) initWithValues: (NSDictionary*)dict; +- (NSDictionary*) asDictionary; + + +@end + diff --git a/samples/client/wordnik-api/objc/client/NIKSimpleDefinition.m b/samples/client/wordnik-api/objc/client/NIKSimpleDefinition.m new file mode 100644 index 00000000000..72e4b1a24c6 --- /dev/null +++ b/samples/client/wordnik-api/objc/client/NIKSimpleDefinition.m @@ -0,0 +1,46 @@ +#import "NIKDate.h" +#import "NIKSimpleDefinition.h" + +@implementation NIKSimpleDefinition + +@synthesize text = _text; +@synthesize source = _source; +@synthesize note = _note; +@synthesize partOfSpeech = _partOfSpeech; +- (id) text: (NSString*) text + source: (NSString*) source + note: (NSString*) note + partOfSpeech: (NSString*) partOfSpeech + { + _text = text; + _source = source; + _note = note; + _partOfSpeech = partOfSpeech; + return self; + } + +- (id) initWithValues: (NSDictionary*)dict +{ + /* isContainer: , baseType: NSString, complexType: */ + _text = [dict objectForKey:@"text"]; + /* isContainer: , baseType: NSString, complexType: */ + _source = [dict objectForKey:@"source"]; + /* isContainer: , baseType: NSString, complexType: */ + _note = [dict objectForKey:@"note"]; + /* isContainer: , baseType: NSString, complexType: */ + _partOfSpeech = [dict objectForKey:@"partOfSpeech"]; + return self; +} + +-(NSDictionary*) asDictionary { + NSMutableDictionary* dict = [[NSMutableDictionary alloc] init]; + if(_text != nil) [dict setObject:_text forKey:@"text"]; + if(_source != nil) [dict setObject:_source forKey:@"source"]; + if(_note != nil) [dict setObject:_note forKey:@"note"]; + if(_partOfSpeech != nil) [dict setObject:_partOfSpeech forKey:@"partOfSpeech"]; + NSDictionary* output = [dict copy]; + return output; +} + +@end + diff --git a/samples/client/wordnik-api/objc/client/NIKSimpleExample.h b/samples/client/wordnik-api/objc/client/NIKSimpleExample.h new file mode 100644 index 00000000000..f6338ff48b2 --- /dev/null +++ b/samples/client/wordnik-api/objc/client/NIKSimpleExample.h @@ -0,0 +1,28 @@ +#import +#import "NIKSwaggerObject.h" + +@interface NIKSimpleExample : NIKSwaggerObject { +@private + NSNumber* __id; //NSNumber + NSString* _text; //NSString + NSString* _title; //NSString + NSString* _url; //NSString + } + + + +@property(nonatomic) NSNumber* _id; +@property(nonatomic) NSString* text; +@property(nonatomic) NSString* title; +@property(nonatomic) NSString* url; +- (id) _id: (NSNumber*) _id + text: (NSString*) text + title: (NSString*) title + url: (NSString*) url; + +- (id) initWithValues: (NSDictionary*)dict; +- (NSDictionary*) asDictionary; + + +@end + diff --git a/samples/client/wordnik-api/objc/client/NIKSimpleExample.m b/samples/client/wordnik-api/objc/client/NIKSimpleExample.m new file mode 100644 index 00000000000..da7d7aa1d81 --- /dev/null +++ b/samples/client/wordnik-api/objc/client/NIKSimpleExample.m @@ -0,0 +1,46 @@ +#import "NIKDate.h" +#import "NIKSimpleExample.h" + +@implementation NIKSimpleExample + +@synthesize _id = __id; +@synthesize text = _text; +@synthesize title = _title; +@synthesize url = _url; +- (id) _id: (NSNumber*) _id + text: (NSString*) text + title: (NSString*) title + url: (NSString*) url + { + __id = _id; + _text = text; + _title = title; + _url = url; + return self; + } + +- (id) initWithValues: (NSDictionary*)dict +{ + /* isContainer: , baseType: NSNumber, complexType: */ + __id = [dict objectForKey:@"id"]; + /* isContainer: , baseType: NSString, complexType: */ + _text = [dict objectForKey:@"text"]; + /* isContainer: , baseType: NSString, complexType: */ + _title = [dict objectForKey:@"title"]; + /* isContainer: , baseType: NSString, complexType: */ + _url = [dict objectForKey:@"url"]; + return self; +} + +-(NSDictionary*) asDictionary { + NSMutableDictionary* dict = [[NSMutableDictionary alloc] init]; + if(__id != nil) [dict setObject:__id forKey:@"id"]; + if(_text != nil) [dict setObject:_text forKey:@"text"]; + if(_title != nil) [dict setObject:_title forKey:@"title"]; + if(_url != nil) [dict setObject:_url forKey:@"url"]; + NSDictionary* output = [dict copy]; + return output; +} + +@end + diff --git a/samples/client/wordnik-api/objc/client/NIKStringValue.h b/samples/client/wordnik-api/objc/client/NIKStringValue.h new file mode 100644 index 00000000000..723279334b7 --- /dev/null +++ b/samples/client/wordnik-api/objc/client/NIKStringValue.h @@ -0,0 +1,19 @@ +#import +#import "NIKSwaggerObject.h" + +@interface NIKStringValue : NIKSwaggerObject { +@private + NSString* _word; //NSString + } + + + +@property(nonatomic) NSString* word; +- (id) word: (NSString*) word; + +- (id) initWithValues: (NSDictionary*)dict; +- (NSDictionary*) asDictionary; + + +@end + diff --git a/samples/client/wordnik-api/objc/client/NIKStringValue.m b/samples/client/wordnik-api/objc/client/NIKStringValue.m new file mode 100644 index 00000000000..08060d7c128 --- /dev/null +++ b/samples/client/wordnik-api/objc/client/NIKStringValue.m @@ -0,0 +1,28 @@ +#import "NIKDate.h" +#import "NIKStringValue.h" + +@implementation NIKStringValue + +@synthesize word = _word; +- (id) word: (NSString*) word + { + _word = word; + return self; + } + +- (id) initWithValues: (NSDictionary*)dict +{ + /* isContainer: , baseType: NSString, complexType: */ + _word = [dict objectForKey:@"word"]; + return self; +} + +-(NSDictionary*) asDictionary { + NSMutableDictionary* dict = [[NSMutableDictionary alloc] init]; + if(_word != nil) [dict setObject:_word forKey:@"word"]; + NSDictionary* output = [dict copy]; + return output; +} + +@end + diff --git a/samples/client/wordnik-api/objc/client/NIKSwaggerObject.h b/samples/client/wordnik-api/objc/client/NIKSwaggerObject.h new file mode 100644 index 00000000000..18f95663de1 --- /dev/null +++ b/samples/client/wordnik-api/objc/client/NIKSwaggerObject.h @@ -0,0 +1,6 @@ +#import + +@interface NIKSwaggerObject : NSObject +- (id) initWithValues: (NSDictionary*)dict; +- (NSDictionary*) asDictionary; +@end diff --git a/samples/client/wordnik-api/objc/client/NIKSwaggerObject.m b/samples/client/wordnik-api/objc/client/NIKSwaggerObject.m new file mode 100644 index 00000000000..2467ce13ca8 --- /dev/null +++ b/samples/client/wordnik-api/objc/client/NIKSwaggerObject.m @@ -0,0 +1,10 @@ +#import "NIKSwaggerObject.h" + +@implementation NIKSwaggerObject +- (id) initWithValues: (NSDictionary*)dict { + return self; +} +- (NSDictionary*) asDictionary{ + return [NSDictionary init]; +} +@end diff --git a/samples/client/wordnik-api/objc/client/NIKSyllable.h b/samples/client/wordnik-api/objc/client/NIKSyllable.h new file mode 100644 index 00000000000..a060aa865f4 --- /dev/null +++ b/samples/client/wordnik-api/objc/client/NIKSyllable.h @@ -0,0 +1,25 @@ +#import +#import "NIKSwaggerObject.h" + +@interface NIKSyllable : NIKSwaggerObject { +@private + NSString* _text; //NSString + NSNumber* _seq; //NSNumber + NSString* _type; //NSString + } + + + +@property(nonatomic) NSString* text; +@property(nonatomic) NSNumber* seq; +@property(nonatomic) NSString* type; +- (id) text: (NSString*) text + seq: (NSNumber*) seq + type: (NSString*) type; + +- (id) initWithValues: (NSDictionary*)dict; +- (NSDictionary*) asDictionary; + + +@end + diff --git a/samples/client/wordnik-api/objc/client/NIKSyllable.m b/samples/client/wordnik-api/objc/client/NIKSyllable.m new file mode 100644 index 00000000000..5b042726ebd --- /dev/null +++ b/samples/client/wordnik-api/objc/client/NIKSyllable.m @@ -0,0 +1,40 @@ +#import "NIKDate.h" +#import "NIKSyllable.h" + +@implementation NIKSyllable + +@synthesize text = _text; +@synthesize seq = _seq; +@synthesize type = _type; +- (id) text: (NSString*) text + seq: (NSNumber*) seq + type: (NSString*) type + { + _text = text; + _seq = seq; + _type = type; + return self; + } + +- (id) initWithValues: (NSDictionary*)dict +{ + /* isContainer: , baseType: NSString, complexType: */ + _text = [dict objectForKey:@"text"]; + /* isContainer: , baseType: NSNumber, complexType: */ + _seq = [dict objectForKey:@"seq"]; + /* isContainer: , baseType: NSString, complexType: */ + _type = [dict objectForKey:@"type"]; + return self; +} + +-(NSDictionary*) asDictionary { + NSMutableDictionary* dict = [[NSMutableDictionary alloc] init]; + if(_text != nil) [dict setObject:_text forKey:@"text"]; + if(_seq != nil) [dict setObject:_seq forKey:@"seq"]; + if(_type != nil) [dict setObject:_type forKey:@"type"]; + NSDictionary* output = [dict copy]; + return output; +} + +@end + diff --git a/samples/client/wordnik-api/objc/client/NIKTextPron.h b/samples/client/wordnik-api/objc/client/NIKTextPron.h new file mode 100644 index 00000000000..d748a23c468 --- /dev/null +++ b/samples/client/wordnik-api/objc/client/NIKTextPron.h @@ -0,0 +1,25 @@ +#import +#import "NIKSwaggerObject.h" + +@interface NIKTextPron : NIKSwaggerObject { +@private + NSString* _raw; //NSString + NSNumber* _seq; //NSNumber + NSString* _rawType; //NSString + } + + + +@property(nonatomic) NSString* raw; +@property(nonatomic) NSNumber* seq; +@property(nonatomic) NSString* rawType; +- (id) raw: (NSString*) raw + seq: (NSNumber*) seq + rawType: (NSString*) rawType; + +- (id) initWithValues: (NSDictionary*)dict; +- (NSDictionary*) asDictionary; + + +@end + diff --git a/samples/client/wordnik-api/objc/client/NIKTextPron.m b/samples/client/wordnik-api/objc/client/NIKTextPron.m new file mode 100644 index 00000000000..14d8f6d9180 --- /dev/null +++ b/samples/client/wordnik-api/objc/client/NIKTextPron.m @@ -0,0 +1,40 @@ +#import "NIKDate.h" +#import "NIKTextPron.h" + +@implementation NIKTextPron + +@synthesize raw = _raw; +@synthesize seq = _seq; +@synthesize rawType = _rawType; +- (id) raw: (NSString*) raw + seq: (NSNumber*) seq + rawType: (NSString*) rawType + { + _raw = raw; + _seq = seq; + _rawType = rawType; + return self; + } + +- (id) initWithValues: (NSDictionary*)dict +{ + /* isContainer: , baseType: NSString, complexType: */ + _raw = [dict objectForKey:@"raw"]; + /* isContainer: , baseType: NSNumber, complexType: */ + _seq = [dict objectForKey:@"seq"]; + /* isContainer: , baseType: NSString, complexType: */ + _rawType = [dict objectForKey:@"rawType"]; + return self; +} + +-(NSDictionary*) asDictionary { + NSMutableDictionary* dict = [[NSMutableDictionary alloc] init]; + if(_raw != nil) [dict setObject:_raw forKey:@"raw"]; + if(_seq != nil) [dict setObject:_seq forKey:@"seq"]; + if(_rawType != nil) [dict setObject:_rawType forKey:@"rawType"]; + NSDictionary* output = [dict copy]; + return output; +} + +@end + diff --git a/samples/client/wordnik-api/objc/client/NIKUser.h b/samples/client/wordnik-api/objc/client/NIKUser.h new file mode 100644 index 00000000000..daf5f2d830e --- /dev/null +++ b/samples/client/wordnik-api/objc/client/NIKUser.h @@ -0,0 +1,40 @@ +#import +#import "NIKSwaggerObject.h" + +@interface NIKUser : NIKSwaggerObject { +@private + NSNumber* __id; //NSNumber + NSString* _username; //NSString + NSNumber* _status; //NSNumber + NSString* _email; //NSString + NSString* _faceBookId; //NSString + NSString* _userName; //NSString + NSString* _displayName; //NSString + NSString* _password; //NSString + } + + + +@property(nonatomic) NSNumber* _id; +@property(nonatomic) NSString* username; +@property(nonatomic) NSNumber* status; +@property(nonatomic) NSString* email; +@property(nonatomic) NSString* faceBookId; +@property(nonatomic) NSString* userName; +@property(nonatomic) NSString* displayName; +@property(nonatomic) NSString* password; +- (id) _id: (NSNumber*) _id + username: (NSString*) username + status: (NSNumber*) status + email: (NSString*) email + faceBookId: (NSString*) faceBookId + userName: (NSString*) userName + displayName: (NSString*) displayName + password: (NSString*) password; + +- (id) initWithValues: (NSDictionary*)dict; +- (NSDictionary*) asDictionary; + + +@end + diff --git a/samples/client/wordnik-api/objc/client/NIKUser.m b/samples/client/wordnik-api/objc/client/NIKUser.m new file mode 100644 index 00000000000..7514eee8360 --- /dev/null +++ b/samples/client/wordnik-api/objc/client/NIKUser.m @@ -0,0 +1,70 @@ +#import "NIKDate.h" +#import "NIKUser.h" + +@implementation NIKUser + +@synthesize _id = __id; +@synthesize username = _username; +@synthesize status = _status; +@synthesize email = _email; +@synthesize faceBookId = _faceBookId; +@synthesize userName = _userName; +@synthesize displayName = _displayName; +@synthesize password = _password; +- (id) _id: (NSNumber*) _id + username: (NSString*) username + status: (NSNumber*) status + email: (NSString*) email + faceBookId: (NSString*) faceBookId + userName: (NSString*) userName + displayName: (NSString*) displayName + password: (NSString*) password + { + __id = _id; + _username = username; + _status = status; + _email = email; + _faceBookId = faceBookId; + _userName = userName; + _displayName = displayName; + _password = password; + return self; + } + +- (id) initWithValues: (NSDictionary*)dict +{ + /* isContainer: , baseType: NSNumber, complexType: */ + __id = [dict objectForKey:@"id"]; + /* isContainer: , baseType: NSString, complexType: */ + _username = [dict objectForKey:@"username"]; + /* isContainer: , baseType: NSNumber, complexType: */ + _status = [dict objectForKey:@"status"]; + /* isContainer: , baseType: NSString, complexType: */ + _email = [dict objectForKey:@"email"]; + /* isContainer: , baseType: NSString, complexType: */ + _faceBookId = [dict objectForKey:@"faceBookId"]; + /* isContainer: , baseType: NSString, complexType: */ + _userName = [dict objectForKey:@"userName"]; + /* isContainer: , baseType: NSString, complexType: */ + _displayName = [dict objectForKey:@"displayName"]; + /* isContainer: , baseType: NSString, complexType: */ + _password = [dict objectForKey:@"password"]; + return self; +} + +-(NSDictionary*) asDictionary { + NSMutableDictionary* dict = [[NSMutableDictionary alloc] init]; + if(__id != nil) [dict setObject:__id forKey:@"id"]; + if(_username != nil) [dict setObject:_username forKey:@"username"]; + if(_status != nil) [dict setObject:_status forKey:@"status"]; + if(_email != nil) [dict setObject:_email forKey:@"email"]; + if(_faceBookId != nil) [dict setObject:_faceBookId forKey:@"faceBookId"]; + if(_userName != nil) [dict setObject:_userName forKey:@"userName"]; + if(_displayName != nil) [dict setObject:_displayName forKey:@"displayName"]; + if(_password != nil) [dict setObject:_password forKey:@"password"]; + NSDictionary* output = [dict copy]; + return output; +} + +@end + diff --git a/samples/client/wordnik-api/objc/client/NIKWordApi.h b/samples/client/wordnik-api/objc/client/NIKWordApi.h new file mode 100644 index 00000000000..31e116bfc7e --- /dev/null +++ b/samples/client/wordnik-api/objc/client/NIKWordApi.h @@ -0,0 +1,49 @@ +#import +#import "NIKApiInvoker.h" +#import "NIKDefinition.h" +#import "NIKTextPron.h" +#import "NIKExample.h" +#import "NIKSyllable.h" +#import "NIKAudioFile.h" +#import "NIKExampleSearchResults.h" +#import "NIKWordObject.h" +#import "NIKBigram.h" +#import "NIKRelated.h" +#import "NIKFrequencySummary.h" + + +@interface NIKWordApi: NSObject { + +@private + NSOperationQueue *_queue; + NIKApiInvoker * _api; +} +@property(nonatomic, readonly) NSOperationQueue* queue; +@property(nonatomic, readonly) NIKApiInvoker* api; + +-(void) addHeader:(NSString*) value + forKey:(NSString*)key; + +-(void) getExamplesWithCompletionBlock :(NSString*) word includeDuplicates:(NSString*) includeDuplicates useCanonical:(NSString*) useCanonical skip:(NSNumber*) skip limit:(NSNumber*) limit + completionHandler:(void (^)(NIKExampleSearchResults*, NSError *))completionBlock; +-(void) getWordWithCompletionBlock :(NSString*) word useCanonical:(NSString*) useCanonical includeSuggestions:(NSString*) includeSuggestions + completionHandler:(void (^)(NIKWordObject*, NSError *))completionBlock; +-(void) getDefinitionsWithCompletionBlock :(NSString*) word partOfSpeech:(NSString*) partOfSpeech sourceDictionaries:(NSString*) sourceDictionaries limit:(NSNumber*) limit includeRelated:(NSString*) includeRelated useCanonical:(NSString*) useCanonical includeTags:(NSString*) includeTags + completionHandler:(void (^)(NSArray*, NSError *))completionBlock; +-(void) getTopExampleWithCompletionBlock :(NSString*) word useCanonical:(NSString*) useCanonical + completionHandler:(void (^)(NIKExample*, NSError *))completionBlock; +-(void) getRelatedWordsWithCompletionBlock :(NSString*) word relationshipTypes:(NSString*) relationshipTypes useCanonical:(NSString*) useCanonical limitPerRelationshipType:(NSNumber*) limitPerRelationshipType + completionHandler:(void (^)(NSArray*, NSError *))completionBlock; +-(void) getTextPronunciationsWithCompletionBlock :(NSString*) word sourceDictionary:(NSString*) sourceDictionary typeFormat:(NSString*) typeFormat useCanonical:(NSString*) useCanonical limit:(NSNumber*) limit + completionHandler:(void (^)(NSArray*, NSError *))completionBlock; +-(void) getHyphenationWithCompletionBlock :(NSString*) word sourceDictionary:(NSString*) sourceDictionary useCanonical:(NSString*) useCanonical limit:(NSNumber*) limit + completionHandler:(void (^)(NSArray*, NSError *))completionBlock; +-(void) getWordFrequencyWithCompletionBlock :(NSString*) word useCanonical:(NSString*) useCanonical startYear:(NSNumber*) startYear endYear:(NSNumber*) endYear + completionHandler:(void (^)(NIKFrequencySummary*, NSError *))completionBlock; +-(void) getPhrasesWithCompletionBlock :(NSString*) word limit:(NSNumber*) limit wlmi:(NSNumber*) wlmi useCanonical:(NSString*) useCanonical + completionHandler:(void (^)(NSArray*, NSError *))completionBlock; +-(void) getEtymologiesWithCompletionBlock :(NSString*) word useCanonical:(NSString*) useCanonical + completionHandler:(void (^)(NSArray*, NSError *))completionBlock; +-(void) getAudioWithCompletionBlock :(NSString*) word useCanonical:(NSString*) useCanonical limit:(NSNumber*) limit + completionHandler:(void (^)(NSArray*, NSError *))completionBlock; +@end diff --git a/samples/client/wordnik-api/objc/client/NIKWordApi.m b/samples/client/wordnik-api/objc/client/NIKWordApi.m new file mode 100644 index 00000000000..2507908c326 --- /dev/null +++ b/samples/client/wordnik-api/objc/client/NIKWordApi.m @@ -0,0 +1,1100 @@ +#import "NIKWordApi.h" +#import "NIKDefinition.h" +#import "NIKTextPron.h" +#import "NIKExample.h" +#import "NIKSyllable.h" +#import "NIKAudioFile.h" +#import "NIKExampleSearchResults.h" +#import "NIKWordObject.h" +#import "NIKBigram.h" +#import "NIKRelated.h" +#import "NIKFrequencySummary.h" + + + +@implementation NIKWordApi +static NSString * basePath = @"http://api.wordnik.com/v4"; + +@synthesize queue = _queue; +@synthesize api = _api; + +- (id) init { + self = [super init]; + _queue = [[NSOperationQueue alloc] init]; + _api = [[NIKApiInvoker alloc] init]; + + return self; +} + +-(void) addHeader:(NSString*) value + forKey:(NSString*)key { + [_api addHeader:value forKey:key]; +} + +/** + * + * returnTypeIsPrimitive: + * returnBaseType: NIKExampleSearchResults + * returnContainer: + * + **/ +-(void) getExamplesWithCompletionBlock :(NSString*) word includeDuplicates:(NSString*) includeDuplicates useCanonical:(NSString*) useCanonical skip:(NSNumber*) skip limit:(NSNumber*) limit + completionHandler:(void (^)(NIKExampleSearchResults*, NSError *))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: [_api escapeString:word]]; + NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init]; + if(includeDuplicates != nil) + [queryParams setValue:includeDuplicates forKey:@"includeDuplicates"]; + if(useCanonical != nil) + [queryParams setValue:useCanonical forKey:@"useCanonical"]; + if(skip != nil) + [queryParams setValue:skip forKey:@"skip"]; + if(limit != nil) + [queryParams setValue:limit forKey:@"limit"]; + NSMutableDictionary* headerParams = [[NSMutableDictionary alloc] init]; + id bodyDictionary = nil; + if(word == nil) { + // error + } + // not a return container + [_api dictionaryWithCompletionBlock: requestUrl + method: @"GET" + queryParams: queryParams + body: bodyDictionary + headerParams: headerParams + completionHandler: ^(NSDictionary *data, NSError *error) { + if (error) { + completionBlock(nil, error);return; + } + + completionBlock( [[NIKExampleSearchResults alloc]initWithValues: data], nil);}]; + +} + +/** + * + * returnTypeIsPrimitive: + * returnBaseType: NIKWordObject + * returnContainer: + * + **/ +-(void) getWordWithCompletionBlock :(NSString*) word useCanonical:(NSString*) useCanonical includeSuggestions:(NSString*) includeSuggestions + completionHandler:(void (^)(NIKWordObject*, NSError *))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: [_api escapeString:word]]; + NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init]; + if(useCanonical != nil) + [queryParams setValue:useCanonical forKey:@"useCanonical"]; + if(includeSuggestions != nil) + [queryParams setValue:includeSuggestions forKey:@"includeSuggestions"]; + NSMutableDictionary* headerParams = [[NSMutableDictionary alloc] init]; + id bodyDictionary = nil; + if(word == nil) { + // error + } + // not a return container + [_api dictionaryWithCompletionBlock: requestUrl + method: @"GET" + queryParams: queryParams + body: bodyDictionary + headerParams: headerParams + completionHandler: ^(NSDictionary *data, NSError *error) { + if (error) { + completionBlock(nil, error);return; + } + + completionBlock( [[NIKWordObject alloc]initWithValues: data], nil);}]; + +} + +/** + * + * returnTypeIsPrimitive: + * returnBaseType: NIKDefinition + * returnContainer: List + * + **/ +-(void) getDefinitionsWithCompletionBlock :(NSString*) word partOfSpeech:(NSString*) partOfSpeech sourceDictionaries:(NSString*) sourceDictionaries limit:(NSNumber*) limit includeRelated:(NSString*) includeRelated useCanonical:(NSString*) useCanonical includeTags:(NSString*) includeTags + completionHandler:(void (^)(NSArray*, NSError *))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: [_api escapeString:word]]; + NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init]; + if(limit != nil) + [queryParams setValue:limit forKey:@"limit"]; + if(partOfSpeech != nil) + [queryParams setValue:partOfSpeech forKey:@"partOfSpeech"]; + if(includeRelated != nil) + [queryParams setValue:includeRelated forKey:@"includeRelated"]; + if(sourceDictionaries != nil) + [queryParams setValue:sourceDictionaries forKey:@"sourceDictionaries"]; + if(useCanonical != nil) + [queryParams setValue:useCanonical forKey:@"useCanonical"]; + if(includeTags != nil) + [queryParams setValue:includeTags forKey:@"includeTags"]; + NSMutableDictionary* headerParams = [[NSMutableDictionary alloc] init]; + id bodyDictionary = nil; + if(word == nil) { + // error + } + // it's a returnContainer + [_api dictionaryWithCompletionBlock: requestUrl + method: @"GET" + queryParams: queryParams + body: bodyDictionary + headerParams: headerParams + completionHandler: ^(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) { + NIKDefinition* d = [[NIKDefinition alloc]initWithValues: dict]; + [objs addObject:d]; + } + completionBlock(objs, nil); + } + }]; + +} + +/** + * + * returnTypeIsPrimitive: + * returnBaseType: NIKExample + * returnContainer: + * + **/ +-(void) getTopExampleWithCompletionBlock :(NSString*) word useCanonical:(NSString*) useCanonical + completionHandler:(void (^)(NIKExample*, NSError *))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: [_api escapeString:word]]; + NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init]; + if(useCanonical != nil) + [queryParams setValue:useCanonical forKey:@"useCanonical"]; + NSMutableDictionary* headerParams = [[NSMutableDictionary alloc] init]; + id bodyDictionary = nil; + if(word == nil) { + // error + } + // not a return container + [_api dictionaryWithCompletionBlock: requestUrl + method: @"GET" + queryParams: queryParams + body: bodyDictionary + headerParams: headerParams + completionHandler: ^(NSDictionary *data, NSError *error) { + if (error) { + completionBlock(nil, error);return; + } + + completionBlock( [[NIKExample alloc]initWithValues: data], nil);}]; + +} + +/** + * + * returnTypeIsPrimitive: + * returnBaseType: NIKRelated + * returnContainer: List + * + **/ +-(void) getRelatedWordsWithCompletionBlock :(NSString*) word relationshipTypes:(NSString*) relationshipTypes useCanonical:(NSString*) useCanonical limitPerRelationshipType:(NSNumber*) limitPerRelationshipType + completionHandler:(void (^)(NSArray*, NSError *))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: [_api escapeString:word]]; + NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init]; + if(useCanonical != nil) + [queryParams setValue:useCanonical forKey:@"useCanonical"]; + if(relationshipTypes != nil) + [queryParams setValue:relationshipTypes forKey:@"relationshipTypes"]; + if(limitPerRelationshipType != nil) + [queryParams setValue:limitPerRelationshipType forKey:@"limitPerRelationshipType"]; + NSMutableDictionary* headerParams = [[NSMutableDictionary alloc] init]; + id bodyDictionary = nil; + if(word == nil) { + // error + } + // it's a returnContainer + [_api dictionaryWithCompletionBlock: requestUrl + method: @"GET" + queryParams: queryParams + body: bodyDictionary + headerParams: headerParams + completionHandler: ^(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) { + NIKRelated* d = [[NIKRelated alloc]initWithValues: dict]; + [objs addObject:d]; + } + completionBlock(objs, nil); + } + }]; + +} + +/** + * + * returnTypeIsPrimitive: + * returnBaseType: NIKTextPron + * returnContainer: List + * + **/ +-(void) getTextPronunciationsWithCompletionBlock :(NSString*) word sourceDictionary:(NSString*) sourceDictionary typeFormat:(NSString*) typeFormat useCanonical:(NSString*) useCanonical limit:(NSNumber*) limit + completionHandler:(void (^)(NSArray*, NSError *))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: [_api escapeString:word]]; + NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init]; + if(useCanonical != nil) + [queryParams setValue:useCanonical forKey:@"useCanonical"]; + if(sourceDictionary != nil) + [queryParams setValue:sourceDictionary forKey:@"sourceDictionary"]; + if(typeFormat != nil) + [queryParams setValue:typeFormat forKey:@"typeFormat"]; + if(limit != nil) + [queryParams setValue:limit forKey:@"limit"]; + NSMutableDictionary* headerParams = [[NSMutableDictionary alloc] init]; + id bodyDictionary = nil; + if(word == nil) { + // error + } + // it's a returnContainer + [_api dictionaryWithCompletionBlock: requestUrl + method: @"GET" + queryParams: queryParams + body: bodyDictionary + headerParams: headerParams + completionHandler: ^(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) { + NIKTextPron* d = [[NIKTextPron alloc]initWithValues: dict]; + [objs addObject:d]; + } + completionBlock(objs, nil); + } + }]; + +} + +/** + * + * returnTypeIsPrimitive: + * returnBaseType: NIKSyllable + * returnContainer: List + * + **/ +-(void) getHyphenationWithCompletionBlock :(NSString*) word sourceDictionary:(NSString*) sourceDictionary useCanonical:(NSString*) useCanonical limit:(NSNumber*) limit + completionHandler:(void (^)(NSArray*, NSError *))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: [_api escapeString:word]]; + NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init]; + if(useCanonical != nil) + [queryParams setValue:useCanonical forKey:@"useCanonical"]; + if(sourceDictionary != nil) + [queryParams setValue:sourceDictionary forKey:@"sourceDictionary"]; + if(limit != nil) + [queryParams setValue:limit forKey:@"limit"]; + NSMutableDictionary* headerParams = [[NSMutableDictionary alloc] init]; + id bodyDictionary = nil; + if(word == nil) { + // error + } + // it's a returnContainer + [_api dictionaryWithCompletionBlock: requestUrl + method: @"GET" + queryParams: queryParams + body: bodyDictionary + headerParams: headerParams + completionHandler: ^(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) { + NIKSyllable* d = [[NIKSyllable alloc]initWithValues: dict]; + [objs addObject:d]; + } + completionBlock(objs, nil); + } + }]; + +} + +/** + * + * returnTypeIsPrimitive: + * returnBaseType: NIKFrequencySummary + * returnContainer: + * + **/ +-(void) getWordFrequencyWithCompletionBlock :(NSString*) word useCanonical:(NSString*) useCanonical startYear:(NSNumber*) startYear endYear:(NSNumber*) endYear + completionHandler:(void (^)(NIKFrequencySummary*, NSError *))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: [_api escapeString:word]]; + NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init]; + if(useCanonical != nil) + [queryParams setValue:useCanonical forKey:@"useCanonical"]; + if(startYear != nil) + [queryParams setValue:startYear forKey:@"startYear"]; + if(endYear != nil) + [queryParams setValue:endYear forKey:@"endYear"]; + NSMutableDictionary* headerParams = [[NSMutableDictionary alloc] init]; + id bodyDictionary = nil; + if(word == nil) { + // error + } + // not a return container + [_api dictionaryWithCompletionBlock: requestUrl + method: @"GET" + queryParams: queryParams + body: bodyDictionary + headerParams: headerParams + completionHandler: ^(NSDictionary *data, NSError *error) { + if (error) { + completionBlock(nil, error);return; + } + + completionBlock( [[NIKFrequencySummary alloc]initWithValues: data], nil);}]; + +} + +/** + * + * returnTypeIsPrimitive: + * returnBaseType: NIKBigram + * returnContainer: List + * + **/ +-(void) getPhrasesWithCompletionBlock :(NSString*) word limit:(NSNumber*) limit wlmi:(NSNumber*) wlmi useCanonical:(NSString*) useCanonical + completionHandler:(void (^)(NSArray*, NSError *))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: [_api escapeString:word]]; + NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init]; + if(limit != nil) + [queryParams setValue:limit forKey:@"limit"]; + if(wlmi != nil) + [queryParams setValue:wlmi forKey:@"wlmi"]; + if(useCanonical != nil) + [queryParams setValue:useCanonical forKey:@"useCanonical"]; + NSMutableDictionary* headerParams = [[NSMutableDictionary alloc] init]; + id bodyDictionary = nil; + if(word == nil) { + // error + } + // it's a returnContainer + [_api dictionaryWithCompletionBlock: requestUrl + method: @"GET" + queryParams: queryParams + body: bodyDictionary + headerParams: headerParams + completionHandler: ^(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) { + NIKBigram* d = [[NIKBigram alloc]initWithValues: dict]; + [objs addObject:d]; + } + completionBlock(objs, nil); + } + }]; + +} + +/** + * + * returnTypeIsPrimitive: true + * returnBaseType: NSString + * returnContainer: List + * + **/ +-(void) getEtymologiesWithCompletionBlock :(NSString*) word useCanonical:(NSString*) useCanonical + completionHandler:(void (^)(NSArray*, NSError *))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: [_api escapeString:word]]; + NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init]; + if(useCanonical != nil) + [queryParams setValue:useCanonical forKey:@"useCanonical"]; + NSMutableDictionary* headerParams = [[NSMutableDictionary alloc] init]; + id bodyDictionary = nil; + if(word == nil) { + // error + } + // it's a returnContainer + [_api dictionaryWithCompletionBlock: requestUrl + method: @"GET" + queryParams: queryParams + body: bodyDictionary + headerParams: headerParams + completionHandler: ^(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* d = [[NSString alloc]initWithString: data]; + [objs addObject:d]; + } + completionBlock(objs, nil); + } + // it's a primitive type in the response + }]; + +} + +/** + * + * returnTypeIsPrimitive: + * returnBaseType: NIKAudioFile + * returnContainer: List + * + **/ +-(void) getAudioWithCompletionBlock :(NSString*) word useCanonical:(NSString*) useCanonical limit:(NSNumber*) limit + completionHandler:(void (^)(NSArray*, NSError *))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: [_api escapeString:word]]; + NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init]; + if(useCanonical != nil) + [queryParams setValue:useCanonical forKey:@"useCanonical"]; + if(limit != nil) + [queryParams setValue:limit forKey:@"limit"]; + NSMutableDictionary* headerParams = [[NSMutableDictionary alloc] init]; + id bodyDictionary = nil; + if(word == nil) { + // error + } + // it's a returnContainer + [_api dictionaryWithCompletionBlock: requestUrl + method: @"GET" + queryParams: queryParams + body: bodyDictionary + headerParams: headerParams + completionHandler: ^(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) { + NIKAudioFile* d = [[NIKAudioFile alloc]initWithValues: dict]; + [objs addObject:d]; + } + completionBlock(objs, nil); + } + }]; + +} + +-(void) getExamplesAsJsonWithCompletionBlock :(NSString*) word includeDuplicates:(NSString*) includeDuplicates useCanonical:(NSString*) useCanonical skip:(NSNumber*) skip limit:(NSNumber*) limit + completionHandler:(void (^)(NSString*, NSError *))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:@""]; + + [requestUrl replaceCharactersInRange: [requestUrl rangeOfString:[NSString stringWithFormat:@"%@%@%@", @"{", @"word", @"}"]] withString: [_api escapeString:word]]; + NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init]; + if(includeDuplicates != nil) + [queryParams setValue:includeDuplicates forKey:@"includeDuplicates"]; + if(useCanonical != nil) + [queryParams setValue:useCanonical forKey:@"useCanonical"]; + if(skip != nil) + [queryParams setValue:skip forKey:@"skip"]; + if(limit != nil) + [queryParams setValue:limit forKey:@"limit"]; + NSMutableDictionary* headerParams = [[NSMutableDictionary alloc] init]; + id bodyDictionary = nil; + if(word == nil) { + // error + } + [_api dictionaryWithCompletionBlock: requestUrl + method: @"GET" + queryParams: queryParams + body: bodyDictionary + headerParams: headerParams + completionHandler: ^(NSDictionary *data, NSError *error) { + if (error) { + completionBlock(nil, error);return; + } + + NSData * responseData = nil; + if([data isKindOfClass:[NSDictionary class]]){ + responseData = [NSJSONSerialization dataWithJSONObject:data + options:kNilOptions error:&error]; + } + else if ([data isKindOfClass:[NSArray class]]){ + responseData = [NSJSONSerialization dataWithJSONObject:data + options:kNilOptions error:&error]; + } + NSString * json = [[NSString alloc]initWithData:responseData encoding:NSUTF8StringEncoding]; + completionBlock(json, nil); + + }]; + +} + +-(void) getWordAsJsonWithCompletionBlock :(NSString*) word useCanonical:(NSString*) useCanonical includeSuggestions:(NSString*) includeSuggestions + completionHandler:(void (^)(NSString*, NSError *))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:@""]; + + [requestUrl replaceCharactersInRange: [requestUrl rangeOfString:[NSString stringWithFormat:@"%@%@%@", @"{", @"word", @"}"]] withString: [_api escapeString:word]]; + NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init]; + if(useCanonical != nil) + [queryParams setValue:useCanonical forKey:@"useCanonical"]; + if(includeSuggestions != nil) + [queryParams setValue:includeSuggestions forKey:@"includeSuggestions"]; + NSMutableDictionary* headerParams = [[NSMutableDictionary alloc] init]; + id bodyDictionary = nil; + if(word == nil) { + // error + } + [_api dictionaryWithCompletionBlock: requestUrl + method: @"GET" + queryParams: queryParams + body: bodyDictionary + headerParams: headerParams + completionHandler: ^(NSDictionary *data, NSError *error) { + if (error) { + completionBlock(nil, error);return; + } + + NSData * responseData = nil; + if([data isKindOfClass:[NSDictionary class]]){ + responseData = [NSJSONSerialization dataWithJSONObject:data + options:kNilOptions error:&error]; + } + else if ([data isKindOfClass:[NSArray class]]){ + responseData = [NSJSONSerialization dataWithJSONObject:data + options:kNilOptions error:&error]; + } + NSString * json = [[NSString alloc]initWithData:responseData encoding:NSUTF8StringEncoding]; + completionBlock(json, nil); + + }]; + +} + +-(void) getDefinitionsAsJsonWithCompletionBlock :(NSString*) word partOfSpeech:(NSString*) partOfSpeech sourceDictionaries:(NSString*) sourceDictionaries limit:(NSNumber*) limit includeRelated:(NSString*) includeRelated useCanonical:(NSString*) useCanonical includeTags:(NSString*) includeTags + completionHandler:(void (^)(NSString*, NSError *))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:@""]; + + [requestUrl replaceCharactersInRange: [requestUrl rangeOfString:[NSString stringWithFormat:@"%@%@%@", @"{", @"word", @"}"]] withString: [_api escapeString:word]]; + NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init]; + if(limit != nil) + [queryParams setValue:limit forKey:@"limit"]; + if(partOfSpeech != nil) + [queryParams setValue:partOfSpeech forKey:@"partOfSpeech"]; + if(includeRelated != nil) + [queryParams setValue:includeRelated forKey:@"includeRelated"]; + if(sourceDictionaries != nil) + [queryParams setValue:sourceDictionaries forKey:@"sourceDictionaries"]; + if(useCanonical != nil) + [queryParams setValue:useCanonical forKey:@"useCanonical"]; + if(includeTags != nil) + [queryParams setValue:includeTags forKey:@"includeTags"]; + NSMutableDictionary* headerParams = [[NSMutableDictionary alloc] init]; + id bodyDictionary = nil; + if(word == nil) { + // error + } + [_api dictionaryWithCompletionBlock: requestUrl + method: @"GET" + queryParams: queryParams + body: bodyDictionary + headerParams: headerParams + completionHandler: ^(NSDictionary *data, NSError *error) { + if (error) { + completionBlock(nil, error);return; + } + + NSData * responseData = nil; + if([data isKindOfClass:[NSDictionary class]]){ + responseData = [NSJSONSerialization dataWithJSONObject:data + options:kNilOptions error:&error]; + } + else if ([data isKindOfClass:[NSArray class]]){ + responseData = [NSJSONSerialization dataWithJSONObject:data + options:kNilOptions error:&error]; + } + NSString * json = [[NSString alloc]initWithData:responseData encoding:NSUTF8StringEncoding]; + completionBlock(json, nil); + + }]; + +} + +-(void) getTopExampleAsJsonWithCompletionBlock :(NSString*) word useCanonical:(NSString*) useCanonical + completionHandler:(void (^)(NSString*, NSError *))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:@""]; + + [requestUrl replaceCharactersInRange: [requestUrl rangeOfString:[NSString stringWithFormat:@"%@%@%@", @"{", @"word", @"}"]] withString: [_api escapeString:word]]; + NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init]; + if(useCanonical != nil) + [queryParams setValue:useCanonical forKey:@"useCanonical"]; + NSMutableDictionary* headerParams = [[NSMutableDictionary alloc] init]; + id bodyDictionary = nil; + if(word == nil) { + // error + } + [_api dictionaryWithCompletionBlock: requestUrl + method: @"GET" + queryParams: queryParams + body: bodyDictionary + headerParams: headerParams + completionHandler: ^(NSDictionary *data, NSError *error) { + if (error) { + completionBlock(nil, error);return; + } + + NSData * responseData = nil; + if([data isKindOfClass:[NSDictionary class]]){ + responseData = [NSJSONSerialization dataWithJSONObject:data + options:kNilOptions error:&error]; + } + else if ([data isKindOfClass:[NSArray class]]){ + responseData = [NSJSONSerialization dataWithJSONObject:data + options:kNilOptions error:&error]; + } + NSString * json = [[NSString alloc]initWithData:responseData encoding:NSUTF8StringEncoding]; + completionBlock(json, nil); + + }]; + +} + +-(void) getRelatedWordsAsJsonWithCompletionBlock :(NSString*) word relationshipTypes:(NSString*) relationshipTypes useCanonical:(NSString*) useCanonical limitPerRelationshipType:(NSNumber*) limitPerRelationshipType + completionHandler:(void (^)(NSString*, NSError *))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:@""]; + + [requestUrl replaceCharactersInRange: [requestUrl rangeOfString:[NSString stringWithFormat:@"%@%@%@", @"{", @"word", @"}"]] withString: [_api escapeString:word]]; + NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init]; + if(useCanonical != nil) + [queryParams setValue:useCanonical forKey:@"useCanonical"]; + if(relationshipTypes != nil) + [queryParams setValue:relationshipTypes forKey:@"relationshipTypes"]; + if(limitPerRelationshipType != nil) + [queryParams setValue:limitPerRelationshipType forKey:@"limitPerRelationshipType"]; + NSMutableDictionary* headerParams = [[NSMutableDictionary alloc] init]; + id bodyDictionary = nil; + if(word == nil) { + // error + } + [_api dictionaryWithCompletionBlock: requestUrl + method: @"GET" + queryParams: queryParams + body: bodyDictionary + headerParams: headerParams + completionHandler: ^(NSDictionary *data, NSError *error) { + if (error) { + completionBlock(nil, error);return; + } + + NSData * responseData = nil; + if([data isKindOfClass:[NSDictionary class]]){ + responseData = [NSJSONSerialization dataWithJSONObject:data + options:kNilOptions error:&error]; + } + else if ([data isKindOfClass:[NSArray class]]){ + responseData = [NSJSONSerialization dataWithJSONObject:data + options:kNilOptions error:&error]; + } + NSString * json = [[NSString alloc]initWithData:responseData encoding:NSUTF8StringEncoding]; + completionBlock(json, nil); + + }]; + +} + +-(void) getTextPronunciationsAsJsonWithCompletionBlock :(NSString*) word sourceDictionary:(NSString*) sourceDictionary typeFormat:(NSString*) typeFormat useCanonical:(NSString*) useCanonical limit:(NSNumber*) limit + completionHandler:(void (^)(NSString*, NSError *))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:@""]; + + [requestUrl replaceCharactersInRange: [requestUrl rangeOfString:[NSString stringWithFormat:@"%@%@%@", @"{", @"word", @"}"]] withString: [_api escapeString:word]]; + NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init]; + if(useCanonical != nil) + [queryParams setValue:useCanonical forKey:@"useCanonical"]; + if(sourceDictionary != nil) + [queryParams setValue:sourceDictionary forKey:@"sourceDictionary"]; + if(typeFormat != nil) + [queryParams setValue:typeFormat forKey:@"typeFormat"]; + if(limit != nil) + [queryParams setValue:limit forKey:@"limit"]; + NSMutableDictionary* headerParams = [[NSMutableDictionary alloc] init]; + id bodyDictionary = nil; + if(word == nil) { + // error + } + [_api dictionaryWithCompletionBlock: requestUrl + method: @"GET" + queryParams: queryParams + body: bodyDictionary + headerParams: headerParams + completionHandler: ^(NSDictionary *data, NSError *error) { + if (error) { + completionBlock(nil, error);return; + } + + NSData * responseData = nil; + if([data isKindOfClass:[NSDictionary class]]){ + responseData = [NSJSONSerialization dataWithJSONObject:data + options:kNilOptions error:&error]; + } + else if ([data isKindOfClass:[NSArray class]]){ + responseData = [NSJSONSerialization dataWithJSONObject:data + options:kNilOptions error:&error]; + } + NSString * json = [[NSString alloc]initWithData:responseData encoding:NSUTF8StringEncoding]; + completionBlock(json, nil); + + }]; + +} + +-(void) getHyphenationAsJsonWithCompletionBlock :(NSString*) word sourceDictionary:(NSString*) sourceDictionary useCanonical:(NSString*) useCanonical limit:(NSNumber*) limit + completionHandler:(void (^)(NSString*, NSError *))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:@""]; + + [requestUrl replaceCharactersInRange: [requestUrl rangeOfString:[NSString stringWithFormat:@"%@%@%@", @"{", @"word", @"}"]] withString: [_api escapeString:word]]; + NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init]; + if(useCanonical != nil) + [queryParams setValue:useCanonical forKey:@"useCanonical"]; + if(sourceDictionary != nil) + [queryParams setValue:sourceDictionary forKey:@"sourceDictionary"]; + if(limit != nil) + [queryParams setValue:limit forKey:@"limit"]; + NSMutableDictionary* headerParams = [[NSMutableDictionary alloc] init]; + id bodyDictionary = nil; + if(word == nil) { + // error + } + [_api dictionaryWithCompletionBlock: requestUrl + method: @"GET" + queryParams: queryParams + body: bodyDictionary + headerParams: headerParams + completionHandler: ^(NSDictionary *data, NSError *error) { + if (error) { + completionBlock(nil, error);return; + } + + NSData * responseData = nil; + if([data isKindOfClass:[NSDictionary class]]){ + responseData = [NSJSONSerialization dataWithJSONObject:data + options:kNilOptions error:&error]; + } + else if ([data isKindOfClass:[NSArray class]]){ + responseData = [NSJSONSerialization dataWithJSONObject:data + options:kNilOptions error:&error]; + } + NSString * json = [[NSString alloc]initWithData:responseData encoding:NSUTF8StringEncoding]; + completionBlock(json, nil); + + }]; + +} + +-(void) getWordFrequencyAsJsonWithCompletionBlock :(NSString*) word useCanonical:(NSString*) useCanonical startYear:(NSNumber*) startYear endYear:(NSNumber*) endYear + completionHandler:(void (^)(NSString*, NSError *))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:@""]; + + [requestUrl replaceCharactersInRange: [requestUrl rangeOfString:[NSString stringWithFormat:@"%@%@%@", @"{", @"word", @"}"]] withString: [_api escapeString:word]]; + NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init]; + if(useCanonical != nil) + [queryParams setValue:useCanonical forKey:@"useCanonical"]; + if(startYear != nil) + [queryParams setValue:startYear forKey:@"startYear"]; + if(endYear != nil) + [queryParams setValue:endYear forKey:@"endYear"]; + NSMutableDictionary* headerParams = [[NSMutableDictionary alloc] init]; + id bodyDictionary = nil; + if(word == nil) { + // error + } + [_api dictionaryWithCompletionBlock: requestUrl + method: @"GET" + queryParams: queryParams + body: bodyDictionary + headerParams: headerParams + completionHandler: ^(NSDictionary *data, NSError *error) { + if (error) { + completionBlock(nil, error);return; + } + + NSData * responseData = nil; + if([data isKindOfClass:[NSDictionary class]]){ + responseData = [NSJSONSerialization dataWithJSONObject:data + options:kNilOptions error:&error]; + } + else if ([data isKindOfClass:[NSArray class]]){ + responseData = [NSJSONSerialization dataWithJSONObject:data + options:kNilOptions error:&error]; + } + NSString * json = [[NSString alloc]initWithData:responseData encoding:NSUTF8StringEncoding]; + completionBlock(json, nil); + + }]; + +} + +-(void) getPhrasesAsJsonWithCompletionBlock :(NSString*) word limit:(NSNumber*) limit wlmi:(NSNumber*) wlmi useCanonical:(NSString*) useCanonical + completionHandler:(void (^)(NSString*, NSError *))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:@""]; + + [requestUrl replaceCharactersInRange: [requestUrl rangeOfString:[NSString stringWithFormat:@"%@%@%@", @"{", @"word", @"}"]] withString: [_api escapeString:word]]; + NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init]; + if(limit != nil) + [queryParams setValue:limit forKey:@"limit"]; + if(wlmi != nil) + [queryParams setValue:wlmi forKey:@"wlmi"]; + if(useCanonical != nil) + [queryParams setValue:useCanonical forKey:@"useCanonical"]; + NSMutableDictionary* headerParams = [[NSMutableDictionary alloc] init]; + id bodyDictionary = nil; + if(word == nil) { + // error + } + [_api dictionaryWithCompletionBlock: requestUrl + method: @"GET" + queryParams: queryParams + body: bodyDictionary + headerParams: headerParams + completionHandler: ^(NSDictionary *data, NSError *error) { + if (error) { + completionBlock(nil, error);return; + } + + NSData * responseData = nil; + if([data isKindOfClass:[NSDictionary class]]){ + responseData = [NSJSONSerialization dataWithJSONObject:data + options:kNilOptions error:&error]; + } + else if ([data isKindOfClass:[NSArray class]]){ + responseData = [NSJSONSerialization dataWithJSONObject:data + options:kNilOptions error:&error]; + } + NSString * json = [[NSString alloc]initWithData:responseData encoding:NSUTF8StringEncoding]; + completionBlock(json, nil); + + }]; + +} + +-(void) getEtymologiesAsJsonWithCompletionBlock :(NSString*) word useCanonical:(NSString*) useCanonical + completionHandler:(void (^)(NSString*, NSError *))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:@""]; + + [requestUrl replaceCharactersInRange: [requestUrl rangeOfString:[NSString stringWithFormat:@"%@%@%@", @"{", @"word", @"}"]] withString: [_api escapeString:word]]; + NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init]; + if(useCanonical != nil) + [queryParams setValue:useCanonical forKey:@"useCanonical"]; + NSMutableDictionary* headerParams = [[NSMutableDictionary alloc] init]; + id bodyDictionary = nil; + if(word == nil) { + // error + } + [_api dictionaryWithCompletionBlock: requestUrl + method: @"GET" + queryParams: queryParams + body: bodyDictionary + headerParams: headerParams + completionHandler: ^(NSDictionary *data, NSError *error) { + if (error) { + completionBlock(nil, error);return; + } + + NSData * responseData = nil; + if([data isKindOfClass:[NSDictionary class]]){ + responseData = [NSJSONSerialization dataWithJSONObject:data + options:kNilOptions error:&error]; + } + else if ([data isKindOfClass:[NSArray class]]){ + responseData = [NSJSONSerialization dataWithJSONObject:data + options:kNilOptions error:&error]; + } + NSString * json = [[NSString alloc]initWithData:responseData encoding:NSUTF8StringEncoding]; + completionBlock(json, nil); + + }]; + +} + +-(void) getAudioAsJsonWithCompletionBlock :(NSString*) word useCanonical:(NSString*) useCanonical limit:(NSNumber*) limit + completionHandler:(void (^)(NSString*, NSError *))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:@""]; + + [requestUrl replaceCharactersInRange: [requestUrl rangeOfString:[NSString stringWithFormat:@"%@%@%@", @"{", @"word", @"}"]] withString: [_api escapeString:word]]; + NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init]; + if(useCanonical != nil) + [queryParams setValue:useCanonical forKey:@"useCanonical"]; + if(limit != nil) + [queryParams setValue:limit forKey:@"limit"]; + NSMutableDictionary* headerParams = [[NSMutableDictionary alloc] init]; + id bodyDictionary = nil; + if(word == nil) { + // error + } + [_api dictionaryWithCompletionBlock: requestUrl + method: @"GET" + queryParams: queryParams + body: bodyDictionary + headerParams: headerParams + completionHandler: ^(NSDictionary *data, NSError *error) { + if (error) { + completionBlock(nil, error);return; + } + + NSData * responseData = nil; + if([data isKindOfClass:[NSDictionary class]]){ + responseData = [NSJSONSerialization dataWithJSONObject:data + options:kNilOptions error:&error]; + } + else if ([data isKindOfClass:[NSArray class]]){ + responseData = [NSJSONSerialization dataWithJSONObject:data + options:kNilOptions error:&error]; + } + NSString * json = [[NSString alloc]initWithData:responseData encoding:NSUTF8StringEncoding]; + completionBlock(json, nil); + + }]; + +} + + +@end diff --git a/samples/client/wordnik-api/objc/client/NIKWordList.h b/samples/client/wordnik-api/objc/client/NIKWordList.h new file mode 100644 index 00000000000..acc8423fe14 --- /dev/null +++ b/samples/client/wordnik-api/objc/client/NIKWordList.h @@ -0,0 +1,50 @@ +#import +#import "NIKSwaggerObject.h" +#import "NIKDate.h" + +@interface NIKWordList : NIKSwaggerObject { +@private + NSNumber* __id; //NSNumber + NIKDate* _updatedAt; //NIKDate + NSString* _username; //NSString + NSString* _permalink; //NSString + NSString* _description; //NSString + NIKDate* _createdAt; //NIKDate + NIKDate* _lastActivityAt; //NIKDate + NSString* _name; //NSString + NSNumber* _userId; //NSNumber + NSNumber* _numberWordsInList; //NSNumber + NSString* _type; //NSString + } + + + +@property(nonatomic) NSNumber* _id; +@property(nonatomic) NIKDate* updatedAt; +@property(nonatomic) NSString* username; +@property(nonatomic) NSString* permalink; +@property(nonatomic) NSString* description; +@property(nonatomic) NIKDate* createdAt; +@property(nonatomic) NIKDate* lastActivityAt; +@property(nonatomic) NSString* name; +@property(nonatomic) NSNumber* userId; +@property(nonatomic) NSNumber* numberWordsInList; +@property(nonatomic) NSString* type; +- (id) _id: (NSNumber*) _id + updatedAt: (NIKDate*) updatedAt + username: (NSString*) username + permalink: (NSString*) permalink + description: (NSString*) description + createdAt: (NIKDate*) createdAt + lastActivityAt: (NIKDate*) lastActivityAt + name: (NSString*) name + userId: (NSNumber*) userId + numberWordsInList: (NSNumber*) numberWordsInList + type: (NSString*) type; + +- (id) initWithValues: (NSDictionary*)dict; +- (NSDictionary*) asDictionary; + + +@end + diff --git a/samples/client/wordnik-api/objc/client/NIKWordList.m b/samples/client/wordnik-api/objc/client/NIKWordList.m new file mode 100644 index 00000000000..4e6ff1a1de9 --- /dev/null +++ b/samples/client/wordnik-api/objc/client/NIKWordList.m @@ -0,0 +1,142 @@ +#import "NIKDate.h" +#import "NIKWordList.h" + +@implementation NIKWordList + +@synthesize _id = __id; +@synthesize updatedAt = _updatedAt; +@synthesize username = _username; +@synthesize permalink = _permalink; +@synthesize description = _description; +@synthesize createdAt = _createdAt; +@synthesize lastActivityAt = _lastActivityAt; +@synthesize name = _name; +@synthesize userId = _userId; +@synthesize numberWordsInList = _numberWordsInList; +@synthesize type = _type; +- (id) _id: (NSNumber*) _id + updatedAt: (NIKDate*) updatedAt + username: (NSString*) username + permalink: (NSString*) permalink + description: (NSString*) description + createdAt: (NIKDate*) createdAt + lastActivityAt: (NIKDate*) lastActivityAt + name: (NSString*) name + userId: (NSNumber*) userId + numberWordsInList: (NSNumber*) numberWordsInList + type: (NSString*) type + { + __id = _id; + _updatedAt = updatedAt; + _username = username; + _permalink = permalink; + _description = description; + _createdAt = createdAt; + _lastActivityAt = lastActivityAt; + _name = name; + _userId = userId; + _numberWordsInList = numberWordsInList; + _type = type; + return self; + } + +- (id) initWithValues: (NSDictionary*)dict +{ + /* isContainer: , baseType: NSNumber, complexType: */ + __id = [dict objectForKey:@"id"]; + /* isContainer: , baseType: NIKDate, complexType: NIKDate */ + id updatedAt_dict = [dict objectForKey:@"updatedAt"]; + _updatedAt = [[NIKDate alloc]initWithValues:updatedAt_dict]; + /* isContainer: , baseType: NSString, complexType: */ + _username = [dict objectForKey:@"username"]; + /* isContainer: , baseType: NSString, complexType: */ + _permalink = [dict objectForKey:@"permalink"]; + /* isContainer: , baseType: NSString, complexType: */ + _description = [dict objectForKey:@"description"]; + /* isContainer: , baseType: NIKDate, complexType: NIKDate */ + id createdAt_dict = [dict objectForKey:@"createdAt"]; + _createdAt = [[NIKDate alloc]initWithValues:createdAt_dict]; + /* isContainer: , baseType: NIKDate, complexType: NIKDate */ + id lastActivityAt_dict = [dict objectForKey:@"lastActivityAt"]; + _lastActivityAt = [[NIKDate alloc]initWithValues:lastActivityAt_dict]; + /* isContainer: , baseType: NSString, complexType: */ + _name = [dict objectForKey:@"name"]; + /* isContainer: , baseType: NSNumber, complexType: */ + _userId = [dict objectForKey:@"userId"]; + /* isContainer: , baseType: NSNumber, complexType: */ + _numberWordsInList = [dict objectForKey:@"numberWordsInList"]; + /* isContainer: , baseType: NSString, complexType: */ + _type = [dict objectForKey:@"type"]; + return self; +} + +-(NSDictionary*) asDictionary { + NSMutableDictionary* dict = [[NSMutableDictionary alloc] init]; + if(__id != nil) [dict setObject:__id forKey:@"id"]; + if(_updatedAt != nil){ + if([_updatedAt isKindOfClass:[NSArray class]]){ + NSMutableArray * array = [[NSMutableArray alloc] init]; + for( NIKDate * updatedAt in (NSArray*)_updatedAt) { + [array addObject:[(NIKSwaggerObject*)updatedAt asDictionary]]; + } + [dict setObject:array forKey:@"updatedAt"]; + } + else if(_updatedAt && [_updatedAt isKindOfClass:[NIKDate class]]) { + NSString * dateString = [(NIKDate*)_updatedAt toString]; + if(dateString){ + [dict setObject:dateString forKey:@"updatedAt"]; + } + } + } + else { + if(_updatedAt != nil) [dict setObject:[(NIKSwaggerObject*)_updatedAt asDictionary]forKey:@"updatedAt"]; + } + if(_username != nil) [dict setObject:_username forKey:@"username"]; + if(_permalink != nil) [dict setObject:_permalink forKey:@"permalink"]; + if(_description != nil) [dict setObject:_description forKey:@"description"]; + if(_createdAt != nil){ + if([_createdAt isKindOfClass:[NSArray class]]){ + NSMutableArray * array = [[NSMutableArray alloc] init]; + for( NIKDate * createdAt in (NSArray*)_createdAt) { + [array addObject:[(NIKSwaggerObject*)createdAt asDictionary]]; + } + [dict setObject:array forKey:@"createdAt"]; + } + else if(_createdAt && [_createdAt isKindOfClass:[NIKDate class]]) { + NSString * dateString = [(NIKDate*)_createdAt toString]; + if(dateString){ + [dict setObject:dateString forKey:@"createdAt"]; + } + } + } + else { + if(_createdAt != nil) [dict setObject:[(NIKSwaggerObject*)_createdAt asDictionary]forKey:@"createdAt"]; + } + if(_lastActivityAt != nil){ + if([_lastActivityAt isKindOfClass:[NSArray class]]){ + NSMutableArray * array = [[NSMutableArray alloc] init]; + for( NIKDate * lastActivityAt in (NSArray*)_lastActivityAt) { + [array addObject:[(NIKSwaggerObject*)lastActivityAt asDictionary]]; + } + [dict setObject:array forKey:@"lastActivityAt"]; + } + else if(_lastActivityAt && [_lastActivityAt isKindOfClass:[NIKDate class]]) { + NSString * dateString = [(NIKDate*)_lastActivityAt toString]; + if(dateString){ + [dict setObject:dateString forKey:@"lastActivityAt"]; + } + } + } + else { + if(_lastActivityAt != nil) [dict setObject:[(NIKSwaggerObject*)_lastActivityAt asDictionary]forKey:@"lastActivityAt"]; + } + if(_name != nil) [dict setObject:_name forKey:@"name"]; + if(_userId != nil) [dict setObject:_userId forKey:@"userId"]; + if(_numberWordsInList != nil) [dict setObject:_numberWordsInList forKey:@"numberWordsInList"]; + if(_type != nil) [dict setObject:_type forKey:@"type"]; + NSDictionary* output = [dict copy]; + return output; +} + +@end + diff --git a/samples/client/wordnik-api/objc/client/NIKWordListApi.h b/samples/client/wordnik-api/objc/client/NIKWordListApi.h new file mode 100644 index 00000000000..a68d548dccc --- /dev/null +++ b/samples/client/wordnik-api/objc/client/NIKWordListApi.h @@ -0,0 +1,32 @@ +#import +#import "NIKApiInvoker.h" +#import "NIKWordList.h" +#import "NIKStringValue.h" +#import "NIKWordListWord.h" + + +@interface NIKWordListApi: NSObject { + +@private + NSOperationQueue *_queue; + NIKApiInvoker * _api; +} +@property(nonatomic, readonly) NSOperationQueue* queue; +@property(nonatomic, readonly) NIKApiInvoker* api; + +-(void) addHeader:(NSString*) value + forKey:(NSString*)key; + +-(void) updateWordListWithCompletionBlock :(NSString*) permalink body:(NIKWordList*) body auth_token:(NSString*) auth_token + completionHandler:(void (^)(NSError *))completionBlock; +-(void) deleteWordListWithCompletionBlock :(NSString*) permalink auth_token:(NSString*) auth_token + completionHandler:(void (^)(NSError *))completionBlock; +-(void) getWordListByPermalinkWithCompletionBlock :(NSString*) permalink auth_token:(NSString*) auth_token + completionHandler:(void (^)(NIKWordList*, NSError *))completionBlock; +-(void) addWordsToWordListWithCompletionBlock :(NSString*) permalink body:(NSArray*) body auth_token:(NSString*) auth_token + completionHandler:(void (^)(NSError *))completionBlock; +-(void) getWordListWordsWithCompletionBlock :(NSString*) permalink auth_token:(NSString*) auth_token sortBy:(NSString*) sortBy sortOrder:(NSString*) sortOrder skip:(NSNumber*) skip limit:(NSNumber*) limit + completionHandler:(void (^)(NSArray*, NSError *))completionBlock; +-(void) deleteWordsFromWordListWithCompletionBlock :(NSString*) permalink body:(NSArray*) body auth_token:(NSString*) auth_token + completionHandler:(void (^)(NSError *))completionBlock; +@end diff --git a/samples/client/wordnik-api/objc/client/NIKWordListApi.m b/samples/client/wordnik-api/objc/client/NIKWordListApi.m new file mode 100644 index 00000000000..1ea2e9a60f9 --- /dev/null +++ b/samples/client/wordnik-api/objc/client/NIKWordListApi.m @@ -0,0 +1,684 @@ +#import "NIKWordListApi.h" +#import "NIKWordList.h" +#import "NIKStringValue.h" +#import "NIKWordListWord.h" + + + +@implementation NIKWordListApi +static NSString * basePath = @"http://api.wordnik.com/v4"; + +@synthesize queue = _queue; +@synthesize api = _api; + +- (id) init { + self = [super init]; + _queue = [[NSOperationQueue alloc] init]; + _api = [[NIKApiInvoker alloc] init]; + + return self; +} + +-(void) addHeader:(NSString*) value + forKey:(NSString*)key { + [_api addHeader:value forKey:key]; +} + +/** + * + * returnTypeIsPrimitive: true + * returnBaseType: + * returnContainer: + * + **/ +-(void) updateWordListWithCompletionBlock :(NSString*) permalink body:(NIKWordList*) body auth_token:(NSString*) auth_token + completionHandler:(void (^)(NSError *))completionBlock{ + + NSMutableString* requestUrl = [NSMutableString stringWithFormat:@"%@/wordList.{format}/{permalink}", 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:@"%@%@%@", @"{", @"permalink", @"}"]] withString: [_api escapeString:permalink]]; + NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init]; + NSMutableDictionary* headerParams = [[NSMutableDictionary alloc] init]; + if(auth_token != nil) + [headerParams setValue:auth_token forKey:@"auth_token"]; + id bodyDictionary = nil; + if(body != nil && [body isKindOfClass:[NSArray class]]){ + NSMutableArray * objs = [[NSMutableArray alloc] init]; + for (id dict in (NSArray*)body) { + if([dict respondsToSelector:@selector(asDictionary)]) { + [objs addObject:[(NIKSwaggerObject*)dict asDictionary]]; + } + else{ + [objs addObject:dict]; + } + } + bodyDictionary = objs; + } + else if([body respondsToSelector:@selector(asDictionary)]) { + bodyDictionary = [(NIKSwaggerObject*)body asDictionary]; + } + else if([body isKindOfClass:[NSString class]]) { + bodyDictionary = body; + } + else{ + NSLog(@"don't know what to do with %@", body); + } + + if(permalink == nil) { + // error + } + if(auth_token == nil) { + // error + } + // not a return container + [_api stringWithCompletionBlock: requestUrl + method: @"PUT" + queryParams: queryParams + body: bodyDictionary + headerParams: headerParams + completionHandler: ^(NSString *data, NSError *error) { + if (error) { + completionBlock(error); + return; + } + completionBlock(nil); + }]; + +} + +/** + * + * returnTypeIsPrimitive: true + * returnBaseType: + * returnContainer: + * + **/ +-(void) deleteWordListWithCompletionBlock :(NSString*) permalink auth_token:(NSString*) auth_token + completionHandler:(void (^)(NSError *))completionBlock{ + + NSMutableString* requestUrl = [NSMutableString stringWithFormat:@"%@/wordList.{format}/{permalink}", 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:@"%@%@%@", @"{", @"permalink", @"}"]] withString: [_api escapeString:permalink]]; + NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init]; + NSMutableDictionary* headerParams = [[NSMutableDictionary alloc] init]; + if(auth_token != nil) + [headerParams setValue:auth_token forKey:@"auth_token"]; + id bodyDictionary = nil; + if(permalink == nil) { + // error + } + if(auth_token == nil) { + // error + } + // not a return container + [_api stringWithCompletionBlock: requestUrl + method: @"DELETE" + queryParams: queryParams + body: bodyDictionary + headerParams: headerParams + completionHandler: ^(NSString *data, NSError *error) { + if (error) { + completionBlock(error); + return; + } + completionBlock(nil); + }]; + +} + +/** + * + * returnTypeIsPrimitive: + * returnBaseType: NIKWordList + * returnContainer: + * + **/ +-(void) getWordListByPermalinkWithCompletionBlock :(NSString*) permalink auth_token:(NSString*) auth_token + completionHandler:(void (^)(NIKWordList*, NSError *))completionBlock{ + + NSMutableString* requestUrl = [NSMutableString stringWithFormat:@"%@/wordList.{format}/{permalink}", 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:@"%@%@%@", @"{", @"permalink", @"}"]] withString: [_api escapeString:permalink]]; + NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init]; + NSMutableDictionary* headerParams = [[NSMutableDictionary alloc] init]; + if(auth_token != nil) + [headerParams setValue:auth_token forKey:@"auth_token"]; + id bodyDictionary = nil; + if(permalink == nil) { + // error + } + if(auth_token == nil) { + // error + } + // not a return container + [_api dictionaryWithCompletionBlock: requestUrl + method: @"GET" + queryParams: queryParams + body: bodyDictionary + headerParams: headerParams + completionHandler: ^(NSDictionary *data, NSError *error) { + if (error) { + completionBlock(nil, error);return; + } + + completionBlock( [[NIKWordList alloc]initWithValues: data], nil);}]; + +} + +/** + * + * returnTypeIsPrimitive: true + * returnBaseType: + * returnContainer: + * + **/ +-(void) addWordsToWordListWithCompletionBlock :(NSString*) permalink body:(NSArray*) body auth_token:(NSString*) auth_token + completionHandler:(void (^)(NSError *))completionBlock{ + + NSMutableString* requestUrl = [NSMutableString stringWithFormat:@"%@/wordList.{format}/{permalink}/words", 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:@"%@%@%@", @"{", @"permalink", @"}"]] withString: [_api escapeString:permalink]]; + NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init]; + NSMutableDictionary* headerParams = [[NSMutableDictionary alloc] init]; + if(auth_token != nil) + [headerParams setValue:auth_token forKey:@"auth_token"]; + id bodyDictionary = nil; + if(body != nil && [body isKindOfClass:[NSArray class]]){ + NSMutableArray * objs = [[NSMutableArray alloc] init]; + for (id dict in (NSArray*)body) { + if([dict respondsToSelector:@selector(asDictionary)]) { + [objs addObject:[(NIKSwaggerObject*)dict asDictionary]]; + } + else{ + [objs addObject:dict]; + } + } + bodyDictionary = objs; + } + else if([body respondsToSelector:@selector(asDictionary)]) { + bodyDictionary = [(NIKSwaggerObject*)body asDictionary]; + } + else if([body isKindOfClass:[NSString class]]) { + bodyDictionary = body; + } + else{ + NSLog(@"don't know what to do with %@", body); + } + + if(permalink == nil) { + // error + } + if(auth_token == nil) { + // error + } + // not a return container + [_api stringWithCompletionBlock: requestUrl + method: @"POST" + queryParams: queryParams + body: bodyDictionary + headerParams: headerParams + completionHandler: ^(NSString *data, NSError *error) { + if (error) { + completionBlock(error); + return; + } + completionBlock(nil); + }]; + +} + +/** + * + * returnTypeIsPrimitive: + * returnBaseType: NIKWordListWord + * returnContainer: List + * + **/ +-(void) getWordListWordsWithCompletionBlock :(NSString*) permalink auth_token:(NSString*) auth_token sortBy:(NSString*) sortBy sortOrder:(NSString*) sortOrder skip:(NSNumber*) skip limit:(NSNumber*) limit + completionHandler:(void (^)(NSArray*, NSError *))completionBlock{ + + NSMutableString* requestUrl = [NSMutableString stringWithFormat:@"%@/wordList.{format}/{permalink}/words", 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:@"%@%@%@", @"{", @"permalink", @"}"]] withString: [_api escapeString:permalink]]; + NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init]; + if(sortBy != nil) + [queryParams setValue:sortBy forKey:@"sortBy"]; + if(sortOrder != nil) + [queryParams setValue:sortOrder forKey:@"sortOrder"]; + if(skip != nil) + [queryParams setValue:skip forKey:@"skip"]; + if(limit != nil) + [queryParams setValue:limit forKey:@"limit"]; + NSMutableDictionary* headerParams = [[NSMutableDictionary alloc] init]; + if(auth_token != nil) + [headerParams setValue:auth_token forKey:@"auth_token"]; + id bodyDictionary = nil; + if(permalink == nil) { + // error + } + if(auth_token == nil) { + // error + } + // it's a returnContainer + [_api dictionaryWithCompletionBlock: requestUrl + method: @"GET" + queryParams: queryParams + body: bodyDictionary + headerParams: headerParams + completionHandler: ^(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) { + NIKWordListWord* d = [[NIKWordListWord alloc]initWithValues: dict]; + [objs addObject:d]; + } + completionBlock(objs, nil); + } + }]; + +} + +/** + * + * returnTypeIsPrimitive: true + * returnBaseType: + * returnContainer: + * + **/ +-(void) deleteWordsFromWordListWithCompletionBlock :(NSString*) permalink body:(NSArray*) body auth_token:(NSString*) auth_token + completionHandler:(void (^)(NSError *))completionBlock{ + + NSMutableString* requestUrl = [NSMutableString stringWithFormat:@"%@/wordList.{format}/{permalink}/deleteWords", 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:@"%@%@%@", @"{", @"permalink", @"}"]] withString: [_api escapeString:permalink]]; + NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init]; + NSMutableDictionary* headerParams = [[NSMutableDictionary alloc] init]; + if(auth_token != nil) + [headerParams setValue:auth_token forKey:@"auth_token"]; + id bodyDictionary = nil; + if(body != nil && [body isKindOfClass:[NSArray class]]){ + NSMutableArray * objs = [[NSMutableArray alloc] init]; + for (id dict in (NSArray*)body) { + if([dict respondsToSelector:@selector(asDictionary)]) { + [objs addObject:[(NIKSwaggerObject*)dict asDictionary]]; + } + else{ + [objs addObject:dict]; + } + } + bodyDictionary = objs; + } + else if([body respondsToSelector:@selector(asDictionary)]) { + bodyDictionary = [(NIKSwaggerObject*)body asDictionary]; + } + else if([body isKindOfClass:[NSString class]]) { + bodyDictionary = body; + } + else{ + NSLog(@"don't know what to do with %@", body); + } + + if(permalink == nil) { + // error + } + if(auth_token == nil) { + // error + } + // not a return container + [_api stringWithCompletionBlock: requestUrl + method: @"POST" + queryParams: queryParams + body: bodyDictionary + headerParams: headerParams + completionHandler: ^(NSString *data, NSError *error) { + if (error) { + completionBlock(error); + return; + } + completionBlock(nil); + }]; + +} + +-(void) updateWordListAsJsonWithCompletionBlock :(NSString*) permalink body:(NIKWordList*) body auth_token:(NSString*) auth_token + completionHandler:(void (^)(NSError *))completionBlock{ + + NSMutableString* requestUrl = [NSMutableString stringWithFormat:@"%@/wordList.{format}/{permalink}", basePath]; + + // remove format in URL if needed + if ([requestUrl rangeOfString:@".{format}"].location != NSNotFound) + [requestUrl replaceCharactersInRange: [requestUrl rangeOfString:@".{format}"] withString:@""]; + + [requestUrl replaceCharactersInRange: [requestUrl rangeOfString:[NSString stringWithFormat:@"%@%@%@", @"{", @"permalink", @"}"]] withString: [_api escapeString:permalink]]; + NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init]; + NSMutableDictionary* headerParams = [[NSMutableDictionary alloc] init]; + if(auth_token != nil) + [headerParams setValue:auth_token forKey:@"auth_token"]; + id bodyDictionary = nil; + if(body != nil && [body isKindOfClass:[NSArray class]]){ + NSMutableArray * objs = [[NSMutableArray alloc] init]; + for (id dict in (NSArray*)body) { + if([dict respondsToSelector:@selector(asDictionary)]) { + [objs addObject:[(NIKSwaggerObject*)dict asDictionary]]; + } + else{ + [objs addObject:dict]; + } + } + bodyDictionary = objs; + } + else if([body respondsToSelector:@selector(asDictionary)]) { + bodyDictionary = [(NIKSwaggerObject*)body asDictionary]; + } + else if([body isKindOfClass:[NSString class]]) { + bodyDictionary = body; + } + else{ + NSLog(@"don't know what to do with %@", body); + } + + if(permalink == nil) { + // error + } + if(auth_token == nil) { + // error + } + [_api dictionaryWithCompletionBlock: requestUrl + method: @"PUT" + queryParams: queryParams + body: bodyDictionary + headerParams: headerParams + completionHandler: ^(NSDictionary *data, NSError *error) { + if (error) { + completionBlock(error);return; + } + + completionBlock(nil); + }]; + +} + +-(void) deleteWordListAsJsonWithCompletionBlock :(NSString*) permalink auth_token:(NSString*) auth_token + completionHandler:(void (^)(NSError *))completionBlock{ + + NSMutableString* requestUrl = [NSMutableString stringWithFormat:@"%@/wordList.{format}/{permalink}", basePath]; + + // remove format in URL if needed + if ([requestUrl rangeOfString:@".{format}"].location != NSNotFound) + [requestUrl replaceCharactersInRange: [requestUrl rangeOfString:@".{format}"] withString:@""]; + + [requestUrl replaceCharactersInRange: [requestUrl rangeOfString:[NSString stringWithFormat:@"%@%@%@", @"{", @"permalink", @"}"]] withString: [_api escapeString:permalink]]; + NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init]; + NSMutableDictionary* headerParams = [[NSMutableDictionary alloc] init]; + if(auth_token != nil) + [headerParams setValue:auth_token forKey:@"auth_token"]; + id bodyDictionary = nil; + if(permalink == nil) { + // error + } + if(auth_token == nil) { + // error + } + [_api dictionaryWithCompletionBlock: requestUrl + method: @"DELETE" + queryParams: queryParams + body: bodyDictionary + headerParams: headerParams + completionHandler: ^(NSDictionary *data, NSError *error) { + if (error) { + completionBlock(error);return; + } + + completionBlock(nil); + }]; + +} + +-(void) getWordListByPermalinkAsJsonWithCompletionBlock :(NSString*) permalink auth_token:(NSString*) auth_token + completionHandler:(void (^)(NSString*, NSError *))completionBlock{ + + NSMutableString* requestUrl = [NSMutableString stringWithFormat:@"%@/wordList.{format}/{permalink}", basePath]; + + // remove format in URL if needed + if ([requestUrl rangeOfString:@".{format}"].location != NSNotFound) + [requestUrl replaceCharactersInRange: [requestUrl rangeOfString:@".{format}"] withString:@""]; + + [requestUrl replaceCharactersInRange: [requestUrl rangeOfString:[NSString stringWithFormat:@"%@%@%@", @"{", @"permalink", @"}"]] withString: [_api escapeString:permalink]]; + NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init]; + NSMutableDictionary* headerParams = [[NSMutableDictionary alloc] init]; + if(auth_token != nil) + [headerParams setValue:auth_token forKey:@"auth_token"]; + id bodyDictionary = nil; + if(permalink == nil) { + // error + } + if(auth_token == nil) { + // error + } + [_api dictionaryWithCompletionBlock: requestUrl + method: @"GET" + queryParams: queryParams + body: bodyDictionary + headerParams: headerParams + completionHandler: ^(NSDictionary *data, NSError *error) { + if (error) { + completionBlock(nil, error);return; + } + + NSData * responseData = nil; + if([data isKindOfClass:[NSDictionary class]]){ + responseData = [NSJSONSerialization dataWithJSONObject:data + options:kNilOptions error:&error]; + } + else if ([data isKindOfClass:[NSArray class]]){ + responseData = [NSJSONSerialization dataWithJSONObject:data + options:kNilOptions error:&error]; + } + NSString * json = [[NSString alloc]initWithData:responseData encoding:NSUTF8StringEncoding]; + completionBlock(json, nil); + + }]; + +} + +-(void) addWordsToWordListAsJsonWithCompletionBlock :(NSString*) permalink body:(NSArray*) body auth_token:(NSString*) auth_token + completionHandler:(void (^)(NSError *))completionBlock{ + + NSMutableString* requestUrl = [NSMutableString stringWithFormat:@"%@/wordList.{format}/{permalink}/words", basePath]; + + // remove format in URL if needed + if ([requestUrl rangeOfString:@".{format}"].location != NSNotFound) + [requestUrl replaceCharactersInRange: [requestUrl rangeOfString:@".{format}"] withString:@""]; + + [requestUrl replaceCharactersInRange: [requestUrl rangeOfString:[NSString stringWithFormat:@"%@%@%@", @"{", @"permalink", @"}"]] withString: [_api escapeString:permalink]]; + NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init]; + NSMutableDictionary* headerParams = [[NSMutableDictionary alloc] init]; + if(auth_token != nil) + [headerParams setValue:auth_token forKey:@"auth_token"]; + id bodyDictionary = nil; + if(body != nil && [body isKindOfClass:[NSArray class]]){ + NSMutableArray * objs = [[NSMutableArray alloc] init]; + for (id dict in (NSArray*)body) { + if([dict respondsToSelector:@selector(asDictionary)]) { + [objs addObject:[(NIKSwaggerObject*)dict asDictionary]]; + } + else{ + [objs addObject:dict]; + } + } + bodyDictionary = objs; + } + else if([body respondsToSelector:@selector(asDictionary)]) { + bodyDictionary = [(NIKSwaggerObject*)body asDictionary]; + } + else if([body isKindOfClass:[NSString class]]) { + bodyDictionary = body; + } + else{ + NSLog(@"don't know what to do with %@", body); + } + + if(permalink == nil) { + // error + } + if(auth_token == nil) { + // error + } + [_api dictionaryWithCompletionBlock: requestUrl + method: @"POST" + queryParams: queryParams + body: bodyDictionary + headerParams: headerParams + completionHandler: ^(NSDictionary *data, NSError *error) { + if (error) { + completionBlock(error);return; + } + + completionBlock(nil); + }]; + +} + +-(void) getWordListWordsAsJsonWithCompletionBlock :(NSString*) permalink auth_token:(NSString*) auth_token sortBy:(NSString*) sortBy sortOrder:(NSString*) sortOrder skip:(NSNumber*) skip limit:(NSNumber*) limit + completionHandler:(void (^)(NSString*, NSError *))completionBlock{ + + NSMutableString* requestUrl = [NSMutableString stringWithFormat:@"%@/wordList.{format}/{permalink}/words", basePath]; + + // remove format in URL if needed + if ([requestUrl rangeOfString:@".{format}"].location != NSNotFound) + [requestUrl replaceCharactersInRange: [requestUrl rangeOfString:@".{format}"] withString:@""]; + + [requestUrl replaceCharactersInRange: [requestUrl rangeOfString:[NSString stringWithFormat:@"%@%@%@", @"{", @"permalink", @"}"]] withString: [_api escapeString:permalink]]; + NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init]; + if(sortBy != nil) + [queryParams setValue:sortBy forKey:@"sortBy"]; + if(sortOrder != nil) + [queryParams setValue:sortOrder forKey:@"sortOrder"]; + if(skip != nil) + [queryParams setValue:skip forKey:@"skip"]; + if(limit != nil) + [queryParams setValue:limit forKey:@"limit"]; + NSMutableDictionary* headerParams = [[NSMutableDictionary alloc] init]; + if(auth_token != nil) + [headerParams setValue:auth_token forKey:@"auth_token"]; + id bodyDictionary = nil; + if(permalink == nil) { + // error + } + if(auth_token == nil) { + // error + } + [_api dictionaryWithCompletionBlock: requestUrl + method: @"GET" + queryParams: queryParams + body: bodyDictionary + headerParams: headerParams + completionHandler: ^(NSDictionary *data, NSError *error) { + if (error) { + completionBlock(nil, error);return; + } + + NSData * responseData = nil; + if([data isKindOfClass:[NSDictionary class]]){ + responseData = [NSJSONSerialization dataWithJSONObject:data + options:kNilOptions error:&error]; + } + else if ([data isKindOfClass:[NSArray class]]){ + responseData = [NSJSONSerialization dataWithJSONObject:data + options:kNilOptions error:&error]; + } + NSString * json = [[NSString alloc]initWithData:responseData encoding:NSUTF8StringEncoding]; + completionBlock(json, nil); + + }]; + +} + +-(void) deleteWordsFromWordListAsJsonWithCompletionBlock :(NSString*) permalink body:(NSArray*) body auth_token:(NSString*) auth_token + completionHandler:(void (^)(NSError *))completionBlock{ + + NSMutableString* requestUrl = [NSMutableString stringWithFormat:@"%@/wordList.{format}/{permalink}/deleteWords", basePath]; + + // remove format in URL if needed + if ([requestUrl rangeOfString:@".{format}"].location != NSNotFound) + [requestUrl replaceCharactersInRange: [requestUrl rangeOfString:@".{format}"] withString:@""]; + + [requestUrl replaceCharactersInRange: [requestUrl rangeOfString:[NSString stringWithFormat:@"%@%@%@", @"{", @"permalink", @"}"]] withString: [_api escapeString:permalink]]; + NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init]; + NSMutableDictionary* headerParams = [[NSMutableDictionary alloc] init]; + if(auth_token != nil) + [headerParams setValue:auth_token forKey:@"auth_token"]; + id bodyDictionary = nil; + if(body != nil && [body isKindOfClass:[NSArray class]]){ + NSMutableArray * objs = [[NSMutableArray alloc] init]; + for (id dict in (NSArray*)body) { + if([dict respondsToSelector:@selector(asDictionary)]) { + [objs addObject:[(NIKSwaggerObject*)dict asDictionary]]; + } + else{ + [objs addObject:dict]; + } + } + bodyDictionary = objs; + } + else if([body respondsToSelector:@selector(asDictionary)]) { + bodyDictionary = [(NIKSwaggerObject*)body asDictionary]; + } + else if([body isKindOfClass:[NSString class]]) { + bodyDictionary = body; + } + else{ + NSLog(@"don't know what to do with %@", body); + } + + if(permalink == nil) { + // error + } + if(auth_token == nil) { + // error + } + [_api dictionaryWithCompletionBlock: requestUrl + method: @"POST" + queryParams: queryParams + body: bodyDictionary + headerParams: headerParams + completionHandler: ^(NSDictionary *data, NSError *error) { + if (error) { + completionBlock(error);return; + } + + completionBlock(nil); + }]; + +} + + +@end diff --git a/samples/client/wordnik-api/objc/client/NIKWordListWord.h b/samples/client/wordnik-api/objc/client/NIKWordListWord.h new file mode 100644 index 00000000000..76446ab2503 --- /dev/null +++ b/samples/client/wordnik-api/objc/client/NIKWordListWord.h @@ -0,0 +1,38 @@ +#import +#import "NIKSwaggerObject.h" +#import "NIKDate.h" + +@interface NIKWordListWord : NIKSwaggerObject { +@private + NSNumber* __id; //NSNumber + NSString* _username; //NSString + NIKDate* _createdAt; //NIKDate + NSNumber* _userId; //NSNumber + NSNumber* _numberCommentsOnWord; //NSNumber + NSString* _word; //NSString + NSNumber* _numberLists; //NSNumber + } + + + +@property(nonatomic) NSNumber* _id; +@property(nonatomic) NSString* username; +@property(nonatomic) NIKDate* createdAt; +@property(nonatomic) NSNumber* userId; +@property(nonatomic) NSNumber* numberCommentsOnWord; +@property(nonatomic) NSString* word; +@property(nonatomic) NSNumber* numberLists; +- (id) _id: (NSNumber*) _id + username: (NSString*) username + createdAt: (NIKDate*) createdAt + userId: (NSNumber*) userId + numberCommentsOnWord: (NSNumber*) numberCommentsOnWord + word: (NSString*) word + numberLists: (NSNumber*) numberLists; + +- (id) initWithValues: (NSDictionary*)dict; +- (NSDictionary*) asDictionary; + + +@end + diff --git a/samples/client/wordnik-api/objc/client/NIKWordListWord.m b/samples/client/wordnik-api/objc/client/NIKWordListWord.m new file mode 100644 index 00000000000..9066a346a18 --- /dev/null +++ b/samples/client/wordnik-api/objc/client/NIKWordListWord.m @@ -0,0 +1,82 @@ +#import "NIKDate.h" +#import "NIKWordListWord.h" + +@implementation NIKWordListWord + +@synthesize _id = __id; +@synthesize username = _username; +@synthesize createdAt = _createdAt; +@synthesize userId = _userId; +@synthesize numberCommentsOnWord = _numberCommentsOnWord; +@synthesize word = _word; +@synthesize numberLists = _numberLists; +- (id) _id: (NSNumber*) _id + username: (NSString*) username + createdAt: (NIKDate*) createdAt + userId: (NSNumber*) userId + numberCommentsOnWord: (NSNumber*) numberCommentsOnWord + word: (NSString*) word + numberLists: (NSNumber*) numberLists + { + __id = _id; + _username = username; + _createdAt = createdAt; + _userId = userId; + _numberCommentsOnWord = numberCommentsOnWord; + _word = word; + _numberLists = numberLists; + return self; + } + +- (id) initWithValues: (NSDictionary*)dict +{ + /* isContainer: , baseType: NSNumber, complexType: */ + __id = [dict objectForKey:@"id"]; + /* isContainer: , baseType: NSString, complexType: */ + _username = [dict objectForKey:@"username"]; + /* isContainer: , baseType: NIKDate, complexType: NIKDate */ + id createdAt_dict = [dict objectForKey:@"createdAt"]; + _createdAt = [[NIKDate alloc]initWithValues:createdAt_dict]; + /* isContainer: , baseType: NSNumber, complexType: */ + _userId = [dict objectForKey:@"userId"]; + /* isContainer: , baseType: NSNumber, complexType: */ + _numberCommentsOnWord = [dict objectForKey:@"numberCommentsOnWord"]; + /* isContainer: , baseType: NSString, complexType: */ + _word = [dict objectForKey:@"word"]; + /* isContainer: , baseType: NSNumber, complexType: */ + _numberLists = [dict objectForKey:@"numberLists"]; + return self; +} + +-(NSDictionary*) asDictionary { + NSMutableDictionary* dict = [[NSMutableDictionary alloc] init]; + if(__id != nil) [dict setObject:__id forKey:@"id"]; + if(_username != nil) [dict setObject:_username forKey:@"username"]; + if(_createdAt != nil){ + if([_createdAt isKindOfClass:[NSArray class]]){ + NSMutableArray * array = [[NSMutableArray alloc] init]; + for( NIKDate * createdAt in (NSArray*)_createdAt) { + [array addObject:[(NIKSwaggerObject*)createdAt asDictionary]]; + } + [dict setObject:array forKey:@"createdAt"]; + } + else if(_createdAt && [_createdAt isKindOfClass:[NIKDate class]]) { + NSString * dateString = [(NIKDate*)_createdAt toString]; + if(dateString){ + [dict setObject:dateString forKey:@"createdAt"]; + } + } + } + else { + if(_createdAt != nil) [dict setObject:[(NIKSwaggerObject*)_createdAt asDictionary]forKey:@"createdAt"]; + } + if(_userId != nil) [dict setObject:_userId forKey:@"userId"]; + if(_numberCommentsOnWord != nil) [dict setObject:_numberCommentsOnWord forKey:@"numberCommentsOnWord"]; + if(_word != nil) [dict setObject:_word forKey:@"word"]; + if(_numberLists != nil) [dict setObject:_numberLists forKey:@"numberLists"]; + NSDictionary* output = [dict copy]; + return output; +} + +@end + diff --git a/samples/client/wordnik-api/objc/client/NIKWordListsApi.h b/samples/client/wordnik-api/objc/client/NIKWordListsApi.h new file mode 100644 index 00000000000..ad2db126592 --- /dev/null +++ b/samples/client/wordnik-api/objc/client/NIKWordListsApi.h @@ -0,0 +1,20 @@ +#import +#import "NIKApiInvoker.h" +#import "NIKWordList.h" + + +@interface NIKWordListsApi: NSObject { + +@private + NSOperationQueue *_queue; + NIKApiInvoker * _api; +} +@property(nonatomic, readonly) NSOperationQueue* queue; +@property(nonatomic, readonly) NIKApiInvoker* api; + +-(void) addHeader:(NSString*) value + forKey:(NSString*)key; + +-(void) createWordListWithCompletionBlock :(NIKWordList*) body auth_token:(NSString*) auth_token + completionHandler:(void (^)(NIKWordList*, NSError *))completionBlock; +@end diff --git a/samples/client/wordnik-api/objc/client/NIKWordListsApi.m b/samples/client/wordnik-api/objc/client/NIKWordListsApi.m new file mode 100644 index 00000000000..9d72214e945 --- /dev/null +++ b/samples/client/wordnik-api/objc/client/NIKWordListsApi.m @@ -0,0 +1,152 @@ +#import "NIKWordListsApi.h" +#import "NIKWordList.h" + + + +@implementation NIKWordListsApi +static NSString * basePath = @"http://api.wordnik.com/v4"; + +@synthesize queue = _queue; +@synthesize api = _api; + +- (id) init { + self = [super init]; + _queue = [[NSOperationQueue alloc] init]; + _api = [[NIKApiInvoker alloc] init]; + + return self; +} + +-(void) addHeader:(NSString*) value + forKey:(NSString*)key { + [_api addHeader:value forKey:key]; +} + +/** + * + * returnTypeIsPrimitive: + * returnBaseType: NIKWordList + * returnContainer: + * + **/ +-(void) createWordListWithCompletionBlock :(NIKWordList*) body auth_token:(NSString*) auth_token + completionHandler:(void (^)(NIKWordList*, NSError *))completionBlock{ + + NSMutableString* requestUrl = [NSMutableString stringWithFormat:@"%@/wordLists.{format}", basePath]; + + // remove format in URL if needed + if ([requestUrl rangeOfString:@".{format}"].location != NSNotFound) + [requestUrl replaceCharactersInRange: [requestUrl rangeOfString:@".{format}"] withString:@".json"]; + + NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init]; + NSMutableDictionary* headerParams = [[NSMutableDictionary alloc] init]; + if(auth_token != nil) + [headerParams setValue:auth_token forKey:@"auth_token"]; + id bodyDictionary = nil; + if(body != nil && [body isKindOfClass:[NSArray class]]){ + NSMutableArray * objs = [[NSMutableArray alloc] init]; + for (id dict in (NSArray*)body) { + if([dict respondsToSelector:@selector(asDictionary)]) { + [objs addObject:[(NIKSwaggerObject*)dict asDictionary]]; + } + else{ + [objs addObject:dict]; + } + } + bodyDictionary = objs; + } + else if([body respondsToSelector:@selector(asDictionary)]) { + bodyDictionary = [(NIKSwaggerObject*)body asDictionary]; + } + else if([body isKindOfClass:[NSString class]]) { + bodyDictionary = body; + } + else{ + NSLog(@"don't know what to do with %@", body); + } + + if(auth_token == nil) { + // error + } + // not a return container + [_api dictionaryWithCompletionBlock: requestUrl + method: @"POST" + queryParams: queryParams + body: bodyDictionary + headerParams: headerParams + completionHandler: ^(NSDictionary *data, NSError *error) { + if (error) { + completionBlock(nil, error);return; + } + + completionBlock( [[NIKWordList alloc]initWithValues: data], nil);}]; + +} + +-(void) createWordListAsJsonWithCompletionBlock :(NIKWordList*) body auth_token:(NSString*) auth_token + completionHandler:(void (^)(NSString*, NSError *))completionBlock{ + + NSMutableString* requestUrl = [NSMutableString stringWithFormat:@"%@/wordLists.{format}", basePath]; + + // remove format in URL if needed + if ([requestUrl rangeOfString:@".{format}"].location != NSNotFound) + [requestUrl replaceCharactersInRange: [requestUrl rangeOfString:@".{format}"] withString:@""]; + + NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init]; + NSMutableDictionary* headerParams = [[NSMutableDictionary alloc] init]; + if(auth_token != nil) + [headerParams setValue:auth_token forKey:@"auth_token"]; + id bodyDictionary = nil; + if(body != nil && [body isKindOfClass:[NSArray class]]){ + NSMutableArray * objs = [[NSMutableArray alloc] init]; + for (id dict in (NSArray*)body) { + if([dict respondsToSelector:@selector(asDictionary)]) { + [objs addObject:[(NIKSwaggerObject*)dict asDictionary]]; + } + else{ + [objs addObject:dict]; + } + } + bodyDictionary = objs; + } + else if([body respondsToSelector:@selector(asDictionary)]) { + bodyDictionary = [(NIKSwaggerObject*)body asDictionary]; + } + else if([body isKindOfClass:[NSString class]]) { + bodyDictionary = body; + } + else{ + NSLog(@"don't know what to do with %@", body); + } + + if(auth_token == nil) { + // error + } + [_api dictionaryWithCompletionBlock: requestUrl + method: @"POST" + queryParams: queryParams + body: bodyDictionary + headerParams: headerParams + completionHandler: ^(NSDictionary *data, NSError *error) { + if (error) { + completionBlock(nil, error);return; + } + + NSData * responseData = nil; + if([data isKindOfClass:[NSDictionary class]]){ + responseData = [NSJSONSerialization dataWithJSONObject:data + options:kNilOptions error:&error]; + } + else if ([data isKindOfClass:[NSArray class]]){ + responseData = [NSJSONSerialization dataWithJSONObject:data + options:kNilOptions error:&error]; + } + NSString * json = [[NSString alloc]initWithData:responseData encoding:NSUTF8StringEncoding]; + completionBlock(json, nil); + + }]; + +} + + +@end diff --git a/samples/client/wordnik-api/objc/client/NIKWordObject.h b/samples/client/wordnik-api/objc/client/NIKWordObject.h new file mode 100644 index 00000000000..8f81c0644bf --- /dev/null +++ b/samples/client/wordnik-api/objc/client/NIKWordObject.h @@ -0,0 +1,34 @@ +#import +#import "NIKSwaggerObject.h" + +@interface NIKWordObject : NIKSwaggerObject { +@private + NSNumber* __id; //NSNumber + NSString* _originalWord; //NSString + NSString* _word; //NSString + NSArray* _suggestions; //NSString + NSString* _canonicalForm; //NSString + NSString* _vulgar; //NSString + } + + + +@property(nonatomic) NSNumber* _id; +@property(nonatomic) NSString* originalWord; +@property(nonatomic) NSString* word; +@property(nonatomic) NSArray* suggestions; +@property(nonatomic) NSString* canonicalForm; +@property(nonatomic) NSString* vulgar; +- (id) _id: (NSNumber*) _id + originalWord: (NSString*) originalWord + word: (NSString*) word + suggestions: (NSArray*) suggestions + canonicalForm: (NSString*) canonicalForm + vulgar: (NSString*) vulgar; + +- (id) initWithValues: (NSDictionary*)dict; +- (NSDictionary*) asDictionary; + + +@end + diff --git a/samples/client/wordnik-api/objc/client/NIKWordObject.m b/samples/client/wordnik-api/objc/client/NIKWordObject.m new file mode 100644 index 00000000000..2f69e842012 --- /dev/null +++ b/samples/client/wordnik-api/objc/client/NIKWordObject.m @@ -0,0 +1,58 @@ +#import "NIKDate.h" +#import "NIKWordObject.h" + +@implementation NIKWordObject + +@synthesize _id = __id; +@synthesize originalWord = _originalWord; +@synthesize word = _word; +@synthesize suggestions = _suggestions; +@synthesize canonicalForm = _canonicalForm; +@synthesize vulgar = _vulgar; +- (id) _id: (NSNumber*) _id + originalWord: (NSString*) originalWord + word: (NSString*) word + suggestions: (NSArray*) suggestions + canonicalForm: (NSString*) canonicalForm + vulgar: (NSString*) vulgar + { + __id = _id; + _originalWord = originalWord; + _word = word; + _suggestions = suggestions; + _canonicalForm = canonicalForm; + _vulgar = vulgar; + return self; + } + +- (id) initWithValues: (NSDictionary*)dict +{ + /* isContainer: , baseType: NSNumber, complexType: */ + __id = [dict objectForKey:@"id"]; + /* isContainer: , baseType: NSString, complexType: */ + _originalWord = [dict objectForKey:@"originalWord"]; + /* isContainer: , baseType: NSString, complexType: */ + _word = [dict objectForKey:@"word"]; + /* isContainer: true, baseType: NSString, complexType: */ + _suggestions = [dict objectForKey:@"suggestions"]; + /* isContainer: , baseType: NSString, complexType: */ + _canonicalForm = [dict objectForKey:@"canonicalForm"]; + /* isContainer: , baseType: NSString, complexType: */ + _vulgar = [dict objectForKey:@"vulgar"]; + return self; +} + +-(NSDictionary*) asDictionary { + NSMutableDictionary* dict = [[NSMutableDictionary alloc] init]; + if(__id != nil) [dict setObject:__id forKey:@"id"]; + if(_originalWord != nil) [dict setObject:_originalWord forKey:@"originalWord"]; + if(_word != nil) [dict setObject:_word forKey:@"word"]; + if(_suggestions != nil) [dict setObject:_suggestions forKey:@"suggestions"]; + if(_canonicalForm != nil) [dict setObject:_canonicalForm forKey:@"canonicalForm"]; + if(_vulgar != nil) [dict setObject:_vulgar forKey:@"vulgar"]; + NSDictionary* output = [dict copy]; + return output; +} + +@end + diff --git a/samples/client/wordnik-api/objc/client/NIKWordOfTheDay.h b/samples/client/wordnik-api/objc/client/NIKWordOfTheDay.h new file mode 100644 index 00000000000..267ecf81fee --- /dev/null +++ b/samples/client/wordnik-api/objc/client/NIKWordOfTheDay.h @@ -0,0 +1,56 @@ +#import +#import "NIKSwaggerObject.h" +#import "NIKDate.h" +#import "NIKSimpleDefinition.h" +#import "NIKSimpleExample.h" +#import "NIKContentProvider.h" + +@interface NIKWordOfTheDay : NIKSwaggerObject { +@private + NSNumber* __id; //NSNumber + NSString* _parentId; //NSString + NSString* _category; //NSString + NSString* _createdBy; //NSString + NIKDate* _createdAt; //NIKDate + NIKContentProvider* _contentProvider; //ContentProvider + NSString* _word; //NSString + NSString* _htmlExtra; //NSString + NSArray* _definitions; //SimpleDefinition + NSArray* _examples; //SimpleExample + NIKDate* _publishDate; //NIKDate + NSString* _note; //NSString + } + + + +@property(nonatomic) NSNumber* _id; +@property(nonatomic) NSString* parentId; +@property(nonatomic) NSString* category; +@property(nonatomic) NSString* createdBy; +@property(nonatomic) NIKDate* createdAt; +@property(nonatomic) NIKContentProvider* contentProvider; +@property(nonatomic) NSString* word; +@property(nonatomic) NSString* htmlExtra; +@property(nonatomic) NSArray* definitions; +@property(nonatomic) NSArray* examples; +@property(nonatomic) NIKDate* publishDate; +@property(nonatomic) NSString* note; +- (id) _id: (NSNumber*) _id + parentId: (NSString*) parentId + category: (NSString*) category + createdBy: (NSString*) createdBy + createdAt: (NIKDate*) createdAt + contentProvider: (NIKContentProvider*) contentProvider + word: (NSString*) word + htmlExtra: (NSString*) htmlExtra + definitions: (NSArray*) definitions + examples: (NSArray*) examples + publishDate: (NIKDate*) publishDate + note: (NSString*) note; + +- (id) initWithValues: (NSDictionary*)dict; +- (NSDictionary*) asDictionary; + + +@end + diff --git a/samples/client/wordnik-api/objc/client/NIKWordOfTheDay.m b/samples/client/wordnik-api/objc/client/NIKWordOfTheDay.m new file mode 100644 index 00000000000..ed89ac23abd --- /dev/null +++ b/samples/client/wordnik-api/objc/client/NIKWordOfTheDay.m @@ -0,0 +1,202 @@ +#import "NIKDate.h" +#import "NIKWordOfTheDay.h" + +@implementation NIKWordOfTheDay + +@synthesize _id = __id; +@synthesize parentId = _parentId; +@synthesize category = _category; +@synthesize createdBy = _createdBy; +@synthesize createdAt = _createdAt; +@synthesize contentProvider = _contentProvider; +@synthesize word = _word; +@synthesize htmlExtra = _htmlExtra; +@synthesize definitions = _definitions; +@synthesize examples = _examples; +@synthesize publishDate = _publishDate; +@synthesize note = _note; +- (id) _id: (NSNumber*) _id + parentId: (NSString*) parentId + category: (NSString*) category + createdBy: (NSString*) createdBy + createdAt: (NIKDate*) createdAt + contentProvider: (NIKContentProvider*) contentProvider + word: (NSString*) word + htmlExtra: (NSString*) htmlExtra + definitions: (NSArray*) definitions + examples: (NSArray*) examples + publishDate: (NIKDate*) publishDate + note: (NSString*) note + { + __id = _id; + _parentId = parentId; + _category = category; + _createdBy = createdBy; + _createdAt = createdAt; + _contentProvider = contentProvider; + _word = word; + _htmlExtra = htmlExtra; + _definitions = definitions; + _examples = examples; + _publishDate = publishDate; + _note = note; + return self; + } + +- (id) initWithValues: (NSDictionary*)dict +{ + /* isContainer: , baseType: NSNumber, complexType: */ + __id = [dict objectForKey:@"id"]; + /* isContainer: , baseType: NSString, complexType: */ + _parentId = [dict objectForKey:@"parentId"]; + /* isContainer: , baseType: NSString, complexType: */ + _category = [dict objectForKey:@"category"]; + /* isContainer: , baseType: NSString, complexType: */ + _createdBy = [dict objectForKey:@"createdBy"]; + /* isContainer: , baseType: NIKDate, complexType: NIKDate */ + id createdAt_dict = [dict objectForKey:@"createdAt"]; + _createdAt = [[NIKDate alloc]initWithValues:createdAt_dict]; + /* isContainer: , baseType: ContentProvider, complexType: NIKContentProvider */ + id contentProvider_dict = [dict objectForKey:@"contentProvider"]; + _contentProvider = [[NIKContentProvider alloc]initWithValues:contentProvider_dict]; + /* isContainer: , baseType: NSString, complexType: */ + _word = [dict objectForKey:@"word"]; + /* isContainer: , baseType: NSString, complexType: */ + _htmlExtra = [dict objectForKey:@"htmlExtra"]; + /* isContainer: true, baseType: SimpleDefinition, complexType: NIKSimpleDefinition */ + id definitions_dict = [dict objectForKey:@"definitions"]; + if([definitions_dict isKindOfClass:[NSArray class]]) { + if([(NSArray*)definitions_dict count] > 0) { + NSMutableArray * objs = [[NSMutableArray alloc] initWithCapacity:[(NSArray*)definitions_dict count]]; + for (NSDictionary* dict in (NSArray*)definitions_dict) { + NIKSimpleDefinition* d = [[NIKSimpleDefinition alloc]initWithValues:dict]; + [objs addObject:d]; + } + _definitions = [[NSArray alloc] initWithArray:objs]; + } + } + /* isContainer: true, baseType: SimpleExample, complexType: NIKSimpleExample */ + id examples_dict = [dict objectForKey:@"examples"]; + if([examples_dict isKindOfClass:[NSArray class]]) { + if([(NSArray*)examples_dict count] > 0) { + NSMutableArray * objs = [[NSMutableArray alloc] initWithCapacity:[(NSArray*)examples_dict count]]; + for (NSDictionary* dict in (NSArray*)examples_dict) { + NIKSimpleExample* d = [[NIKSimpleExample alloc]initWithValues:dict]; + [objs addObject:d]; + } + _examples = [[NSArray alloc] initWithArray:objs]; + } + } + /* isContainer: , baseType: NIKDate, complexType: NIKDate */ + id publishDate_dict = [dict objectForKey:@"publishDate"]; + _publishDate = [[NIKDate alloc]initWithValues:publishDate_dict]; + /* isContainer: , baseType: NSString, complexType: */ + _note = [dict objectForKey:@"note"]; + return self; +} + +-(NSDictionary*) asDictionary { + NSMutableDictionary* dict = [[NSMutableDictionary alloc] init]; + if(__id != nil) [dict setObject:__id forKey:@"id"]; + if(_parentId != nil) [dict setObject:_parentId forKey:@"parentId"]; + if(_category != nil) [dict setObject:_category forKey:@"category"]; + if(_createdBy != nil) [dict setObject:_createdBy forKey:@"createdBy"]; + if(_createdAt != nil){ + if([_createdAt isKindOfClass:[NSArray class]]){ + NSMutableArray * array = [[NSMutableArray alloc] init]; + for( NIKDate * createdAt in (NSArray*)_createdAt) { + [array addObject:[(NIKSwaggerObject*)createdAt asDictionary]]; + } + [dict setObject:array forKey:@"createdAt"]; + } + else if(_createdAt && [_createdAt isKindOfClass:[NIKDate class]]) { + NSString * dateString = [(NIKDate*)_createdAt toString]; + if(dateString){ + [dict setObject:dateString forKey:@"createdAt"]; + } + } + } + else { + if(_createdAt != nil) [dict setObject:[(NIKSwaggerObject*)_createdAt asDictionary]forKey:@"createdAt"]; + } + if(_contentProvider != nil){ + if([_contentProvider isKindOfClass:[NSArray class]]){ + NSMutableArray * array = [[NSMutableArray alloc] init]; + for( NIKContentProvider * contentProvider in (NSArray*)_contentProvider) { + [array addObject:[(NIKSwaggerObject*)contentProvider asDictionary]]; + } + [dict setObject:array forKey:@"contentProvider"]; + } + else if(_contentProvider && [_contentProvider isKindOfClass:[NIKDate class]]) { + NSString * dateString = [(NIKDate*)_contentProvider toString]; + if(dateString){ + [dict setObject:dateString forKey:@"contentProvider"]; + } + } + } + else { + if(_contentProvider != nil) [dict setObject:[(NIKSwaggerObject*)_contentProvider asDictionary]forKey:@"contentProvider"]; + } + if(_word != nil) [dict setObject:_word forKey:@"word"]; + if(_htmlExtra != nil) [dict setObject:_htmlExtra forKey:@"htmlExtra"]; + if(_definitions != nil){ + if([_definitions isKindOfClass:[NSArray class]]){ + NSMutableArray * array = [[NSMutableArray alloc] init]; + for( NIKSimpleDefinition * definitions in (NSArray*)_definitions) { + [array addObject:[(NIKSwaggerObject*)definitions asDictionary]]; + } + [dict setObject:array forKey:@"definitions"]; + } + else if(_definitions && [_definitions isKindOfClass:[NIKDate class]]) { + NSString * dateString = [(NIKDate*)_definitions toString]; + if(dateString){ + [dict setObject:dateString forKey:@"definitions"]; + } + } + } + else { + if(_definitions != nil) [dict setObject:[(NIKSwaggerObject*)_definitions asDictionary]forKey:@"definitions"]; + } + if(_examples != nil){ + if([_examples isKindOfClass:[NSArray class]]){ + NSMutableArray * array = [[NSMutableArray alloc] init]; + for( NIKSimpleExample * examples in (NSArray*)_examples) { + [array addObject:[(NIKSwaggerObject*)examples asDictionary]]; + } + [dict setObject:array forKey:@"examples"]; + } + else if(_examples && [_examples isKindOfClass:[NIKDate class]]) { + NSString * dateString = [(NIKDate*)_examples toString]; + if(dateString){ + [dict setObject:dateString forKey:@"examples"]; + } + } + } + else { + if(_examples != nil) [dict setObject:[(NIKSwaggerObject*)_examples asDictionary]forKey:@"examples"]; + } + if(_publishDate != nil){ + if([_publishDate isKindOfClass:[NSArray class]]){ + NSMutableArray * array = [[NSMutableArray alloc] init]; + for( NIKDate * publishDate in (NSArray*)_publishDate) { + [array addObject:[(NIKSwaggerObject*)publishDate asDictionary]]; + } + [dict setObject:array forKey:@"publishDate"]; + } + else if(_publishDate && [_publishDate isKindOfClass:[NIKDate class]]) { + NSString * dateString = [(NIKDate*)_publishDate toString]; + if(dateString){ + [dict setObject:dateString forKey:@"publishDate"]; + } + } + } + else { + if(_publishDate != nil) [dict setObject:[(NIKSwaggerObject*)_publishDate asDictionary]forKey:@"publishDate"]; + } + if(_note != nil) [dict setObject:_note forKey:@"note"]; + NSDictionary* output = [dict copy]; + return output; +} + +@end + diff --git a/samples/client/wordnik-api/objc/client/NIKWordSearchResult.h b/samples/client/wordnik-api/objc/client/NIKWordSearchResult.h new file mode 100644 index 00000000000..e81683ec764 --- /dev/null +++ b/samples/client/wordnik-api/objc/client/NIKWordSearchResult.h @@ -0,0 +1,25 @@ +#import +#import "NIKSwaggerObject.h" + +@interface NIKWordSearchResult : NIKSwaggerObject { +@private + NSNumber* _count; //NSNumber + NSNumber* _lexicality; //NSNumber + NSString* _word; //NSString + } + + + +@property(nonatomic) NSNumber* count; +@property(nonatomic) NSNumber* lexicality; +@property(nonatomic) NSString* word; +- (id) count: (NSNumber*) count + lexicality: (NSNumber*) lexicality + word: (NSString*) word; + +- (id) initWithValues: (NSDictionary*)dict; +- (NSDictionary*) asDictionary; + + +@end + diff --git a/samples/client/wordnik-api/objc/client/NIKWordSearchResult.m b/samples/client/wordnik-api/objc/client/NIKWordSearchResult.m new file mode 100644 index 00000000000..8624302a12b --- /dev/null +++ b/samples/client/wordnik-api/objc/client/NIKWordSearchResult.m @@ -0,0 +1,40 @@ +#import "NIKDate.h" +#import "NIKWordSearchResult.h" + +@implementation NIKWordSearchResult + +@synthesize count = _count; +@synthesize lexicality = _lexicality; +@synthesize word = _word; +- (id) count: (NSNumber*) count + lexicality: (NSNumber*) lexicality + word: (NSString*) word + { + _count = count; + _lexicality = lexicality; + _word = word; + return self; + } + +- (id) initWithValues: (NSDictionary*)dict +{ + /* isContainer: , baseType: NSNumber, complexType: */ + _count = [dict objectForKey:@"count"]; + /* isContainer: , baseType: NSNumber, complexType: */ + _lexicality = [dict objectForKey:@"lexicality"]; + /* isContainer: , baseType: NSString, complexType: */ + _word = [dict objectForKey:@"word"]; + return self; +} + +-(NSDictionary*) asDictionary { + NSMutableDictionary* dict = [[NSMutableDictionary alloc] init]; + if(_count != nil) [dict setObject:_count forKey:@"count"]; + if(_lexicality != nil) [dict setObject:_lexicality forKey:@"lexicality"]; + if(_word != nil) [dict setObject:_word forKey:@"word"]; + NSDictionary* output = [dict copy]; + return output; +} + +@end + diff --git a/samples/client/wordnik-api/objc/client/NIKWordSearchResults.h b/samples/client/wordnik-api/objc/client/NIKWordSearchResults.h new file mode 100644 index 00000000000..f3cce1fd21c --- /dev/null +++ b/samples/client/wordnik-api/objc/client/NIKWordSearchResults.h @@ -0,0 +1,23 @@ +#import +#import "NIKSwaggerObject.h" +#import "NIKWordSearchResult.h" + +@interface NIKWordSearchResults : NIKSwaggerObject { +@private + NSNumber* _totalResults; //NSNumber + NSArray* _searchResults; //WordSearchResult + } + + + +@property(nonatomic) NSNumber* totalResults; +@property(nonatomic) NSArray* searchResults; +- (id) totalResults: (NSNumber*) totalResults + searchResults: (NSArray*) searchResults; + +- (id) initWithValues: (NSDictionary*)dict; +- (NSDictionary*) asDictionary; + + +@end + diff --git a/samples/client/wordnik-api/objc/client/NIKWordSearchResults.m b/samples/client/wordnik-api/objc/client/NIKWordSearchResults.m new file mode 100644 index 00000000000..5ac81b926b3 --- /dev/null +++ b/samples/client/wordnik-api/objc/client/NIKWordSearchResults.m @@ -0,0 +1,61 @@ +#import "NIKDate.h" +#import "NIKWordSearchResults.h" + +@implementation NIKWordSearchResults + +@synthesize totalResults = _totalResults; +@synthesize searchResults = _searchResults; +- (id) totalResults: (NSNumber*) totalResults + searchResults: (NSArray*) searchResults + { + _totalResults = totalResults; + _searchResults = searchResults; + return self; + } + +- (id) initWithValues: (NSDictionary*)dict +{ + /* isContainer: , baseType: NSNumber, complexType: */ + _totalResults = [dict objectForKey:@"totalResults"]; + /* isContainer: true, baseType: WordSearchResult, complexType: NIKWordSearchResult */ + id searchResults_dict = [dict objectForKey:@"searchResults"]; + if([searchResults_dict isKindOfClass:[NSArray class]]) { + if([(NSArray*)searchResults_dict count] > 0) { + NSMutableArray * objs = [[NSMutableArray alloc] initWithCapacity:[(NSArray*)searchResults_dict count]]; + for (NSDictionary* dict in (NSArray*)searchResults_dict) { + NIKWordSearchResult* d = [[NIKWordSearchResult alloc]initWithValues:dict]; + [objs addObject:d]; + } + _searchResults = [[NSArray alloc] initWithArray:objs]; + } + } + return self; +} + +-(NSDictionary*) asDictionary { + NSMutableDictionary* dict = [[NSMutableDictionary alloc] init]; + if(_totalResults != nil) [dict setObject:_totalResults forKey:@"totalResults"]; + if(_searchResults != nil){ + if([_searchResults isKindOfClass:[NSArray class]]){ + NSMutableArray * array = [[NSMutableArray alloc] init]; + for( NIKWordSearchResult * searchResults in (NSArray*)_searchResults) { + [array addObject:[(NIKSwaggerObject*)searchResults asDictionary]]; + } + [dict setObject:array forKey:@"searchResults"]; + } + else if(_searchResults && [_searchResults isKindOfClass:[NIKDate class]]) { + NSString * dateString = [(NIKDate*)_searchResults toString]; + if(dateString){ + [dict setObject:dateString forKey:@"searchResults"]; + } + } + } + else { + if(_searchResults != nil) [dict setObject:[(NIKSwaggerObject*)_searchResults asDictionary]forKey:@"searchResults"]; + } + NSDictionary* output = [dict copy]; + return output; +} + +@end + diff --git a/samples/client/wordnik-api/objc/client/NIKWordsApi.h b/samples/client/wordnik-api/objc/client/NIKWordsApi.h new file mode 100644 index 00000000000..d87182c8bf5 --- /dev/null +++ b/samples/client/wordnik-api/objc/client/NIKWordsApi.h @@ -0,0 +1,31 @@ +#import +#import "NIKApiInvoker.h" +#import "NIKWordObject.h" +#import "NIKDefinitionSearchResults.h" +#import "NIKWordOfTheDay.h" +#import "NIKWordSearchResults.h" + + +@interface NIKWordsApi: NSObject { + +@private + NSOperationQueue *_queue; + NIKApiInvoker * _api; +} +@property(nonatomic, readonly) NSOperationQueue* queue; +@property(nonatomic, readonly) NIKApiInvoker* api; + +-(void) addHeader:(NSString*) value + forKey:(NSString*)key; + +-(void) searchWordsWithCompletionBlock :(NSString*) query includePartOfSpeech:(NSString*) includePartOfSpeech excludePartOfSpeech:(NSString*) excludePartOfSpeech caseSensitive:(NSString*) caseSensitive minCorpusCount:(NSNumber*) minCorpusCount maxCorpusCount:(NSNumber*) maxCorpusCount minDictionaryCount:(NSNumber*) minDictionaryCount maxDictionaryCount:(NSNumber*) maxDictionaryCount minLength:(NSNumber*) minLength maxLength:(NSNumber*) maxLength skip:(NSNumber*) skip limit:(NSNumber*) limit + completionHandler:(void (^)(NIKWordSearchResults*, NSError *))completionBlock; +-(void) getWordOfTheDayWithCompletionBlock :(NSString*) date + completionHandler:(void (^)(NIKWordOfTheDay*, NSError *))completionBlock; +-(void) reverseDictionaryWithCompletionBlock :(NSString*) query findSenseForWord:(NSString*) findSenseForWord includeSourceDictionaries:(NSString*) includeSourceDictionaries excludeSourceDictionaries:(NSString*) excludeSourceDictionaries includePartOfSpeech:(NSString*) includePartOfSpeech excludePartOfSpeech:(NSString*) excludePartOfSpeech expandTerms:(NSString*) expandTerms sortBy:(NSString*) sortBy sortOrder:(NSString*) sortOrder minCorpusCount:(NSNumber*) minCorpusCount maxCorpusCount:(NSNumber*) maxCorpusCount minLength:(NSNumber*) minLength maxLength:(NSNumber*) maxLength includeTags:(NSString*) includeTags skip:(NSString*) skip limit:(NSNumber*) limit + completionHandler:(void (^)(NIKDefinitionSearchResults*, NSError *))completionBlock; +-(void) getRandomWordsWithCompletionBlock :(NSString*) includePartOfSpeech excludePartOfSpeech:(NSString*) excludePartOfSpeech sortBy:(NSString*) sortBy sortOrder:(NSString*) sortOrder hasDictionaryDef:(NSString*) hasDictionaryDef minCorpusCount:(NSNumber*) minCorpusCount maxCorpusCount:(NSNumber*) maxCorpusCount minDictionaryCount:(NSNumber*) minDictionaryCount maxDictionaryCount:(NSNumber*) maxDictionaryCount minLength:(NSNumber*) minLength maxLength:(NSNumber*) maxLength limit:(NSNumber*) limit + completionHandler:(void (^)(NSArray*, NSError *))completionBlock; +-(void) getRandomWordWithCompletionBlock :(NSString*) includePartOfSpeech excludePartOfSpeech:(NSString*) excludePartOfSpeech hasDictionaryDef:(NSString*) hasDictionaryDef minCorpusCount:(NSNumber*) minCorpusCount maxCorpusCount:(NSNumber*) maxCorpusCount minDictionaryCount:(NSNumber*) minDictionaryCount maxDictionaryCount:(NSNumber*) maxDictionaryCount minLength:(NSNumber*) minLength maxLength:(NSNumber*) maxLength + completionHandler:(void (^)(NIKWordObject*, NSError *))completionBlock; +@end diff --git a/samples/client/wordnik-api/objc/client/NIKWordsApi.m b/samples/client/wordnik-api/objc/client/NIKWordsApi.m new file mode 100644 index 00000000000..ed3057d1b5d --- /dev/null +++ b/samples/client/wordnik-api/objc/client/NIKWordsApi.m @@ -0,0 +1,607 @@ +#import "NIKWordsApi.h" +#import "NIKWordObject.h" +#import "NIKDefinitionSearchResults.h" +#import "NIKWordOfTheDay.h" +#import "NIKWordSearchResults.h" + + + +@implementation NIKWordsApi +static NSString * basePath = @"http://api.wordnik.com/v4"; + +@synthesize queue = _queue; +@synthesize api = _api; + +- (id) init { + self = [super init]; + _queue = [[NSOperationQueue alloc] init]; + _api = [[NIKApiInvoker alloc] init]; + + return self; +} + +-(void) addHeader:(NSString*) value + forKey:(NSString*)key { + [_api addHeader:value forKey:key]; +} + +/** + * + * returnTypeIsPrimitive: + * returnBaseType: NIKWordSearchResults + * returnContainer: + * + **/ +-(void) searchWordsWithCompletionBlock :(NSString*) query includePartOfSpeech:(NSString*) includePartOfSpeech excludePartOfSpeech:(NSString*) excludePartOfSpeech caseSensitive:(NSString*) caseSensitive minCorpusCount:(NSNumber*) minCorpusCount maxCorpusCount:(NSNumber*) maxCorpusCount minDictionaryCount:(NSNumber*) minDictionaryCount maxDictionaryCount:(NSNumber*) maxDictionaryCount minLength:(NSNumber*) minLength maxLength:(NSNumber*) maxLength skip:(NSNumber*) skip limit:(NSNumber*) limit + completionHandler:(void (^)(NIKWordSearchResults*, NSError *))completionBlock{ + + NSMutableString* requestUrl = [NSMutableString stringWithFormat:@"%@/words.{format}/search/{query}", 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:@"%@%@%@", @"{", @"query", @"}"]] withString: [_api escapeString:query]]; + NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init]; + if(caseSensitive != nil) + [queryParams setValue:caseSensitive forKey:@"caseSensitive"]; + if(includePartOfSpeech != nil) + [queryParams setValue:includePartOfSpeech forKey:@"includePartOfSpeech"]; + if(excludePartOfSpeech != nil) + [queryParams setValue:excludePartOfSpeech forKey:@"excludePartOfSpeech"]; + if(minCorpusCount != nil) + [queryParams setValue:minCorpusCount forKey:@"minCorpusCount"]; + if(maxCorpusCount != nil) + [queryParams setValue:maxCorpusCount forKey:@"maxCorpusCount"]; + if(minDictionaryCount != nil) + [queryParams setValue:minDictionaryCount forKey:@"minDictionaryCount"]; + if(maxDictionaryCount != nil) + [queryParams setValue:maxDictionaryCount forKey:@"maxDictionaryCount"]; + if(minLength != nil) + [queryParams setValue:minLength forKey:@"minLength"]; + if(maxLength != nil) + [queryParams setValue:maxLength forKey:@"maxLength"]; + if(skip != nil) + [queryParams setValue:skip forKey:@"skip"]; + if(limit != nil) + [queryParams setValue:limit forKey:@"limit"]; + NSMutableDictionary* headerParams = [[NSMutableDictionary alloc] init]; + id bodyDictionary = nil; + if(query == nil) { + // error + } + // not a return container + [_api dictionaryWithCompletionBlock: requestUrl + method: @"GET" + queryParams: queryParams + body: bodyDictionary + headerParams: headerParams + completionHandler: ^(NSDictionary *data, NSError *error) { + if (error) { + completionBlock(nil, error);return; + } + + completionBlock( [[NIKWordSearchResults alloc]initWithValues: data], nil);}]; + +} + +/** + * + * returnTypeIsPrimitive: + * returnBaseType: NIKWordOfTheDay + * returnContainer: + * + **/ +-(void) getWordOfTheDayWithCompletionBlock :(NSString*) date + completionHandler:(void (^)(NIKWordOfTheDay*, NSError *))completionBlock{ + + NSMutableString* requestUrl = [NSMutableString stringWithFormat:@"%@/words.{format}/wordOfTheDay", basePath]; + + // remove format in URL if needed + if ([requestUrl rangeOfString:@".{format}"].location != NSNotFound) + [requestUrl replaceCharactersInRange: [requestUrl rangeOfString:@".{format}"] withString:@".json"]; + + NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init]; + if(date != nil) + [queryParams setValue:date forKey:@"date"]; + NSMutableDictionary* headerParams = [[NSMutableDictionary alloc] init]; + id bodyDictionary = nil; + // not a return container + [_api dictionaryWithCompletionBlock: requestUrl + method: @"GET" + queryParams: queryParams + body: bodyDictionary + headerParams: headerParams + completionHandler: ^(NSDictionary *data, NSError *error) { + if (error) { + completionBlock(nil, error);return; + } + + completionBlock( [[NIKWordOfTheDay alloc]initWithValues: data], nil);}]; + +} + +/** + * + * returnTypeIsPrimitive: + * returnBaseType: NIKDefinitionSearchResults + * returnContainer: + * + **/ +-(void) reverseDictionaryWithCompletionBlock :(NSString*) query findSenseForWord:(NSString*) findSenseForWord includeSourceDictionaries:(NSString*) includeSourceDictionaries excludeSourceDictionaries:(NSString*) excludeSourceDictionaries includePartOfSpeech:(NSString*) includePartOfSpeech excludePartOfSpeech:(NSString*) excludePartOfSpeech expandTerms:(NSString*) expandTerms sortBy:(NSString*) sortBy sortOrder:(NSString*) sortOrder minCorpusCount:(NSNumber*) minCorpusCount maxCorpusCount:(NSNumber*) maxCorpusCount minLength:(NSNumber*) minLength maxLength:(NSNumber*) maxLength includeTags:(NSString*) includeTags skip:(NSString*) skip limit:(NSNumber*) limit + completionHandler:(void (^)(NIKDefinitionSearchResults*, NSError *))completionBlock{ + + NSMutableString* requestUrl = [NSMutableString stringWithFormat:@"%@/words.{format}/reverseDictionary", basePath]; + + // remove format in URL if needed + if ([requestUrl rangeOfString:@".{format}"].location != NSNotFound) + [requestUrl replaceCharactersInRange: [requestUrl rangeOfString:@".{format}"] withString:@".json"]; + + NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init]; + if(query != nil) + [queryParams setValue:query forKey:@"query"]; + if(findSenseForWord != nil) + [queryParams setValue:findSenseForWord forKey:@"findSenseForWord"]; + if(includeSourceDictionaries != nil) + [queryParams setValue:includeSourceDictionaries forKey:@"includeSourceDictionaries"]; + if(excludeSourceDictionaries != nil) + [queryParams setValue:excludeSourceDictionaries forKey:@"excludeSourceDictionaries"]; + if(includePartOfSpeech != nil) + [queryParams setValue:includePartOfSpeech forKey:@"includePartOfSpeech"]; + if(excludePartOfSpeech != nil) + [queryParams setValue:excludePartOfSpeech forKey:@"excludePartOfSpeech"]; + if(minCorpusCount != nil) + [queryParams setValue:minCorpusCount forKey:@"minCorpusCount"]; + if(maxCorpusCount != nil) + [queryParams setValue:maxCorpusCount forKey:@"maxCorpusCount"]; + if(minLength != nil) + [queryParams setValue:minLength forKey:@"minLength"]; + if(maxLength != nil) + [queryParams setValue:maxLength forKey:@"maxLength"]; + if(expandTerms != nil) + [queryParams setValue:expandTerms forKey:@"expandTerms"]; + if(includeTags != nil) + [queryParams setValue:includeTags forKey:@"includeTags"]; + if(sortBy != nil) + [queryParams setValue:sortBy forKey:@"sortBy"]; + if(sortOrder != nil) + [queryParams setValue:sortOrder forKey:@"sortOrder"]; + if(skip != nil) + [queryParams setValue:skip forKey:@"skip"]; + if(limit != nil) + [queryParams setValue:limit forKey:@"limit"]; + NSMutableDictionary* headerParams = [[NSMutableDictionary alloc] init]; + id bodyDictionary = nil; + if(query == nil) { + // error + } + // not a return container + [_api dictionaryWithCompletionBlock: requestUrl + method: @"GET" + queryParams: queryParams + body: bodyDictionary + headerParams: headerParams + completionHandler: ^(NSDictionary *data, NSError *error) { + if (error) { + completionBlock(nil, error);return; + } + + completionBlock( [[NIKDefinitionSearchResults alloc]initWithValues: data], nil);}]; + +} + +/** + * + * returnTypeIsPrimitive: + * returnBaseType: NIKWordObject + * returnContainer: List + * + **/ +-(void) getRandomWordsWithCompletionBlock :(NSString*) includePartOfSpeech excludePartOfSpeech:(NSString*) excludePartOfSpeech sortBy:(NSString*) sortBy sortOrder:(NSString*) sortOrder hasDictionaryDef:(NSString*) hasDictionaryDef minCorpusCount:(NSNumber*) minCorpusCount maxCorpusCount:(NSNumber*) maxCorpusCount minDictionaryCount:(NSNumber*) minDictionaryCount maxDictionaryCount:(NSNumber*) maxDictionaryCount minLength:(NSNumber*) minLength maxLength:(NSNumber*) maxLength limit:(NSNumber*) limit + completionHandler:(void (^)(NSArray*, NSError *))completionBlock{ + + NSMutableString* requestUrl = [NSMutableString stringWithFormat:@"%@/words.{format}/randomWords", basePath]; + + // remove format in URL if needed + if ([requestUrl rangeOfString:@".{format}"].location != NSNotFound) + [requestUrl replaceCharactersInRange: [requestUrl rangeOfString:@".{format}"] withString:@".json"]; + + NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init]; + if(hasDictionaryDef != nil) + [queryParams setValue:hasDictionaryDef forKey:@"hasDictionaryDef"]; + if(includePartOfSpeech != nil) + [queryParams setValue:includePartOfSpeech forKey:@"includePartOfSpeech"]; + if(excludePartOfSpeech != nil) + [queryParams setValue:excludePartOfSpeech forKey:@"excludePartOfSpeech"]; + if(minCorpusCount != nil) + [queryParams setValue:minCorpusCount forKey:@"minCorpusCount"]; + if(maxCorpusCount != nil) + [queryParams setValue:maxCorpusCount forKey:@"maxCorpusCount"]; + if(minDictionaryCount != nil) + [queryParams setValue:minDictionaryCount forKey:@"minDictionaryCount"]; + if(maxDictionaryCount != nil) + [queryParams setValue:maxDictionaryCount forKey:@"maxDictionaryCount"]; + if(minLength != nil) + [queryParams setValue:minLength forKey:@"minLength"]; + if(maxLength != nil) + [queryParams setValue:maxLength forKey:@"maxLength"]; + if(sortBy != nil) + [queryParams setValue:sortBy forKey:@"sortBy"]; + if(sortOrder != nil) + [queryParams setValue:sortOrder forKey:@"sortOrder"]; + if(limit != nil) + [queryParams setValue:limit forKey:@"limit"]; + NSMutableDictionary* headerParams = [[NSMutableDictionary alloc] init]; + id bodyDictionary = nil; + // it's a returnContainer + [_api dictionaryWithCompletionBlock: requestUrl + method: @"GET" + queryParams: queryParams + body: bodyDictionary + headerParams: headerParams + completionHandler: ^(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) { + NIKWordObject* d = [[NIKWordObject alloc]initWithValues: dict]; + [objs addObject:d]; + } + completionBlock(objs, nil); + } + }]; + +} + +/** + * + * returnTypeIsPrimitive: + * returnBaseType: NIKWordObject + * returnContainer: + * + **/ +-(void) getRandomWordWithCompletionBlock :(NSString*) includePartOfSpeech excludePartOfSpeech:(NSString*) excludePartOfSpeech hasDictionaryDef:(NSString*) hasDictionaryDef minCorpusCount:(NSNumber*) minCorpusCount maxCorpusCount:(NSNumber*) maxCorpusCount minDictionaryCount:(NSNumber*) minDictionaryCount maxDictionaryCount:(NSNumber*) maxDictionaryCount minLength:(NSNumber*) minLength maxLength:(NSNumber*) maxLength + completionHandler:(void (^)(NIKWordObject*, NSError *))completionBlock{ + + NSMutableString* requestUrl = [NSMutableString stringWithFormat:@"%@/words.{format}/randomWord", basePath]; + + // remove format in URL if needed + if ([requestUrl rangeOfString:@".{format}"].location != NSNotFound) + [requestUrl replaceCharactersInRange: [requestUrl rangeOfString:@".{format}"] withString:@".json"]; + + NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init]; + if(hasDictionaryDef != nil) + [queryParams setValue:hasDictionaryDef forKey:@"hasDictionaryDef"]; + if(includePartOfSpeech != nil) + [queryParams setValue:includePartOfSpeech forKey:@"includePartOfSpeech"]; + if(excludePartOfSpeech != nil) + [queryParams setValue:excludePartOfSpeech forKey:@"excludePartOfSpeech"]; + if(minCorpusCount != nil) + [queryParams setValue:minCorpusCount forKey:@"minCorpusCount"]; + if(maxCorpusCount != nil) + [queryParams setValue:maxCorpusCount forKey:@"maxCorpusCount"]; + if(minDictionaryCount != nil) + [queryParams setValue:minDictionaryCount forKey:@"minDictionaryCount"]; + if(maxDictionaryCount != nil) + [queryParams setValue:maxDictionaryCount forKey:@"maxDictionaryCount"]; + if(minLength != nil) + [queryParams setValue:minLength forKey:@"minLength"]; + if(maxLength != nil) + [queryParams setValue:maxLength forKey:@"maxLength"]; + NSMutableDictionary* headerParams = [[NSMutableDictionary alloc] init]; + id bodyDictionary = nil; + // not a return container + [_api dictionaryWithCompletionBlock: requestUrl + method: @"GET" + queryParams: queryParams + body: bodyDictionary + headerParams: headerParams + completionHandler: ^(NSDictionary *data, NSError *error) { + if (error) { + completionBlock(nil, error);return; + } + + completionBlock( [[NIKWordObject alloc]initWithValues: data], nil);}]; + +} + +-(void) searchWordsAsJsonWithCompletionBlock :(NSString*) query includePartOfSpeech:(NSString*) includePartOfSpeech excludePartOfSpeech:(NSString*) excludePartOfSpeech caseSensitive:(NSString*) caseSensitive minCorpusCount:(NSNumber*) minCorpusCount maxCorpusCount:(NSNumber*) maxCorpusCount minDictionaryCount:(NSNumber*) minDictionaryCount maxDictionaryCount:(NSNumber*) maxDictionaryCount minLength:(NSNumber*) minLength maxLength:(NSNumber*) maxLength skip:(NSNumber*) skip limit:(NSNumber*) limit + completionHandler:(void (^)(NSString*, NSError *))completionBlock{ + + NSMutableString* requestUrl = [NSMutableString stringWithFormat:@"%@/words.{format}/search/{query}", basePath]; + + // remove format in URL if needed + if ([requestUrl rangeOfString:@".{format}"].location != NSNotFound) + [requestUrl replaceCharactersInRange: [requestUrl rangeOfString:@".{format}"] withString:@""]; + + [requestUrl replaceCharactersInRange: [requestUrl rangeOfString:[NSString stringWithFormat:@"%@%@%@", @"{", @"query", @"}"]] withString: [_api escapeString:query]]; + NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init]; + if(caseSensitive != nil) + [queryParams setValue:caseSensitive forKey:@"caseSensitive"]; + if(includePartOfSpeech != nil) + [queryParams setValue:includePartOfSpeech forKey:@"includePartOfSpeech"]; + if(excludePartOfSpeech != nil) + [queryParams setValue:excludePartOfSpeech forKey:@"excludePartOfSpeech"]; + if(minCorpusCount != nil) + [queryParams setValue:minCorpusCount forKey:@"minCorpusCount"]; + if(maxCorpusCount != nil) + [queryParams setValue:maxCorpusCount forKey:@"maxCorpusCount"]; + if(minDictionaryCount != nil) + [queryParams setValue:minDictionaryCount forKey:@"minDictionaryCount"]; + if(maxDictionaryCount != nil) + [queryParams setValue:maxDictionaryCount forKey:@"maxDictionaryCount"]; + if(minLength != nil) + [queryParams setValue:minLength forKey:@"minLength"]; + if(maxLength != nil) + [queryParams setValue:maxLength forKey:@"maxLength"]; + if(skip != nil) + [queryParams setValue:skip forKey:@"skip"]; + if(limit != nil) + [queryParams setValue:limit forKey:@"limit"]; + NSMutableDictionary* headerParams = [[NSMutableDictionary alloc] init]; + id bodyDictionary = nil; + if(query == nil) { + // error + } + [_api dictionaryWithCompletionBlock: requestUrl + method: @"GET" + queryParams: queryParams + body: bodyDictionary + headerParams: headerParams + completionHandler: ^(NSDictionary *data, NSError *error) { + if (error) { + completionBlock(nil, error);return; + } + + NSData * responseData = nil; + if([data isKindOfClass:[NSDictionary class]]){ + responseData = [NSJSONSerialization dataWithJSONObject:data + options:kNilOptions error:&error]; + } + else if ([data isKindOfClass:[NSArray class]]){ + responseData = [NSJSONSerialization dataWithJSONObject:data + options:kNilOptions error:&error]; + } + NSString * json = [[NSString alloc]initWithData:responseData encoding:NSUTF8StringEncoding]; + completionBlock(json, nil); + + }]; + +} + +-(void) getWordOfTheDayAsJsonWithCompletionBlock :(NSString*) date + completionHandler:(void (^)(NSString*, NSError *))completionBlock{ + + NSMutableString* requestUrl = [NSMutableString stringWithFormat:@"%@/words.{format}/wordOfTheDay", basePath]; + + // remove format in URL if needed + if ([requestUrl rangeOfString:@".{format}"].location != NSNotFound) + [requestUrl replaceCharactersInRange: [requestUrl rangeOfString:@".{format}"] withString:@""]; + + NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init]; + if(date != nil) + [queryParams setValue:date forKey:@"date"]; + NSMutableDictionary* headerParams = [[NSMutableDictionary alloc] init]; + id bodyDictionary = nil; + [_api dictionaryWithCompletionBlock: requestUrl + method: @"GET" + queryParams: queryParams + body: bodyDictionary + headerParams: headerParams + completionHandler: ^(NSDictionary *data, NSError *error) { + if (error) { + completionBlock(nil, error);return; + } + + NSData * responseData = nil; + if([data isKindOfClass:[NSDictionary class]]){ + responseData = [NSJSONSerialization dataWithJSONObject:data + options:kNilOptions error:&error]; + } + else if ([data isKindOfClass:[NSArray class]]){ + responseData = [NSJSONSerialization dataWithJSONObject:data + options:kNilOptions error:&error]; + } + NSString * json = [[NSString alloc]initWithData:responseData encoding:NSUTF8StringEncoding]; + completionBlock(json, nil); + + }]; + +} + +-(void) reverseDictionaryAsJsonWithCompletionBlock :(NSString*) query findSenseForWord:(NSString*) findSenseForWord includeSourceDictionaries:(NSString*) includeSourceDictionaries excludeSourceDictionaries:(NSString*) excludeSourceDictionaries includePartOfSpeech:(NSString*) includePartOfSpeech excludePartOfSpeech:(NSString*) excludePartOfSpeech expandTerms:(NSString*) expandTerms sortBy:(NSString*) sortBy sortOrder:(NSString*) sortOrder minCorpusCount:(NSNumber*) minCorpusCount maxCorpusCount:(NSNumber*) maxCorpusCount minLength:(NSNumber*) minLength maxLength:(NSNumber*) maxLength includeTags:(NSString*) includeTags skip:(NSString*) skip limit:(NSNumber*) limit + completionHandler:(void (^)(NSString*, NSError *))completionBlock{ + + NSMutableString* requestUrl = [NSMutableString stringWithFormat:@"%@/words.{format}/reverseDictionary", basePath]; + + // remove format in URL if needed + if ([requestUrl rangeOfString:@".{format}"].location != NSNotFound) + [requestUrl replaceCharactersInRange: [requestUrl rangeOfString:@".{format}"] withString:@""]; + + NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init]; + if(query != nil) + [queryParams setValue:query forKey:@"query"]; + if(findSenseForWord != nil) + [queryParams setValue:findSenseForWord forKey:@"findSenseForWord"]; + if(includeSourceDictionaries != nil) + [queryParams setValue:includeSourceDictionaries forKey:@"includeSourceDictionaries"]; + if(excludeSourceDictionaries != nil) + [queryParams setValue:excludeSourceDictionaries forKey:@"excludeSourceDictionaries"]; + if(includePartOfSpeech != nil) + [queryParams setValue:includePartOfSpeech forKey:@"includePartOfSpeech"]; + if(excludePartOfSpeech != nil) + [queryParams setValue:excludePartOfSpeech forKey:@"excludePartOfSpeech"]; + if(minCorpusCount != nil) + [queryParams setValue:minCorpusCount forKey:@"minCorpusCount"]; + if(maxCorpusCount != nil) + [queryParams setValue:maxCorpusCount forKey:@"maxCorpusCount"]; + if(minLength != nil) + [queryParams setValue:minLength forKey:@"minLength"]; + if(maxLength != nil) + [queryParams setValue:maxLength forKey:@"maxLength"]; + if(expandTerms != nil) + [queryParams setValue:expandTerms forKey:@"expandTerms"]; + if(includeTags != nil) + [queryParams setValue:includeTags forKey:@"includeTags"]; + if(sortBy != nil) + [queryParams setValue:sortBy forKey:@"sortBy"]; + if(sortOrder != nil) + [queryParams setValue:sortOrder forKey:@"sortOrder"]; + if(skip != nil) + [queryParams setValue:skip forKey:@"skip"]; + if(limit != nil) + [queryParams setValue:limit forKey:@"limit"]; + NSMutableDictionary* headerParams = [[NSMutableDictionary alloc] init]; + id bodyDictionary = nil; + if(query == nil) { + // error + } + [_api dictionaryWithCompletionBlock: requestUrl + method: @"GET" + queryParams: queryParams + body: bodyDictionary + headerParams: headerParams + completionHandler: ^(NSDictionary *data, NSError *error) { + if (error) { + completionBlock(nil, error);return; + } + + NSData * responseData = nil; + if([data isKindOfClass:[NSDictionary class]]){ + responseData = [NSJSONSerialization dataWithJSONObject:data + options:kNilOptions error:&error]; + } + else if ([data isKindOfClass:[NSArray class]]){ + responseData = [NSJSONSerialization dataWithJSONObject:data + options:kNilOptions error:&error]; + } + NSString * json = [[NSString alloc]initWithData:responseData encoding:NSUTF8StringEncoding]; + completionBlock(json, nil); + + }]; + +} + +-(void) getRandomWordsAsJsonWithCompletionBlock :(NSString*) includePartOfSpeech excludePartOfSpeech:(NSString*) excludePartOfSpeech sortBy:(NSString*) sortBy sortOrder:(NSString*) sortOrder hasDictionaryDef:(NSString*) hasDictionaryDef minCorpusCount:(NSNumber*) minCorpusCount maxCorpusCount:(NSNumber*) maxCorpusCount minDictionaryCount:(NSNumber*) minDictionaryCount maxDictionaryCount:(NSNumber*) maxDictionaryCount minLength:(NSNumber*) minLength maxLength:(NSNumber*) maxLength limit:(NSNumber*) limit + completionHandler:(void (^)(NSString*, NSError *))completionBlock{ + + NSMutableString* requestUrl = [NSMutableString stringWithFormat:@"%@/words.{format}/randomWords", basePath]; + + // remove format in URL if needed + if ([requestUrl rangeOfString:@".{format}"].location != NSNotFound) + [requestUrl replaceCharactersInRange: [requestUrl rangeOfString:@".{format}"] withString:@""]; + + NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init]; + if(hasDictionaryDef != nil) + [queryParams setValue:hasDictionaryDef forKey:@"hasDictionaryDef"]; + if(includePartOfSpeech != nil) + [queryParams setValue:includePartOfSpeech forKey:@"includePartOfSpeech"]; + if(excludePartOfSpeech != nil) + [queryParams setValue:excludePartOfSpeech forKey:@"excludePartOfSpeech"]; + if(minCorpusCount != nil) + [queryParams setValue:minCorpusCount forKey:@"minCorpusCount"]; + if(maxCorpusCount != nil) + [queryParams setValue:maxCorpusCount forKey:@"maxCorpusCount"]; + if(minDictionaryCount != nil) + [queryParams setValue:minDictionaryCount forKey:@"minDictionaryCount"]; + if(maxDictionaryCount != nil) + [queryParams setValue:maxDictionaryCount forKey:@"maxDictionaryCount"]; + if(minLength != nil) + [queryParams setValue:minLength forKey:@"minLength"]; + if(maxLength != nil) + [queryParams setValue:maxLength forKey:@"maxLength"]; + if(sortBy != nil) + [queryParams setValue:sortBy forKey:@"sortBy"]; + if(sortOrder != nil) + [queryParams setValue:sortOrder forKey:@"sortOrder"]; + if(limit != nil) + [queryParams setValue:limit forKey:@"limit"]; + NSMutableDictionary* headerParams = [[NSMutableDictionary alloc] init]; + id bodyDictionary = nil; + [_api dictionaryWithCompletionBlock: requestUrl + method: @"GET" + queryParams: queryParams + body: bodyDictionary + headerParams: headerParams + completionHandler: ^(NSDictionary *data, NSError *error) { + if (error) { + completionBlock(nil, error);return; + } + + NSData * responseData = nil; + if([data isKindOfClass:[NSDictionary class]]){ + responseData = [NSJSONSerialization dataWithJSONObject:data + options:kNilOptions error:&error]; + } + else if ([data isKindOfClass:[NSArray class]]){ + responseData = [NSJSONSerialization dataWithJSONObject:data + options:kNilOptions error:&error]; + } + NSString * json = [[NSString alloc]initWithData:responseData encoding:NSUTF8StringEncoding]; + completionBlock(json, nil); + + }]; + +} + +-(void) getRandomWordAsJsonWithCompletionBlock :(NSString*) includePartOfSpeech excludePartOfSpeech:(NSString*) excludePartOfSpeech hasDictionaryDef:(NSString*) hasDictionaryDef minCorpusCount:(NSNumber*) minCorpusCount maxCorpusCount:(NSNumber*) maxCorpusCount minDictionaryCount:(NSNumber*) minDictionaryCount maxDictionaryCount:(NSNumber*) maxDictionaryCount minLength:(NSNumber*) minLength maxLength:(NSNumber*) maxLength + completionHandler:(void (^)(NSString*, NSError *))completionBlock{ + + NSMutableString* requestUrl = [NSMutableString stringWithFormat:@"%@/words.{format}/randomWord", basePath]; + + // remove format in URL if needed + if ([requestUrl rangeOfString:@".{format}"].location != NSNotFound) + [requestUrl replaceCharactersInRange: [requestUrl rangeOfString:@".{format}"] withString:@""]; + + NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init]; + if(hasDictionaryDef != nil) + [queryParams setValue:hasDictionaryDef forKey:@"hasDictionaryDef"]; + if(includePartOfSpeech != nil) + [queryParams setValue:includePartOfSpeech forKey:@"includePartOfSpeech"]; + if(excludePartOfSpeech != nil) + [queryParams setValue:excludePartOfSpeech forKey:@"excludePartOfSpeech"]; + if(minCorpusCount != nil) + [queryParams setValue:minCorpusCount forKey:@"minCorpusCount"]; + if(maxCorpusCount != nil) + [queryParams setValue:maxCorpusCount forKey:@"maxCorpusCount"]; + if(minDictionaryCount != nil) + [queryParams setValue:minDictionaryCount forKey:@"minDictionaryCount"]; + if(maxDictionaryCount != nil) + [queryParams setValue:maxDictionaryCount forKey:@"maxDictionaryCount"]; + if(minLength != nil) + [queryParams setValue:minLength forKey:@"minLength"]; + if(maxLength != nil) + [queryParams setValue:maxLength forKey:@"maxLength"]; + NSMutableDictionary* headerParams = [[NSMutableDictionary alloc] init]; + id bodyDictionary = nil; + [_api dictionaryWithCompletionBlock: requestUrl + method: @"GET" + queryParams: queryParams + body: bodyDictionary + headerParams: headerParams + completionHandler: ^(NSDictionary *data, NSError *error) { + if (error) { + completionBlock(nil, error);return; + } + + NSData * responseData = nil; + if([data isKindOfClass:[NSDictionary class]]){ + responseData = [NSJSONSerialization dataWithJSONObject:data + options:kNilOptions error:&error]; + } + else if ([data isKindOfClass:[NSArray class]]){ + responseData = [NSJSONSerialization dataWithJSONObject:data + options:kNilOptions error:&error]; + } + NSString * json = [[NSString alloc]initWithData:responseData encoding:NSUTF8StringEncoding]; + completionBlock(json, nil); + + }]; + +} + + +@end diff --git a/samples/client/wordnik-api/objc/tests/WordnikApiClientTests-Info.plist b/samples/client/wordnik-api/objc/tests/WordnikApiClientTests-Info.plist new file mode 100644 index 00000000000..dd6d9a681de --- /dev/null +++ b/samples/client/wordnik-api/objc/tests/WordnikApiClientTests-Info.plist @@ -0,0 +1,22 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleExecutable + ${EXECUTABLE_NAME} + CFBundleIdentifier + com.wordnik.${PRODUCT_NAME:rfc1034identifier} + CFBundleInfoDictionaryVersion + 6.0 + CFBundlePackageType + BNDL + CFBundleShortVersionString + 1.0 + CFBundleSignature + ???? + CFBundleVersion + 1 + + diff --git a/samples/client/wordnik-api/objc/tests/WordnikApiClientTests-Prefix.pch b/samples/client/wordnik-api/objc/tests/WordnikApiClientTests-Prefix.pch new file mode 100644 index 00000000000..535985c646b --- /dev/null +++ b/samples/client/wordnik-api/objc/tests/WordnikApiClientTests-Prefix.pch @@ -0,0 +1,7 @@ +// +// Prefix header for all source files of the 'WordnikApiClientTests' target in the 'WordnikApiClientTests' project +// + +#ifdef __OBJC__ + #import +#endif diff --git a/samples/client/wordnik-api/scala/ScalaWordnikApiCodegen.scala b/samples/client/wordnik-api/scala/ScalaWordnikApiCodegen.scala index 8190682ecf9..038e9cb0c03 100644 --- a/samples/client/wordnik-api/scala/ScalaWordnikApiCodegen.scala +++ b/samples/client/wordnik-api/scala/ScalaWordnikApiCodegen.scala @@ -1,3 +1,19 @@ +/** + * Copyright 2012 Wordnik, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + import com.wordnik.swagger.codegen.BasicScalaGenerator import com.wordnik.swagger.core._