forked from loafle/openapi-generator-original
updated with latest codegen
This commit is contained in:
parent
8c1539ab24
commit
a38fbe8d21
@ -8,25 +8,31 @@
|
||||
}
|
||||
@property(nonatomic, readonly) NSOperationQueue* queue;
|
||||
@property(nonatomic, readonly) NSMutableDictionary * defaultHeaders;
|
||||
@property(nonatomic, assign) NSURLRequestCachePolicy cachePolicy;
|
||||
|
||||
+ (NIKApiInvoker*)sharedInstance;
|
||||
|
||||
- (void)updateLoadCountWithDelta:(NSInteger)countDelta;
|
||||
- (void)startLoad;
|
||||
- (void)stopLoad;
|
||||
|
||||
|
||||
-(void) addHeader:(NSString*) value
|
||||
forKey:(NSString*)key;
|
||||
-(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;
|
||||
-(void) dictionary:(NSString*) path
|
||||
method:(NSString*) method
|
||||
queryParams:(NSDictionary*) queryParams
|
||||
body:(id)body
|
||||
headerParams:(NSDictionary*) headerParams
|
||||
completionBlock:(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;
|
||||
-(void) stringWithCompletionBlock:(NSString*) path
|
||||
method:(NSString*) method
|
||||
queryParams:(NSDictionary*) queryParams
|
||||
body:(id)body
|
||||
headerParams:(NSDictionary*) headerParams
|
||||
completionBlock:(void (^)(NSString*, NSError *))completionBlock;
|
||||
|
||||
@end
|
||||
|
@ -5,10 +5,42 @@
|
||||
@synthesize queue = _queue;
|
||||
@synthesize defaultHeaders = _defaultHeaders;
|
||||
|
||||
|
||||
static NSInteger __LoadingObjectsCount = 0;
|
||||
|
||||
+ (NIKApiInvoker*)sharedInstance {
|
||||
static NIKApiInvoker *_sharedInstance = nil;
|
||||
if (!_sharedInstance) {
|
||||
_sharedInstance = [[NIKApiInvoker alloc] init];
|
||||
}
|
||||
return _sharedInstance;
|
||||
}
|
||||
|
||||
- (void)updateLoadCountWithDelta:(NSInteger)countDelta {
|
||||
@synchronized(self) {
|
||||
__LoadingObjectsCount += countDelta;
|
||||
__LoadingObjectsCount = (__LoadingObjectsCount < 0) ? 0 : __LoadingObjectsCount ;
|
||||
|
||||
#if TARGET_OS_IPHONE
|
||||
[UIApplication sharedApplication].networkActivityIndicatorVisible = __LoadingObjectsCount > 0;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
- (void)startLoad {
|
||||
[self updateLoadCountWithDelta:1];
|
||||
}
|
||||
|
||||
- (void)stopLoad {
|
||||
[self updateLoadCountWithDelta:-1];
|
||||
}
|
||||
|
||||
|
||||
- (id) init {
|
||||
self = [super init];
|
||||
_queue = [[NSOperationQueue alloc] init];
|
||||
_defaultHeaders = [[NSMutableDictionary alloc] init];
|
||||
_cachePolicy = NSURLRequestUseProtocolCachePolicy;
|
||||
return self;
|
||||
}
|
||||
|
||||
@ -19,19 +51,19 @@
|
||||
|
||||
-(NSString*) escapeString:(NSString *)unescaped {
|
||||
return (NSString *)CFBridgingRelease(CFURLCreateStringByAddingPercentEscapes(
|
||||
NULL,
|
||||
(__bridge CFStringRef) unescaped,
|
||||
NULL,
|
||||
(CFStringRef)@"!*'();:@&=+$,/?%#[]",
|
||||
kCFStringEncodingUTF8));
|
||||
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
|
||||
-(void) dictionary:(NSString*) path
|
||||
method:(NSString*) method
|
||||
queryParams:(NSDictionary*) queryParams
|
||||
body:(id) body
|
||||
headerParams:(NSDictionary*) headerParams
|
||||
completionBlock:(void (^)(NSDictionary*, NSError *))completionBlock
|
||||
{
|
||||
NSMutableString * requestUrl = [NSMutableString stringWithFormat:@"%@", path];
|
||||
NSString * separator = nil;
|
||||
@ -52,108 +84,15 @@
|
||||
counter += 1;
|
||||
}
|
||||
}
|
||||
NSLog(@"request url: %@", requestUrl);
|
||||
if ([[NSUserDefaults standardUserDefaults] boolForKey:@"RVBLogging"]) {
|
||||
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 setCachePolicy:self.cachePolicy];
|
||||
[request setTimeoutInterval:30];
|
||||
|
||||
for(NSString * key in [_defaultHeaders keyEnumerator]){
|
||||
@ -184,15 +123,153 @@
|
||||
[request setHTTPBody:data];
|
||||
|
||||
[request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
|
||||
[request setCachePolicy:NSURLRequestReloadIgnoringLocalCacheData];
|
||||
|
||||
NSLog(@"request: %@", request);
|
||||
}
|
||||
|
||||
// Handle caching on GET requests
|
||||
if ((_cachePolicy == NSURLRequestReturnCacheDataElseLoad || _cachePolicy == NSURLRequestReturnCacheDataDontLoad) && [method isEqualToString:@"GET"]) {
|
||||
NSCachedURLResponse *cacheResponse = [[NSURLCache sharedURLCache] cachedResponseForRequest:request];
|
||||
NSData *data = [cacheResponse data];
|
||||
if (data) {
|
||||
NSError *error = nil;
|
||||
NSDictionary* results = [NSJSONSerialization JSONObjectWithData:data
|
||||
options:kNilOptions
|
||||
error:&error];
|
||||
completionBlock(results, nil);
|
||||
}
|
||||
}
|
||||
|
||||
if (_cachePolicy == NSURLRequestReturnCacheDataDontLoad)
|
||||
return;
|
||||
|
||||
[self startLoad];
|
||||
NSDate *date = [NSDate date];
|
||||
[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);
|
||||
if ([[NSUserDefaults standardUserDefaults] boolForKey:@"RVBLogging"]) {
|
||||
NSLog(@"fetched results (%f seconds): %@", [[NSDate date] timeIntervalSinceDate:date], results);
|
||||
}
|
||||
}
|
||||
|
||||
[self stopLoad];
|
||||
}];
|
||||
}
|
||||
|
||||
-(void) stringWithCompletionBlock:(NSString*) path
|
||||
method:(NSString*) method
|
||||
queryParams:(NSDictionary*) queryParams
|
||||
body:(id) body
|
||||
headerParams:(NSDictionary*) headerParams
|
||||
completionBlock:(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 appendString:[NSString stringWithFormat:@"%@%@=%@", separator,
|
||||
[self escapeString:key], value]];
|
||||
counter += 1;
|
||||
}
|
||||
}
|
||||
if ([[NSUserDefaults standardUserDefaults] boolForKey:@"RVBLogging"]) {
|
||||
NSLog(@"request url: %@", requestUrl);
|
||||
}
|
||||
|
||||
NSURL* URL = [NSURL URLWithString:requestUrl];
|
||||
|
||||
NSMutableURLRequest* request = [[NSMutableURLRequest alloc] init];
|
||||
[request setURL:URL];
|
||||
[request setCachePolicy:self.cachePolicy];
|
||||
[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"];
|
||||
}
|
||||
|
||||
|
||||
// Handle caching on GET requests
|
||||
if ((_cachePolicy == NSURLRequestReturnCacheDataElseLoad || _cachePolicy == NSURLRequestReturnCacheDataDontLoad) && [method isEqualToString:@"GET"]) {
|
||||
NSCachedURLResponse *cacheResponse = [[NSURLCache sharedURLCache] cachedResponseForRequest:request];
|
||||
NSData *data = [cacheResponse data];
|
||||
if (data) {
|
||||
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);
|
||||
if ([[NSUserDefaults standardUserDefaults] boolForKey:@"RVBLogging"]) {
|
||||
// NSLog(@"cached results: %@", results);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (_cachePolicy == NSURLRequestReturnCacheDataDontLoad)
|
||||
return;
|
||||
|
||||
[self startLoad];
|
||||
NSDate *date = [NSDate date];
|
||||
[NSURLConnection sendAsynchronousRequest:request queue:_queue completionHandler:
|
||||
^(NSURLResponse *response, NSData *data, NSError *error) {
|
||||
int statusCode = [(NSHTTPURLResponse*)response statusCode];
|
||||
|
||||
if (error) {
|
||||
completionBlock(nil, error);
|
||||
return;
|
||||
@ -213,10 +290,14 @@
|
||||
if(([results characterAtIndex:0] == '\"') && ([results characterAtIndex:([results length] - 1) == '\"'])){
|
||||
results = [results substringWithRange:NSMakeRange(1, [results length] -2)];
|
||||
}
|
||||
|
||||
}
|
||||
completionBlock(results, nil);
|
||||
if ([[NSUserDefaults standardUserDefaults] boolForKey:@"RVBLogging"]) {
|
||||
NSLog(@"fetched results (%f seconds): %@", [[NSDate date] timeIntervalSinceDate:date], results);
|
||||
}
|
||||
}
|
||||
[self stopLoad];
|
||||
}];
|
||||
return nil;
|
||||
}
|
||||
@end
|
@ -1,13 +1,7 @@
|
||||
#import <Foundation/Foundation.h>
|
||||
#import "NIKSwaggerObject.h"
|
||||
|
||||
@interface NIKCategory : NIKSwaggerObject {
|
||||
@private
|
||||
NSNumber* __id; //NSNumber
|
||||
NSString* _name; //NSString
|
||||
}
|
||||
|
||||
|
||||
@interface NIKCategory : NIKSwaggerObject
|
||||
|
||||
@property(nonatomic) NSNumber* _id;
|
||||
@property(nonatomic) NSString* name;
|
||||
|
@ -3,27 +3,30 @@
|
||||
|
||||
@implementation NIKCategory
|
||||
|
||||
@synthesize _id = __id;
|
||||
@synthesize name = _name;
|
||||
- (id) _id: (NSNumber*) _id
|
||||
name: (NSString*) name
|
||||
{
|
||||
__id = _id;
|
||||
_name = name;
|
||||
return self;
|
||||
}
|
||||
|
||||
- (id) initWithValues: (NSDictionary*)dict
|
||||
-(id)_id: (NSNumber*) _id
|
||||
name: (NSString*) name
|
||||
{
|
||||
__id = [dict objectForKey:@"id"];
|
||||
_name = [dict objectForKey:@"name"];
|
||||
__id = _id;
|
||||
_name = name;
|
||||
return self;
|
||||
}
|
||||
|
||||
-(id) initWithValues:(NSDictionary*)dict
|
||||
{
|
||||
self = [super init];
|
||||
if(self) {
|
||||
__id = dict[@"id"];
|
||||
_name = dict[@"name"];
|
||||
|
||||
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
-(NSDictionary*) asDictionary {
|
||||
NSMutableDictionary* dict = [[NSMutableDictionary alloc] init];
|
||||
if(__id != nil) [dict setObject:__id forKey:@"id"];
|
||||
if(_name != nil) [dict setObject:_name forKey:@"name"];
|
||||
if(__id != nil) dict[@"id"] = __id ;
|
||||
if(_name != nil) dict[@"name"] = _name ;
|
||||
NSDictionary* output = [dict copy];
|
||||
return output;
|
||||
}
|
||||
|
@ -2,16 +2,7 @@
|
||||
#import "NIKSwaggerObject.h"
|
||||
#import "NIKDate.h"
|
||||
|
||||
@interface NIKOrder : NIKSwaggerObject {
|
||||
@private
|
||||
NSNumber* __id; //NSNumber
|
||||
NSNumber* _petId; //NSNumber
|
||||
NSString* _status; //NSString
|
||||
NSNumber* _quantity; //NSNumber
|
||||
NIKDate* _shipDate; //NIKDate
|
||||
}
|
||||
|
||||
|
||||
@interface NIKOrder : NIKSwaggerObject
|
||||
|
||||
@property(nonatomic) NSNumber* _id;
|
||||
@property(nonatomic) NSNumber* petId;
|
||||
|
@ -3,59 +3,59 @@
|
||||
|
||||
@implementation NIKOrder
|
||||
|
||||
@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)_id: (NSNumber*) _id
|
||||
petId: (NSNumber*) petId
|
||||
status: (NSString*) status
|
||||
quantity: (NSNumber*) quantity
|
||||
shipDate: (NIKDate*) shipDate
|
||||
{
|
||||
__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];
|
||||
__id = _id;
|
||||
_petId = petId;
|
||||
_status = status;
|
||||
_quantity = quantity;
|
||||
_shipDate = shipDate;
|
||||
return self;
|
||||
}
|
||||
|
||||
-(id) initWithValues:(NSDictionary*)dict
|
||||
{
|
||||
self = [super init];
|
||||
if(self) {
|
||||
__id = dict[@"id"];
|
||||
_petId = dict[@"petId"];
|
||||
_status = dict[@"status"];
|
||||
_quantity = dict[@"quantity"];
|
||||
id shipDate_dict = dict[@"shipDate"];
|
||||
_shipDate = [[NIKDate alloc]initWithValues:shipDate_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(__id != nil) dict[@"id"] = __id ;
|
||||
if(_petId != nil) dict[@"petId"] = _petId ;
|
||||
if(_status != nil) dict[@"status"] = _status ;
|
||||
if(_quantity != nil) dict[@"quantity"] = _quantity ;
|
||||
if(_shipDate != nil){
|
||||
if([_shipDate isKindOfClass:[NSArray class]]){
|
||||
NSMutableArray * array = [[NSMutableArray alloc] init];
|
||||
for( NIKDate * shipDate in (NSArray*)_shipDate) {
|
||||
for( NIKDate *shipDate in (NSArray*)_shipDate) {
|
||||
[array addObject:[(NIKSwaggerObject*)shipDate asDictionary]];
|
||||
}
|
||||
[dict setObject:array forKey:@"shipDate"];
|
||||
dict[@"shipDate"] = array;
|
||||
}
|
||||
else if(_shipDate && [_shipDate isKindOfClass:[NIKDate class]]) {
|
||||
NSString * dateString = [(NIKDate*)_shipDate toString];
|
||||
if(dateString){
|
||||
[dict setObject:dateString forKey:@"shipDate"];
|
||||
dict[@"shipDate"] = dateString;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
if(_shipDate != nil) [dict setObject:[(NIKSwaggerObject*)_shipDate asDictionary]forKey:@"shipDate"];
|
||||
if(_shipDate != nil) dict[@"shipDate"] = [(NIKSwaggerObject*)_shipDate asDictionary];
|
||||
}
|
||||
NSDictionary* output = [dict copy];
|
||||
return output;
|
||||
|
@ -3,17 +3,7 @@
|
||||
#import "NIKCategory.h"
|
||||
#import "NIKTag.h"
|
||||
|
||||
@interface NIKPet : NIKSwaggerObject {
|
||||
@private
|
||||
NSArray* _tags; //Tag
|
||||
NSNumber* __id; //NSNumber
|
||||
NIKCategory* _category; //Category
|
||||
NSString* _status; //NSString
|
||||
NSString* _name; //NSString
|
||||
NSArray* _photoUrls; //NSString
|
||||
}
|
||||
|
||||
|
||||
@interface NIKPet : NIKSwaggerObject
|
||||
|
||||
@property(nonatomic) NSArray* tags;
|
||||
@property(nonatomic) NSNumber* _id;
|
||||
|
@ -3,47 +3,55 @@
|
||||
|
||||
@implementation NIKPet
|
||||
|
||||
@synthesize tags = _tags;
|
||||
@synthesize _id = __id;
|
||||
@synthesize category = _category;
|
||||
@synthesize status = _status;
|
||||
@synthesize name = _name;
|
||||
@synthesize photoUrls = _photoUrls;
|
||||
- (id) tags: (NSArray*) tags
|
||||
_id: (NSNumber*) _id
|
||||
category: (NIKCategory*) category
|
||||
status: (NSString*) status
|
||||
name: (NSString*) name
|
||||
photoUrls: (NSArray*) photoUrls
|
||||
{
|
||||
_tags = tags;
|
||||
__id = _id;
|
||||
_category = category;
|
||||
_status = status;
|
||||
_name = name;
|
||||
_photoUrls = photoUrls;
|
||||
return self;
|
||||
}
|
||||
|
||||
- (id) initWithValues: (NSDictionary*)dict
|
||||
-(id)tags: (NSArray*) tags
|
||||
_id: (NSNumber*) _id
|
||||
category: (NIKCategory*) category
|
||||
status: (NSString*) status
|
||||
name: (NSString*) name
|
||||
photoUrls: (NSArray*) photoUrls
|
||||
{
|
||||
id tags_dict = [dict objectForKey:@"tags"];
|
||||
if([tags_dict isKindOfClass:[NSArray class]]) {
|
||||
if([(NSArray*)tags_dict count] > 0) {
|
||||
_tags = tags;
|
||||
__id = _id;
|
||||
_category = category;
|
||||
_status = status;
|
||||
_name = name;
|
||||
_photoUrls = photoUrls;
|
||||
return self;
|
||||
}
|
||||
|
||||
-(id) initWithValues:(NSDictionary*)dict
|
||||
{
|
||||
self = [super init];
|
||||
if(self) {
|
||||
id tags_dict = dict[@"tags"];
|
||||
if([tags_dict isKindOfClass:[NSArray class]]) {
|
||||
|
||||
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];
|
||||
|
||||
if([(NSArray*)tags_dict count] > 0) {
|
||||
for (NSDictionary* dict in (NSArray*)tags_dict) {
|
||||
NIKTag* d = [[NIKTag alloc] initWithValues:dict];
|
||||
[objs addObject:d];
|
||||
}
|
||||
|
||||
_tags = [[NSArray alloc] initWithArray:objs];
|
||||
}
|
||||
else {
|
||||
_tags = [[NSArray alloc] init];
|
||||
}
|
||||
_tags = [[NSArray alloc] initWithArray:objs];
|
||||
}
|
||||
else {
|
||||
_tags = [[NSArray alloc] init];
|
||||
}
|
||||
__id = dict[@"id"];
|
||||
id category_dict = dict[@"category"];
|
||||
_category = [[NIKCategory alloc]initWithValues:category_dict];
|
||||
_status = dict[@"status"];
|
||||
_name = dict[@"name"];
|
||||
_photoUrls = dict[@"photoUrls"];
|
||||
|
||||
|
||||
}
|
||||
__id = [dict objectForKey:@"id"];
|
||||
id category_dict = [dict objectForKey:@"category"];
|
||||
_category = [[NIKCategory alloc]initWithValues:category_dict];
|
||||
_status = [dict objectForKey:@"status"];
|
||||
_name = [dict objectForKey:@"name"];
|
||||
_photoUrls = [dict objectForKey:@"photoUrls"];
|
||||
return self;
|
||||
}
|
||||
|
||||
@ -52,43 +60,43 @@
|
||||
if(_tags != nil){
|
||||
if([_tags isKindOfClass:[NSArray class]]){
|
||||
NSMutableArray * array = [[NSMutableArray alloc] init];
|
||||
for( NIKTag * tags in (NSArray*)_tags) {
|
||||
for( NIKTag *tags in (NSArray*)_tags) {
|
||||
[array addObject:[(NIKSwaggerObject*)tags asDictionary]];
|
||||
}
|
||||
[dict setObject:array forKey:@"tags"];
|
||||
dict[@"tags"] = array;
|
||||
}
|
||||
else if(_tags && [_tags isKindOfClass:[NIKDate class]]) {
|
||||
NSString * dateString = [(NIKDate*)_tags toString];
|
||||
if(dateString){
|
||||
[dict setObject:dateString forKey:@"tags"];
|
||||
dict[@"tags"] = dateString;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
if(_tags != nil) [dict setObject:[(NIKSwaggerObject*)_tags asDictionary]forKey:@"tags"];
|
||||
if(_tags != nil) dict[@"tags"] = [(NIKSwaggerObject*)_tags asDictionary];
|
||||
}
|
||||
if(__id != nil) [dict setObject:__id forKey:@"id"];
|
||||
if(__id != nil) dict[@"id"] = __id ;
|
||||
if(_category != nil){
|
||||
if([_category isKindOfClass:[NSArray class]]){
|
||||
NSMutableArray * array = [[NSMutableArray alloc] init];
|
||||
for( NIKCategory * category in (NSArray*)_category) {
|
||||
for( NIKCategory *category in (NSArray*)_category) {
|
||||
[array addObject:[(NIKSwaggerObject*)category asDictionary]];
|
||||
}
|
||||
[dict setObject:array forKey:@"category"];
|
||||
dict[@"category"] = array;
|
||||
}
|
||||
else if(_category && [_category isKindOfClass:[NIKDate class]]) {
|
||||
NSString * dateString = [(NIKDate*)_category toString];
|
||||
if(dateString){
|
||||
[dict setObject:dateString forKey:@"category"];
|
||||
dict[@"category"] = dateString;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
if(_category != nil) [dict setObject:[(NIKSwaggerObject*)_category asDictionary]forKey:@"category"];
|
||||
if(_category != nil) dict[@"category"] = [(NIKSwaggerObject*)_category asDictionary];
|
||||
}
|
||||
if(_status != nil) [dict setObject:_status forKey:@"status"];
|
||||
if(_name != nil) [dict setObject:_name forKey:@"name"];
|
||||
if(_photoUrls != nil) [dict setObject:_photoUrls forKey:@"photoUrls"];
|
||||
if(_status != nil) dict[@"status"] = _status ;
|
||||
if(_name != nil) dict[@"name"] = _name ;
|
||||
if(_photoUrls != nil) dict[@"photoUrls"] = _photoUrls ;
|
||||
NSDictionary* output = [dict copy];
|
||||
return output;
|
||||
}
|
||||
|
@ -12,17 +12,51 @@
|
||||
@property(nonatomic, readonly) NSOperationQueue* queue;
|
||||
@property(nonatomic, readonly) NIKApiInvoker* api;
|
||||
|
||||
-(void) addHeader:(NSString*) value
|
||||
forKey:(NSString*)key;
|
||||
-(void) addHeader:(NSString*)value forKey:(NSString*)key;
|
||||
|
||||
/**
|
||||
|
||||
Find pet by ID
|
||||
Returns a pet based on ID
|
||||
@param petId ID of pet that needs to be fetched
|
||||
*/
|
||||
-(void) getPetByIdWithCompletionBlock :(NSString*) petId
|
||||
completionHandler:(void (^)(NIKPet*, NSError *))completionBlock;
|
||||
completionHandler: (void (^)(NIKPet* output, NSError* error))completionBlock;
|
||||
|
||||
/**
|
||||
|
||||
Add a new pet to the store
|
||||
|
||||
@param body Pet object that needs to be added to the store
|
||||
*/
|
||||
-(void) addPetWithCompletionBlock :(NIKPet*) body
|
||||
completionHandler:(void (^)(NSError *))completionBlock;
|
||||
completionHandler: (void (^)(NSError* error))completionBlock;
|
||||
|
||||
/**
|
||||
|
||||
Update an existing pet
|
||||
|
||||
@param body Pet object that needs to be updated in the store
|
||||
*/
|
||||
-(void) updatePetWithCompletionBlock :(NIKPet*) body
|
||||
completionHandler:(void (^)(NSError *))completionBlock;
|
||||
completionHandler: (void (^)(NSError* error))completionBlock;
|
||||
|
||||
/**
|
||||
|
||||
Finds Pets by status
|
||||
Multiple status values can be provided with comma seperated strings
|
||||
@param status Status values that need to be considered for filter
|
||||
*/
|
||||
-(void) findPetsByStatusWithCompletionBlock :(NSString*) status
|
||||
completionHandler:(void (^)(NSArray*, NSError *))completionBlock;
|
||||
completionHandler: (void (^)(NSArray* output, NSError* error))completionBlock;
|
||||
|
||||
/**
|
||||
|
||||
Finds Pets by tags
|
||||
Muliple tags can be provided with comma seperated strings. Use tag1, tag2, tag3 for testing.
|
||||
@param tags Tags to filter by
|
||||
*/
|
||||
-(void) findPetsByTagsWithCompletionBlock :(NSString*) tags
|
||||
completionHandler:(void (^)(NSArray*, NSError *))completionBlock;
|
||||
completionHandler: (void (^)(NSArray* output, NSError* error))completionBlock;
|
||||
|
||||
@end
|
||||
|
@ -9,10 +9,20 @@ static NSString * basePath = @"http://petstore.swagger.wordnik.com/api";
|
||||
@synthesize queue = _queue;
|
||||
@synthesize api = _api;
|
||||
|
||||
- (id) init {
|
||||
+(NIKPetApi*) apiWithHeader:(NSString*)headerValue key:(NSString*)key {
|
||||
static NIKPetApi* singletonAPI = nil;
|
||||
|
||||
if (singletonAPI == nil) {
|
||||
singletonAPI = [[NIKPetApi alloc] init];
|
||||
[singletonAPI addHeader:headerValue forKey:key];
|
||||
}
|
||||
return singletonAPI;
|
||||
}
|
||||
|
||||
-(id) init {
|
||||
self = [super init];
|
||||
_queue = [[NSOperationQueue alloc] init];
|
||||
_api = [[NIKApiInvoker alloc] init];
|
||||
_api = [NIKApiInvoker sharedInstance];
|
||||
|
||||
return self;
|
||||
}
|
||||
@ -22,15 +32,8 @@ static NSString * basePath = @"http://petstore.swagger.wordnik.com/api";
|
||||
[_api addHeader:value forKey:key];
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* returnTypeIsPrimitive:
|
||||
* returnBaseType: NIKPet
|
||||
* returnContainer:
|
||||
*
|
||||
**/
|
||||
-(void) getPetByIdWithCompletionBlock :(NSString*) petId
|
||||
completionHandler:(void (^)(NIKPet*, NSError *))completionBlock{
|
||||
-(void) getPetByIdWithCompletionBlock:(NSString*) petId
|
||||
completionHandler: (void (^)(NIKPet* output, NSError* error))completionBlock{
|
||||
|
||||
NSMutableString* requestUrl = [NSMutableString stringWithFormat:@"%@/pet.{format}/{petId}", basePath];
|
||||
|
||||
@ -45,29 +48,23 @@ static NSString * basePath = @"http://petstore.swagger.wordnik.com/api";
|
||||
if(petId == nil) {
|
||||
// error
|
||||
}
|
||||
[_api dictionaryWithCompletionBlock: requestUrl
|
||||
method: @"GET"
|
||||
queryParams: queryParams
|
||||
body: bodyDictionary
|
||||
headerParams: headerParams
|
||||
completionHandler: ^(NSDictionary *data, NSError *error) {
|
||||
[_api dictionary:requestUrl
|
||||
method:@"GET"
|
||||
queryParams:queryParams
|
||||
body:bodyDictionary
|
||||
headerParams:headerParams
|
||||
completionBlock:^(NSDictionary *data, NSError *error) {
|
||||
if (error) {
|
||||
completionBlock(nil, error);return;
|
||||
}
|
||||
|
||||
completionBlock( [[NIKPet alloc]initWithValues: data], nil);}];
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* returnTypeIsPrimitive: true
|
||||
* returnBaseType:
|
||||
* returnContainer:
|
||||
*
|
||||
**/
|
||||
-(void) addPetWithCompletionBlock :(NIKPet*) body
|
||||
completionHandler:(void (^)(NSError *))completionBlock{
|
||||
-(void) addPetWithCompletionBlock:(NIKPet*) body
|
||||
completionHandler: (void (^)(NSError* error))completionBlock{
|
||||
|
||||
NSMutableString* requestUrl = [NSMutableString stringWithFormat:@"%@/pet.{format}", basePath];
|
||||
|
||||
@ -103,12 +100,12 @@ static NSString * basePath = @"http://petstore.swagger.wordnik.com/api";
|
||||
if(body == nil) {
|
||||
// error
|
||||
}
|
||||
[_api stringWithCompletionBlock: requestUrl
|
||||
method: @"POST"
|
||||
queryParams: queryParams
|
||||
body: bodyDictionary
|
||||
headerParams: headerParams
|
||||
completionHandler: ^(NSString *data, NSError *error) {
|
||||
[_api stringWithCompletionBlock:requestUrl
|
||||
method:@"POST"
|
||||
queryParams:queryParams
|
||||
body:bodyDictionary
|
||||
headerParams:headerParams
|
||||
completionBlock:^(NSString *data, NSError *error) {
|
||||
if (error) {
|
||||
completionBlock(error);
|
||||
return;
|
||||
@ -116,17 +113,11 @@ static NSString * basePath = @"http://petstore.swagger.wordnik.com/api";
|
||||
completionBlock(nil);
|
||||
}];
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* returnTypeIsPrimitive: true
|
||||
* returnBaseType:
|
||||
* returnContainer:
|
||||
*
|
||||
**/
|
||||
-(void) updatePetWithCompletionBlock :(NIKPet*) body
|
||||
completionHandler:(void (^)(NSError *))completionBlock{
|
||||
-(void) updatePetWithCompletionBlock:(NIKPet*) body
|
||||
completionHandler: (void (^)(NSError* error))completionBlock{
|
||||
|
||||
NSMutableString* requestUrl = [NSMutableString stringWithFormat:@"%@/pet.{format}", basePath];
|
||||
|
||||
@ -162,12 +153,12 @@ static NSString * basePath = @"http://petstore.swagger.wordnik.com/api";
|
||||
if(body == nil) {
|
||||
// error
|
||||
}
|
||||
[_api stringWithCompletionBlock: requestUrl
|
||||
method: @"PUT"
|
||||
queryParams: queryParams
|
||||
body: bodyDictionary
|
||||
headerParams: headerParams
|
||||
completionHandler: ^(NSString *data, NSError *error) {
|
||||
[_api stringWithCompletionBlock:requestUrl
|
||||
method:@"PUT"
|
||||
queryParams:queryParams
|
||||
body:bodyDictionary
|
||||
headerParams:headerParams
|
||||
completionBlock:^(NSString *data, NSError *error) {
|
||||
if (error) {
|
||||
completionBlock(error);
|
||||
return;
|
||||
@ -175,17 +166,11 @@ static NSString * basePath = @"http://petstore.swagger.wordnik.com/api";
|
||||
completionBlock(nil);
|
||||
}];
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* returnTypeIsPrimitive:
|
||||
* returnBaseType: NIKPet
|
||||
* returnContainer: List
|
||||
*
|
||||
**/
|
||||
-(void) findPetsByStatusWithCompletionBlock :(NSString*) status
|
||||
completionHandler:(void (^)(NSArray*, NSError *))completionBlock{
|
||||
-(void) findPetsByStatusWithCompletionBlock:(NSString*) status
|
||||
completionHandler: (void (^)(NSArray* output, NSError* error))completionBlock{
|
||||
|
||||
NSMutableString* requestUrl = [NSMutableString stringWithFormat:@"%@/pet.{format}/findByStatus", basePath];
|
||||
|
||||
@ -195,18 +180,18 @@ static NSString * basePath = @"http://petstore.swagger.wordnik.com/api";
|
||||
|
||||
NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init];
|
||||
if(status != nil)
|
||||
[queryParams setValue:status forKey:@"status"];
|
||||
queryParams[@"status"] = 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) {
|
||||
[_api dictionary: requestUrl
|
||||
method: @"GET"
|
||||
queryParams: queryParams
|
||||
body: bodyDictionary
|
||||
headerParams: headerParams
|
||||
completionBlock: ^(NSDictionary *data, NSError *error) {
|
||||
if (error) {
|
||||
completionBlock(nil, error);return;
|
||||
}
|
||||
@ -221,17 +206,11 @@ static NSString * basePath = @"http://petstore.swagger.wordnik.com/api";
|
||||
}
|
||||
}];
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* returnTypeIsPrimitive:
|
||||
* returnBaseType: NIKPet
|
||||
* returnContainer: List
|
||||
*
|
||||
**/
|
||||
-(void) findPetsByTagsWithCompletionBlock :(NSString*) tags
|
||||
completionHandler:(void (^)(NSArray*, NSError *))completionBlock{
|
||||
-(void) findPetsByTagsWithCompletionBlock:(NSString*) tags
|
||||
completionHandler: (void (^)(NSArray* output, NSError* error))completionBlock{
|
||||
|
||||
NSMutableString* requestUrl = [NSMutableString stringWithFormat:@"%@/pet.{format}/findByTags", basePath];
|
||||
|
||||
@ -241,18 +220,18 @@ static NSString * basePath = @"http://petstore.swagger.wordnik.com/api";
|
||||
|
||||
NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init];
|
||||
if(tags != nil)
|
||||
[queryParams setValue:tags forKey:@"tags"];
|
||||
queryParams[@"tags"] = 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) {
|
||||
[_api dictionary: requestUrl
|
||||
method: @"GET"
|
||||
queryParams: queryParams
|
||||
body: bodyDictionary
|
||||
headerParams: headerParams
|
||||
completionBlock: ^(NSDictionary *data, NSError *error) {
|
||||
if (error) {
|
||||
completionBlock(nil, error);return;
|
||||
}
|
||||
@ -267,9 +246,11 @@ static NSString * basePath = @"http://petstore.swagger.wordnik.com/api";
|
||||
}
|
||||
}];
|
||||
|
||||
|
||||
}
|
||||
|
||||
-(void) getPetByIdAsJsonWithCompletionBlock :(NSString*) petId
|
||||
|
||||
completionHandler:(void (^)(NSString*, NSError *))completionBlock{
|
||||
|
||||
NSMutableString* requestUrl = [NSMutableString stringWithFormat:@"%@/pet.{format}/{petId}", basePath];
|
||||
@ -285,12 +266,12 @@ static NSString * basePath = @"http://petstore.swagger.wordnik.com/api";
|
||||
if(petId == nil) {
|
||||
// error
|
||||
}
|
||||
[_api dictionaryWithCompletionBlock: requestUrl
|
||||
method: @"GET"
|
||||
queryParams: queryParams
|
||||
body: bodyDictionary
|
||||
headerParams: headerParams
|
||||
completionHandler: ^(NSDictionary *data, NSError *error) {
|
||||
[_api dictionary:requestUrl
|
||||
method:@"GET"
|
||||
queryParams:queryParams
|
||||
body:bodyDictionary
|
||||
headerParams:headerParams
|
||||
completionBlock:^(NSDictionary *data, NSError *error) {
|
||||
if (error) {
|
||||
completionBlock(nil, error);return;
|
||||
}
|
||||
@ -307,11 +288,14 @@ static NSString * basePath = @"http://petstore.swagger.wordnik.com/api";
|
||||
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];
|
||||
@ -348,22 +332,25 @@ static NSString * basePath = @"http://petstore.swagger.wordnik.com/api";
|
||||
if(body == nil) {
|
||||
// error
|
||||
}
|
||||
[_api dictionaryWithCompletionBlock: requestUrl
|
||||
method: @"POST"
|
||||
queryParams: queryParams
|
||||
body: bodyDictionary
|
||||
headerParams: headerParams
|
||||
completionHandler: ^(NSDictionary *data, NSError *error) {
|
||||
[_api dictionary:requestUrl
|
||||
method:@"POST"
|
||||
queryParams:queryParams
|
||||
body:bodyDictionary
|
||||
headerParams:headerParams
|
||||
completionBlock:^(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];
|
||||
@ -400,22 +387,25 @@ static NSString * basePath = @"http://petstore.swagger.wordnik.com/api";
|
||||
if(body == nil) {
|
||||
// error
|
||||
}
|
||||
[_api dictionaryWithCompletionBlock: requestUrl
|
||||
method: @"PUT"
|
||||
queryParams: queryParams
|
||||
body: bodyDictionary
|
||||
headerParams: headerParams
|
||||
completionHandler: ^(NSDictionary *data, NSError *error) {
|
||||
[_api dictionary:requestUrl
|
||||
method:@"PUT"
|
||||
queryParams:queryParams
|
||||
body:bodyDictionary
|
||||
headerParams:headerParams
|
||||
completionBlock:^(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];
|
||||
@ -426,18 +416,18 @@ static NSString * basePath = @"http://petstore.swagger.wordnik.com/api";
|
||||
|
||||
NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init];
|
||||
if(status != nil)
|
||||
[queryParams setValue:status forKey:@"status"];
|
||||
queryParams[@"status"] = 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) {
|
||||
[_api dictionary:requestUrl
|
||||
method:@"GET"
|
||||
queryParams:queryParams
|
||||
body:bodyDictionary
|
||||
headerParams:headerParams
|
||||
completionBlock:^(NSDictionary *data, NSError *error) {
|
||||
if (error) {
|
||||
completionBlock(nil, error);return;
|
||||
}
|
||||
@ -454,11 +444,14 @@ static NSString * basePath = @"http://petstore.swagger.wordnik.com/api";
|
||||
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];
|
||||
@ -469,18 +462,18 @@ static NSString * basePath = @"http://petstore.swagger.wordnik.com/api";
|
||||
|
||||
NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init];
|
||||
if(tags != nil)
|
||||
[queryParams setValue:tags forKey:@"tags"];
|
||||
queryParams[@"tags"] = 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) {
|
||||
[_api dictionary:requestUrl
|
||||
method:@"GET"
|
||||
queryParams:queryParams
|
||||
body:bodyDictionary
|
||||
headerParams:headerParams
|
||||
completionBlock:^(NSDictionary *data, NSError *error) {
|
||||
if (error) {
|
||||
completionBlock(nil, error);return;
|
||||
}
|
||||
@ -497,8 +490,10 @@ static NSString * basePath = @"http://petstore.swagger.wordnik.com/api";
|
||||
NSString * json = [[NSString alloc]initWithData:responseData encoding:NSUTF8StringEncoding];
|
||||
completionBlock(json, nil);
|
||||
|
||||
|
||||
}];
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -12,13 +12,33 @@
|
||||
@property(nonatomic, readonly) NSOperationQueue* queue;
|
||||
@property(nonatomic, readonly) NIKApiInvoker* api;
|
||||
|
||||
-(void) addHeader:(NSString*) value
|
||||
forKey:(NSString*)key;
|
||||
-(void) addHeader:(NSString*)value forKey:(NSString*)key;
|
||||
|
||||
/**
|
||||
|
||||
Find purchase order by ID
|
||||
For valid response try integer IDs with value <= 5. Anything above 5 or nonintegers will generate API errors
|
||||
@param orderId ID of pet that needs to be fetched
|
||||
*/
|
||||
-(void) getOrderByIdWithCompletionBlock :(NSString*) orderId
|
||||
completionHandler:(void (^)(NIKOrder*, NSError *))completionBlock;
|
||||
completionHandler: (void (^)(NIKOrder* output, NSError* error))completionBlock;
|
||||
|
||||
/**
|
||||
|
||||
Delete purchase order by ID
|
||||
For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors
|
||||
@param orderId ID of the order that needs to be deleted
|
||||
*/
|
||||
-(void) deleteOrderWithCompletionBlock :(NSString*) orderId
|
||||
completionHandler:(void (^)(NSError *))completionBlock;
|
||||
completionHandler: (void (^)(NSError* error))completionBlock;
|
||||
|
||||
/**
|
||||
|
||||
Place an order for a pet
|
||||
|
||||
@param body order placed for purchasing the pet
|
||||
*/
|
||||
-(void) placeOrderWithCompletionBlock :(NIKOrder*) body
|
||||
completionHandler:(void (^)(NSError *))completionBlock;
|
||||
completionHandler: (void (^)(NSError* error))completionBlock;
|
||||
|
||||
@end
|
||||
|
@ -9,10 +9,20 @@ static NSString * basePath = @"http://petstore.swagger.wordnik.com/api";
|
||||
@synthesize queue = _queue;
|
||||
@synthesize api = _api;
|
||||
|
||||
- (id) init {
|
||||
+(NIKStoreApi*) apiWithHeader:(NSString*)headerValue key:(NSString*)key {
|
||||
static NIKStoreApi* singletonAPI = nil;
|
||||
|
||||
if (singletonAPI == nil) {
|
||||
singletonAPI = [[NIKStoreApi alloc] init];
|
||||
[singletonAPI addHeader:headerValue forKey:key];
|
||||
}
|
||||
return singletonAPI;
|
||||
}
|
||||
|
||||
-(id) init {
|
||||
self = [super init];
|
||||
_queue = [[NSOperationQueue alloc] init];
|
||||
_api = [[NIKApiInvoker alloc] init];
|
||||
_api = [NIKApiInvoker sharedInstance];
|
||||
|
||||
return self;
|
||||
}
|
||||
@ -22,15 +32,8 @@ static NSString * basePath = @"http://petstore.swagger.wordnik.com/api";
|
||||
[_api addHeader:value forKey:key];
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* returnTypeIsPrimitive:
|
||||
* returnBaseType: NIKOrder
|
||||
* returnContainer:
|
||||
*
|
||||
**/
|
||||
-(void) getOrderByIdWithCompletionBlock :(NSString*) orderId
|
||||
completionHandler:(void (^)(NIKOrder*, NSError *))completionBlock{
|
||||
-(void) getOrderByIdWithCompletionBlock:(NSString*) orderId
|
||||
completionHandler: (void (^)(NIKOrder* output, NSError* error))completionBlock{
|
||||
|
||||
NSMutableString* requestUrl = [NSMutableString stringWithFormat:@"%@/store.{format}/order/{orderId}", basePath];
|
||||
|
||||
@ -45,29 +48,23 @@ static NSString * basePath = @"http://petstore.swagger.wordnik.com/api";
|
||||
if(orderId == nil) {
|
||||
// error
|
||||
}
|
||||
[_api dictionaryWithCompletionBlock: requestUrl
|
||||
method: @"GET"
|
||||
queryParams: queryParams
|
||||
body: bodyDictionary
|
||||
headerParams: headerParams
|
||||
completionHandler: ^(NSDictionary *data, NSError *error) {
|
||||
[_api dictionary:requestUrl
|
||||
method:@"GET"
|
||||
queryParams:queryParams
|
||||
body:bodyDictionary
|
||||
headerParams:headerParams
|
||||
completionBlock:^(NSDictionary *data, NSError *error) {
|
||||
if (error) {
|
||||
completionBlock(nil, error);return;
|
||||
}
|
||||
|
||||
completionBlock( [[NIKOrder alloc]initWithValues: data], nil);}];
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* returnTypeIsPrimitive: true
|
||||
* returnBaseType:
|
||||
* returnContainer:
|
||||
*
|
||||
**/
|
||||
-(void) deleteOrderWithCompletionBlock :(NSString*) orderId
|
||||
completionHandler:(void (^)(NSError *))completionBlock{
|
||||
-(void) deleteOrderWithCompletionBlock:(NSString*) orderId
|
||||
completionHandler: (void (^)(NSError* error))completionBlock{
|
||||
|
||||
NSMutableString* requestUrl = [NSMutableString stringWithFormat:@"%@/store.{format}/order/{orderId}", basePath];
|
||||
|
||||
@ -82,12 +79,12 @@ static NSString * basePath = @"http://petstore.swagger.wordnik.com/api";
|
||||
if(orderId == nil) {
|
||||
// error
|
||||
}
|
||||
[_api stringWithCompletionBlock: requestUrl
|
||||
method: @"DELETE"
|
||||
queryParams: queryParams
|
||||
body: bodyDictionary
|
||||
headerParams: headerParams
|
||||
completionHandler: ^(NSString *data, NSError *error) {
|
||||
[_api stringWithCompletionBlock:requestUrl
|
||||
method:@"DELETE"
|
||||
queryParams:queryParams
|
||||
body:bodyDictionary
|
||||
headerParams:headerParams
|
||||
completionBlock:^(NSString *data, NSError *error) {
|
||||
if (error) {
|
||||
completionBlock(error);
|
||||
return;
|
||||
@ -95,17 +92,11 @@ static NSString * basePath = @"http://petstore.swagger.wordnik.com/api";
|
||||
completionBlock(nil);
|
||||
}];
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* returnTypeIsPrimitive: true
|
||||
* returnBaseType:
|
||||
* returnContainer:
|
||||
*
|
||||
**/
|
||||
-(void) placeOrderWithCompletionBlock :(NIKOrder*) body
|
||||
completionHandler:(void (^)(NSError *))completionBlock{
|
||||
-(void) placeOrderWithCompletionBlock:(NIKOrder*) body
|
||||
completionHandler: (void (^)(NSError* error))completionBlock{
|
||||
|
||||
NSMutableString* requestUrl = [NSMutableString stringWithFormat:@"%@/store.{format}/order", basePath];
|
||||
|
||||
@ -141,12 +132,12 @@ static NSString * basePath = @"http://petstore.swagger.wordnik.com/api";
|
||||
if(body == nil) {
|
||||
// error
|
||||
}
|
||||
[_api stringWithCompletionBlock: requestUrl
|
||||
method: @"POST"
|
||||
queryParams: queryParams
|
||||
body: bodyDictionary
|
||||
headerParams: headerParams
|
||||
completionHandler: ^(NSString *data, NSError *error) {
|
||||
[_api stringWithCompletionBlock:requestUrl
|
||||
method:@"POST"
|
||||
queryParams:queryParams
|
||||
body:bodyDictionary
|
||||
headerParams:headerParams
|
||||
completionBlock:^(NSString *data, NSError *error) {
|
||||
if (error) {
|
||||
completionBlock(error);
|
||||
return;
|
||||
@ -154,9 +145,11 @@ static NSString * basePath = @"http://petstore.swagger.wordnik.com/api";
|
||||
completionBlock(nil);
|
||||
}];
|
||||
|
||||
|
||||
}
|
||||
|
||||
-(void) getOrderByIdAsJsonWithCompletionBlock :(NSString*) orderId
|
||||
|
||||
completionHandler:(void (^)(NSString*, NSError *))completionBlock{
|
||||
|
||||
NSMutableString* requestUrl = [NSMutableString stringWithFormat:@"%@/store.{format}/order/{orderId}", basePath];
|
||||
@ -172,12 +165,12 @@ static NSString * basePath = @"http://petstore.swagger.wordnik.com/api";
|
||||
if(orderId == nil) {
|
||||
// error
|
||||
}
|
||||
[_api dictionaryWithCompletionBlock: requestUrl
|
||||
method: @"GET"
|
||||
queryParams: queryParams
|
||||
body: bodyDictionary
|
||||
headerParams: headerParams
|
||||
completionHandler: ^(NSDictionary *data, NSError *error) {
|
||||
[_api dictionary:requestUrl
|
||||
method:@"GET"
|
||||
queryParams:queryParams
|
||||
body:bodyDictionary
|
||||
headerParams:headerParams
|
||||
completionBlock:^(NSDictionary *data, NSError *error) {
|
||||
if (error) {
|
||||
completionBlock(nil, error);return;
|
||||
}
|
||||
@ -194,11 +187,14 @@ static NSString * basePath = @"http://petstore.swagger.wordnik.com/api";
|
||||
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];
|
||||
@ -214,22 +210,25 @@ static NSString * basePath = @"http://petstore.swagger.wordnik.com/api";
|
||||
if(orderId == nil) {
|
||||
// error
|
||||
}
|
||||
[_api dictionaryWithCompletionBlock: requestUrl
|
||||
method: @"DELETE"
|
||||
queryParams: queryParams
|
||||
body: bodyDictionary
|
||||
headerParams: headerParams
|
||||
completionHandler: ^(NSDictionary *data, NSError *error) {
|
||||
[_api dictionary:requestUrl
|
||||
method:@"DELETE"
|
||||
queryParams:queryParams
|
||||
body:bodyDictionary
|
||||
headerParams:headerParams
|
||||
completionBlock:^(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];
|
||||
@ -266,19 +265,21 @@ static NSString * basePath = @"http://petstore.swagger.wordnik.com/api";
|
||||
if(body == nil) {
|
||||
// error
|
||||
}
|
||||
[_api dictionaryWithCompletionBlock: requestUrl
|
||||
method: @"POST"
|
||||
queryParams: queryParams
|
||||
body: bodyDictionary
|
||||
headerParams: headerParams
|
||||
completionHandler: ^(NSDictionary *data, NSError *error) {
|
||||
[_api dictionary:requestUrl
|
||||
method:@"POST"
|
||||
queryParams:queryParams
|
||||
body:bodyDictionary
|
||||
headerParams:headerParams
|
||||
completionBlock:^(NSDictionary *data, NSError *error) {
|
||||
if (error) {
|
||||
completionBlock(error);return;
|
||||
}
|
||||
|
||||
completionBlock(nil);
|
||||
|
||||
}];
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,13 +1,7 @@
|
||||
#import <Foundation/Foundation.h>
|
||||
#import "NIKSwaggerObject.h"
|
||||
|
||||
@interface NIKTag : NIKSwaggerObject {
|
||||
@private
|
||||
NSNumber* __id; //NSNumber
|
||||
NSString* _name; //NSString
|
||||
}
|
||||
|
||||
|
||||
@interface NIKTag : NIKSwaggerObject
|
||||
|
||||
@property(nonatomic) NSNumber* _id;
|
||||
@property(nonatomic) NSString* name;
|
||||
|
@ -3,27 +3,30 @@
|
||||
|
||||
@implementation NIKTag
|
||||
|
||||
@synthesize _id = __id;
|
||||
@synthesize name = _name;
|
||||
- (id) _id: (NSNumber*) _id
|
||||
name: (NSString*) name
|
||||
{
|
||||
__id = _id;
|
||||
_name = name;
|
||||
return self;
|
||||
}
|
||||
|
||||
- (id) initWithValues: (NSDictionary*)dict
|
||||
-(id)_id: (NSNumber*) _id
|
||||
name: (NSString*) name
|
||||
{
|
||||
__id = [dict objectForKey:@"id"];
|
||||
_name = [dict objectForKey:@"name"];
|
||||
__id = _id;
|
||||
_name = name;
|
||||
return self;
|
||||
}
|
||||
|
||||
-(id) initWithValues:(NSDictionary*)dict
|
||||
{
|
||||
self = [super init];
|
||||
if(self) {
|
||||
__id = dict[@"id"];
|
||||
_name = dict[@"name"];
|
||||
|
||||
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
-(NSDictionary*) asDictionary {
|
||||
NSMutableDictionary* dict = [[NSMutableDictionary alloc] init];
|
||||
if(__id != nil) [dict setObject:__id forKey:@"id"];
|
||||
if(_name != nil) [dict setObject:_name forKey:@"name"];
|
||||
if(__id != nil) dict[@"id"] = __id ;
|
||||
if(_name != nil) dict[@"name"] = _name ;
|
||||
NSDictionary* output = [dict copy];
|
||||
return output;
|
||||
}
|
||||
|
@ -1,19 +1,7 @@
|
||||
#import <Foundation/Foundation.h>
|
||||
#import "NIKSwaggerObject.h"
|
||||
|
||||
@interface NIKUser : NIKSwaggerObject {
|
||||
@private
|
||||
NSNumber* __id; //NSNumber
|
||||
NSString* _lastName; //NSString
|
||||
NSString* _phone; //NSString
|
||||
NSString* _username; //NSString
|
||||
NSString* _email; //NSString
|
||||
NSNumber* _userStatus; //NSNumber
|
||||
NSString* _firstName; //NSString
|
||||
NSString* _password; //NSString
|
||||
}
|
||||
|
||||
|
||||
@interface NIKUser : NIKSwaggerObject
|
||||
|
||||
@property(nonatomic) NSNumber* _id;
|
||||
@property(nonatomic) NSString* lastName;
|
||||
|
@ -3,57 +3,54 @@
|
||||
|
||||
@implementation NIKUser
|
||||
|
||||
@synthesize _id = __id;
|
||||
@synthesize lastName = _lastName;
|
||||
@synthesize phone = _phone;
|
||||
@synthesize username = _username;
|
||||
@synthesize email = _email;
|
||||
@synthesize userStatus = _userStatus;
|
||||
@synthesize firstName = _firstName;
|
||||
@synthesize password = _password;
|
||||
- (id) _id: (NSNumber*) _id
|
||||
lastName: (NSString*) lastName
|
||||
phone: (NSString*) phone
|
||||
username: (NSString*) username
|
||||
email: (NSString*) email
|
||||
userStatus: (NSNumber*) userStatus
|
||||
firstName: (NSString*) firstName
|
||||
password: (NSString*) password
|
||||
{
|
||||
__id = _id;
|
||||
_lastName = lastName;
|
||||
_phone = phone;
|
||||
_username = username;
|
||||
_email = email;
|
||||
_userStatus = userStatus;
|
||||
_firstName = firstName;
|
||||
_password = password;
|
||||
return self;
|
||||
}
|
||||
|
||||
- (id) initWithValues: (NSDictionary*)dict
|
||||
-(id)_id: (NSNumber*) _id
|
||||
lastName: (NSString*) lastName
|
||||
phone: (NSString*) phone
|
||||
username: (NSString*) username
|
||||
email: (NSString*) email
|
||||
userStatus: (NSNumber*) userStatus
|
||||
firstName: (NSString*) firstName
|
||||
password: (NSString*) password
|
||||
{
|
||||
__id = [dict objectForKey:@"id"];
|
||||
_lastName = [dict objectForKey:@"lastName"];
|
||||
_phone = [dict objectForKey:@"phone"];
|
||||
_username = [dict objectForKey:@"username"];
|
||||
_email = [dict objectForKey:@"email"];
|
||||
_userStatus = [dict objectForKey:@"userStatus"];
|
||||
_firstName = [dict objectForKey:@"firstName"];
|
||||
_password = [dict objectForKey:@"password"];
|
||||
__id = _id;
|
||||
_lastName = lastName;
|
||||
_phone = phone;
|
||||
_username = username;
|
||||
_email = email;
|
||||
_userStatus = userStatus;
|
||||
_firstName = firstName;
|
||||
_password = password;
|
||||
return self;
|
||||
}
|
||||
|
||||
-(id) initWithValues:(NSDictionary*)dict
|
||||
{
|
||||
self = [super init];
|
||||
if(self) {
|
||||
__id = dict[@"id"];
|
||||
_lastName = dict[@"lastName"];
|
||||
_phone = dict[@"phone"];
|
||||
_username = dict[@"username"];
|
||||
_email = dict[@"email"];
|
||||
_userStatus = dict[@"userStatus"];
|
||||
_firstName = dict[@"firstName"];
|
||||
_password = dict[@"password"];
|
||||
|
||||
|
||||
}
|
||||
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(_phone != nil) [dict setObject:_phone forKey:@"phone"];
|
||||
if(_username != nil) [dict setObject:_username forKey:@"username"];
|
||||
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"];
|
||||
if(__id != nil) dict[@"id"] = __id ;
|
||||
if(_lastName != nil) dict[@"lastName"] = _lastName ;
|
||||
if(_phone != nil) dict[@"phone"] = _phone ;
|
||||
if(_username != nil) dict[@"username"] = _username ;
|
||||
if(_email != nil) dict[@"email"] = _email ;
|
||||
if(_userStatus != nil) dict[@"userStatus"] = _userStatus ;
|
||||
if(_firstName != nil) dict[@"firstName"] = _firstName ;
|
||||
if(_password != nil) dict[@"password"] = _password ;
|
||||
NSDictionary* output = [dict copy];
|
||||
return output;
|
||||
}
|
||||
|
@ -12,23 +12,80 @@
|
||||
@property(nonatomic, readonly) NSOperationQueue* queue;
|
||||
@property(nonatomic, readonly) NIKApiInvoker* api;
|
||||
|
||||
-(void) addHeader:(NSString*) value
|
||||
forKey:(NSString*)key;
|
||||
-(void) addHeader:(NSString*)value forKey:(NSString*)key;
|
||||
|
||||
/**
|
||||
|
||||
Creates list of users with given input array
|
||||
|
||||
@param body List of user object
|
||||
*/
|
||||
-(void) createUsersWithArrayInputWithCompletionBlock :(NSArray*) body
|
||||
completionHandler:(void (^)(NSError *))completionBlock;
|
||||
completionHandler: (void (^)(NSError* error))completionBlock;
|
||||
|
||||
/**
|
||||
|
||||
Create user
|
||||
This can only be done by the logged in user.
|
||||
@param body Created user object
|
||||
*/
|
||||
-(void) createUserWithCompletionBlock :(NIKUser*) body
|
||||
completionHandler:(void (^)(NSError *))completionBlock;
|
||||
completionHandler: (void (^)(NSError* error))completionBlock;
|
||||
|
||||
/**
|
||||
|
||||
Creates list of users with given list input
|
||||
|
||||
@param body List of user object
|
||||
*/
|
||||
-(void) createUsersWithListInputWithCompletionBlock :(NSArray*) body
|
||||
completionHandler:(void (^)(NSError *))completionBlock;
|
||||
-(void) updateUserWithCompletionBlock :(NSString*) username body:(NIKUser*) body
|
||||
completionHandler:(void (^)(NSError *))completionBlock;
|
||||
completionHandler: (void (^)(NSError* error))completionBlock;
|
||||
|
||||
/**
|
||||
|
||||
Updated user
|
||||
This can only be done by the logged in user.
|
||||
@param username name that need to be deleted
|
||||
@param body Updated user object
|
||||
*/
|
||||
-(void) updateUserWithCompletionBlock :(NSString*) username
|
||||
body:(NIKUser*) body
|
||||
completionHandler: (void (^)(NSError* error))completionBlock;
|
||||
|
||||
/**
|
||||
|
||||
Delete user
|
||||
This can only be done by the logged in user.
|
||||
@param username The name that needs to be deleted
|
||||
*/
|
||||
-(void) deleteUserWithCompletionBlock :(NSString*) username
|
||||
completionHandler:(void (^)(NSError *))completionBlock;
|
||||
completionHandler: (void (^)(NSError* error))completionBlock;
|
||||
|
||||
/**
|
||||
|
||||
Get user by user name
|
||||
|
||||
@param username The name that needs to be fetched. Use user1 for testing.
|
||||
*/
|
||||
-(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;
|
||||
completionHandler: (void (^)(NIKUser* output, NSError* error))completionBlock;
|
||||
|
||||
/**
|
||||
|
||||
Logs user into the system
|
||||
|
||||
@param username The user name for login
|
||||
@param password The password for login in clear text
|
||||
*/
|
||||
-(void) loginUserWithCompletionBlock :(NSString*) username
|
||||
password:(NSString*) password
|
||||
completionHandler: (void (^)(NSString* output, NSError* error))completionBlock;
|
||||
|
||||
/**
|
||||
|
||||
Logs out current logged in user session
|
||||
|
||||
*/
|
||||
-(void) logoutUserWithCompletionBlock :(void (^)(NSError* error))completionBlock;
|
||||
|
||||
@end
|
||||
|
@ -9,10 +9,20 @@ static NSString * basePath = @"http://petstore.swagger.wordnik.com/api";
|
||||
@synthesize queue = _queue;
|
||||
@synthesize api = _api;
|
||||
|
||||
- (id) init {
|
||||
+(NIKUserApi*) apiWithHeader:(NSString*)headerValue key:(NSString*)key {
|
||||
static NIKUserApi* singletonAPI = nil;
|
||||
|
||||
if (singletonAPI == nil) {
|
||||
singletonAPI = [[NIKUserApi alloc] init];
|
||||
[singletonAPI addHeader:headerValue forKey:key];
|
||||
}
|
||||
return singletonAPI;
|
||||
}
|
||||
|
||||
-(id) init {
|
||||
self = [super init];
|
||||
_queue = [[NSOperationQueue alloc] init];
|
||||
_api = [[NIKApiInvoker alloc] init];
|
||||
_api = [NIKApiInvoker sharedInstance];
|
||||
|
||||
return self;
|
||||
}
|
||||
@ -22,15 +32,8 @@ static NSString * basePath = @"http://petstore.swagger.wordnik.com/api";
|
||||
[_api addHeader:value forKey:key];
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* returnTypeIsPrimitive: true
|
||||
* returnBaseType:
|
||||
* returnContainer:
|
||||
*
|
||||
**/
|
||||
-(void) createUsersWithArrayInputWithCompletionBlock :(NSArray*) body
|
||||
completionHandler:(void (^)(NSError *))completionBlock{
|
||||
-(void) createUsersWithArrayInputWithCompletionBlock:(NSArray*) body
|
||||
completionHandler: (void (^)(NSError* error))completionBlock{
|
||||
|
||||
NSMutableString* requestUrl = [NSMutableString stringWithFormat:@"%@/user.{format}/createWithArray", basePath];
|
||||
|
||||
@ -66,12 +69,12 @@ static NSString * basePath = @"http://petstore.swagger.wordnik.com/api";
|
||||
if(body == nil) {
|
||||
// error
|
||||
}
|
||||
[_api stringWithCompletionBlock: requestUrl
|
||||
method: @"POST"
|
||||
queryParams: queryParams
|
||||
body: bodyDictionary
|
||||
headerParams: headerParams
|
||||
completionHandler: ^(NSString *data, NSError *error) {
|
||||
[_api stringWithCompletionBlock:requestUrl
|
||||
method:@"POST"
|
||||
queryParams:queryParams
|
||||
body:bodyDictionary
|
||||
headerParams:headerParams
|
||||
completionBlock:^(NSString *data, NSError *error) {
|
||||
if (error) {
|
||||
completionBlock(error);
|
||||
return;
|
||||
@ -79,17 +82,11 @@ static NSString * basePath = @"http://petstore.swagger.wordnik.com/api";
|
||||
completionBlock(nil);
|
||||
}];
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* returnTypeIsPrimitive: true
|
||||
* returnBaseType:
|
||||
* returnContainer:
|
||||
*
|
||||
**/
|
||||
-(void) createUserWithCompletionBlock :(NIKUser*) body
|
||||
completionHandler:(void (^)(NSError *))completionBlock{
|
||||
-(void) createUserWithCompletionBlock:(NIKUser*) body
|
||||
completionHandler: (void (^)(NSError* error))completionBlock{
|
||||
|
||||
NSMutableString* requestUrl = [NSMutableString stringWithFormat:@"%@/user.{format}", basePath];
|
||||
|
||||
@ -125,12 +122,12 @@ static NSString * basePath = @"http://petstore.swagger.wordnik.com/api";
|
||||
if(body == nil) {
|
||||
// error
|
||||
}
|
||||
[_api stringWithCompletionBlock: requestUrl
|
||||
method: @"POST"
|
||||
queryParams: queryParams
|
||||
body: bodyDictionary
|
||||
headerParams: headerParams
|
||||
completionHandler: ^(NSString *data, NSError *error) {
|
||||
[_api stringWithCompletionBlock:requestUrl
|
||||
method:@"POST"
|
||||
queryParams:queryParams
|
||||
body:bodyDictionary
|
||||
headerParams:headerParams
|
||||
completionBlock:^(NSString *data, NSError *error) {
|
||||
if (error) {
|
||||
completionBlock(error);
|
||||
return;
|
||||
@ -138,17 +135,11 @@ static NSString * basePath = @"http://petstore.swagger.wordnik.com/api";
|
||||
completionBlock(nil);
|
||||
}];
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* returnTypeIsPrimitive: true
|
||||
* returnBaseType:
|
||||
* returnContainer:
|
||||
*
|
||||
**/
|
||||
-(void) createUsersWithListInputWithCompletionBlock :(NSArray*) body
|
||||
completionHandler:(void (^)(NSError *))completionBlock{
|
||||
-(void) createUsersWithListInputWithCompletionBlock:(NSArray*) body
|
||||
completionHandler: (void (^)(NSError* error))completionBlock{
|
||||
|
||||
NSMutableString* requestUrl = [NSMutableString stringWithFormat:@"%@/user.{format}/createWithList", basePath];
|
||||
|
||||
@ -184,12 +175,12 @@ static NSString * basePath = @"http://petstore.swagger.wordnik.com/api";
|
||||
if(body == nil) {
|
||||
// error
|
||||
}
|
||||
[_api stringWithCompletionBlock: requestUrl
|
||||
method: @"POST"
|
||||
queryParams: queryParams
|
||||
body: bodyDictionary
|
||||
headerParams: headerParams
|
||||
completionHandler: ^(NSString *data, NSError *error) {
|
||||
[_api stringWithCompletionBlock:requestUrl
|
||||
method:@"POST"
|
||||
queryParams:queryParams
|
||||
body:bodyDictionary
|
||||
headerParams:headerParams
|
||||
completionBlock:^(NSString *data, NSError *error) {
|
||||
if (error) {
|
||||
completionBlock(error);
|
||||
return;
|
||||
@ -197,17 +188,12 @@ static NSString * basePath = @"http://petstore.swagger.wordnik.com/api";
|
||||
completionBlock(nil);
|
||||
}];
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* returnTypeIsPrimitive: true
|
||||
* returnBaseType:
|
||||
* returnContainer:
|
||||
*
|
||||
**/
|
||||
-(void) updateUserWithCompletionBlock :(NSString*) username body:(NIKUser*) body
|
||||
completionHandler:(void (^)(NSError *))completionBlock{
|
||||
-(void) updateUserWithCompletionBlock:(NSString*) username
|
||||
body:(NIKUser*) body
|
||||
completionHandler: (void (^)(NSError* error))completionBlock{
|
||||
|
||||
NSMutableString* requestUrl = [NSMutableString stringWithFormat:@"%@/user.{format}/{username}", basePath];
|
||||
|
||||
@ -247,12 +233,12 @@ static NSString * basePath = @"http://petstore.swagger.wordnik.com/api";
|
||||
if(body == nil) {
|
||||
// error
|
||||
}
|
||||
[_api stringWithCompletionBlock: requestUrl
|
||||
method: @"PUT"
|
||||
queryParams: queryParams
|
||||
body: bodyDictionary
|
||||
headerParams: headerParams
|
||||
completionHandler: ^(NSString *data, NSError *error) {
|
||||
[_api stringWithCompletionBlock:requestUrl
|
||||
method:@"PUT"
|
||||
queryParams:queryParams
|
||||
body:bodyDictionary
|
||||
headerParams:headerParams
|
||||
completionBlock:^(NSString *data, NSError *error) {
|
||||
if (error) {
|
||||
completionBlock(error);
|
||||
return;
|
||||
@ -260,17 +246,11 @@ static NSString * basePath = @"http://petstore.swagger.wordnik.com/api";
|
||||
completionBlock(nil);
|
||||
}];
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* returnTypeIsPrimitive: true
|
||||
* returnBaseType:
|
||||
* returnContainer:
|
||||
*
|
||||
**/
|
||||
-(void) deleteUserWithCompletionBlock :(NSString*) username
|
||||
completionHandler:(void (^)(NSError *))completionBlock{
|
||||
-(void) deleteUserWithCompletionBlock:(NSString*) username
|
||||
completionHandler: (void (^)(NSError* error))completionBlock{
|
||||
|
||||
NSMutableString* requestUrl = [NSMutableString stringWithFormat:@"%@/user.{format}/{username}", basePath];
|
||||
|
||||
@ -285,12 +265,12 @@ static NSString * basePath = @"http://petstore.swagger.wordnik.com/api";
|
||||
if(username == nil) {
|
||||
// error
|
||||
}
|
||||
[_api stringWithCompletionBlock: requestUrl
|
||||
method: @"DELETE"
|
||||
queryParams: queryParams
|
||||
body: bodyDictionary
|
||||
headerParams: headerParams
|
||||
completionHandler: ^(NSString *data, NSError *error) {
|
||||
[_api stringWithCompletionBlock:requestUrl
|
||||
method:@"DELETE"
|
||||
queryParams:queryParams
|
||||
body:bodyDictionary
|
||||
headerParams:headerParams
|
||||
completionBlock:^(NSString *data, NSError *error) {
|
||||
if (error) {
|
||||
completionBlock(error);
|
||||
return;
|
||||
@ -298,17 +278,11 @@ static NSString * basePath = @"http://petstore.swagger.wordnik.com/api";
|
||||
completionBlock(nil);
|
||||
}];
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* returnTypeIsPrimitive:
|
||||
* returnBaseType: NIKUser
|
||||
* returnContainer:
|
||||
*
|
||||
**/
|
||||
-(void) getUserByNameWithCompletionBlock :(NSString*) username
|
||||
completionHandler:(void (^)(NIKUser*, NSError *))completionBlock{
|
||||
-(void) getUserByNameWithCompletionBlock:(NSString*) username
|
||||
completionHandler: (void (^)(NIKUser* output, NSError* error))completionBlock{
|
||||
|
||||
NSMutableString* requestUrl = [NSMutableString stringWithFormat:@"%@/user.{format}/{username}", basePath];
|
||||
|
||||
@ -323,29 +297,24 @@ static NSString * basePath = @"http://petstore.swagger.wordnik.com/api";
|
||||
if(username == nil) {
|
||||
// error
|
||||
}
|
||||
[_api dictionaryWithCompletionBlock: requestUrl
|
||||
method: @"GET"
|
||||
queryParams: queryParams
|
||||
body: bodyDictionary
|
||||
headerParams: headerParams
|
||||
completionHandler: ^(NSDictionary *data, NSError *error) {
|
||||
[_api dictionary:requestUrl
|
||||
method:@"GET"
|
||||
queryParams:queryParams
|
||||
body:bodyDictionary
|
||||
headerParams:headerParams
|
||||
completionBlock:^(NSDictionary *data, NSError *error) {
|
||||
if (error) {
|
||||
completionBlock(nil, error);return;
|
||||
}
|
||||
|
||||
completionBlock( [[NIKUser alloc]initWithValues: data], nil);}];
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* returnTypeIsPrimitive: true
|
||||
* returnBaseType: NSString
|
||||
* returnContainer:
|
||||
*
|
||||
**/
|
||||
-(void) loginUserWithCompletionBlock :(NSString*) username password:(NSString*) password
|
||||
completionHandler:(void (^)(NSString*, NSError *))completionBlock{
|
||||
-(void) loginUserWithCompletionBlock:(NSString*) username
|
||||
password:(NSString*) password
|
||||
completionHandler: (void (^)(NSString* output, NSError* error))completionBlock{
|
||||
|
||||
NSMutableString* requestUrl = [NSMutableString stringWithFormat:@"%@/user.{format}/login", basePath];
|
||||
|
||||
@ -355,9 +324,9 @@ static NSString * basePath = @"http://petstore.swagger.wordnik.com/api";
|
||||
|
||||
NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init];
|
||||
if(username != nil)
|
||||
[queryParams setValue:username forKey:@"username"];
|
||||
queryParams[@"username"] = username;
|
||||
if(password != nil)
|
||||
[queryParams setValue:password forKey:@"password"];
|
||||
queryParams[@"password"] = password;
|
||||
NSMutableDictionary* headerParams = [[NSMutableDictionary alloc] init];
|
||||
id bodyDictionary = nil;
|
||||
if(username == nil) {
|
||||
@ -366,12 +335,12 @@ static NSString * basePath = @"http://petstore.swagger.wordnik.com/api";
|
||||
if(password == nil) {
|
||||
// error
|
||||
}
|
||||
[_api stringWithCompletionBlock: requestUrl
|
||||
method: @"GET"
|
||||
queryParams: queryParams
|
||||
body: bodyDictionary
|
||||
headerParams: headerParams
|
||||
completionHandler: ^(NSString *data, NSError *error) {
|
||||
[_api stringWithCompletionBlock:requestUrl
|
||||
method:@"GET"
|
||||
queryParams:queryParams
|
||||
body:bodyDictionary
|
||||
headerParams:headerParams
|
||||
completionBlock:^(NSString *data, NSError *error) {
|
||||
if (error) {
|
||||
completionBlock(nil, error);
|
||||
return;
|
||||
@ -379,29 +348,11 @@ static NSString * basePath = @"http://petstore.swagger.wordnik.com/api";
|
||||
|
||||
completionBlock( [[NSString alloc]initWithString: data], nil);
|
||||
}];
|
||||
[_api dictionaryWithCompletionBlock: requestUrl
|
||||
method: @"GET"
|
||||
queryParams: queryParams
|
||||
body: bodyDictionary
|
||||
headerParams: headerParams
|
||||
completionHandler: ^(NSDictionary *data, NSError *error) {
|
||||
if (error) {
|
||||
completionBlock(nil, error);return;
|
||||
}
|
||||
|
||||
completionBlock( [[NSString alloc]initWithString: data], nil);}];
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* returnTypeIsPrimitive: true
|
||||
* returnBaseType:
|
||||
* returnContainer:
|
||||
*
|
||||
**/
|
||||
-(void) logoutUserWithCompletionBlock :
|
||||
completionHandler:(void (^)(NSError *))completionBlock{
|
||||
-(void) logoutUserWithCompletionBlock: (void (^)(NSError* error))completionBlock{
|
||||
|
||||
NSMutableString* requestUrl = [NSMutableString stringWithFormat:@"%@/user.{format}/logout", basePath];
|
||||
|
||||
@ -412,12 +363,12 @@ static NSString * basePath = @"http://petstore.swagger.wordnik.com/api";
|
||||
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) {
|
||||
[_api stringWithCompletionBlock:requestUrl
|
||||
method:@"GET"
|
||||
queryParams:queryParams
|
||||
body:bodyDictionary
|
||||
headerParams:headerParams
|
||||
completionBlock:^(NSString *data, NSError *error) {
|
||||
if (error) {
|
||||
completionBlock(error);
|
||||
return;
|
||||
@ -425,9 +376,11 @@ static NSString * basePath = @"http://petstore.swagger.wordnik.com/api";
|
||||
completionBlock(nil);
|
||||
}];
|
||||
|
||||
|
||||
}
|
||||
|
||||
-(void) createUsersWithArrayInputAsJsonWithCompletionBlock :(NSArray*) body
|
||||
|
||||
completionHandler:(void (^)(NSError *))completionBlock{
|
||||
|
||||
NSMutableString* requestUrl = [NSMutableString stringWithFormat:@"%@/user.{format}/createWithArray", basePath];
|
||||
@ -464,22 +417,25 @@ static NSString * basePath = @"http://petstore.swagger.wordnik.com/api";
|
||||
if(body == nil) {
|
||||
// error
|
||||
}
|
||||
[_api dictionaryWithCompletionBlock: requestUrl
|
||||
method: @"POST"
|
||||
queryParams: queryParams
|
||||
body: bodyDictionary
|
||||
headerParams: headerParams
|
||||
completionHandler: ^(NSDictionary *data, NSError *error) {
|
||||
[_api dictionary:requestUrl
|
||||
method:@"POST"
|
||||
queryParams:queryParams
|
||||
body:bodyDictionary
|
||||
headerParams:headerParams
|
||||
completionBlock:^(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];
|
||||
@ -516,22 +472,25 @@ static NSString * basePath = @"http://petstore.swagger.wordnik.com/api";
|
||||
if(body == nil) {
|
||||
// error
|
||||
}
|
||||
[_api dictionaryWithCompletionBlock: requestUrl
|
||||
method: @"POST"
|
||||
queryParams: queryParams
|
||||
body: bodyDictionary
|
||||
headerParams: headerParams
|
||||
completionHandler: ^(NSDictionary *data, NSError *error) {
|
||||
[_api dictionary:requestUrl
|
||||
method:@"POST"
|
||||
queryParams:queryParams
|
||||
body:bodyDictionary
|
||||
headerParams:headerParams
|
||||
completionBlock:^(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];
|
||||
@ -568,22 +527,26 @@ static NSString * basePath = @"http://petstore.swagger.wordnik.com/api";
|
||||
if(body == nil) {
|
||||
// error
|
||||
}
|
||||
[_api dictionaryWithCompletionBlock: requestUrl
|
||||
method: @"POST"
|
||||
queryParams: queryParams
|
||||
body: bodyDictionary
|
||||
headerParams: headerParams
|
||||
completionHandler: ^(NSDictionary *data, NSError *error) {
|
||||
[_api dictionary:requestUrl
|
||||
method:@"POST"
|
||||
queryParams:queryParams
|
||||
body:bodyDictionary
|
||||
headerParams:headerParams
|
||||
completionBlock:^(NSDictionary *data, NSError *error) {
|
||||
if (error) {
|
||||
completionBlock(error);return;
|
||||
}
|
||||
|
||||
completionBlock(nil);
|
||||
|
||||
}];
|
||||
|
||||
|
||||
}
|
||||
|
||||
-(void) updateUserAsJsonWithCompletionBlock :(NSString*) username body:(NIKUser*) body
|
||||
-(void) updateUserAsJsonWithCompletionBlock :(NSString*) username
|
||||
body:(NIKUser*) body
|
||||
|
||||
completionHandler:(void (^)(NSError *))completionBlock{
|
||||
|
||||
NSMutableString* requestUrl = [NSMutableString stringWithFormat:@"%@/user.{format}/{username}", basePath];
|
||||
@ -624,22 +587,25 @@ static NSString * basePath = @"http://petstore.swagger.wordnik.com/api";
|
||||
if(body == nil) {
|
||||
// error
|
||||
}
|
||||
[_api dictionaryWithCompletionBlock: requestUrl
|
||||
method: @"PUT"
|
||||
queryParams: queryParams
|
||||
body: bodyDictionary
|
||||
headerParams: headerParams
|
||||
completionHandler: ^(NSDictionary *data, NSError *error) {
|
||||
[_api dictionary:requestUrl
|
||||
method:@"PUT"
|
||||
queryParams:queryParams
|
||||
body:bodyDictionary
|
||||
headerParams:headerParams
|
||||
completionBlock:^(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];
|
||||
@ -655,22 +621,25 @@ static NSString * basePath = @"http://petstore.swagger.wordnik.com/api";
|
||||
if(username == nil) {
|
||||
// error
|
||||
}
|
||||
[_api dictionaryWithCompletionBlock: requestUrl
|
||||
method: @"DELETE"
|
||||
queryParams: queryParams
|
||||
body: bodyDictionary
|
||||
headerParams: headerParams
|
||||
completionHandler: ^(NSDictionary *data, NSError *error) {
|
||||
[_api dictionary:requestUrl
|
||||
method:@"DELETE"
|
||||
queryParams:queryParams
|
||||
body:bodyDictionary
|
||||
headerParams:headerParams
|
||||
completionBlock:^(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];
|
||||
@ -686,12 +655,12 @@ static NSString * basePath = @"http://petstore.swagger.wordnik.com/api";
|
||||
if(username == nil) {
|
||||
// error
|
||||
}
|
||||
[_api dictionaryWithCompletionBlock: requestUrl
|
||||
method: @"GET"
|
||||
queryParams: queryParams
|
||||
body: bodyDictionary
|
||||
headerParams: headerParams
|
||||
completionHandler: ^(NSDictionary *data, NSError *error) {
|
||||
[_api dictionary:requestUrl
|
||||
method:@"GET"
|
||||
queryParams:queryParams
|
||||
body:bodyDictionary
|
||||
headerParams:headerParams
|
||||
completionBlock:^(NSDictionary *data, NSError *error) {
|
||||
if (error) {
|
||||
completionBlock(nil, error);return;
|
||||
}
|
||||
@ -708,11 +677,15 @@ static NSString * basePath = @"http://petstore.swagger.wordnik.com/api";
|
||||
NSString * json = [[NSString alloc]initWithData:responseData encoding:NSUTF8StringEncoding];
|
||||
completionBlock(json, nil);
|
||||
|
||||
|
||||
}];
|
||||
|
||||
|
||||
}
|
||||
|
||||
-(void) loginUserAsJsonWithCompletionBlock :(NSString*) username password:(NSString*) password
|
||||
-(void) loginUserAsJsonWithCompletionBlock :(NSString*) username
|
||||
password:(NSString*) password
|
||||
|
||||
completionHandler:(void (^)(NSString*, NSError *))completionBlock{
|
||||
|
||||
NSMutableString* requestUrl = [NSMutableString stringWithFormat:@"%@/user.{format}/login", basePath];
|
||||
@ -723,9 +696,9 @@ static NSString * basePath = @"http://petstore.swagger.wordnik.com/api";
|
||||
|
||||
NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init];
|
||||
if(username != nil)
|
||||
[queryParams setValue:username forKey:@"username"];
|
||||
queryParams[@"username"] = username;
|
||||
if(password != nil)
|
||||
[queryParams setValue:password forKey:@"password"];
|
||||
queryParams[@"password"] = password;
|
||||
NSMutableDictionary* headerParams = [[NSMutableDictionary alloc] init];
|
||||
id bodyDictionary = nil;
|
||||
if(username == nil) {
|
||||
@ -734,12 +707,12 @@ static NSString * basePath = @"http://petstore.swagger.wordnik.com/api";
|
||||
if(password == nil) {
|
||||
// error
|
||||
}
|
||||
[_api dictionaryWithCompletionBlock: requestUrl
|
||||
method: @"GET"
|
||||
queryParams: queryParams
|
||||
body: bodyDictionary
|
||||
headerParams: headerParams
|
||||
completionHandler: ^(NSDictionary *data, NSError *error) {
|
||||
[_api dictionary:requestUrl
|
||||
method:@"GET"
|
||||
queryParams:queryParams
|
||||
body:bodyDictionary
|
||||
headerParams:headerParams
|
||||
completionBlock:^(NSDictionary *data, NSError *error) {
|
||||
if (error) {
|
||||
completionBlock(nil, error);return;
|
||||
}
|
||||
@ -756,11 +729,14 @@ static NSString * basePath = @"http://petstore.swagger.wordnik.com/api";
|
||||
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];
|
||||
@ -772,19 +748,21 @@ static NSString * basePath = @"http://petstore.swagger.wordnik.com/api";
|
||||
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) {
|
||||
[_api dictionary:requestUrl
|
||||
method:@"GET"
|
||||
queryParams:queryParams
|
||||
body:bodyDictionary
|
||||
headerParams:headerParams
|
||||
completionBlock:^(NSDictionary *data, NSError *error) {
|
||||
if (error) {
|
||||
completionBlock(error);return;
|
||||
}
|
||||
|
||||
completionBlock(nil);
|
||||
|
||||
}];
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -314,7 +314,7 @@
|
||||
if([[tag name] isEqualToString:@"tag1"] || [[tag name] isEqualToString:@"tag2"])
|
||||
hasTag = true;
|
||||
}
|
||||
STAssertEquals(hasTag, true, @"didn't find tag in pet");
|
||||
if(!hasTag) STFail(@"failed to find tag in pet");
|
||||
}
|
||||
done = true;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user