mirror of
				https://github.com/OpenAPITools/openapi-generator.git
				synced 2025-11-04 10:43:44 +00:00 
			
		
		
		
	moved folders
This commit is contained in:
		
							parent
							
								
									e65e5a730d
								
							
						
					
					
						commit
						a3f08e87fd
					
				
							
								
								
									
										32
									
								
								samples/client/petstore/objc/client/NIKApiInvoker.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										32
									
								
								samples/client/petstore/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/petstore/objc/client/NIKApiInvoker.m
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										222
									
								
								samples/client/petstore/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
 | 
				
			||||||
							
								
								
									
										25
									
								
								samples/client/petstore/objc/client/NIKCategory.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										25
									
								
								samples/client/petstore/objc/client/NIKCategory.h
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,25 @@
 | 
				
			|||||||
 | 
					#import <Foundation/Foundation.h>
 | 
				
			||||||
 | 
					#import "NIKSwaggerObject.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					@interface NIKCategory : NIKSwaggerObject {
 | 
				
			||||||
 | 
					@private
 | 
				
			||||||
 | 
					    NSDictionary* raw;
 | 
				
			||||||
 | 
					    NSNumber* __id; //NSNumber
 | 
				
			||||||
 | 
					    NSString* _name; //NSString
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					@property(nonatomic) NSDictionary* raw;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					@property(nonatomic) NSNumber* _id;
 | 
				
			||||||
 | 
					@property(nonatomic) NSString* name;
 | 
				
			||||||
 | 
					- (id) _id: (NSNumber*) _id
 | 
				
			||||||
 | 
					     name: (NSString*) name;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					- (id) initWithValues: (NSDictionary*)dict;
 | 
				
			||||||
 | 
					- (NSDictionary*) asDictionary;
 | 
				
			||||||
 | 
					- (NSDictionary*) asRaw;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					@end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
							
								
								
									
										38
									
								
								samples/client/petstore/objc/client/NIKCategory.m
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										38
									
								
								samples/client/petstore/objc/client/NIKCategory.m
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,38 @@
 | 
				
			|||||||
 | 
					#import "NIKDate.h"
 | 
				
			||||||
 | 
					#import "NIKCategory.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					@implementation NIKCategory
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					@synthesize raw = _raw;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					@synthesize _id = __id;
 | 
				
			||||||
 | 
					@synthesize name = _name;
 | 
				
			||||||
 | 
					- (id) _id: (NSNumber*) _id
 | 
				
			||||||
 | 
					       name: (NSString*) name
 | 
				
			||||||
 | 
					       {
 | 
				
			||||||
 | 
					          __id = _id;
 | 
				
			||||||
 | 
					          _name = name;
 | 
				
			||||||
 | 
					          return self;
 | 
				
			||||||
 | 
					       }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					- (id) initWithValues: (NSDictionary*)dict
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    __id = [dict objectForKey:@"id"];
 | 
				
			||||||
 | 
					    _name = [dict objectForKey:@"name"];
 | 
				
			||||||
 | 
					    self.raw = [[NSDictionary alloc] initWithDictionary:dict];
 | 
				
			||||||
 | 
					    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;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					-(NSDictionary*) asRaw {
 | 
				
			||||||
 | 
					    return _raw;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					@end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
							
								
								
									
										13
									
								
								samples/client/petstore/objc/client/NIKDate.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										13
									
								
								samples/client/petstore/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/petstore/objc/client/NIKDate.m
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										34
									
								
								samples/client/petstore/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
 | 
				
			||||||
							
								
								
									
										35
									
								
								samples/client/petstore/objc/client/NIKOrder.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										35
									
								
								samples/client/petstore/objc/client/NIKOrder.h
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,35 @@
 | 
				
			|||||||
 | 
					#import <Foundation/Foundation.h>
 | 
				
			||||||
 | 
					#import "NIKSwaggerObject.h"
 | 
				
			||||||
 | 
					#import "NIKDate.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					@interface NIKOrder : NIKSwaggerObject {
 | 
				
			||||||
 | 
					@private
 | 
				
			||||||
 | 
					    NSDictionary* raw;
 | 
				
			||||||
 | 
					    NSNumber* __id; //NSNumber
 | 
				
			||||||
 | 
					    NSNumber* _petId; //NSNumber
 | 
				
			||||||
 | 
					    NSString* _status; //NSString
 | 
				
			||||||
 | 
					    NSNumber* _quantity; //NSNumber
 | 
				
			||||||
 | 
					    NIKDate* _shipDate; //NIKDate
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					@property(nonatomic) NSDictionary* raw;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					@property(nonatomic) NSNumber* _id;
 | 
				
			||||||
 | 
					@property(nonatomic) NSNumber* petId;
 | 
				
			||||||
 | 
					@property(nonatomic) NSString* status;
 | 
				
			||||||
 | 
					@property(nonatomic) NSNumber* quantity;
 | 
				
			||||||
 | 
					@property(nonatomic) NIKDate* shipDate;
 | 
				
			||||||
 | 
					- (id) _id: (NSNumber*) _id
 | 
				
			||||||
 | 
					     petId: (NSNumber*) petId
 | 
				
			||||||
 | 
					     status: (NSString*) status
 | 
				
			||||||
 | 
					     quantity: (NSNumber*) quantity
 | 
				
			||||||
 | 
					     shipDate: (NIKDate*) shipDate;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					- (id) initWithValues: (NSDictionary*)dict;
 | 
				
			||||||
 | 
					- (NSDictionary*) asDictionary;
 | 
				
			||||||
 | 
					- (NSDictionary*) asRaw;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					@end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
							
								
								
									
										71
									
								
								samples/client/petstore/objc/client/NIKOrder.m
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										71
									
								
								samples/client/petstore/objc/client/NIKOrder.m
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,71 @@
 | 
				
			|||||||
 | 
					#import "NIKDate.h"
 | 
				
			||||||
 | 
					#import "NIKOrder.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					@implementation NIKOrder
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					@synthesize raw = _raw;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					@synthesize _id = __id;
 | 
				
			||||||
 | 
					@synthesize petId = _petId;
 | 
				
			||||||
 | 
					@synthesize status = _status;
 | 
				
			||||||
 | 
					@synthesize quantity = _quantity;
 | 
				
			||||||
 | 
					@synthesize shipDate = _shipDate;
 | 
				
			||||||
 | 
					- (id) _id: (NSNumber*) _id
 | 
				
			||||||
 | 
					       petId: (NSNumber*) petId
 | 
				
			||||||
 | 
					       status: (NSString*) status
 | 
				
			||||||
 | 
					       quantity: (NSNumber*) quantity
 | 
				
			||||||
 | 
					       shipDate: (NIKDate*) shipDate
 | 
				
			||||||
 | 
					       {
 | 
				
			||||||
 | 
					          __id = _id;
 | 
				
			||||||
 | 
					          _petId = petId;
 | 
				
			||||||
 | 
					          _status = status;
 | 
				
			||||||
 | 
					          _quantity = quantity;
 | 
				
			||||||
 | 
					          _shipDate = shipDate;
 | 
				
			||||||
 | 
					          return self;
 | 
				
			||||||
 | 
					       }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					- (id) initWithValues: (NSDictionary*)dict
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    __id = [dict objectForKey:@"id"];
 | 
				
			||||||
 | 
					    _petId = [dict objectForKey:@"petId"];
 | 
				
			||||||
 | 
					    _status = [dict objectForKey:@"status"];
 | 
				
			||||||
 | 
					    _quantity = [dict objectForKey:@"quantity"];
 | 
				
			||||||
 | 
					    id shipDate_dict = [dict objectForKey:@"shipDate"];
 | 
				
			||||||
 | 
					    _shipDate = [[NIKDate alloc]initWithValues:shipDate_dict];
 | 
				
			||||||
 | 
					    self.raw = [[NSDictionary alloc] initWithDictionary:dict];
 | 
				
			||||||
 | 
					    return self;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					-(NSDictionary*) asDictionary {
 | 
				
			||||||
 | 
					    NSMutableDictionary* dict = [[NSMutableDictionary alloc] init];
 | 
				
			||||||
 | 
					    if(__id != nil) [dict setObject:__id forKey:@"id"];
 | 
				
			||||||
 | 
					    if(_petId != nil) [dict setObject:_petId forKey:@"petId"];
 | 
				
			||||||
 | 
					    if(_status != nil) [dict setObject:_status forKey:@"status"];
 | 
				
			||||||
 | 
					    if(_quantity != nil) [dict setObject:_quantity forKey:@"quantity"];
 | 
				
			||||||
 | 
					    if(_shipDate != nil){
 | 
				
			||||||
 | 
					        if([_shipDate isKindOfClass:[NSArray class]]){
 | 
				
			||||||
 | 
					            NSMutableArray * array = [[NSMutableArray alloc] init];
 | 
				
			||||||
 | 
					            for( NIKDate * shipDate in (NSArray*)_shipDate) {
 | 
				
			||||||
 | 
					                [array addObject:[(NIKSwaggerObject*)shipDate asDictionary]];
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            [dict setObject:array forKey:@"shipDate"];
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        else if(_shipDate && [_shipDate isKindOfClass:[NIKDate class]]) {
 | 
				
			||||||
 | 
					            NSString * dateString = [(NIKDate*)_shipDate toString];
 | 
				
			||||||
 | 
					            if(dateString){
 | 
				
			||||||
 | 
					                [dict setObject:dateString forKey:@"shipDate"];   
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    else {
 | 
				
			||||||
 | 
					    if(_shipDate != nil) [dict setObject:[(NIKSwaggerObject*)_shipDate asDictionary]forKey:@"shipDate"];
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    NSDictionary* output = [dict copy];
 | 
				
			||||||
 | 
					    return output;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					-(NSDictionary*) asRaw {
 | 
				
			||||||
 | 
					    return _raw;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					@end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
							
								
								
									
										39
									
								
								samples/client/petstore/objc/client/NIKPet.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										39
									
								
								samples/client/petstore/objc/client/NIKPet.h
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,39 @@
 | 
				
			|||||||
 | 
					#import <Foundation/Foundation.h>
 | 
				
			||||||
 | 
					#import "NIKSwaggerObject.h"
 | 
				
			||||||
 | 
					#import "NIKCategory.h"
 | 
				
			||||||
 | 
					#import "NIKTag.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					@interface NIKPet : NIKSwaggerObject {
 | 
				
			||||||
 | 
					@private
 | 
				
			||||||
 | 
					    NSDictionary* raw;
 | 
				
			||||||
 | 
					    NSNumber* __id; //NSNumber
 | 
				
			||||||
 | 
					    NSArray* _tags; //Tag
 | 
				
			||||||
 | 
					    NIKCategory* _category; //Category
 | 
				
			||||||
 | 
					    NSString* _status; //NSString
 | 
				
			||||||
 | 
					    NSString* _name; //NSString
 | 
				
			||||||
 | 
					    NSArray* _photoUrls; //NSString
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					@property(nonatomic) NSDictionary* raw;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					@property(nonatomic) NSNumber* _id;
 | 
				
			||||||
 | 
					@property(nonatomic) NSArray* tags;
 | 
				
			||||||
 | 
					@property(nonatomic) NIKCategory* category;
 | 
				
			||||||
 | 
					@property(nonatomic) NSString* status;
 | 
				
			||||||
 | 
					@property(nonatomic) NSString* name;
 | 
				
			||||||
 | 
					@property(nonatomic) NSArray* photoUrls;
 | 
				
			||||||
 | 
					- (id) _id: (NSNumber*) _id
 | 
				
			||||||
 | 
					     tags: (NSArray*) tags
 | 
				
			||||||
 | 
					     category: (NIKCategory*) category
 | 
				
			||||||
 | 
					     status: (NSString*) status
 | 
				
			||||||
 | 
					     name: (NSString*) name
 | 
				
			||||||
 | 
					     photoUrls: (NSArray*) photoUrls;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					- (id) initWithValues: (NSDictionary*)dict;
 | 
				
			||||||
 | 
					- (NSDictionary*) asDictionary;
 | 
				
			||||||
 | 
					- (NSDictionary*) asRaw;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					@end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
							
								
								
									
										106
									
								
								samples/client/petstore/objc/client/NIKPet.m
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										106
									
								
								samples/client/petstore/objc/client/NIKPet.m
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,106 @@
 | 
				
			|||||||
 | 
					#import "NIKDate.h"
 | 
				
			||||||
 | 
					#import "NIKPet.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					@implementation NIKPet
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					@synthesize raw = _raw;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					@synthesize _id = __id;
 | 
				
			||||||
 | 
					@synthesize tags = _tags;
 | 
				
			||||||
 | 
					@synthesize category = _category;
 | 
				
			||||||
 | 
					@synthesize status = _status;
 | 
				
			||||||
 | 
					@synthesize name = _name;
 | 
				
			||||||
 | 
					@synthesize photoUrls = _photoUrls;
 | 
				
			||||||
 | 
					- (id) _id: (NSNumber*) _id
 | 
				
			||||||
 | 
					       tags: (NSArray*) tags
 | 
				
			||||||
 | 
					       category: (NIKCategory*) category
 | 
				
			||||||
 | 
					       status: (NSString*) status
 | 
				
			||||||
 | 
					       name: (NSString*) name
 | 
				
			||||||
 | 
					       photoUrls: (NSArray*) photoUrls
 | 
				
			||||||
 | 
					       {
 | 
				
			||||||
 | 
					          __id = _id;
 | 
				
			||||||
 | 
					          _tags = tags;
 | 
				
			||||||
 | 
					          _category = category;
 | 
				
			||||||
 | 
					          _status = status;
 | 
				
			||||||
 | 
					          _name = name;
 | 
				
			||||||
 | 
					          _photoUrls = photoUrls;
 | 
				
			||||||
 | 
					          return self;
 | 
				
			||||||
 | 
					       }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					- (id) initWithValues: (NSDictionary*)dict
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    __id = [dict objectForKey:@"id"];
 | 
				
			||||||
 | 
					    id tags_dict = [dict objectForKey:@"tags"];
 | 
				
			||||||
 | 
					    if([tags_dict isKindOfClass:[NSArray class]]) {
 | 
				
			||||||
 | 
					        if([(NSArray*)tags_dict count] > 0) {
 | 
				
			||||||
 | 
					            NSMutableArray * objs = [[NSMutableArray alloc] initWithCapacity:[(NSArray*)tags_dict count]];
 | 
				
			||||||
 | 
					            for (NSDictionary* dict in (NSArray*)tags_dict) {
 | 
				
			||||||
 | 
					                NIKTag* d = [[NIKTag alloc]initWithValues:dict];
 | 
				
			||||||
 | 
					                [objs addObject:d];
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            _tags = [[NSArray alloc] initWithArray:objs];
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
 | 
					    else if([tags_dict isKindOfClass:[NSDictionary class]] && [(NSDictionary*)tags_dict count] > 0) {
 | 
				
			||||||
 | 
					        _tags = [[NIKTag alloc]initWithValues:(NSDictionary*)tags_dict];
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    id category_dict = [dict objectForKey:@"category"];
 | 
				
			||||||
 | 
					    _category = [[NIKCategory alloc]initWithValues:category_dict];
 | 
				
			||||||
 | 
					    _status = [dict objectForKey:@"status"];
 | 
				
			||||||
 | 
					    _name = [dict objectForKey:@"name"];
 | 
				
			||||||
 | 
					    _photoUrls = [dict objectForKey:@"photoUrls"];
 | 
				
			||||||
 | 
					    self.raw = [[NSDictionary alloc] initWithDictionary:dict];
 | 
				
			||||||
 | 
					    return self;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					-(NSDictionary*) asDictionary {
 | 
				
			||||||
 | 
					    NSMutableDictionary* dict = [[NSMutableDictionary alloc] init];
 | 
				
			||||||
 | 
					    if(__id != nil) [dict setObject:__id forKey:@"id"];
 | 
				
			||||||
 | 
					    if(_tags != nil){
 | 
				
			||||||
 | 
					        if([_tags isKindOfClass:[NSArray class]]){
 | 
				
			||||||
 | 
					            NSMutableArray * array = [[NSMutableArray alloc] init];
 | 
				
			||||||
 | 
					            for( NIKTag * tags in (NSArray*)_tags) {
 | 
				
			||||||
 | 
					                [array addObject:[(NIKSwaggerObject*)tags asDictionary]];
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            [dict setObject:array forKey:@"tags"];
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        else if(_tags && [_tags isKindOfClass:[NIKDate class]]) {
 | 
				
			||||||
 | 
					            NSString * dateString = [(NIKDate*)_tags toString];
 | 
				
			||||||
 | 
					            if(dateString){
 | 
				
			||||||
 | 
					                [dict setObject:dateString forKey:@"tags"];   
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    else {
 | 
				
			||||||
 | 
					    if(_tags != nil) [dict setObject:[(NIKSwaggerObject*)_tags asDictionary]forKey:@"tags"];
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    if(_category != nil){
 | 
				
			||||||
 | 
					        if([_category isKindOfClass:[NSArray class]]){
 | 
				
			||||||
 | 
					            NSMutableArray * array = [[NSMutableArray alloc] init];
 | 
				
			||||||
 | 
					            for( NIKCategory * category in (NSArray*)_category) {
 | 
				
			||||||
 | 
					                [array addObject:[(NIKSwaggerObject*)category asDictionary]];
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            [dict setObject:array forKey:@"category"];
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        else if(_category && [_category isKindOfClass:[NIKDate class]]) {
 | 
				
			||||||
 | 
					            NSString * dateString = [(NIKDate*)_category toString];
 | 
				
			||||||
 | 
					            if(dateString){
 | 
				
			||||||
 | 
					                [dict setObject:dateString forKey:@"category"];   
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    else {
 | 
				
			||||||
 | 
					    if(_category != nil) [dict setObject:[(NIKSwaggerObject*)_category asDictionary]forKey:@"category"];
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    if(_status != nil) [dict setObject:_status forKey:@"status"];
 | 
				
			||||||
 | 
					    if(_name != nil) [dict setObject:_name forKey:@"name"];
 | 
				
			||||||
 | 
					    if(_photoUrls != nil) [dict setObject:_photoUrls forKey:@"photoUrls"];
 | 
				
			||||||
 | 
					    NSDictionary* output = [dict copy];
 | 
				
			||||||
 | 
					    return output;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					-(NSDictionary*) asRaw {
 | 
				
			||||||
 | 
					    return _raw;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					@end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
							
								
								
									
										28
									
								
								samples/client/petstore/objc/client/NIKPetApi.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										28
									
								
								samples/client/petstore/objc/client/NIKPetApi.h
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,28 @@
 | 
				
			|||||||
 | 
					#import <Foundation/Foundation.h>
 | 
				
			||||||
 | 
					#import "NIKApiInvoker.h"
 | 
				
			||||||
 | 
					#import "NIKPet.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					@interface NIKPetApi: NSObject {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					@private
 | 
				
			||||||
 | 
					    NSOperationQueue *_queue;
 | 
				
			||||||
 | 
					    NIKApiInvoker * _api;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					@property(nonatomic, readonly) NSOperationQueue* queue;
 | 
				
			||||||
 | 
					@property(nonatomic, readonly) NIKApiInvoker* api;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					-(void) addHeader:(NSString*) value
 | 
				
			||||||
 | 
					           forKey:(NSString*)key;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					-(void) getPetByIdWithCompletionBlock :(NSString*) petId 
 | 
				
			||||||
 | 
					        completionHandler:(void (^)(NIKPet*, NSError *))completionBlock;
 | 
				
			||||||
 | 
					-(void) addPetWithCompletionBlock :(NIKPet*) body 
 | 
				
			||||||
 | 
					        completionHandler:(void (^)(NSError *))completionBlock;
 | 
				
			||||||
 | 
					-(void) updatePetWithCompletionBlock :(NIKPet*) body 
 | 
				
			||||||
 | 
					        completionHandler:(void (^)(NSError *))completionBlock;
 | 
				
			||||||
 | 
					-(void) findPetsByStatusWithCompletionBlock :(NSString*) status 
 | 
				
			||||||
 | 
					        completionHandler:(void (^)(NSArray*, NSError *))completionBlock;
 | 
				
			||||||
 | 
					-(void) findPetsByTagsWithCompletionBlock :(NSString*) tags 
 | 
				
			||||||
 | 
					        completionHandler:(void (^)(NSArray*, NSError *))completionBlock;
 | 
				
			||||||
 | 
					@end
 | 
				
			||||||
							
								
								
									
										473
									
								
								samples/client/petstore/objc/client/NIKPetApi.m
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										473
									
								
								samples/client/petstore/objc/client/NIKPetApi.m
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,473 @@
 | 
				
			|||||||
 | 
					#import "NIKPetApi.h"
 | 
				
			||||||
 | 
					#import "NIKPet.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					@implementation NIKPetApi
 | 
				
			||||||
 | 
					static NSString * basePath = @"http://petstore.swagger.wordnik.com/api";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					@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];
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					-(void) getPetByIdWithCompletionBlock :(NSString*) petId 
 | 
				
			||||||
 | 
					        completionHandler:(void (^)(NIKPet*, NSError *))completionBlock{
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    NSMutableString* requestUrl = [NSMutableString stringWithFormat:@"%@/pet.{format}/{petId}", 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:@"%@%@%@", @"{", @"petId", @"}"]] withString: [_api escapeString:petId]];
 | 
				
			||||||
 | 
					    NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init];
 | 
				
			||||||
 | 
					    NSMutableDictionary* headerParams = [[NSMutableDictionary alloc] init];
 | 
				
			||||||
 | 
					    id bodyDictionary = nil;
 | 
				
			||||||
 | 
					        if(petId == nil) {
 | 
				
			||||||
 | 
					        // error
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    [_api dictionaryWithCompletionBlock: requestUrl 
 | 
				
			||||||
 | 
					                                 method: @"GET" 
 | 
				
			||||||
 | 
					                            queryParams: queryParams 
 | 
				
			||||||
 | 
					                                   body: bodyDictionary 
 | 
				
			||||||
 | 
					                           headerParams: headerParams
 | 
				
			||||||
 | 
					                      completionHandler: ^(NSDictionary *data, NSError *error) {
 | 
				
			||||||
 | 
					    if (error) {
 | 
				
			||||||
 | 
					            completionBlock(nil, error);return;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        completionBlock( [[NIKPet alloc]initWithValues: data], nil);
 | 
				
			||||||
 | 
					    }];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					-(void) addPetWithCompletionBlock :(NIKPet*) body 
 | 
				
			||||||
 | 
					        completionHandler:(void (^)(NSError *))completionBlock{
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    NSMutableString* requestUrl = [NSMutableString stringWithFormat:@"%@/pet.{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];
 | 
				
			||||||
 | 
					    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(body == nil) {
 | 
				
			||||||
 | 
					        // error
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    [_api stringWithCompletionBlock: requestUrl 
 | 
				
			||||||
 | 
					                             method: @"POST" 
 | 
				
			||||||
 | 
					                        queryParams: queryParams 
 | 
				
			||||||
 | 
					                               body: bodyDictionary 
 | 
				
			||||||
 | 
					                       headerParams: headerParams
 | 
				
			||||||
 | 
					                  completionHandler: ^(NSString *data, NSError *error) {
 | 
				
			||||||
 | 
					    if (error) {
 | 
				
			||||||
 | 
					            completionBlock(error);return;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        completionBlock(nil);
 | 
				
			||||||
 | 
					    }];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					-(void) updatePetWithCompletionBlock :(NIKPet*) body 
 | 
				
			||||||
 | 
					        completionHandler:(void (^)(NSError *))completionBlock{
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    NSMutableString* requestUrl = [NSMutableString stringWithFormat:@"%@/pet.{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];
 | 
				
			||||||
 | 
					    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(body == nil) {
 | 
				
			||||||
 | 
					        // error
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    [_api stringWithCompletionBlock: requestUrl 
 | 
				
			||||||
 | 
					                             method: @"PUT" 
 | 
				
			||||||
 | 
					                        queryParams: queryParams 
 | 
				
			||||||
 | 
					                               body: bodyDictionary 
 | 
				
			||||||
 | 
					                       headerParams: headerParams
 | 
				
			||||||
 | 
					                  completionHandler: ^(NSString *data, NSError *error) {
 | 
				
			||||||
 | 
					    if (error) {
 | 
				
			||||||
 | 
					            completionBlock(error);return;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        completionBlock(nil);
 | 
				
			||||||
 | 
					    }];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					-(void) findPetsByStatusWithCompletionBlock :(NSString*) status 
 | 
				
			||||||
 | 
					        completionHandler:(void (^)(NSArray*, NSError *))completionBlock{
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    NSMutableString* requestUrl = [NSMutableString stringWithFormat:@"%@/pet.{format}/findByStatus", 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(status != nil)
 | 
				
			||||||
 | 
					        [queryParams setValue:status forKey:@"status"];
 | 
				
			||||||
 | 
					    NSMutableDictionary* headerParams = [[NSMutableDictionary alloc] init];
 | 
				
			||||||
 | 
					    id bodyDictionary = nil;
 | 
				
			||||||
 | 
					        if(status == nil) {
 | 
				
			||||||
 | 
					        // error
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    [_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) {
 | 
				
			||||||
 | 
					                NIKPet* d = [[NIKPet alloc]initWithValues: dict];
 | 
				
			||||||
 | 
					                [objs addObject:d];
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            completionBlock(objs, nil);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					    }];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					-(void) findPetsByTagsWithCompletionBlock :(NSString*) tags 
 | 
				
			||||||
 | 
					        completionHandler:(void (^)(NSArray*, NSError *))completionBlock{
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    NSMutableString* requestUrl = [NSMutableString stringWithFormat:@"%@/pet.{format}/findByTags", 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(tags != nil)
 | 
				
			||||||
 | 
					        [queryParams setValue:tags forKey:@"tags"];
 | 
				
			||||||
 | 
					    NSMutableDictionary* headerParams = [[NSMutableDictionary alloc] init];
 | 
				
			||||||
 | 
					    id bodyDictionary = nil;
 | 
				
			||||||
 | 
					        if(tags == nil) {
 | 
				
			||||||
 | 
					        // error
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    [_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) {
 | 
				
			||||||
 | 
					                NIKPet* d = [[NIKPet alloc]initWithValues: dict];
 | 
				
			||||||
 | 
					                [objs addObject:d];
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            completionBlock(objs, nil);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					    }];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					-(void) getPetByIdAsJsonWithCompletionBlock :(NSString*) petId 
 | 
				
			||||||
 | 
					        completionHandler:(void (^)(NSString*, NSError *))completionBlock{
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    NSMutableString* requestUrl = [NSMutableString stringWithFormat:@"%@/pet.{format}/{petId}", 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:@"%@%@%@", @"{", @"petId", @"}"]] withString: [_api escapeString:petId]];
 | 
				
			||||||
 | 
					    NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init];
 | 
				
			||||||
 | 
					    NSMutableDictionary* headerParams = [[NSMutableDictionary alloc] init];
 | 
				
			||||||
 | 
					    id bodyDictionary = nil;
 | 
				
			||||||
 | 
					    if(petId == 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) addPetAsJsonWithCompletionBlock :(NIKPet*) body 
 | 
				
			||||||
 | 
					        completionHandler:(void (^)(NSError *))completionBlock{
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    NSMutableString* requestUrl = [NSMutableString stringWithFormat:@"%@/pet.{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];
 | 
				
			||||||
 | 
					    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(body == 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) updatePetAsJsonWithCompletionBlock :(NIKPet*) body 
 | 
				
			||||||
 | 
					        completionHandler:(void (^)(NSError *))completionBlock{
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    NSMutableString* requestUrl = [NSMutableString stringWithFormat:@"%@/pet.{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];
 | 
				
			||||||
 | 
					    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(body == 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) findPetsByStatusAsJsonWithCompletionBlock :(NSString*) status 
 | 
				
			||||||
 | 
					        completionHandler:(void (^)(NSString*, NSError *))completionBlock{
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    NSMutableString* requestUrl = [NSMutableString stringWithFormat:@"%@/pet.{format}/findByStatus", 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(status != nil)
 | 
				
			||||||
 | 
					        [queryParams setValue:status forKey:@"status"];
 | 
				
			||||||
 | 
					    NSMutableDictionary* headerParams = [[NSMutableDictionary alloc] init];
 | 
				
			||||||
 | 
					    id bodyDictionary = nil;
 | 
				
			||||||
 | 
					    if(status == 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) findPetsByTagsAsJsonWithCompletionBlock :(NSString*) tags 
 | 
				
			||||||
 | 
					        completionHandler:(void (^)(NSString*, NSError *))completionBlock{
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    NSMutableString* requestUrl = [NSMutableString stringWithFormat:@"%@/pet.{format}/findByTags", 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(tags != nil)
 | 
				
			||||||
 | 
					        [queryParams setValue:tags forKey:@"tags"];
 | 
				
			||||||
 | 
					    NSMutableDictionary* headerParams = [[NSMutableDictionary alloc] init];
 | 
				
			||||||
 | 
					    id bodyDictionary = nil;
 | 
				
			||||||
 | 
					    if(tags == 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
 | 
				
			||||||
							
								
								
									
										24
									
								
								samples/client/petstore/objc/client/NIKStoreApi.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										24
									
								
								samples/client/petstore/objc/client/NIKStoreApi.h
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,24 @@
 | 
				
			|||||||
 | 
					#import <Foundation/Foundation.h>
 | 
				
			||||||
 | 
					#import "NIKApiInvoker.h"
 | 
				
			||||||
 | 
					#import "NIKOrder.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					@interface NIKStoreApi: NSObject {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					@private
 | 
				
			||||||
 | 
					    NSOperationQueue *_queue;
 | 
				
			||||||
 | 
					    NIKApiInvoker * _api;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					@property(nonatomic, readonly) NSOperationQueue* queue;
 | 
				
			||||||
 | 
					@property(nonatomic, readonly) NIKApiInvoker* api;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					-(void) addHeader:(NSString*) value
 | 
				
			||||||
 | 
					           forKey:(NSString*)key;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					-(void) getOrderByIdWithCompletionBlock :(NSString*) orderId 
 | 
				
			||||||
 | 
					        completionHandler:(void (^)(NIKOrder*, NSError *))completionBlock;
 | 
				
			||||||
 | 
					-(void) deleteOrderWithCompletionBlock :(NSString*) orderId 
 | 
				
			||||||
 | 
					        completionHandler:(void (^)(NSError *))completionBlock;
 | 
				
			||||||
 | 
					-(void) placeOrderWithCompletionBlock :(NIKOrder*) body 
 | 
				
			||||||
 | 
					        completionHandler:(void (^)(NSError *))completionBlock;
 | 
				
			||||||
 | 
					@end
 | 
				
			||||||
							
								
								
									
										265
									
								
								samples/client/petstore/objc/client/NIKStoreApi.m
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										265
									
								
								samples/client/petstore/objc/client/NIKStoreApi.m
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,265 @@
 | 
				
			|||||||
 | 
					#import "NIKStoreApi.h"
 | 
				
			||||||
 | 
					#import "NIKOrder.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					@implementation NIKStoreApi
 | 
				
			||||||
 | 
					static NSString * basePath = @"http://petstore.swagger.wordnik.com/api";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					@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];
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					-(void) getOrderByIdWithCompletionBlock :(NSString*) orderId 
 | 
				
			||||||
 | 
					        completionHandler:(void (^)(NIKOrder*, NSError *))completionBlock{
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    NSMutableString* requestUrl = [NSMutableString stringWithFormat:@"%@/store.{format}/order/{orderId}", 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:@"%@%@%@", @"{", @"orderId", @"}"]] withString: [_api escapeString:orderId]];
 | 
				
			||||||
 | 
					    NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init];
 | 
				
			||||||
 | 
					    NSMutableDictionary* headerParams = [[NSMutableDictionary alloc] init];
 | 
				
			||||||
 | 
					    id bodyDictionary = nil;
 | 
				
			||||||
 | 
					        if(orderId == nil) {
 | 
				
			||||||
 | 
					        // error
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    [_api dictionaryWithCompletionBlock: requestUrl 
 | 
				
			||||||
 | 
					                                 method: @"GET" 
 | 
				
			||||||
 | 
					                            queryParams: queryParams 
 | 
				
			||||||
 | 
					                                   body: bodyDictionary 
 | 
				
			||||||
 | 
					                           headerParams: headerParams
 | 
				
			||||||
 | 
					                      completionHandler: ^(NSDictionary *data, NSError *error) {
 | 
				
			||||||
 | 
					    if (error) {
 | 
				
			||||||
 | 
					            completionBlock(nil, error);return;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        completionBlock( [[NIKOrder alloc]initWithValues: data], nil);
 | 
				
			||||||
 | 
					    }];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					-(void) deleteOrderWithCompletionBlock :(NSString*) orderId 
 | 
				
			||||||
 | 
					        completionHandler:(void (^)(NSError *))completionBlock{
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    NSMutableString* requestUrl = [NSMutableString stringWithFormat:@"%@/store.{format}/order/{orderId}", 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:@"%@%@%@", @"{", @"orderId", @"}"]] withString: [_api escapeString:orderId]];
 | 
				
			||||||
 | 
					    NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init];
 | 
				
			||||||
 | 
					    NSMutableDictionary* headerParams = [[NSMutableDictionary alloc] init];
 | 
				
			||||||
 | 
					    id bodyDictionary = nil;
 | 
				
			||||||
 | 
					        if(orderId == nil) {
 | 
				
			||||||
 | 
					        // error
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    [_api stringWithCompletionBlock: requestUrl 
 | 
				
			||||||
 | 
					                             method: @"DELETE" 
 | 
				
			||||||
 | 
					                        queryParams: queryParams 
 | 
				
			||||||
 | 
					                               body: bodyDictionary 
 | 
				
			||||||
 | 
					                       headerParams: headerParams
 | 
				
			||||||
 | 
					                  completionHandler: ^(NSString *data, NSError *error) {
 | 
				
			||||||
 | 
					    if (error) {
 | 
				
			||||||
 | 
					            completionBlock(error);return;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        completionBlock(nil);
 | 
				
			||||||
 | 
					    }];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					-(void) placeOrderWithCompletionBlock :(NIKOrder*) body 
 | 
				
			||||||
 | 
					        completionHandler:(void (^)(NSError *))completionBlock{
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    NSMutableString* requestUrl = [NSMutableString stringWithFormat:@"%@/store.{format}/order", 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];
 | 
				
			||||||
 | 
					    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(body == nil) {
 | 
				
			||||||
 | 
					        // error
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    [_api stringWithCompletionBlock: requestUrl 
 | 
				
			||||||
 | 
					                             method: @"POST" 
 | 
				
			||||||
 | 
					                        queryParams: queryParams 
 | 
				
			||||||
 | 
					                               body: bodyDictionary 
 | 
				
			||||||
 | 
					                       headerParams: headerParams
 | 
				
			||||||
 | 
					                  completionHandler: ^(NSString *data, NSError *error) {
 | 
				
			||||||
 | 
					    if (error) {
 | 
				
			||||||
 | 
					            completionBlock(error);return;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        completionBlock(nil);
 | 
				
			||||||
 | 
					    }];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					-(void) getOrderByIdAsJsonWithCompletionBlock :(NSString*) orderId 
 | 
				
			||||||
 | 
					        completionHandler:(void (^)(NSString*, NSError *))completionBlock{
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    NSMutableString* requestUrl = [NSMutableString stringWithFormat:@"%@/store.{format}/order/{orderId}", 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:@"%@%@%@", @"{", @"orderId", @"}"]] withString: [_api escapeString:orderId]];
 | 
				
			||||||
 | 
					    NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init];
 | 
				
			||||||
 | 
					    NSMutableDictionary* headerParams = [[NSMutableDictionary alloc] init];
 | 
				
			||||||
 | 
					    id bodyDictionary = nil;
 | 
				
			||||||
 | 
					    if(orderId == 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) deleteOrderAsJsonWithCompletionBlock :(NSString*) orderId 
 | 
				
			||||||
 | 
					        completionHandler:(void (^)(NSError *))completionBlock{
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    NSMutableString* requestUrl = [NSMutableString stringWithFormat:@"%@/store.{format}/order/{orderId}", 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:@"%@%@%@", @"{", @"orderId", @"}"]] withString: [_api escapeString:orderId]];
 | 
				
			||||||
 | 
					    NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init];
 | 
				
			||||||
 | 
					    NSMutableDictionary* headerParams = [[NSMutableDictionary alloc] init];
 | 
				
			||||||
 | 
					    id bodyDictionary = nil;
 | 
				
			||||||
 | 
					    if(orderId == 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) placeOrderAsJsonWithCompletionBlock :(NIKOrder*) body 
 | 
				
			||||||
 | 
					        completionHandler:(void (^)(NSError *))completionBlock{
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    NSMutableString* requestUrl = [NSMutableString stringWithFormat:@"%@/store.{format}/order", 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];
 | 
				
			||||||
 | 
					    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(body == 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
 | 
				
			||||||
							
								
								
									
										6
									
								
								samples/client/petstore/objc/client/NIKSwaggerObject.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										6
									
								
								samples/client/petstore/objc/client/NIKSwaggerObject.h
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,6 @@
 | 
				
			|||||||
 | 
					#import <Foundation/Foundation.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					@interface NIKSwaggerObject : NSObject
 | 
				
			||||||
 | 
					- (id) initWithValues: (NSDictionary*)dict;
 | 
				
			||||||
 | 
					- (NSDictionary*) asDictionary;
 | 
				
			||||||
 | 
					@end
 | 
				
			||||||
							
								
								
									
										10
									
								
								samples/client/petstore/objc/client/NIKSwaggerObject.m
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										10
									
								
								samples/client/petstore/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/petstore/objc/client/NIKTag.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										25
									
								
								samples/client/petstore/objc/client/NIKTag.h
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,25 @@
 | 
				
			|||||||
 | 
					#import <Foundation/Foundation.h>
 | 
				
			||||||
 | 
					#import "NIKSwaggerObject.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					@interface NIKTag : NIKSwaggerObject {
 | 
				
			||||||
 | 
					@private
 | 
				
			||||||
 | 
					    NSDictionary* raw;
 | 
				
			||||||
 | 
					    NSNumber* __id; //NSNumber
 | 
				
			||||||
 | 
					    NSString* _name; //NSString
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					@property(nonatomic) NSDictionary* raw;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					@property(nonatomic) NSNumber* _id;
 | 
				
			||||||
 | 
					@property(nonatomic) NSString* name;
 | 
				
			||||||
 | 
					- (id) _id: (NSNumber*) _id
 | 
				
			||||||
 | 
					     name: (NSString*) name;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					- (id) initWithValues: (NSDictionary*)dict;
 | 
				
			||||||
 | 
					- (NSDictionary*) asDictionary;
 | 
				
			||||||
 | 
					- (NSDictionary*) asRaw;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					@end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
							
								
								
									
										38
									
								
								samples/client/petstore/objc/client/NIKTag.m
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										38
									
								
								samples/client/petstore/objc/client/NIKTag.m
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,38 @@
 | 
				
			|||||||
 | 
					#import "NIKDate.h"
 | 
				
			||||||
 | 
					#import "NIKTag.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					@implementation NIKTag
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					@synthesize raw = _raw;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					@synthesize _id = __id;
 | 
				
			||||||
 | 
					@synthesize name = _name;
 | 
				
			||||||
 | 
					- (id) _id: (NSNumber*) _id
 | 
				
			||||||
 | 
					       name: (NSString*) name
 | 
				
			||||||
 | 
					       {
 | 
				
			||||||
 | 
					          __id = _id;
 | 
				
			||||||
 | 
					          _name = name;
 | 
				
			||||||
 | 
					          return self;
 | 
				
			||||||
 | 
					       }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					- (id) initWithValues: (NSDictionary*)dict
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    __id = [dict objectForKey:@"id"];
 | 
				
			||||||
 | 
					    _name = [dict objectForKey:@"name"];
 | 
				
			||||||
 | 
					    self.raw = [[NSDictionary alloc] initWithDictionary:dict];
 | 
				
			||||||
 | 
					    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;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					-(NSDictionary*) asRaw {
 | 
				
			||||||
 | 
					    return _raw;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					@end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
							
								
								
									
										43
									
								
								samples/client/petstore/objc/client/NIKUser.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										43
									
								
								samples/client/petstore/objc/client/NIKUser.h
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,43 @@
 | 
				
			|||||||
 | 
					#import <Foundation/Foundation.h>
 | 
				
			||||||
 | 
					#import "NIKSwaggerObject.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					@interface NIKUser : NIKSwaggerObject {
 | 
				
			||||||
 | 
					@private
 | 
				
			||||||
 | 
					    NSDictionary* raw;
 | 
				
			||||||
 | 
					    NSNumber* __id; //NSNumber
 | 
				
			||||||
 | 
					    NSString* _lastName; //NSString
 | 
				
			||||||
 | 
					    NSString* _username; //NSString
 | 
				
			||||||
 | 
					    NSString* _phone; //NSString
 | 
				
			||||||
 | 
					    NSString* _email; //NSString
 | 
				
			||||||
 | 
					    NSNumber* _userStatus; //NSNumber
 | 
				
			||||||
 | 
					    NSString* _firstName; //NSString
 | 
				
			||||||
 | 
					    NSString* _password; //NSString
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					@property(nonatomic) NSDictionary* raw;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					@property(nonatomic) NSNumber* _id;
 | 
				
			||||||
 | 
					@property(nonatomic) NSString* lastName;
 | 
				
			||||||
 | 
					@property(nonatomic) NSString* username;
 | 
				
			||||||
 | 
					@property(nonatomic) NSString* phone;
 | 
				
			||||||
 | 
					@property(nonatomic) NSString* email;
 | 
				
			||||||
 | 
					@property(nonatomic) NSNumber* userStatus;
 | 
				
			||||||
 | 
					@property(nonatomic) NSString* firstName;
 | 
				
			||||||
 | 
					@property(nonatomic) NSString* password;
 | 
				
			||||||
 | 
					- (id) _id: (NSNumber*) _id
 | 
				
			||||||
 | 
					     lastName: (NSString*) lastName
 | 
				
			||||||
 | 
					     username: (NSString*) username
 | 
				
			||||||
 | 
					     phone: (NSString*) phone
 | 
				
			||||||
 | 
					     email: (NSString*) email
 | 
				
			||||||
 | 
					     userStatus: (NSNumber*) userStatus
 | 
				
			||||||
 | 
					     firstName: (NSString*) firstName
 | 
				
			||||||
 | 
					     password: (NSString*) password;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					- (id) initWithValues: (NSDictionary*)dict;
 | 
				
			||||||
 | 
					- (NSDictionary*) asDictionary;
 | 
				
			||||||
 | 
					- (NSDictionary*) asRaw;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					@end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
							
								
								
									
										68
									
								
								samples/client/petstore/objc/client/NIKUser.m
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										68
									
								
								samples/client/petstore/objc/client/NIKUser.m
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,68 @@
 | 
				
			|||||||
 | 
					#import "NIKDate.h"
 | 
				
			||||||
 | 
					#import "NIKUser.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					@implementation NIKUser
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					@synthesize raw = _raw;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					@synthesize _id = __id;
 | 
				
			||||||
 | 
					@synthesize lastName = _lastName;
 | 
				
			||||||
 | 
					@synthesize username = _username;
 | 
				
			||||||
 | 
					@synthesize phone = _phone;
 | 
				
			||||||
 | 
					@synthesize email = _email;
 | 
				
			||||||
 | 
					@synthesize userStatus = _userStatus;
 | 
				
			||||||
 | 
					@synthesize firstName = _firstName;
 | 
				
			||||||
 | 
					@synthesize password = _password;
 | 
				
			||||||
 | 
					- (id) _id: (NSNumber*) _id
 | 
				
			||||||
 | 
					       lastName: (NSString*) lastName
 | 
				
			||||||
 | 
					       username: (NSString*) username
 | 
				
			||||||
 | 
					       phone: (NSString*) phone
 | 
				
			||||||
 | 
					       email: (NSString*) email
 | 
				
			||||||
 | 
					       userStatus: (NSNumber*) userStatus
 | 
				
			||||||
 | 
					       firstName: (NSString*) firstName
 | 
				
			||||||
 | 
					       password: (NSString*) password
 | 
				
			||||||
 | 
					       {
 | 
				
			||||||
 | 
					          __id = _id;
 | 
				
			||||||
 | 
					          _lastName = lastName;
 | 
				
			||||||
 | 
					          _username = username;
 | 
				
			||||||
 | 
					          _phone = phone;
 | 
				
			||||||
 | 
					          _email = email;
 | 
				
			||||||
 | 
					          _userStatus = userStatus;
 | 
				
			||||||
 | 
					          _firstName = firstName;
 | 
				
			||||||
 | 
					          _password = password;
 | 
				
			||||||
 | 
					          return self;
 | 
				
			||||||
 | 
					       }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					- (id) initWithValues: (NSDictionary*)dict
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    __id = [dict objectForKey:@"id"];
 | 
				
			||||||
 | 
					    _lastName = [dict objectForKey:@"lastName"];
 | 
				
			||||||
 | 
					    _username = [dict objectForKey:@"username"];
 | 
				
			||||||
 | 
					    _phone = [dict objectForKey:@"phone"];
 | 
				
			||||||
 | 
					    _email = [dict objectForKey:@"email"];
 | 
				
			||||||
 | 
					    _userStatus = [dict objectForKey:@"userStatus"];
 | 
				
			||||||
 | 
					    _firstName = [dict objectForKey:@"firstName"];
 | 
				
			||||||
 | 
					    _password = [dict objectForKey:@"password"];
 | 
				
			||||||
 | 
					    self.raw = [[NSDictionary alloc] initWithDictionary:dict];
 | 
				
			||||||
 | 
					    return self;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					-(NSDictionary*) asDictionary {
 | 
				
			||||||
 | 
					    NSMutableDictionary* dict = [[NSMutableDictionary alloc] init];
 | 
				
			||||||
 | 
					    if(__id != nil) [dict setObject:__id forKey:@"id"];
 | 
				
			||||||
 | 
					    if(_lastName != nil) [dict setObject:_lastName forKey:@"lastName"];
 | 
				
			||||||
 | 
					    if(_username != nil) [dict setObject:_username forKey:@"username"];
 | 
				
			||||||
 | 
					    if(_phone != nil) [dict setObject:_phone forKey:@"phone"];
 | 
				
			||||||
 | 
					    if(_email != nil) [dict setObject:_email forKey:@"email"];
 | 
				
			||||||
 | 
					    if(_userStatus != nil) [dict setObject:_userStatus forKey:@"userStatus"];
 | 
				
			||||||
 | 
					    if(_firstName != nil) [dict setObject:_firstName forKey:@"firstName"];
 | 
				
			||||||
 | 
					    if(_password != nil) [dict setObject:_password forKey:@"password"];
 | 
				
			||||||
 | 
					    NSDictionary* output = [dict copy];
 | 
				
			||||||
 | 
					    return output;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					-(NSDictionary*) asRaw {
 | 
				
			||||||
 | 
					    return _raw;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					@end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
							
								
								
									
										34
									
								
								samples/client/petstore/objc/client/NIKUserApi.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										34
									
								
								samples/client/petstore/objc/client/NIKUserApi.h
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,34 @@
 | 
				
			|||||||
 | 
					#import <Foundation/Foundation.h>
 | 
				
			||||||
 | 
					#import "NIKApiInvoker.h"
 | 
				
			||||||
 | 
					#import "NIKUser.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					@interface NIKUserApi: NSObject {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					@private
 | 
				
			||||||
 | 
					    NSOperationQueue *_queue;
 | 
				
			||||||
 | 
					    NIKApiInvoker * _api;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					@property(nonatomic, readonly) NSOperationQueue* queue;
 | 
				
			||||||
 | 
					@property(nonatomic, readonly) NIKApiInvoker* api;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					-(void) addHeader:(NSString*) value
 | 
				
			||||||
 | 
					           forKey:(NSString*)key;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					-(void) createUsersWithArrayInputWithCompletionBlock :(NSArray*) body 
 | 
				
			||||||
 | 
					        completionHandler:(void (^)(NSError *))completionBlock;
 | 
				
			||||||
 | 
					-(void) createUserWithCompletionBlock :(NIKUser*) body 
 | 
				
			||||||
 | 
					        completionHandler:(void (^)(NSError *))completionBlock;
 | 
				
			||||||
 | 
					-(void) createUsersWithListInputWithCompletionBlock :(NSArray*) body 
 | 
				
			||||||
 | 
					        completionHandler:(void (^)(NSError *))completionBlock;
 | 
				
			||||||
 | 
					-(void) updateUserWithCompletionBlock :(NSString*) username body:(NIKUser*) body 
 | 
				
			||||||
 | 
					        completionHandler:(void (^)(NSError *))completionBlock;
 | 
				
			||||||
 | 
					-(void) deleteUserWithCompletionBlock :(NSString*) username 
 | 
				
			||||||
 | 
					        completionHandler:(void (^)(NSError *))completionBlock;
 | 
				
			||||||
 | 
					-(void) getUserByNameWithCompletionBlock :(NSString*) username 
 | 
				
			||||||
 | 
					        completionHandler:(void (^)(NIKUser*, NSError *))completionBlock;
 | 
				
			||||||
 | 
					-(void) loginUserWithCompletionBlock :(NSString*) username password:(NSString*) password 
 | 
				
			||||||
 | 
					        completionHandler:(void (^)(NSString*, NSError *))completionBlock;
 | 
				
			||||||
 | 
					-(void) logoutUserWithCompletionBlock :
 | 
				
			||||||
 | 
					        completionHandler:(void (^)(NSError *))completionBlock;
 | 
				
			||||||
 | 
					@end
 | 
				
			||||||
							
								
								
									
										724
									
								
								samples/client/petstore/objc/client/NIKUserApi.m
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										724
									
								
								samples/client/petstore/objc/client/NIKUserApi.m
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,724 @@
 | 
				
			|||||||
 | 
					#import "NIKUserApi.h"
 | 
				
			||||||
 | 
					#import "NIKUser.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					@implementation NIKUserApi
 | 
				
			||||||
 | 
					static NSString * basePath = @"http://petstore.swagger.wordnik.com/api";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					@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];
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					-(void) createUsersWithArrayInputWithCompletionBlock :(NSArray*) body 
 | 
				
			||||||
 | 
					        completionHandler:(void (^)(NSError *))completionBlock{
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    NSMutableString* requestUrl = [NSMutableString stringWithFormat:@"%@/user.{format}/createWithArray", 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];
 | 
				
			||||||
 | 
					    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(body == nil) {
 | 
				
			||||||
 | 
					        // error
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    [_api stringWithCompletionBlock: requestUrl 
 | 
				
			||||||
 | 
					                             method: @"POST" 
 | 
				
			||||||
 | 
					                        queryParams: queryParams 
 | 
				
			||||||
 | 
					                               body: bodyDictionary 
 | 
				
			||||||
 | 
					                       headerParams: headerParams
 | 
				
			||||||
 | 
					                  completionHandler: ^(NSString *data, NSError *error) {
 | 
				
			||||||
 | 
					    if (error) {
 | 
				
			||||||
 | 
					            completionBlock(error);return;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        completionBlock(nil);
 | 
				
			||||||
 | 
					    }];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					-(void) createUserWithCompletionBlock :(NIKUser*) body 
 | 
				
			||||||
 | 
					        completionHandler:(void (^)(NSError *))completionBlock{
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    NSMutableString* requestUrl = [NSMutableString stringWithFormat:@"%@/user.{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];
 | 
				
			||||||
 | 
					    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(body == nil) {
 | 
				
			||||||
 | 
					        // error
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    [_api stringWithCompletionBlock: requestUrl 
 | 
				
			||||||
 | 
					                             method: @"POST" 
 | 
				
			||||||
 | 
					                        queryParams: queryParams 
 | 
				
			||||||
 | 
					                               body: bodyDictionary 
 | 
				
			||||||
 | 
					                       headerParams: headerParams
 | 
				
			||||||
 | 
					                  completionHandler: ^(NSString *data, NSError *error) {
 | 
				
			||||||
 | 
					    if (error) {
 | 
				
			||||||
 | 
					            completionBlock(error);return;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        completionBlock(nil);
 | 
				
			||||||
 | 
					    }];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					-(void) createUsersWithListInputWithCompletionBlock :(NSArray*) body 
 | 
				
			||||||
 | 
					        completionHandler:(void (^)(NSError *))completionBlock{
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    NSMutableString* requestUrl = [NSMutableString stringWithFormat:@"%@/user.{format}/createWithList", 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];
 | 
				
			||||||
 | 
					    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(body == nil) {
 | 
				
			||||||
 | 
					        // error
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    [_api stringWithCompletionBlock: requestUrl 
 | 
				
			||||||
 | 
					                             method: @"POST" 
 | 
				
			||||||
 | 
					                        queryParams: queryParams 
 | 
				
			||||||
 | 
					                               body: bodyDictionary 
 | 
				
			||||||
 | 
					                       headerParams: headerParams
 | 
				
			||||||
 | 
					                  completionHandler: ^(NSString *data, NSError *error) {
 | 
				
			||||||
 | 
					    if (error) {
 | 
				
			||||||
 | 
					            completionBlock(error);return;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        completionBlock(nil);
 | 
				
			||||||
 | 
					    }];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					-(void) updateUserWithCompletionBlock :(NSString*) username body:(NIKUser*) body 
 | 
				
			||||||
 | 
					        completionHandler:(void (^)(NSError *))completionBlock{
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    NSMutableString* requestUrl = [NSMutableString stringWithFormat:@"%@/user.{format}/{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
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    [_api stringWithCompletionBlock: requestUrl 
 | 
				
			||||||
 | 
					                             method: @"PUT" 
 | 
				
			||||||
 | 
					                        queryParams: queryParams 
 | 
				
			||||||
 | 
					                               body: bodyDictionary 
 | 
				
			||||||
 | 
					                       headerParams: headerParams
 | 
				
			||||||
 | 
					                  completionHandler: ^(NSString *data, NSError *error) {
 | 
				
			||||||
 | 
					    if (error) {
 | 
				
			||||||
 | 
					            completionBlock(error);return;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        completionBlock(nil);
 | 
				
			||||||
 | 
					    }];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					-(void) deleteUserWithCompletionBlock :(NSString*) username 
 | 
				
			||||||
 | 
					        completionHandler:(void (^)(NSError *))completionBlock{
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    NSMutableString* requestUrl = [NSMutableString stringWithFormat:@"%@/user.{format}/{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(username == nil) {
 | 
				
			||||||
 | 
					        // error
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    [_api stringWithCompletionBlock: requestUrl 
 | 
				
			||||||
 | 
					                             method: @"DELETE" 
 | 
				
			||||||
 | 
					                        queryParams: queryParams 
 | 
				
			||||||
 | 
					                               body: bodyDictionary 
 | 
				
			||||||
 | 
					                       headerParams: headerParams
 | 
				
			||||||
 | 
					                  completionHandler: ^(NSString *data, NSError *error) {
 | 
				
			||||||
 | 
					    if (error) {
 | 
				
			||||||
 | 
					            completionBlock(error);return;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        completionBlock(nil);
 | 
				
			||||||
 | 
					    }];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					-(void) getUserByNameWithCompletionBlock :(NSString*) username 
 | 
				
			||||||
 | 
					        completionHandler:(void (^)(NIKUser*, NSError *))completionBlock{
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    NSMutableString* requestUrl = [NSMutableString stringWithFormat:@"%@/user.{format}/{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(username == nil) {
 | 
				
			||||||
 | 
					        // error
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    [_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) loginUserWithCompletionBlock :(NSString*) username password:(NSString*) password 
 | 
				
			||||||
 | 
					        completionHandler:(void (^)(NSString*, NSError *))completionBlock{
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    NSMutableString* requestUrl = [NSMutableString stringWithFormat:@"%@/user.{format}/login", 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(username != nil)
 | 
				
			||||||
 | 
					        [queryParams setValue:username forKey:@"username"];
 | 
				
			||||||
 | 
					    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 stringWithCompletionBlock: requestUrl 
 | 
				
			||||||
 | 
					                             method: @"GET" 
 | 
				
			||||||
 | 
					                        queryParams: queryParams 
 | 
				
			||||||
 | 
					                               body: bodyDictionary 
 | 
				
			||||||
 | 
					                       headerParams: headerParams
 | 
				
			||||||
 | 
					                  completionHandler: ^(NSString *data, NSError *error) {
 | 
				
			||||||
 | 
					    if (error) {
 | 
				
			||||||
 | 
					            completionBlock(nil, error);return;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        completionBlock( [[NSString alloc]initWithString: data], nil);
 | 
				
			||||||
 | 
					    }];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					-(void) logoutUserWithCompletionBlock :
 | 
				
			||||||
 | 
					        completionHandler:(void (^)(NSError *))completionBlock{
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    NSMutableString* requestUrl = [NSMutableString stringWithFormat:@"%@/user.{format}/logout", 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];
 | 
				
			||||||
 | 
					    id bodyDictionary = nil;
 | 
				
			||||||
 | 
					        [_api stringWithCompletionBlock: requestUrl 
 | 
				
			||||||
 | 
					                             method: @"GET" 
 | 
				
			||||||
 | 
					                        queryParams: queryParams 
 | 
				
			||||||
 | 
					                               body: bodyDictionary 
 | 
				
			||||||
 | 
					                       headerParams: headerParams
 | 
				
			||||||
 | 
					                  completionHandler: ^(NSString *data, NSError *error) {
 | 
				
			||||||
 | 
					    if (error) {
 | 
				
			||||||
 | 
					            completionBlock(error);return;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        completionBlock(nil);
 | 
				
			||||||
 | 
					    }];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					-(void) createUsersWithArrayInputAsJsonWithCompletionBlock :(NSArray*) body 
 | 
				
			||||||
 | 
					        completionHandler:(void (^)(NSError *))completionBlock{
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    NSMutableString* requestUrl = [NSMutableString stringWithFormat:@"%@/user.{format}/createWithArray", 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];
 | 
				
			||||||
 | 
					    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(body == 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) createUserAsJsonWithCompletionBlock :(NIKUser*) body 
 | 
				
			||||||
 | 
					        completionHandler:(void (^)(NSError *))completionBlock{
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    NSMutableString* requestUrl = [NSMutableString stringWithFormat:@"%@/user.{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];
 | 
				
			||||||
 | 
					    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(body == 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) createUsersWithListInputAsJsonWithCompletionBlock :(NSArray*) body 
 | 
				
			||||||
 | 
					        completionHandler:(void (^)(NSError *))completionBlock{
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    NSMutableString* requestUrl = [NSMutableString stringWithFormat:@"%@/user.{format}/createWithList", 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];
 | 
				
			||||||
 | 
					    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(body == 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) updateUserAsJsonWithCompletionBlock :(NSString*) username body:(NIKUser*) body 
 | 
				
			||||||
 | 
					        completionHandler:(void (^)(NSError *))completionBlock{
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    NSMutableString* requestUrl = [NSMutableString stringWithFormat:@"%@/user.{format}/{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: @"PUT" 
 | 
				
			||||||
 | 
					                            queryParams: queryParams 
 | 
				
			||||||
 | 
					                                   body: bodyDictionary 
 | 
				
			||||||
 | 
					                           headerParams: headerParams
 | 
				
			||||||
 | 
					                      completionHandler: ^(NSDictionary *data, NSError *error) {
 | 
				
			||||||
 | 
					        if (error) {
 | 
				
			||||||
 | 
					            completionBlock(error);return;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        completionBlock(nil);
 | 
				
			||||||
 | 
					    }];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					-(void) deleteUserAsJsonWithCompletionBlock :(NSString*) username 
 | 
				
			||||||
 | 
					        completionHandler:(void (^)(NSError *))completionBlock{
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    NSMutableString* requestUrl = [NSMutableString stringWithFormat:@"%@/user.{format}/{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(username == 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) getUserByNameAsJsonWithCompletionBlock :(NSString*) username 
 | 
				
			||||||
 | 
					        completionHandler:(void (^)(NSString*, NSError *))completionBlock{
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    NSMutableString* requestUrl = [NSMutableString stringWithFormat:@"%@/user.{format}/{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(username == 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) loginUserAsJsonWithCompletionBlock :(NSString*) username password:(NSString*) password 
 | 
				
			||||||
 | 
					        completionHandler:(void (^)(NSString*, NSError *))completionBlock{
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    NSMutableString* requestUrl = [NSMutableString stringWithFormat:@"%@/user.{format}/login", 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(username != nil)
 | 
				
			||||||
 | 
					        [queryParams setValue:username forKey:@"username"];
 | 
				
			||||||
 | 
					    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) logoutUserAsJsonWithCompletionBlock :
 | 
				
			||||||
 | 
					        completionHandler:(void (^)(NSError *))completionBlock{
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    NSMutableString* requestUrl = [NSMutableString stringWithFormat:@"%@/user.{format}/logout", 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];
 | 
				
			||||||
 | 
					    id bodyDictionary = nil;
 | 
				
			||||||
 | 
					    [_api dictionaryWithCompletionBlock: requestUrl 
 | 
				
			||||||
 | 
					                                 method: @"GET" 
 | 
				
			||||||
 | 
					                            queryParams: queryParams 
 | 
				
			||||||
 | 
					                                   body: bodyDictionary 
 | 
				
			||||||
 | 
					                           headerParams: headerParams
 | 
				
			||||||
 | 
					                      completionHandler: ^(NSDictionary *data, NSError *error) {
 | 
				
			||||||
 | 
					        if (error) {
 | 
				
			||||||
 | 
					            completionBlock(error);return;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        completionBlock(nil);
 | 
				
			||||||
 | 
					    }];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					@end
 | 
				
			||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user