forked from loafle/openapi-generator-original
added objc wordnik sample
This commit is contained in:
parent
ddc94bcb7c
commit
b4efa892a1
36
samples/client/wordnik-api/objc/ObjcWordnikApiCodegen.scala
Normal file
36
samples/client/wordnik-api/objc/ObjcWordnikApiCodegen.scala
Normal file
@ -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"))
|
||||||
|
}
|
@ -242,8 +242,6 @@
|
|||||||
EA5A02A21613AC66003B3E41 /* NIKWordSearchResults.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = NIKWordSearchResults.m; path = ../client/NIKWordSearchResults.m; sourceTree = "<group>"; };
|
EA5A02A21613AC66003B3E41 /* NIKWordSearchResults.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = NIKWordSearchResults.m; path = ../client/NIKWordSearchResults.m; sourceTree = "<group>"; };
|
||||||
EA5A02CD1613AD47003B3E41 /* WordnikApiClientTests-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = "WordnikApiClientTests-Info.plist"; path = "../tests/WordnikApiClientTests-Info.plist"; sourceTree = "<group>"; };
|
EA5A02CD1613AD47003B3E41 /* WordnikApiClientTests-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = "WordnikApiClientTests-Info.plist"; path = "../tests/WordnikApiClientTests-Info.plist"; sourceTree = "<group>"; };
|
||||||
EA5A02CE1613AD47003B3E41 /* WordnikApiClientTests-Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "WordnikApiClientTests-Prefix.pch"; path = "../tests/WordnikApiClientTests-Prefix.pch"; sourceTree = "<group>"; };
|
EA5A02CE1613AD47003B3E41 /* WordnikApiClientTests-Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "WordnikApiClientTests-Prefix.pch"; path = "../tests/WordnikApiClientTests-Prefix.pch"; sourceTree = "<group>"; };
|
||||||
EA5A02CF1613AD47003B3E41 /* WordnikApiClientTests.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WordnikApiClientTests.h; path = ../tests/WordnikApiClientTests.h; sourceTree = "<group>"; };
|
|
||||||
EA5A02D01613AD47003B3E41 /* WordnikApiClientTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = WordnikApiClientTests.m; path = ../tests/WordnikApiClientTests.m; sourceTree = "<group>"; };
|
|
||||||
EA5A02E41614017E003B3E41 /* WordApiTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WordApiTest.h; path = ../tests/WordApiTest.h; sourceTree = "<group>"; };
|
EA5A02E41614017E003B3E41 /* WordApiTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WordApiTest.h; path = ../tests/WordApiTest.h; sourceTree = "<group>"; };
|
||||||
EA5A02E51614017E003B3E41 /* WordApiTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = WordApiTest.m; path = ../tests/WordApiTest.m; sourceTree = "<group>"; };
|
EA5A02E51614017E003B3E41 /* WordApiTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = WordApiTest.m; path = ../tests/WordApiTest.m; sourceTree = "<group>"; };
|
||||||
/* End PBXFileReference section */
|
/* End PBXFileReference section */
|
||||||
@ -333,8 +331,6 @@
|
|||||||
children = (
|
children = (
|
||||||
EA5A02CD1613AD47003B3E41 /* WordnikApiClientTests-Info.plist */,
|
EA5A02CD1613AD47003B3E41 /* WordnikApiClientTests-Info.plist */,
|
||||||
EA5A02CE1613AD47003B3E41 /* WordnikApiClientTests-Prefix.pch */,
|
EA5A02CE1613AD47003B3E41 /* WordnikApiClientTests-Prefix.pch */,
|
||||||
EA5A02CF1613AD47003B3E41 /* WordnikApiClientTests.h */,
|
|
||||||
EA5A02D01613AD47003B3E41 /* WordnikApiClientTests.m */,
|
|
||||||
EA5A02E41614017E003B3E41 /* WordApiTest.h */,
|
EA5A02E41614017E003B3E41 /* WordApiTest.h */,
|
||||||
EA5A02E51614017E003B3E41 /* WordApiTest.m */,
|
EA5A02E51614017E003B3E41 /* WordApiTest.m */,
|
||||||
);
|
);
|
||||||
|
@ -0,0 +1,7 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<Workspace
|
||||||
|
version = "1.0">
|
||||||
|
<FileRef
|
||||||
|
location = "self:WordnikApiClient.xcodeproj">
|
||||||
|
</FileRef>
|
||||||
|
</Workspace>
|
Binary file not shown.
@ -0,0 +1,72 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<Bucket
|
||||||
|
type = "1"
|
||||||
|
version = "1.0">
|
||||||
|
<FileBreakpoints>
|
||||||
|
<FileBreakpoint
|
||||||
|
shouldBeEnabled = "No"
|
||||||
|
ignoreCount = "0"
|
||||||
|
continueAfterRunningActions = "No"
|
||||||
|
filePath = "../client/NIKWordApi.m"
|
||||||
|
timestampString = "370399943.538529"
|
||||||
|
startingColumnNumber = "9223372036854775807"
|
||||||
|
endingColumnNumber = "9223372036854775807"
|
||||||
|
startingLineNumber = "517"
|
||||||
|
endingLineNumber = "517"
|
||||||
|
landmarkName = "-getEtymologiesWithCompletionBlock:useCanonical:completionHandler:"
|
||||||
|
landmarkType = "5">
|
||||||
|
</FileBreakpoint>
|
||||||
|
<FileBreakpoint
|
||||||
|
shouldBeEnabled = "No"
|
||||||
|
ignoreCount = "0"
|
||||||
|
continueAfterRunningActions = "No"
|
||||||
|
filePath = "../client/NIKWordApi.m"
|
||||||
|
timestampString = "370399951.513734"
|
||||||
|
startingColumnNumber = "9223372036854775807"
|
||||||
|
endingColumnNumber = "9223372036854775807"
|
||||||
|
startingLineNumber = "516"
|
||||||
|
endingLineNumber = "516"
|
||||||
|
landmarkName = "-getEtymologiesWithCompletionBlock:useCanonical:completionHandler:"
|
||||||
|
landmarkType = "5">
|
||||||
|
</FileBreakpoint>
|
||||||
|
<FileBreakpoint
|
||||||
|
shouldBeEnabled = "No"
|
||||||
|
ignoreCount = "0"
|
||||||
|
continueAfterRunningActions = "No"
|
||||||
|
filePath = "../client/NIKApiInvoker.m"
|
||||||
|
timestampString = "370400006.775392"
|
||||||
|
startingColumnNumber = "9223372036854775807"
|
||||||
|
endingColumnNumber = "9223372036854775807"
|
||||||
|
startingLineNumber = "75"
|
||||||
|
endingLineNumber = "75"
|
||||||
|
landmarkName = "-dictionaryWithCompletionBlock:method:queryParams:body:headerParams:completionHandler:"
|
||||||
|
landmarkType = "5">
|
||||||
|
</FileBreakpoint>
|
||||||
|
<FileBreakpoint
|
||||||
|
shouldBeEnabled = "No"
|
||||||
|
ignoreCount = "0"
|
||||||
|
continueAfterRunningActions = "No"
|
||||||
|
filePath = "../client/NIKApiInvoker.m"
|
||||||
|
timestampString = "370400198.266203"
|
||||||
|
startingColumnNumber = "9223372036854775807"
|
||||||
|
endingColumnNumber = "9223372036854775807"
|
||||||
|
startingLineNumber = "99"
|
||||||
|
endingLineNumber = "99"
|
||||||
|
landmarkName = "-dictionaryWithCompletionBlock:method:queryParams:body:headerParams:completionHandler:"
|
||||||
|
landmarkType = "5">
|
||||||
|
</FileBreakpoint>
|
||||||
|
<FileBreakpoint
|
||||||
|
shouldBeEnabled = "No"
|
||||||
|
ignoreCount = "0"
|
||||||
|
continueAfterRunningActions = "No"
|
||||||
|
filePath = "../client/NIKApiInvoker.m"
|
||||||
|
timestampString = "370400308.782596"
|
||||||
|
startingColumnNumber = "9223372036854775807"
|
||||||
|
endingColumnNumber = "9223372036854775807"
|
||||||
|
startingLineNumber = "72"
|
||||||
|
endingLineNumber = "72"
|
||||||
|
landmarkName = "-dictionaryWithCompletionBlock:method:queryParams:body:headerParams:completionHandler:"
|
||||||
|
landmarkType = "5">
|
||||||
|
</FileBreakpoint>
|
||||||
|
</FileBreakpoints>
|
||||||
|
</Bucket>
|
@ -0,0 +1,86 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<Scheme
|
||||||
|
LastUpgradeVersion = "0450"
|
||||||
|
version = "1.3">
|
||||||
|
<BuildAction
|
||||||
|
parallelizeBuildables = "YES"
|
||||||
|
buildImplicitDependencies = "YES">
|
||||||
|
<BuildActionEntries>
|
||||||
|
<BuildActionEntry
|
||||||
|
buildForTesting = "YES"
|
||||||
|
buildForRunning = "YES"
|
||||||
|
buildForProfiling = "YES"
|
||||||
|
buildForArchiving = "YES"
|
||||||
|
buildForAnalyzing = "YES">
|
||||||
|
<BuildableReference
|
||||||
|
BuildableIdentifier = "primary"
|
||||||
|
BlueprintIdentifier = "EA224CFC1613ABE700129740"
|
||||||
|
BuildableName = "WordnikApiClient"
|
||||||
|
BlueprintName = "WordnikApiClient"
|
||||||
|
ReferencedContainer = "container:WordnikApiClient.xcodeproj">
|
||||||
|
</BuildableReference>
|
||||||
|
</BuildActionEntry>
|
||||||
|
</BuildActionEntries>
|
||||||
|
</BuildAction>
|
||||||
|
<TestAction
|
||||||
|
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||||
|
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||||
|
shouldUseLaunchSchemeArgsEnv = "YES"
|
||||||
|
buildConfiguration = "Debug">
|
||||||
|
<Testables>
|
||||||
|
</Testables>
|
||||||
|
<MacroExpansion>
|
||||||
|
<BuildableReference
|
||||||
|
BuildableIdentifier = "primary"
|
||||||
|
BlueprintIdentifier = "EA224CFC1613ABE700129740"
|
||||||
|
BuildableName = "WordnikApiClient"
|
||||||
|
BlueprintName = "WordnikApiClient"
|
||||||
|
ReferencedContainer = "container:WordnikApiClient.xcodeproj">
|
||||||
|
</BuildableReference>
|
||||||
|
</MacroExpansion>
|
||||||
|
</TestAction>
|
||||||
|
<LaunchAction
|
||||||
|
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||||
|
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||||
|
launchStyle = "0"
|
||||||
|
useCustomWorkingDirectory = "NO"
|
||||||
|
buildConfiguration = "Debug"
|
||||||
|
ignoresPersistentStateOnLaunch = "NO"
|
||||||
|
debugDocumentVersioning = "YES"
|
||||||
|
allowLocationSimulation = "YES">
|
||||||
|
<BuildableProductRunnable>
|
||||||
|
<BuildableReference
|
||||||
|
BuildableIdentifier = "primary"
|
||||||
|
BlueprintIdentifier = "EA224CFC1613ABE700129740"
|
||||||
|
BuildableName = "WordnikApiClient"
|
||||||
|
BlueprintName = "WordnikApiClient"
|
||||||
|
ReferencedContainer = "container:WordnikApiClient.xcodeproj">
|
||||||
|
</BuildableReference>
|
||||||
|
</BuildableProductRunnable>
|
||||||
|
<AdditionalOptions>
|
||||||
|
</AdditionalOptions>
|
||||||
|
</LaunchAction>
|
||||||
|
<ProfileAction
|
||||||
|
shouldUseLaunchSchemeArgsEnv = "YES"
|
||||||
|
savedToolIdentifier = ""
|
||||||
|
useCustomWorkingDirectory = "NO"
|
||||||
|
buildConfiguration = "Release"
|
||||||
|
debugDocumentVersioning = "YES">
|
||||||
|
<BuildableProductRunnable>
|
||||||
|
<BuildableReference
|
||||||
|
BuildableIdentifier = "primary"
|
||||||
|
BlueprintIdentifier = "EA224CFC1613ABE700129740"
|
||||||
|
BuildableName = "WordnikApiClient"
|
||||||
|
BlueprintName = "WordnikApiClient"
|
||||||
|
ReferencedContainer = "container:WordnikApiClient.xcodeproj">
|
||||||
|
</BuildableReference>
|
||||||
|
</BuildableProductRunnable>
|
||||||
|
</ProfileAction>
|
||||||
|
<AnalyzeAction
|
||||||
|
buildConfiguration = "Debug">
|
||||||
|
</AnalyzeAction>
|
||||||
|
<ArchiveAction
|
||||||
|
buildConfiguration = "Release"
|
||||||
|
revealArchiveInOrganizer = "YES">
|
||||||
|
</ArchiveAction>
|
||||||
|
</Scheme>
|
@ -0,0 +1,53 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<Scheme
|
||||||
|
LastUpgradeVersion = "0450"
|
||||||
|
version = "1.3">
|
||||||
|
<BuildAction
|
||||||
|
parallelizeBuildables = "YES"
|
||||||
|
buildImplicitDependencies = "YES">
|
||||||
|
</BuildAction>
|
||||||
|
<TestAction
|
||||||
|
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||||
|
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||||
|
shouldUseLaunchSchemeArgsEnv = "YES"
|
||||||
|
buildConfiguration = "Debug">
|
||||||
|
<Testables>
|
||||||
|
<TestableReference
|
||||||
|
skipped = "NO">
|
||||||
|
<BuildableReference
|
||||||
|
BuildableIdentifier = "primary"
|
||||||
|
BlueprintIdentifier = "EA224D131613ABFA00129740"
|
||||||
|
BuildableName = "WordnikApiClientTests.octest"
|
||||||
|
BlueprintName = "WordnikApiClientTests"
|
||||||
|
ReferencedContainer = "container:WordnikApiClient.xcodeproj">
|
||||||
|
</BuildableReference>
|
||||||
|
</TestableReference>
|
||||||
|
</Testables>
|
||||||
|
</TestAction>
|
||||||
|
<LaunchAction
|
||||||
|
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||||
|
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||||
|
launchStyle = "0"
|
||||||
|
useCustomWorkingDirectory = "NO"
|
||||||
|
buildConfiguration = "Debug"
|
||||||
|
ignoresPersistentStateOnLaunch = "NO"
|
||||||
|
debugDocumentVersioning = "YES"
|
||||||
|
allowLocationSimulation = "YES">
|
||||||
|
<AdditionalOptions>
|
||||||
|
</AdditionalOptions>
|
||||||
|
</LaunchAction>
|
||||||
|
<ProfileAction
|
||||||
|
shouldUseLaunchSchemeArgsEnv = "YES"
|
||||||
|
savedToolIdentifier = ""
|
||||||
|
useCustomWorkingDirectory = "NO"
|
||||||
|
buildConfiguration = "Release"
|
||||||
|
debugDocumentVersioning = "YES">
|
||||||
|
</ProfileAction>
|
||||||
|
<AnalyzeAction
|
||||||
|
buildConfiguration = "Debug">
|
||||||
|
</AnalyzeAction>
|
||||||
|
<ArchiveAction
|
||||||
|
buildConfiguration = "Release"
|
||||||
|
revealArchiveInOrganizer = "YES">
|
||||||
|
</ArchiveAction>
|
||||||
|
</Scheme>
|
@ -0,0 +1,32 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||||
|
<plist version="1.0">
|
||||||
|
<dict>
|
||||||
|
<key>SchemeUserState</key>
|
||||||
|
<dict>
|
||||||
|
<key>WordnikApiClient.xcscheme</key>
|
||||||
|
<dict>
|
||||||
|
<key>orderHint</key>
|
||||||
|
<integer>0</integer>
|
||||||
|
</dict>
|
||||||
|
<key>WordnikApiClientTests.xcscheme</key>
|
||||||
|
<dict>
|
||||||
|
<key>orderHint</key>
|
||||||
|
<integer>1</integer>
|
||||||
|
</dict>
|
||||||
|
</dict>
|
||||||
|
<key>SuppressBuildableAutocreation</key>
|
||||||
|
<dict>
|
||||||
|
<key>EA224CFC1613ABE700129740</key>
|
||||||
|
<dict>
|
||||||
|
<key>primary</key>
|
||||||
|
<true/>
|
||||||
|
</dict>
|
||||||
|
<key>EA224D131613ABFA00129740</key>
|
||||||
|
<dict>
|
||||||
|
<key>primary</key>
|
||||||
|
<true/>
|
||||||
|
</dict>
|
||||||
|
</dict>
|
||||||
|
</dict>
|
||||||
|
</plist>
|
@ -0,0 +1,2 @@
|
|||||||
|
/* Localized versions of Info.plist keys */
|
||||||
|
|
31
samples/client/wordnik-api/objc/client/NIKAccountApi.h
Normal file
31
samples/client/wordnik-api/objc/client/NIKAccountApi.h
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
#import <Foundation/Foundation.h>
|
||||||
|
#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
|
505
samples/client/wordnik-api/objc/client/NIKAccountApi.m
Normal file
505
samples/client/wordnik-api/objc/client/NIKAccountApi.m
Normal file
@ -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
|
32
samples/client/wordnik-api/objc/client/NIKApiInvoker.h
Normal file
32
samples/client/wordnik-api/objc/client/NIKApiInvoker.h
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
#import <Foundation/Foundation.h>
|
||||||
|
|
||||||
|
@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
|
222
samples/client/wordnik-api/objc/client/NIKApiInvoker.m
Normal file
222
samples/client/wordnik-api/objc/client/NIKApiInvoker.m
Normal file
@ -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
|
34
samples/client/wordnik-api/objc/client/NIKApiTokenStatus.h
Normal file
34
samples/client/wordnik-api/objc/client/NIKApiTokenStatus.h
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
#import <Foundation/Foundation.h>
|
||||||
|
#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
|
||||||
|
|
58
samples/client/wordnik-api/objc/client/NIKApiTokenStatus.m
Normal file
58
samples/client/wordnik-api/objc/client/NIKApiTokenStatus.m
Normal file
@ -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
|
||||||
|
|
59
samples/client/wordnik-api/objc/client/NIKAudioFile.h
Normal file
59
samples/client/wordnik-api/objc/client/NIKAudioFile.h
Normal file
@ -0,0 +1,59 @@
|
|||||||
|
#import <Foundation/Foundation.h>
|
||||||
|
#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
|
||||||
|
|
124
samples/client/wordnik-api/objc/client/NIKAudioFile.m
Normal file
124
samples/client/wordnik-api/objc/client/NIKAudioFile.m
Normal file
@ -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
|
||||||
|
|
@ -0,0 +1,25 @@
|
|||||||
|
#import <Foundation/Foundation.h>
|
||||||
|
#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
|
||||||
|
|
@ -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
|
||||||
|
|
31
samples/client/wordnik-api/objc/client/NIKBigram.h
Normal file
31
samples/client/wordnik-api/objc/client/NIKBigram.h
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
#import <Foundation/Foundation.h>
|
||||||
|
#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
|
||||||
|
|
52
samples/client/wordnik-api/objc/client/NIKBigram.m
Normal file
52
samples/client/wordnik-api/objc/client/NIKBigram.m
Normal file
@ -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
|
||||||
|
|
22
samples/client/wordnik-api/objc/client/NIKCitation.h
Normal file
22
samples/client/wordnik-api/objc/client/NIKCitation.h
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
#import <Foundation/Foundation.h>
|
||||||
|
#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
|
||||||
|
|
34
samples/client/wordnik-api/objc/client/NIKCitation.m
Normal file
34
samples/client/wordnik-api/objc/client/NIKCitation.m
Normal file
@ -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
|
||||||
|
|
22
samples/client/wordnik-api/objc/client/NIKContentProvider.h
Normal file
22
samples/client/wordnik-api/objc/client/NIKContentProvider.h
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
#import <Foundation/Foundation.h>
|
||||||
|
#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
|
||||||
|
|
34
samples/client/wordnik-api/objc/client/NIKContentProvider.m
Normal file
34
samples/client/wordnik-api/objc/client/NIKContentProvider.m
Normal file
@ -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
|
||||||
|
|
13
samples/client/wordnik-api/objc/client/NIKDate.h
Normal file
13
samples/client/wordnik-api/objc/client/NIKDate.h
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
#import <Foundation/Foundation.h>
|
||||||
|
#import "NIKSwaggerObject.h"
|
||||||
|
|
||||||
|
@interface NIKDate : NIKSwaggerObject {
|
||||||
|
@private
|
||||||
|
NSDate *_date;
|
||||||
|
}
|
||||||
|
@property(nonatomic, readonly) NSDate* date;
|
||||||
|
|
||||||
|
- (id) initWithValues: (NSString*)input;
|
||||||
|
-(NSString*) toString;
|
||||||
|
@end
|
||||||
|
|
34
samples/client/wordnik-api/objc/client/NIKDate.m
Normal file
34
samples/client/wordnik-api/objc/client/NIKDate.m
Normal file
@ -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
|
70
samples/client/wordnik-api/objc/client/NIKDefinition.h
Normal file
70
samples/client/wordnik-api/objc/client/NIKDefinition.h
Normal file
@ -0,0 +1,70 @@
|
|||||||
|
#import <Foundation/Foundation.h>
|
||||||
|
#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
|
||||||
|
|
280
samples/client/wordnik-api/objc/client/NIKDefinition.m
Normal file
280
samples/client/wordnik-api/objc/client/NIKDefinition.m
Normal file
@ -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
|
||||||
|
|
@ -0,0 +1,23 @@
|
|||||||
|
#import <Foundation/Foundation.h>
|
||||||
|
#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
|
||||||
|
|
@ -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
|
||||||
|
|
55
samples/client/wordnik-api/objc/client/NIKExample.h
Normal file
55
samples/client/wordnik-api/objc/client/NIKExample.h
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
#import <Foundation/Foundation.h>
|
||||||
|
#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
|
||||||
|
|
148
samples/client/wordnik-api/objc/client/NIKExample.m
Normal file
148
samples/client/wordnik-api/objc/client/NIKExample.m
Normal file
@ -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
|
||||||
|
|
@ -0,0 +1,24 @@
|
|||||||
|
#import <Foundation/Foundation.h>
|
||||||
|
#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
|
||||||
|
|
@ -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
|
||||||
|
|
19
samples/client/wordnik-api/objc/client/NIKExampleUsage.h
Normal file
19
samples/client/wordnik-api/objc/client/NIKExampleUsage.h
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
#import <Foundation/Foundation.h>
|
||||||
|
#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
|
||||||
|
|
28
samples/client/wordnik-api/objc/client/NIKExampleUsage.m
Normal file
28
samples/client/wordnik-api/objc/client/NIKExampleUsage.m
Normal file
@ -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
|
||||||
|
|
23
samples/client/wordnik-api/objc/client/NIKFacet.h
Normal file
23
samples/client/wordnik-api/objc/client/NIKFacet.h
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
#import <Foundation/Foundation.h>
|
||||||
|
#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
|
||||||
|
|
61
samples/client/wordnik-api/objc/client/NIKFacet.m
Normal file
61
samples/client/wordnik-api/objc/client/NIKFacet.m
Normal file
@ -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
|
||||||
|
|
22
samples/client/wordnik-api/objc/client/NIKFacetValue.h
Normal file
22
samples/client/wordnik-api/objc/client/NIKFacetValue.h
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
#import <Foundation/Foundation.h>
|
||||||
|
#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
|
||||||
|
|
34
samples/client/wordnik-api/objc/client/NIKFacetValue.m
Normal file
34
samples/client/wordnik-api/objc/client/NIKFacetValue.m
Normal file
@ -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
|
||||||
|
|
22
samples/client/wordnik-api/objc/client/NIKFrequency.h
Normal file
22
samples/client/wordnik-api/objc/client/NIKFrequency.h
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
#import <Foundation/Foundation.h>
|
||||||
|
#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
|
||||||
|
|
34
samples/client/wordnik-api/objc/client/NIKFrequency.m
Normal file
34
samples/client/wordnik-api/objc/client/NIKFrequency.m
Normal file
@ -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
|
||||||
|
|
32
samples/client/wordnik-api/objc/client/NIKFrequencySummary.h
Normal file
32
samples/client/wordnik-api/objc/client/NIKFrequencySummary.h
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
#import <Foundation/Foundation.h>
|
||||||
|
#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
|
||||||
|
|
79
samples/client/wordnik-api/objc/client/NIKFrequencySummary.m
Normal file
79
samples/client/wordnik-api/objc/client/NIKFrequencySummary.m
Normal file
@ -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
|
||||||
|
|
22
samples/client/wordnik-api/objc/client/NIKLabel.h
Normal file
22
samples/client/wordnik-api/objc/client/NIKLabel.h
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
#import <Foundation/Foundation.h>
|
||||||
|
#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
|
||||||
|
|
34
samples/client/wordnik-api/objc/client/NIKLabel.m
Normal file
34
samples/client/wordnik-api/objc/client/NIKLabel.m
Normal file
@ -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
|
||||||
|
|
28
samples/client/wordnik-api/objc/client/NIKNote.h
Normal file
28
samples/client/wordnik-api/objc/client/NIKNote.h
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
#import <Foundation/Foundation.h>
|
||||||
|
#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
|
||||||
|
|
46
samples/client/wordnik-api/objc/client/NIKNote.m
Normal file
46
samples/client/wordnik-api/objc/client/NIKNote.m
Normal file
@ -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
|
||||||
|
|
37
samples/client/wordnik-api/objc/client/NIKRelated.h
Normal file
37
samples/client/wordnik-api/objc/client/NIKRelated.h
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
#import <Foundation/Foundation.h>
|
||||||
|
#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
|
||||||
|
|
64
samples/client/wordnik-api/objc/client/NIKRelated.m
Normal file
64
samples/client/wordnik-api/objc/client/NIKRelated.m
Normal file
@ -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
|
||||||
|
|
49
samples/client/wordnik-api/objc/client/NIKScoredWord.h
Normal file
49
samples/client/wordnik-api/objc/client/NIKScoredWord.h
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
#import <Foundation/Foundation.h>
|
||||||
|
#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
|
||||||
|
|
88
samples/client/wordnik-api/objc/client/NIKScoredWord.m
Normal file
88
samples/client/wordnik-api/objc/client/NIKScoredWord.m
Normal file
@ -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
|
||||||
|
|
35
samples/client/wordnik-api/objc/client/NIKSentence.h
Normal file
35
samples/client/wordnik-api/objc/client/NIKSentence.h
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
#import <Foundation/Foundation.h>
|
||||||
|
#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
|
||||||
|
|
85
samples/client/wordnik-api/objc/client/NIKSentence.m
Normal file
85
samples/client/wordnik-api/objc/client/NIKSentence.m
Normal file
@ -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
|
||||||
|
|
28
samples/client/wordnik-api/objc/client/NIKSimpleDefinition.h
Normal file
28
samples/client/wordnik-api/objc/client/NIKSimpleDefinition.h
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
#import <Foundation/Foundation.h>
|
||||||
|
#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
|
||||||
|
|
46
samples/client/wordnik-api/objc/client/NIKSimpleDefinition.m
Normal file
46
samples/client/wordnik-api/objc/client/NIKSimpleDefinition.m
Normal file
@ -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
|
||||||
|
|
28
samples/client/wordnik-api/objc/client/NIKSimpleExample.h
Normal file
28
samples/client/wordnik-api/objc/client/NIKSimpleExample.h
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
#import <Foundation/Foundation.h>
|
||||||
|
#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
|
||||||
|
|
46
samples/client/wordnik-api/objc/client/NIKSimpleExample.m
Normal file
46
samples/client/wordnik-api/objc/client/NIKSimpleExample.m
Normal file
@ -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
|
||||||
|
|
19
samples/client/wordnik-api/objc/client/NIKStringValue.h
Normal file
19
samples/client/wordnik-api/objc/client/NIKStringValue.h
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
#import <Foundation/Foundation.h>
|
||||||
|
#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
|
||||||
|
|
28
samples/client/wordnik-api/objc/client/NIKStringValue.m
Normal file
28
samples/client/wordnik-api/objc/client/NIKStringValue.m
Normal file
@ -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
|
||||||
|
|
@ -0,0 +1,6 @@
|
|||||||
|
#import <Foundation/Foundation.h>
|
||||||
|
|
||||||
|
@interface NIKSwaggerObject : NSObject
|
||||||
|
- (id) initWithValues: (NSDictionary*)dict;
|
||||||
|
- (NSDictionary*) asDictionary;
|
||||||
|
@end
|
10
samples/client/wordnik-api/objc/client/NIKSwaggerObject.m
Normal file
10
samples/client/wordnik-api/objc/client/NIKSwaggerObject.m
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
#import "NIKSwaggerObject.h"
|
||||||
|
|
||||||
|
@implementation NIKSwaggerObject
|
||||||
|
- (id) initWithValues: (NSDictionary*)dict {
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
- (NSDictionary*) asDictionary{
|
||||||
|
return [NSDictionary init];
|
||||||
|
}
|
||||||
|
@end
|
25
samples/client/wordnik-api/objc/client/NIKSyllable.h
Normal file
25
samples/client/wordnik-api/objc/client/NIKSyllable.h
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
#import <Foundation/Foundation.h>
|
||||||
|
#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
|
||||||
|
|
40
samples/client/wordnik-api/objc/client/NIKSyllable.m
Normal file
40
samples/client/wordnik-api/objc/client/NIKSyllable.m
Normal file
@ -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
|
||||||
|
|
25
samples/client/wordnik-api/objc/client/NIKTextPron.h
Normal file
25
samples/client/wordnik-api/objc/client/NIKTextPron.h
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
#import <Foundation/Foundation.h>
|
||||||
|
#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
|
||||||
|
|
40
samples/client/wordnik-api/objc/client/NIKTextPron.m
Normal file
40
samples/client/wordnik-api/objc/client/NIKTextPron.m
Normal file
@ -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
|
||||||
|
|
40
samples/client/wordnik-api/objc/client/NIKUser.h
Normal file
40
samples/client/wordnik-api/objc/client/NIKUser.h
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
#import <Foundation/Foundation.h>
|
||||||
|
#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
|
||||||
|
|
70
samples/client/wordnik-api/objc/client/NIKUser.m
Normal file
70
samples/client/wordnik-api/objc/client/NIKUser.m
Normal file
@ -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
|
||||||
|
|
49
samples/client/wordnik-api/objc/client/NIKWordApi.h
Normal file
49
samples/client/wordnik-api/objc/client/NIKWordApi.h
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
#import <Foundation/Foundation.h>
|
||||||
|
#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
|
1100
samples/client/wordnik-api/objc/client/NIKWordApi.m
Normal file
1100
samples/client/wordnik-api/objc/client/NIKWordApi.m
Normal file
File diff suppressed because it is too large
Load Diff
50
samples/client/wordnik-api/objc/client/NIKWordList.h
Normal file
50
samples/client/wordnik-api/objc/client/NIKWordList.h
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
#import <Foundation/Foundation.h>
|
||||||
|
#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
|
||||||
|
|
142
samples/client/wordnik-api/objc/client/NIKWordList.m
Normal file
142
samples/client/wordnik-api/objc/client/NIKWordList.m
Normal file
@ -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
|
||||||
|
|
32
samples/client/wordnik-api/objc/client/NIKWordListApi.h
Normal file
32
samples/client/wordnik-api/objc/client/NIKWordListApi.h
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
#import <Foundation/Foundation.h>
|
||||||
|
#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
|
684
samples/client/wordnik-api/objc/client/NIKWordListApi.m
Normal file
684
samples/client/wordnik-api/objc/client/NIKWordListApi.m
Normal file
@ -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
|
38
samples/client/wordnik-api/objc/client/NIKWordListWord.h
Normal file
38
samples/client/wordnik-api/objc/client/NIKWordListWord.h
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
#import <Foundation/Foundation.h>
|
||||||
|
#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
|
||||||
|
|
82
samples/client/wordnik-api/objc/client/NIKWordListWord.m
Normal file
82
samples/client/wordnik-api/objc/client/NIKWordListWord.m
Normal file
@ -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
|
||||||
|
|
20
samples/client/wordnik-api/objc/client/NIKWordListsApi.h
Normal file
20
samples/client/wordnik-api/objc/client/NIKWordListsApi.h
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
#import <Foundation/Foundation.h>
|
||||||
|
#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
|
152
samples/client/wordnik-api/objc/client/NIKWordListsApi.m
Normal file
152
samples/client/wordnik-api/objc/client/NIKWordListsApi.m
Normal file
@ -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
|
34
samples/client/wordnik-api/objc/client/NIKWordObject.h
Normal file
34
samples/client/wordnik-api/objc/client/NIKWordObject.h
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
#import <Foundation/Foundation.h>
|
||||||
|
#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
|
||||||
|
|
58
samples/client/wordnik-api/objc/client/NIKWordObject.m
Normal file
58
samples/client/wordnik-api/objc/client/NIKWordObject.m
Normal file
@ -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
|
||||||
|
|
56
samples/client/wordnik-api/objc/client/NIKWordOfTheDay.h
Normal file
56
samples/client/wordnik-api/objc/client/NIKWordOfTheDay.h
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
#import <Foundation/Foundation.h>
|
||||||
|
#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
|
||||||
|
|
202
samples/client/wordnik-api/objc/client/NIKWordOfTheDay.m
Normal file
202
samples/client/wordnik-api/objc/client/NIKWordOfTheDay.m
Normal file
@ -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
|
||||||
|
|
25
samples/client/wordnik-api/objc/client/NIKWordSearchResult.h
Normal file
25
samples/client/wordnik-api/objc/client/NIKWordSearchResult.h
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
#import <Foundation/Foundation.h>
|
||||||
|
#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
|
||||||
|
|
40
samples/client/wordnik-api/objc/client/NIKWordSearchResult.m
Normal file
40
samples/client/wordnik-api/objc/client/NIKWordSearchResult.m
Normal file
@ -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
|
||||||
|
|
@ -0,0 +1,23 @@
|
|||||||
|
#import <Foundation/Foundation.h>
|
||||||
|
#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
|
||||||
|
|
@ -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
|
||||||
|
|
31
samples/client/wordnik-api/objc/client/NIKWordsApi.h
Normal file
31
samples/client/wordnik-api/objc/client/NIKWordsApi.h
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
#import <Foundation/Foundation.h>
|
||||||
|
#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
|
607
samples/client/wordnik-api/objc/client/NIKWordsApi.m
Normal file
607
samples/client/wordnik-api/objc/client/NIKWordsApi.m
Normal file
@ -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
|
@ -0,0 +1,22 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||||
|
<plist version="1.0">
|
||||||
|
<dict>
|
||||||
|
<key>CFBundleDevelopmentRegion</key>
|
||||||
|
<string>en</string>
|
||||||
|
<key>CFBundleExecutable</key>
|
||||||
|
<string>${EXECUTABLE_NAME}</string>
|
||||||
|
<key>CFBundleIdentifier</key>
|
||||||
|
<string>com.wordnik.${PRODUCT_NAME:rfc1034identifier}</string>
|
||||||
|
<key>CFBundleInfoDictionaryVersion</key>
|
||||||
|
<string>6.0</string>
|
||||||
|
<key>CFBundlePackageType</key>
|
||||||
|
<string>BNDL</string>
|
||||||
|
<key>CFBundleShortVersionString</key>
|
||||||
|
<string>1.0</string>
|
||||||
|
<key>CFBundleSignature</key>
|
||||||
|
<string>????</string>
|
||||||
|
<key>CFBundleVersion</key>
|
||||||
|
<string>1</string>
|
||||||
|
</dict>
|
||||||
|
</plist>
|
@ -0,0 +1,7 @@
|
|||||||
|
//
|
||||||
|
// Prefix header for all source files of the 'WordnikApiClientTests' target in the 'WordnikApiClientTests' project
|
||||||
|
//
|
||||||
|
|
||||||
|
#ifdef __OBJC__
|
||||||
|
#import <Cocoa/Cocoa.h>
|
||||||
|
#endif
|
@ -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.codegen.BasicScalaGenerator
|
||||||
|
|
||||||
import com.wordnik.swagger.core._
|
import com.wordnik.swagger.core._
|
||||||
|
Loading…
x
Reference in New Issue
Block a user