forked from loafle/openapi-generator-original
updated samples
This commit is contained in:
parent
422cd88b51
commit
a7f12c04e6
@ -1,3 +1,3 @@
|
||||
platform :ios, '6.0'
|
||||
xcodeproj '/.xcodeproj'
|
||||
pod 'AFNetworking', '~> 1.0'
|
||||
xcodeproj 'swaggerClient/swaggerClient.xcodeproj'
|
||||
pod 'AFNetworking', '~> 2.1'
|
||||
|
@ -1,7 +1,15 @@
|
||||
#import <Foundation/Foundation.h>
|
||||
#import "AFHTTPClient.h"
|
||||
#import "AFHTTPRequestOperationManager.h"
|
||||
|
||||
@interface SWGApiClient : AFHTTPClient
|
||||
/**
|
||||
* A key for `NSError` user info dictionaries.
|
||||
*
|
||||
* The corresponding value is the parsed response body for an HTTP error.
|
||||
*/
|
||||
extern NSString *const SWGResponseObjectErrorKey;
|
||||
|
||||
|
||||
@interface SWGApiClient : AFHTTPRequestOperationManager
|
||||
|
||||
@property(nonatomic, assign) NSURLRequestCachePolicy cachePolicy;
|
||||
@property(nonatomic, assign) NSTimeInterval timeoutInterval;
|
||||
|
@ -1,10 +1,10 @@
|
||||
#import "SWGApiClient.h"
|
||||
#import "SWGFile.h"
|
||||
|
||||
#import "AFJSONRequestOperation.h"
|
||||
|
||||
@implementation SWGApiClient
|
||||
|
||||
NSString *const SWGResponseObjectErrorKey = @"SWGResponseObject";
|
||||
|
||||
static long requestId = 0;
|
||||
static bool offlineState = false;
|
||||
static NSMutableSet * queuedRequests = nil;
|
||||
@ -68,8 +68,6 @@ static bool loggingEnabled = false;
|
||||
SWGApiClient * client = [_pool objectForKey:baseUrl];
|
||||
if (client == nil) {
|
||||
client = [[SWGApiClient alloc] initWithBaseURL:[NSURL URLWithString:baseUrl]];
|
||||
[client registerHTTPOperationClass:[AFJSONRequestOperation class]];
|
||||
client.parameterEncoding = AFJSONParameterEncoding;
|
||||
[_pool setValue:client forKey:baseUrl ];
|
||||
if(loggingEnabled)
|
||||
NSLog(@"new client for path %@", baseUrl);
|
||||
@ -82,7 +80,7 @@ static bool loggingEnabled = false;
|
||||
|
||||
-(void)setHeaderValue:(NSString*) value
|
||||
forKey:(NSString*) forKey {
|
||||
[self setDefaultHeader:forKey value:value];
|
||||
[self.requestSerializer setValue:value forHTTPHeaderField:forKey];
|
||||
}
|
||||
|
||||
+(unsigned long)requestQueueSize {
|
||||
@ -142,6 +140,8 @@ static bool loggingEnabled = false;
|
||||
|
||||
-(id)initWithBaseURL:(NSURL *)url {
|
||||
self = [super initWithBaseURL:url];
|
||||
self.requestSerializer = [AFJSONRequestSerializer serializer];
|
||||
self.responseSerializer = [AFJSONResponseSerializer serializer];
|
||||
if (!self)
|
||||
return nil;
|
||||
return self;
|
||||
@ -160,7 +160,7 @@ static bool loggingEnabled = false;
|
||||
}
|
||||
|
||||
+(void) configureCacheReachibilityForHost:(NSString*)host {
|
||||
[[SWGApiClient sharedClientFromPool:host ] setReachabilityStatusChangeBlock:^(AFNetworkReachabilityStatus status) {
|
||||
[[SWGApiClient sharedClientFromPool:host].reachabilityManager setReachabilityStatusChangeBlock:^(AFNetworkReachabilityStatus status) {
|
||||
reachabilityStatus = status;
|
||||
switch (status) {
|
||||
case AFNetworkReachabilityStatusUnknown:
|
||||
@ -194,6 +194,7 @@ static bool loggingEnabled = false;
|
||||
reachabilityChangeBlock(status);
|
||||
}
|
||||
}];
|
||||
[[SWGApiClient sharedClientFromPool:host].reachabilityManager startMonitoring];
|
||||
}
|
||||
|
||||
-(NSString*) pathWithQueryParamsToString:(NSString*) path
|
||||
@ -247,21 +248,27 @@ static bool loggingEnabled = false;
|
||||
|
||||
if ([body isKindOfClass:[SWGFile class]]){
|
||||
SWGFile * file = (SWGFile*) body;
|
||||
NSString * urlString = [[NSURL URLWithString:path relativeToURL:self.baseURL] absoluteString];
|
||||
|
||||
request = [self multipartFormRequestWithMethod:@"POST"
|
||||
path:path
|
||||
parameters:nil
|
||||
constructingBodyWithBlock: ^(id <AFMultipartFormData> formData) {
|
||||
[formData appendPartWithFileData:[file data]
|
||||
name:@"image"
|
||||
fileName:[file name]
|
||||
mimeType:[file mimeType]];
|
||||
}];
|
||||
request = [self.requestSerializer multipartFormRequestWithMethod:@"POST"
|
||||
URLString:urlString
|
||||
parameters:nil
|
||||
constructingBodyWithBlock:^(id<AFMultipartFormData> formData) {
|
||||
[formData appendPartWithFileData:[file data]
|
||||
name:@"image"
|
||||
fileName:[file name]
|
||||
mimeType:[file mimeType]];
|
||||
}
|
||||
error:nil];
|
||||
}
|
||||
else {
|
||||
request = [self requestWithMethod:method
|
||||
path:[self pathWithQueryParamsToString:path queryParams:queryParams]
|
||||
parameters:body];
|
||||
NSString * pathWithQueryParams = [self pathWithQueryParamsToString:path queryParams:queryParams];
|
||||
NSString * urlString = [[NSURL URLWithString:pathWithQueryParams relativeToURL:self.baseURL] absoluteString];
|
||||
|
||||
request = [self.requestSerializer requestWithMethod:method
|
||||
URLString:urlString
|
||||
parameters:body
|
||||
error:nil];
|
||||
}
|
||||
BOOL hasHeaderParams = false;
|
||||
if(headerParams != nil && [headerParams count] > 0)
|
||||
@ -304,25 +311,31 @@ static bool loggingEnabled = false;
|
||||
}
|
||||
|
||||
NSNumber* requestId = [SWGApiClient queueRequest];
|
||||
AFJSONRequestOperation *op =
|
||||
[AFJSONRequestOperation
|
||||
JSONRequestOperationWithRequest:request
|
||||
success:^(NSURLRequest *request, NSHTTPURLResponse *response, id JSON) {
|
||||
AFHTTPRequestOperation *op =
|
||||
[self HTTPRequestOperationWithRequest:request
|
||||
success:^(AFHTTPRequestOperation *operation, id JSON) {
|
||||
if([self executeRequestWithId:requestId]) {
|
||||
if(self.logServerResponses)
|
||||
[self logResponse:JSON forRequest:request error:nil];
|
||||
completionBlock(JSON, nil);
|
||||
}
|
||||
} failure:^(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error, id data) {
|
||||
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
|
||||
if([self executeRequestWithId:requestId]) {
|
||||
NSMutableDictionary *userInfo = [error.userInfo mutableCopy];
|
||||
if(operation.responseObject) {
|
||||
// Add in the (parsed) response body.
|
||||
userInfo[SWGResponseObjectErrorKey] = operation.responseObject;
|
||||
}
|
||||
NSError *augmentedError = [error initWithDomain:error.domain code:error.code userInfo:userInfo];
|
||||
|
||||
if(self.logServerResponses)
|
||||
[self logResponse:nil forRequest:request error:error];
|
||||
completionBlock(nil, error);
|
||||
[self logResponse:nil forRequest:request error:augmentedError];
|
||||
completionBlock(nil, augmentedError);
|
||||
}
|
||||
}
|
||||
];
|
||||
|
||||
[self enqueueHTTPRequestOperation:op];
|
||||
[self.operationQueue addOperation:op];
|
||||
return requestId;
|
||||
}
|
||||
|
||||
@ -334,30 +347,32 @@ static bool loggingEnabled = false;
|
||||
requestContentType:(NSString*) requestContentType
|
||||
responseContentType:(NSString*) responseContentType
|
||||
completionBlock:(void (^)(NSString*, NSError *))completionBlock {
|
||||
AFHTTPClient *client = self;
|
||||
client.parameterEncoding = AFJSONParameterEncoding;
|
||||
|
||||
NSMutableURLRequest * request = nil;
|
||||
|
||||
if ([body isKindOfClass:[SWGFile class]]){
|
||||
SWGFile * file = (SWGFile*) body;
|
||||
NSString * urlString = [[NSURL URLWithString:path relativeToURL:self.baseURL] absoluteString];
|
||||
|
||||
request = [self multipartFormRequestWithMethod:@"POST"
|
||||
path:path
|
||||
parameters:nil
|
||||
constructingBodyWithBlock: ^(id <AFMultipartFormData> formData) {
|
||||
[formData appendPartWithFileData:[file data]
|
||||
name:@"image"
|
||||
fileName:[file name]
|
||||
mimeType:[file mimeType]];
|
||||
}];
|
||||
request = [self.requestSerializer multipartFormRequestWithMethod:@"POST"
|
||||
URLString:urlString
|
||||
parameters:nil
|
||||
constructingBodyWithBlock:^(id<AFMultipartFormData> formData) {
|
||||
[formData appendPartWithFileData:[file data]
|
||||
name:@"image"
|
||||
fileName:[file name]
|
||||
mimeType:[file mimeType]];
|
||||
}
|
||||
error:nil];
|
||||
}
|
||||
else {
|
||||
request = [self requestWithMethod:method
|
||||
path:[self pathWithQueryParamsToString:path queryParams:queryParams]
|
||||
parameters:body];
|
||||
}
|
||||
NSString * pathWithQueryParams = [self pathWithQueryParamsToString:path queryParams:queryParams];
|
||||
NSString * urlString = [[NSURL URLWithString:pathWithQueryParams relativeToURL:self.baseURL] absoluteString];
|
||||
|
||||
request = [self.requestSerializer requestWithMethod:method
|
||||
URLString:urlString
|
||||
parameters:body
|
||||
error:nil];
|
||||
}
|
||||
BOOL hasHeaderParams = false;
|
||||
if(headerParams != nil && [headerParams count] > 0)
|
||||
hasHeaderParams = true;
|
||||
@ -394,11 +409,9 @@ static bool loggingEnabled = false;
|
||||
[request setHTTPShouldHandleCookies:NO];
|
||||
|
||||
NSNumber* requestId = [SWGApiClient queueRequest];
|
||||
AFHTTPRequestOperation *op = [[AFHTTPRequestOperation alloc] initWithRequest:request];
|
||||
[op setCompletionBlockWithSuccess:
|
||||
^(AFHTTPRequestOperation *resp,
|
||||
id responseObject) {
|
||||
NSString *response = [resp responseString];
|
||||
AFHTTPRequestOperation *op = [self HTTPRequestOperationWithRequest:request
|
||||
success:^(AFHTTPRequestOperation *operation, id responseObject) {
|
||||
NSString *response = [operation responseString];
|
||||
if([self executeRequestWithId:requestId]) {
|
||||
if(self.logServerResponses)
|
||||
[self logResponse:responseObject forRequest:request error:nil];
|
||||
@ -406,13 +419,20 @@ static bool loggingEnabled = false;
|
||||
}
|
||||
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
|
||||
if([self executeRequestWithId:requestId]) {
|
||||
NSMutableDictionary *userInfo = [error.userInfo mutableCopy];
|
||||
if(operation.responseObject) {
|
||||
// Add in the (parsed) response body.
|
||||
userInfo[SWGResponseObjectErrorKey] = operation.responseObject;
|
||||
}
|
||||
NSError *augmentedError = [error initWithDomain:error.domain code:error.code userInfo:userInfo];
|
||||
|
||||
if(self.logServerResponses)
|
||||
[self logResponse:nil forRequest:request error:error];
|
||||
completionBlock(nil, error);
|
||||
[self logResponse:nil forRequest:request error:augmentedError];
|
||||
completionBlock(nil, augmentedError);
|
||||
}
|
||||
}];
|
||||
|
||||
[self enqueueHTTPRequestOperation:op];
|
||||
[self.operationQueue addOperation:op];
|
||||
return requestId;
|
||||
}
|
||||
|
||||
|
@ -7,8 +7,8 @@
|
||||
@property(nonatomic) NSNumber* _id;
|
||||
@property(nonatomic) NSString* name;
|
||||
- (id) _id: (NSNumber*) _id
|
||||
name: (NSString*) name;
|
||||
|
||||
name: (NSString*) name;
|
||||
|
||||
- (id) initWithValues: (NSDictionary*)dict;
|
||||
- (NSDictionary*) asDictionary;
|
||||
|
@ -4,20 +4,25 @@
|
||||
@implementation SWGCategory
|
||||
|
||||
-(id)_id: (NSNumber*) _id
|
||||
name: (NSString*) name {
|
||||
name: (NSString*) name
|
||||
|
||||
{
|
||||
__id = _id;
|
||||
_name = name;
|
||||
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
-(id) initWithValues:(NSDictionary*)dict
|
||||
{
|
||||
self = [super init];
|
||||
if(self) {
|
||||
__id = dict[@"id"];
|
||||
|
||||
_name = dict[@"name"];
|
||||
|
||||
|
||||
}
|
||||
return self;
|
||||
}
|
||||
@ -26,14 +31,11 @@
|
||||
NSMutableDictionary* dict = [[NSMutableDictionary alloc] init];
|
||||
|
||||
|
||||
if(__id != nil)
|
||||
dict[@"id"] = __id;
|
||||
if(__id != nil) dict[@"id"] = __id ;
|
||||
|
||||
|
||||
|
||||
|
||||
if(_name != nil)
|
||||
dict[@"name"] = _name;
|
||||
if(_name != nil) dict[@"name"] = _name ;
|
||||
|
||||
|
||||
|
||||
|
@ -12,16 +12,12 @@
|
||||
@property(nonatomic) NSString* status; /* Order Status */
|
||||
@property(nonatomic) NSNumber* complete;
|
||||
- (id) _id: (NSNumber*) _id
|
||||
petId: (NSNumber*) petId
|
||||
quantity: (NSNumber*) quantity
|
||||
shipDate: (SWGDate*) shipDate
|
||||
status: (NSString*) status
|
||||
complete: (NSNumber*) complete;
|
||||
|
||||
petId: (NSNumber*) petId
|
||||
|
||||
quantity: (NSNumber*) quantity
|
||||
|
||||
shipDate: (SWGDate*) shipDate
|
||||
|
||||
status: (NSString*) status
|
||||
|
||||
complete: (NSNumber*) complete;
|
||||
|
||||
- (id) initWithValues: (NSDictionary*)dict;
|
||||
- (NSDictionary*) asDictionary;
|
||||
|
@ -8,8 +8,9 @@
|
||||
quantity: (NSNumber*) quantity
|
||||
shipDate: (SWGDate*) shipDate
|
||||
status: (NSString*) status
|
||||
complete: (NSNumber*) complete {
|
||||
complete: (NSNumber*) complete
|
||||
|
||||
{
|
||||
__id = _id;
|
||||
_petId = petId;
|
||||
_quantity = quantity;
|
||||
@ -17,23 +18,33 @@
|
||||
_status = status;
|
||||
_complete = complete;
|
||||
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
-(id) initWithValues:(NSDictionary*)dict
|
||||
{
|
||||
self = [super init];
|
||||
if(self) {
|
||||
__id = dict[@"id"];
|
||||
|
||||
_petId = dict[@"petId"];
|
||||
|
||||
_quantity = dict[@"quantity"];
|
||||
|
||||
|
||||
|
||||
id shipDate_dict = dict[@"shipDate"];
|
||||
|
||||
if(shipDate_dict != nil)
|
||||
_shipDate = [[SWGDate alloc]initWithValues:shipDate_dict];
|
||||
|
||||
|
||||
_status = dict[@"status"];
|
||||
|
||||
_complete = dict[@"complete"];
|
||||
|
||||
|
||||
}
|
||||
return self;
|
||||
}
|
||||
@ -42,49 +53,46 @@
|
||||
NSMutableDictionary* dict = [[NSMutableDictionary alloc] init];
|
||||
|
||||
|
||||
if(__id != nil)
|
||||
dict[@"id"] = __id;
|
||||
if(__id != nil) dict[@"id"] = __id ;
|
||||
|
||||
|
||||
|
||||
|
||||
if(_petId != nil)
|
||||
dict[@"petId"] = _petId;
|
||||
if(_petId != nil) dict[@"petId"] = _petId ;
|
||||
|
||||
|
||||
|
||||
|
||||
if(_quantity != nil)
|
||||
dict[@"quantity"] = _quantity;
|
||||
if(_quantity != nil) dict[@"quantity"] = _quantity ;
|
||||
|
||||
|
||||
|
||||
if(_shipDate != nil){
|
||||
|
||||
|
||||
if(_shipDate && [_shipDate isKindOfClass:[SWGDate class]]) {
|
||||
if([_shipDate isKindOfClass:[NSArray class]]){
|
||||
NSMutableArray * array = [[NSMutableArray alloc] init];
|
||||
for( SWGDate *shipDate in (NSArray*)_shipDate) {
|
||||
[array addObject:[(SWGObject*)shipDate asDictionary]];
|
||||
}
|
||||
dict[@"shipDate"] = array;
|
||||
}
|
||||
else if(_shipDate && [_shipDate isKindOfClass:[SWGDate class]]) {
|
||||
NSString * dateString = [(SWGDate*)_shipDate toString];
|
||||
if(dateString){
|
||||
dict[@"shipDate"] = dateString;
|
||||
dict[@"shipDate"] = dateString;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if(_shipDate != nil)
|
||||
dict[@"shipDate"] = [(SWGObject*)_shipDate asDictionary];
|
||||
}
|
||||
|
||||
if(_shipDate != nil) dict[@"shipDate"] = [(SWGObject*)_shipDate asDictionary];
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
if(_status != nil)
|
||||
dict[@"status"] = _status;
|
||||
if(_status != nil) dict[@"status"] = _status ;
|
||||
|
||||
|
||||
|
||||
|
||||
if(_complete != nil)
|
||||
dict[@"complete"] = _complete;
|
||||
if(_complete != nil) dict[@"complete"] = _complete ;
|
||||
|
||||
|
||||
|
||||
|
@ -1,15 +0,0 @@
|
||||
#import <Foundation/Foundation.h>
|
||||
#import "SWGObject.h"
|
||||
#import "NSDictionary.h"
|
||||
#import "SWGOrders.h"
|
||||
#import "NSMutableDictionary.h"
|
||||
|
||||
|
||||
@interface SWGOrders : NSMutableDictionary
|
||||
|
||||
- (id)
|
||||
|
||||
- (id) initWithValues: (NSDictionary*)dict;
|
||||
- (NSDictionary*) asDictionary;
|
||||
|
||||
@end
|
@ -1,27 +0,0 @@
|
||||
#import "SWGDate.h"
|
||||
#import "SWGOrders.h"
|
||||
|
||||
@implementation SWGOrders
|
||||
|
||||
-(id)
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
-(id) initWithValues:(NSDictionary*)dict
|
||||
{
|
||||
self = [super init];
|
||||
if(self) {
|
||||
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
-(NSDictionary*) asDictionary {
|
||||
NSMutableDictionary* dict = [[NSMutableDictionary alloc] init];
|
||||
|
||||
NSDictionary* output = [dict copy];
|
||||
return output;
|
||||
}
|
||||
|
||||
@end
|
@ -13,16 +13,12 @@
|
||||
@property(nonatomic) NSArray* tags;
|
||||
@property(nonatomic) NSString* status; /* pet status in the store */
|
||||
- (id) _id: (NSNumber*) _id
|
||||
category: (SWGCategory*) category
|
||||
name: (NSString*) name
|
||||
photoUrls: (NSArray*) photoUrls
|
||||
tags: (NSArray*) tags
|
||||
status: (NSString*) status;
|
||||
|
||||
category: (SWGCategory*) category
|
||||
|
||||
name: (NSString*) name
|
||||
|
||||
photoUrls: (NSArray*) photoUrls
|
||||
|
||||
tags: (NSArray*) tags
|
||||
|
||||
status: (NSString*) status;
|
||||
|
||||
- (id) initWithValues: (NSDictionary*)dict;
|
||||
- (NSDictionary*) asDictionary;
|
||||
|
@ -8,8 +8,9 @@
|
||||
name: (NSString*) name
|
||||
photoUrls: (NSArray*) photoUrls
|
||||
tags: (NSArray*) tags
|
||||
status: (NSString*) status {
|
||||
status: (NSString*) status
|
||||
|
||||
{
|
||||
__id = _id;
|
||||
_category = category;
|
||||
_name = name;
|
||||
@ -17,41 +18,52 @@
|
||||
_tags = tags;
|
||||
_status = status;
|
||||
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
-(id) initWithValues:(NSDictionary*)dict
|
||||
{
|
||||
self = [super init];
|
||||
if(self) {
|
||||
__id = dict[@"id"];
|
||||
|
||||
|
||||
|
||||
id category_dict = dict[@"category"];
|
||||
|
||||
if(category_dict != nil)
|
||||
_category = [[SWGCategory alloc]initWithValues:category_dict];
|
||||
|
||||
|
||||
_name = dict[@"name"];
|
||||
|
||||
_photoUrls = dict[@"photoUrls"];
|
||||
|
||||
|
||||
|
||||
id tags_dict = dict[@"tags"];
|
||||
|
||||
if([tags_dict isKindOfClass:[NSArray class]]) {
|
||||
NSMutableArray * objs = [[NSMutableArray alloc] initWithCapacity:[(NSArray*)tags_dict count]];
|
||||
if([(NSArray*)tags_dict count] > 0) {
|
||||
for (NSDictionary* dict in (NSArray*)tags_dict) {
|
||||
SWGTag* d = [[SWGTag alloc] initWithValues:dict];
|
||||
SWGTag* d = [[SWGTag alloc] initWithValues:dict];
|
||||
[objs addObject:d];
|
||||
}
|
||||
_tags = [[NSArray alloc] initWithArray:objs];
|
||||
}
|
||||
else {
|
||||
else
|
||||
_tags = [[NSArray alloc] init];
|
||||
}
|
||||
}
|
||||
else {
|
||||
_tags = [[NSArray alloc] init];
|
||||
}
|
||||
|
||||
|
||||
_status = dict[@"status"];
|
||||
|
||||
|
||||
}
|
||||
return self;
|
||||
}
|
||||
@ -60,63 +72,65 @@
|
||||
NSMutableDictionary* dict = [[NSMutableDictionary alloc] init];
|
||||
|
||||
|
||||
if(__id != nil)
|
||||
dict[@"id"] = __id;
|
||||
if(__id != nil) dict[@"id"] = __id ;
|
||||
|
||||
|
||||
|
||||
if(_category != nil){
|
||||
|
||||
|
||||
if(_category && [_category isKindOfClass:[SWGDate class]]) {
|
||||
if([_category isKindOfClass:[NSArray class]]){
|
||||
NSMutableArray * array = [[NSMutableArray alloc] init];
|
||||
for( SWGCategory *category in (NSArray*)_category) {
|
||||
[array addObject:[(SWGObject*)category asDictionary]];
|
||||
}
|
||||
dict[@"category"] = array;
|
||||
}
|
||||
else if(_category && [_category isKindOfClass:[SWGDate class]]) {
|
||||
NSString * dateString = [(SWGDate*)_category toString];
|
||||
if(dateString){
|
||||
dict[@"category"] = dateString;
|
||||
dict[@"category"] = dateString;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if(_category != nil)
|
||||
dict[@"category"] = [(SWGObject*)_category asDictionary];
|
||||
}
|
||||
|
||||
}
|
||||
if(_category != nil) dict[@"category"] = [(SWGObject*)_category asDictionary];
|
||||
|
||||
|
||||
|
||||
if(_name != nil)
|
||||
dict[@"name"] = _name;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if(_photoUrls != nil) {
|
||||
if([_photoUrls isKindOfClass:[NSArray class]]) {
|
||||
dict[@"_photoUrls"] = [[NSArray alloc] initWithArray: (NSArray*) _photoUrls copyItems:true];
|
||||
}
|
||||
else if([_photoUrls isKindOfClass:[NSDictionary class]]) {
|
||||
dict[@"photoUrls"] = [[NSDictionary alloc] initWithDictionary:(NSDictionary*)_photoUrls copyItems:true];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
if(_name != nil) dict[@"name"] = _name ;
|
||||
|
||||
|
||||
|
||||
if(_photoUrls != nil) dict[@"photoUrls"] = _photoUrls ;
|
||||
|
||||
|
||||
|
||||
if(_tags != nil){
|
||||
|
||||
if([_tags isKindOfClass:[NSArray class]]){
|
||||
NSMutableArray * array = [[NSMutableArray alloc] init];
|
||||
for( SWGTag *tags in _tags) {
|
||||
NSMutableArray * array = [[NSMutableArray alloc] init];
|
||||
for( SWGTag *tags in (NSArray*)_tags) {
|
||||
[array addObject:[(SWGObject*)tags asDictionary]];
|
||||
}
|
||||
dict[@"tags"] = array;
|
||||
}
|
||||
else if(_tags && [_tags isKindOfClass:[SWGDate class]]) {
|
||||
NSString * dateString = [(SWGDate*)_tags toString];
|
||||
if(dateString){
|
||||
dict[@"tags"] = dateString;
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
||||
if(_tags != nil) dict[@"tags"] = [(SWGObject*)_tags asDictionary];
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
if(_status != nil)
|
||||
dict[@"status"] = _status;
|
||||
if(_status != nil) dict[@"status"] = _status ;
|
||||
|
||||
|
||||
|
||||
|
@ -1,5 +1,7 @@
|
||||
#import <Foundation/Foundation.h>
|
||||
#import "SWGPet.h"
|
||||
#import "SWGFile.h"
|
||||
#import "SWGObject.h"
|
||||
|
||||
|
||||
@interface SWGPetApi: NSObject
|
||||
@ -14,82 +16,159 @@
|
||||
Update an existing pet
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@param body Pet object that needs to be added to the store
|
||||
|
||||
|
||||
return type:
|
||||
*/
|
||||
-(NSNumber*) updatePetWithCompletionBlock : (SWGPet*) body
|
||||
-(NSNumber*) updatePetWithCompletionBlock :(SWGPet*) body
|
||||
|
||||
|
||||
completionHandler: (void (^)(NSError* error))completionBlock;
|
||||
|
||||
|
||||
/**
|
||||
|
||||
Add a new pet to the store
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@param pet Pet object that needs to be added to the store
|
||||
|
||||
|
||||
return type:
|
||||
*/
|
||||
-(NSNumber*) addPetWithCompletionBlock : (SWGPet*) pet
|
||||
-(NSNumber*) addPetWithCompletionBlock :(SWGPet*) pet
|
||||
|
||||
|
||||
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
|
||||
|
||||
|
||||
return type: NSArray*
|
||||
*/
|
||||
-(NSNumber*) findPetsByStatusWithCompletionBlock : (NSArray*) status
|
||||
-(NSNumber*) findPetsByStatusWithCompletionBlock :(NSArray*) status
|
||||
|
||||
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
|
||||
|
||||
|
||||
return type: NSArray*
|
||||
*/
|
||||
-(NSNumber*) findPetsByTagsWithCompletionBlock : (NSArray*) tags
|
||||
-(NSNumber*) findPetsByTagsWithCompletionBlock :(NSArray*) tags
|
||||
|
||||
completionHandler: (void (^)(NSArray* output, NSError* error))completionBlock;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
|
||||
Find pet by ID
|
||||
|
||||
Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions
|
||||
|
||||
|
||||
|
||||
@param petId ID of pet that needs to be fetched
|
||||
|
||||
|
||||
return type: SWGPet*
|
||||
*/
|
||||
-(NSNumber*) getPetByIdWithCompletionBlock : (NSNumber*) petId
|
||||
-(NSNumber*) getPetByIdWithCompletionBlock :(NSNumber*) petId
|
||||
|
||||
completionHandler: (void (^)(SWGPet* output, NSError* error))completionBlock;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
|
||||
Updates a pet in the store with form data
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@param petId ID of pet that needs to be updated
|
||||
|
||||
@param name Updated name of the pet
|
||||
|
||||
@param status Updated status of the pet
|
||||
|
||||
|
||||
return type:
|
||||
*/
|
||||
-(NSNumber*) updatePetWithFormWithCompletionBlock : (NSString*) petId
|
||||
name: (NSString*) name
|
||||
status: (NSString*) status
|
||||
-(NSNumber*) updatePetWithFormWithCompletionBlock :(NSString*) petId
|
||||
name:(NSString*) name
|
||||
status:(NSString*) status
|
||||
|
||||
|
||||
completionHandler: (void (^)(NSError* error))completionBlock;
|
||||
|
||||
|
||||
/**
|
||||
|
||||
Deletes a pet
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@param api_key
|
||||
|
||||
@param petId Pet id to delete
|
||||
|
||||
|
||||
return type:
|
||||
*/
|
||||
-(NSNumber*) deletePetWithCompletionBlock : (NSString*) api_key
|
||||
petId: (NSNumber*) petId
|
||||
-(NSNumber*) deletePetWithCompletionBlock :(NSString*) api_key
|
||||
petId:(NSNumber*) petId
|
||||
|
||||
|
||||
completionHandler: (void (^)(NSError* error))completionBlock;
|
||||
|
||||
|
||||
/**
|
||||
|
||||
Upload an image for a pet
|
||||
|
||||
|
||||
|
||||
@param petImage image to upload
|
||||
|
||||
|
||||
return type:
|
||||
*/
|
||||
-(NSNumber*) uploadImageWithCompletionBlock :(SWGFile*) petImage
|
||||
|
||||
|
||||
completionHandler: (void (^)(NSError* error))completionBlock;
|
||||
|
||||
|
||||
|
||||
@end
|
@ -2,6 +2,7 @@
|
||||
#import "SWGFile.h"
|
||||
#import "SWGApiClient.h"
|
||||
#import "SWGPet.h"
|
||||
#import "SWGFile.h"
|
||||
|
||||
|
||||
|
||||
@ -52,9 +53,9 @@ static NSString * basePath = @"http://petstore.swagger.wordnik.com/v2";
|
||||
|
||||
-(NSNumber*) updatePetWithCompletionBlock:(SWGPet*) body
|
||||
|
||||
|
||||
completionHandler: (void (^)(NSError* error))completionBlock {
|
||||
|
||||
id m_body = body;
|
||||
NSMutableString* requestUrl = [NSMutableString stringWithFormat:@"%@/pet", basePath];
|
||||
|
||||
// remove format in URL if needed
|
||||
@ -73,9 +74,11 @@ static NSString * basePath = @"http://petstore.swagger.wordnik.com/v2";
|
||||
|
||||
id bodyDictionary = nil;
|
||||
|
||||
if(m_body != nil && [m_body isKindOfClass:[NSArray class]]){
|
||||
id __body = body;
|
||||
|
||||
if(__body != nil && [__body isKindOfClass:[NSArray class]]){
|
||||
NSMutableArray * objs = [[NSMutableArray alloc] init];
|
||||
for (id dict in (NSArray*)m_body) {
|
||||
for (id dict in (NSArray*)__body) {
|
||||
if([dict respondsToSelector:@selector(asDictionary)]) {
|
||||
[objs addObject:[(SWGObject*)dict asDictionary]];
|
||||
}
|
||||
@ -85,39 +88,38 @@ static NSString * basePath = @"http://petstore.swagger.wordnik.com/v2";
|
||||
}
|
||||
bodyDictionary = objs;
|
||||
}
|
||||
else if([m_body respondsToSelector:@selector(asDictionary)]) {
|
||||
bodyDictionary = [(SWGObject*)m_body asDictionary];
|
||||
else if([__body respondsToSelector:@selector(asDictionary)]) {
|
||||
bodyDictionary = [(SWGObject*)__body asDictionary];
|
||||
}
|
||||
else if([m_body isKindOfClass:[NSString class]]) {
|
||||
else if([__body isKindOfClass:[NSString class]]) {
|
||||
// convert it to a dictionary
|
||||
NSError * error;
|
||||
NSString * str = (NSString*)m_body;
|
||||
NSString * str = (NSString*)__body;
|
||||
NSDictionary *JSON =
|
||||
[NSJSONSerialization JSONObjectWithData:[str dataUsingEncoding:NSUTF8StringEncoding]
|
||||
options:NSJSONReadingMutableContainers
|
||||
error:&error];
|
||||
bodyDictionary = JSON;
|
||||
}
|
||||
else if([m_body isKindOfClass: [SWGFile class]]) {
|
||||
else if([__body isKindOfClass: [SWGFile class]]) {
|
||||
requestContentType = @"form-data";
|
||||
bodyDictionary = m_body;
|
||||
bodyDictionary = __body;
|
||||
}
|
||||
else{
|
||||
NSLog(@"don't know what to do with %@", m_body);
|
||||
NSLog(@"don't know what to do with %@", __body);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
SWGApiClient* client = [SWGApiClient sharedClientFromPool:basePath];
|
||||
|
||||
|
||||
|
||||
// primitive response type
|
||||
|
||||
|
||||
|
||||
|
||||
// no return base type
|
||||
return [client stringWithCompletionBlock:requestUrl
|
||||
method:@"PUT"
|
||||
queryParams:queryParams
|
||||
@ -135,13 +137,14 @@ static NSString * basePath = @"http://petstore.swagger.wordnik.com/v2";
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
-(NSNumber*) addPetWithCompletionBlock:(SWGPet*) pet
|
||||
|
||||
|
||||
completionHandler: (void (^)(NSError* error))completionBlock {
|
||||
|
||||
id m_body = pet;
|
||||
NSMutableString* requestUrl = [NSMutableString stringWithFormat:@"%@/pet", basePath];
|
||||
|
||||
// remove format in URL if needed
|
||||
@ -160,9 +163,11 @@ static NSString * basePath = @"http://petstore.swagger.wordnik.com/v2";
|
||||
|
||||
id bodyDictionary = nil;
|
||||
|
||||
if(m_body != nil && [m_body isKindOfClass:[NSArray class]]){
|
||||
id __body = pet;
|
||||
|
||||
if(__body != nil && [__body isKindOfClass:[NSArray class]]){
|
||||
NSMutableArray * objs = [[NSMutableArray alloc] init];
|
||||
for (id dict in (NSArray*)m_body) {
|
||||
for (id dict in (NSArray*)__body) {
|
||||
if([dict respondsToSelector:@selector(asDictionary)]) {
|
||||
[objs addObject:[(SWGObject*)dict asDictionary]];
|
||||
}
|
||||
@ -172,39 +177,38 @@ static NSString * basePath = @"http://petstore.swagger.wordnik.com/v2";
|
||||
}
|
||||
bodyDictionary = objs;
|
||||
}
|
||||
else if([m_body respondsToSelector:@selector(asDictionary)]) {
|
||||
bodyDictionary = [(SWGObject*)m_body asDictionary];
|
||||
else if([__body respondsToSelector:@selector(asDictionary)]) {
|
||||
bodyDictionary = [(SWGObject*)__body asDictionary];
|
||||
}
|
||||
else if([m_body isKindOfClass:[NSString class]]) {
|
||||
else if([__body isKindOfClass:[NSString class]]) {
|
||||
// convert it to a dictionary
|
||||
NSError * error;
|
||||
NSString * str = (NSString*)m_body;
|
||||
NSString * str = (NSString*)__body;
|
||||
NSDictionary *JSON =
|
||||
[NSJSONSerialization JSONObjectWithData:[str dataUsingEncoding:NSUTF8StringEncoding]
|
||||
options:NSJSONReadingMutableContainers
|
||||
error:&error];
|
||||
bodyDictionary = JSON;
|
||||
}
|
||||
else if([m_body isKindOfClass: [SWGFile class]]) {
|
||||
else if([__body isKindOfClass: [SWGFile class]]) {
|
||||
requestContentType = @"form-data";
|
||||
bodyDictionary = m_body;
|
||||
bodyDictionary = __body;
|
||||
}
|
||||
else{
|
||||
NSLog(@"don't know what to do with %@", m_body);
|
||||
NSLog(@"don't know what to do with %@", __body);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
SWGApiClient* client = [SWGApiClient sharedClientFromPool:basePath];
|
||||
|
||||
|
||||
|
||||
// primitive response type
|
||||
|
||||
|
||||
|
||||
|
||||
// no return base type
|
||||
return [client stringWithCompletionBlock:requestUrl
|
||||
method:@"POST"
|
||||
queryParams:queryParams
|
||||
@ -222,13 +226,14 @@ static NSString * basePath = @"http://petstore.swagger.wordnik.com/v2";
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
-(NSNumber*) findPetsByStatusWithCompletionBlock:(NSArray*) status
|
||||
|
||||
completionHandler: (void (^)(NSArray* output, NSError* error))completionBlock
|
||||
{
|
||||
|
||||
id m_body = nil;
|
||||
NSMutableString* requestUrl = [NSMutableString stringWithFormat:@"%@/pet/findByStatus", basePath];
|
||||
|
||||
// remove format in URL if needed
|
||||
@ -243,6 +248,7 @@ static NSString * basePath = @"http://petstore.swagger.wordnik.com/v2";
|
||||
NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init];
|
||||
if(status != nil)
|
||||
queryParams[@"status"] = status;
|
||||
|
||||
NSMutableDictionary* headerParams = [[NSMutableDictionary alloc] init];
|
||||
|
||||
|
||||
@ -253,48 +259,45 @@ static NSString * basePath = @"http://petstore.swagger.wordnik.com/v2";
|
||||
|
||||
SWGApiClient* client = [SWGApiClient sharedClientFromPool:basePath];
|
||||
|
||||
|
||||
// array container response type
|
||||
return [client dictionary: requestUrl
|
||||
method: @"GET"
|
||||
queryParams: queryParams
|
||||
body: bodyDictionary
|
||||
headerParams: headerParams
|
||||
requestContentType: requestContentType
|
||||
responseContentType: responseContentType
|
||||
completionBlock: ^(NSDictionary *data, NSError *error) {
|
||||
if (error) {
|
||||
completionBlock(nil, error);
|
||||
method: @"GET"
|
||||
queryParams: queryParams
|
||||
body: bodyDictionary
|
||||
headerParams: headerParams
|
||||
requestContentType: requestContentType
|
||||
responseContentType: responseContentType
|
||||
completionBlock: ^(NSDictionary *data, NSError *error) {
|
||||
if (error) {
|
||||
completionBlock(nil, error);
|
||||
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if([data isKindOfClass:[NSArray class]]){
|
||||
NSMutableArray * objs = [[NSMutableArray alloc] initWithCapacity:[data count]];
|
||||
for (NSDictionary* dict in (NSArray*)data) {
|
||||
|
||||
|
||||
if([data isKindOfClass:[NSArray class]]){
|
||||
NSMutableArray * objs = [[NSMutableArray alloc] initWithCapacity:[data count]];
|
||||
for (NSDictionary* dict in (NSArray*)data) {
|
||||
SWGPet* d = [[SWGPet alloc]initWithValues: dict];
|
||||
|
||||
|
||||
SWGPet* d = [[SWGPet alloc]initWithValues: dict];
|
||||
|
||||
[objs addObject:d];
|
||||
}
|
||||
completionBlock(objs, nil);
|
||||
}
|
||||
[objs addObject:d];
|
||||
}
|
||||
completionBlock(objs, nil);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}];
|
||||
|
||||
|
||||
}];
|
||||
|
||||
|
||||
}
|
||||
|
||||
-(NSNumber*) findPetsByTagsWithCompletionBlock:(NSArray*) tags
|
||||
|
||||
completionHandler: (void (^)(NSArray* output, NSError* error))completionBlock
|
||||
{
|
||||
|
||||
id m_body = nil;
|
||||
NSMutableString* requestUrl = [NSMutableString stringWithFormat:@"%@/pet/findByTags", basePath];
|
||||
|
||||
// remove format in URL if needed
|
||||
@ -309,6 +312,7 @@ static NSString * basePath = @"http://petstore.swagger.wordnik.com/v2";
|
||||
NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init];
|
||||
if(tags != nil)
|
||||
queryParams[@"tags"] = tags;
|
||||
|
||||
NSMutableDictionary* headerParams = [[NSMutableDictionary alloc] init];
|
||||
|
||||
|
||||
@ -319,48 +323,45 @@ static NSString * basePath = @"http://petstore.swagger.wordnik.com/v2";
|
||||
|
||||
SWGApiClient* client = [SWGApiClient sharedClientFromPool:basePath];
|
||||
|
||||
|
||||
// array container response type
|
||||
return [client dictionary: requestUrl
|
||||
method: @"GET"
|
||||
queryParams: queryParams
|
||||
body: bodyDictionary
|
||||
headerParams: headerParams
|
||||
requestContentType: requestContentType
|
||||
responseContentType: responseContentType
|
||||
completionBlock: ^(NSDictionary *data, NSError *error) {
|
||||
if (error) {
|
||||
completionBlock(nil, error);
|
||||
method: @"GET"
|
||||
queryParams: queryParams
|
||||
body: bodyDictionary
|
||||
headerParams: headerParams
|
||||
requestContentType: requestContentType
|
||||
responseContentType: responseContentType
|
||||
completionBlock: ^(NSDictionary *data, NSError *error) {
|
||||
if (error) {
|
||||
completionBlock(nil, error);
|
||||
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if([data isKindOfClass:[NSArray class]]){
|
||||
NSMutableArray * objs = [[NSMutableArray alloc] initWithCapacity:[data count]];
|
||||
for (NSDictionary* dict in (NSArray*)data) {
|
||||
|
||||
|
||||
if([data isKindOfClass:[NSArray class]]){
|
||||
NSMutableArray * objs = [[NSMutableArray alloc] initWithCapacity:[data count]];
|
||||
for (NSDictionary* dict in (NSArray*)data) {
|
||||
SWGPet* d = [[SWGPet alloc]initWithValues: dict];
|
||||
|
||||
|
||||
SWGPet* d = [[SWGPet alloc]initWithValues: dict];
|
||||
|
||||
[objs addObject:d];
|
||||
}
|
||||
completionBlock(objs, nil);
|
||||
}
|
||||
[objs addObject:d];
|
||||
}
|
||||
completionBlock(objs, nil);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}];
|
||||
|
||||
|
||||
}];
|
||||
|
||||
|
||||
}
|
||||
|
||||
-(NSNumber*) getPetByIdWithCompletionBlock:(NSNumber*) petId
|
||||
|
||||
completionHandler: (void (^)(SWGPet* output, NSError* error))completionBlock
|
||||
{
|
||||
|
||||
id m_body = nil;
|
||||
NSMutableString* requestUrl = [NSMutableString stringWithFormat:@"%@/pet/{petId}", basePath];
|
||||
|
||||
// remove format in URL if needed
|
||||
@ -389,39 +390,39 @@ static NSString * basePath = @"http://petstore.swagger.wordnik.com/v2";
|
||||
|
||||
|
||||
|
||||
|
||||
// comples response type
|
||||
return [client dictionary:requestUrl
|
||||
method:@"GET"
|
||||
queryParams:queryParams
|
||||
body:bodyDictionary
|
||||
headerParams:headerParams
|
||||
requestContentType:requestContentType
|
||||
responseContentType:responseContentType
|
||||
completionBlock:^(NSDictionary *data, NSError *error) {
|
||||
if (error) {
|
||||
completionBlock(nil, error);
|
||||
method:@"GET"
|
||||
queryParams:queryParams
|
||||
body:bodyDictionary
|
||||
headerParams:headerParams
|
||||
requestContentType:requestContentType
|
||||
responseContentType:responseContentType
|
||||
completionBlock:^(NSDictionary *data, NSError *error) {
|
||||
if (error) {
|
||||
completionBlock(nil, error);
|
||||
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
SWGPet *result = nil;
|
||||
if (data) {
|
||||
result = [[SWGPet alloc]initWithValues: data];
|
||||
}
|
||||
completionBlock(result , nil);
|
||||
SWGPet *result = nil;
|
||||
if (data) {
|
||||
result = [[SWGPet alloc]initWithValues: data];
|
||||
}
|
||||
completionBlock(result , nil);
|
||||
|
||||
}];
|
||||
}];
|
||||
|
||||
|
||||
}
|
||||
|
||||
-(NSNumber*) updatePetWithFormWithCompletionBlock:(NSString*) petId
|
||||
name:(NSString*) name
|
||||
status:(NSString*) status
|
||||
name:(NSString*) name
|
||||
status:(NSString*) status
|
||||
|
||||
|
||||
completionHandler: (void (^)(NSError* error))completionBlock {
|
||||
|
||||
id m_body = nil;
|
||||
NSMutableString* requestUrl = [NSMutableString stringWithFormat:@"%@/pet/{petId}", basePath];
|
||||
|
||||
// remove format in URL if needed
|
||||
@ -448,10 +449,10 @@ static NSString * basePath = @"http://petstore.swagger.wordnik.com/v2";
|
||||
|
||||
|
||||
|
||||
// primitive response type
|
||||
|
||||
|
||||
|
||||
|
||||
// no return base type
|
||||
return [client stringWithCompletionBlock:requestUrl
|
||||
method:@"POST"
|
||||
queryParams:queryParams
|
||||
@ -469,14 +470,15 @@ static NSString * basePath = @"http://petstore.swagger.wordnik.com/v2";
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
-(NSNumber*) deletePetWithCompletionBlock:(NSString*) api_key
|
||||
petId:(NSNumber*) petId
|
||||
petId:(NSNumber*) petId
|
||||
|
||||
|
||||
completionHandler: (void (^)(NSError* error))completionBlock {
|
||||
|
||||
id m_body = nil;
|
||||
NSMutableString* requestUrl = [NSMutableString stringWithFormat:@"%@/pet/{petId}", basePath];
|
||||
|
||||
// remove format in URL if needed
|
||||
@ -495,6 +497,7 @@ static NSString * basePath = @"http://petstore.swagger.wordnik.com/v2";
|
||||
if(api_key != nil)
|
||||
headerParams[@"api_key"] = api_key;
|
||||
|
||||
|
||||
id bodyDictionary = nil;
|
||||
|
||||
|
||||
@ -504,10 +507,10 @@ static NSString * basePath = @"http://petstore.swagger.wordnik.com/v2";
|
||||
|
||||
|
||||
|
||||
// primitive response type
|
||||
|
||||
|
||||
|
||||
|
||||
// no return base type
|
||||
return [client stringWithCompletionBlock:requestUrl
|
||||
method:@"DELETE"
|
||||
queryParams:queryParams
|
||||
@ -525,6 +528,61 @@ static NSString * basePath = @"http://petstore.swagger.wordnik.com/v2";
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
-(NSNumber*) uploadImageWithCompletionBlock:(SWGFile*) petImage
|
||||
|
||||
|
||||
completionHandler: (void (^)(NSError* error))completionBlock {
|
||||
|
||||
NSMutableString* requestUrl = [NSMutableString stringWithFormat:@"%@/pet/{petId}/upload", basePath];
|
||||
|
||||
// remove format in URL if needed
|
||||
if ([requestUrl rangeOfString:@".{format}"].location != NSNotFound)
|
||||
[requestUrl replaceCharactersInRange: [requestUrl rangeOfString:@".{format}"] withString:@".json"];
|
||||
|
||||
|
||||
|
||||
NSString* requestContentType = @"application/json";
|
||||
NSString* responseContentType = @"application/json";
|
||||
|
||||
NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init];
|
||||
|
||||
NSMutableDictionary* headerParams = [[NSMutableDictionary alloc] init];
|
||||
|
||||
|
||||
id bodyDictionary = nil;
|
||||
|
||||
|
||||
|
||||
|
||||
SWGApiClient* client = [SWGApiClient sharedClientFromPool:basePath];
|
||||
|
||||
|
||||
|
||||
// primitive response type
|
||||
|
||||
|
||||
// no return base type
|
||||
return [client stringWithCompletionBlock:requestUrl
|
||||
method:@"POST"
|
||||
queryParams:queryParams
|
||||
body:bodyDictionary
|
||||
headerParams:headerParams
|
||||
requestContentType: requestContentType
|
||||
responseContentType: responseContentType
|
||||
completionBlock:^(NSString *data, NSError *error) {
|
||||
if (error) {
|
||||
completionBlock(error);
|
||||
return;
|
||||
}
|
||||
completionBlock(nil);
|
||||
}];
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
#import <Foundation/Foundation.h>
|
||||
#import "SWGOrder.h"
|
||||
#import "SWGObject.h"
|
||||
|
||||
|
||||
@interface SWGStoreApi: NSObject
|
||||
@ -14,32 +15,57 @@
|
||||
Place an order for a pet
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@param body order placed for purchasing the pet
|
||||
|
||||
|
||||
return type: SWGOrder*
|
||||
*/
|
||||
-(NSNumber*) placeOrderWithCompletionBlock : (SWGOrder*) body
|
||||
-(NSNumber*) placeOrderWithCompletionBlock :(SWGOrder*) body
|
||||
|
||||
completionHandler: (void (^)(SWGOrder* output, NSError* error))completionBlock;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
|
||||
Find purchase order by ID
|
||||
|
||||
For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions
|
||||
|
||||
|
||||
|
||||
@param orderId ID of pet that needs to be fetched
|
||||
|
||||
|
||||
return type: SWGOrder*
|
||||
*/
|
||||
-(NSNumber*) getOrderByIdWithCompletionBlock : (NSString*) orderId
|
||||
-(NSNumber*) getOrderByIdWithCompletionBlock :(NSString*) orderId
|
||||
|
||||
completionHandler: (void (^)(SWGOrder* 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
|
||||
|
||||
|
||||
return type:
|
||||
*/
|
||||
-(NSNumber*) deleteOrderWithCompletionBlock : (NSString*) orderId
|
||||
-(NSNumber*) deleteOrderWithCompletionBlock :(NSString*) orderId
|
||||
|
||||
|
||||
completionHandler: (void (^)(NSError* error))completionBlock;
|
||||
|
||||
|
||||
|
||||
@end
|
@ -51,10 +51,10 @@ static NSString * basePath = @"http://petstore.swagger.wordnik.com/v2";
|
||||
|
||||
|
||||
-(NSNumber*) placeOrderWithCompletionBlock:(SWGOrder*) body
|
||||
|
||||
completionHandler: (void (^)(SWGOrder* output, NSError* error))completionBlock
|
||||
{
|
||||
|
||||
id m_body = body;
|
||||
NSMutableString* requestUrl = [NSMutableString stringWithFormat:@"%@/store/order", basePath];
|
||||
|
||||
// remove format in URL if needed
|
||||
@ -73,9 +73,11 @@ static NSString * basePath = @"http://petstore.swagger.wordnik.com/v2";
|
||||
|
||||
id bodyDictionary = nil;
|
||||
|
||||
if(m_body != nil && [m_body isKindOfClass:[NSArray class]]){
|
||||
id __body = body;
|
||||
|
||||
if(__body != nil && [__body isKindOfClass:[NSArray class]]){
|
||||
NSMutableArray * objs = [[NSMutableArray alloc] init];
|
||||
for (id dict in (NSArray*)m_body) {
|
||||
for (id dict in (NSArray*)__body) {
|
||||
if([dict respondsToSelector:@selector(asDictionary)]) {
|
||||
[objs addObject:[(SWGObject*)dict asDictionary]];
|
||||
}
|
||||
@ -85,68 +87,67 @@ static NSString * basePath = @"http://petstore.swagger.wordnik.com/v2";
|
||||
}
|
||||
bodyDictionary = objs;
|
||||
}
|
||||
else if([m_body respondsToSelector:@selector(asDictionary)]) {
|
||||
bodyDictionary = [(SWGObject*)m_body asDictionary];
|
||||
else if([__body respondsToSelector:@selector(asDictionary)]) {
|
||||
bodyDictionary = [(SWGObject*)__body asDictionary];
|
||||
}
|
||||
else if([m_body isKindOfClass:[NSString class]]) {
|
||||
else if([__body isKindOfClass:[NSString class]]) {
|
||||
// convert it to a dictionary
|
||||
NSError * error;
|
||||
NSString * str = (NSString*)m_body;
|
||||
NSString * str = (NSString*)__body;
|
||||
NSDictionary *JSON =
|
||||
[NSJSONSerialization JSONObjectWithData:[str dataUsingEncoding:NSUTF8StringEncoding]
|
||||
options:NSJSONReadingMutableContainers
|
||||
error:&error];
|
||||
bodyDictionary = JSON;
|
||||
}
|
||||
else if([m_body isKindOfClass: [SWGFile class]]) {
|
||||
else if([__body isKindOfClass: [SWGFile class]]) {
|
||||
requestContentType = @"form-data";
|
||||
bodyDictionary = m_body;
|
||||
bodyDictionary = __body;
|
||||
}
|
||||
else{
|
||||
NSLog(@"don't know what to do with %@", m_body);
|
||||
NSLog(@"don't know what to do with %@", __body);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
SWGApiClient* client = [SWGApiClient sharedClientFromPool:basePath];
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// comples response type
|
||||
return [client dictionary:requestUrl
|
||||
method:@"POST"
|
||||
queryParams:queryParams
|
||||
body:bodyDictionary
|
||||
headerParams:headerParams
|
||||
requestContentType:requestContentType
|
||||
responseContentType:responseContentType
|
||||
completionBlock:^(NSDictionary *data, NSError *error) {
|
||||
if (error) {
|
||||
completionBlock(nil, error);
|
||||
method:@"POST"
|
||||
queryParams:queryParams
|
||||
body:bodyDictionary
|
||||
headerParams:headerParams
|
||||
requestContentType:requestContentType
|
||||
responseContentType:responseContentType
|
||||
completionBlock:^(NSDictionary *data, NSError *error) {
|
||||
if (error) {
|
||||
completionBlock(nil, error);
|
||||
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
SWGOrder *result = nil;
|
||||
if (data) {
|
||||
result = [[SWGOrder alloc]initWithValues: data];
|
||||
}
|
||||
completionBlock(result , nil);
|
||||
SWGOrder *result = nil;
|
||||
if (data) {
|
||||
result = [[SWGOrder alloc]initWithValues: data];
|
||||
}
|
||||
completionBlock(result , nil);
|
||||
|
||||
}];
|
||||
}];
|
||||
|
||||
|
||||
}
|
||||
|
||||
-(NSNumber*) getOrderByIdWithCompletionBlock:(NSString*) orderId
|
||||
|
||||
completionHandler: (void (^)(SWGOrder* output, NSError* error))completionBlock
|
||||
{
|
||||
|
||||
id m_body = nil;
|
||||
NSMutableString* requestUrl = [NSMutableString stringWithFormat:@"%@/store/order/{orderId}", basePath];
|
||||
|
||||
// remove format in URL if needed
|
||||
@ -175,37 +176,37 @@ static NSString * basePath = @"http://petstore.swagger.wordnik.com/v2";
|
||||
|
||||
|
||||
|
||||
|
||||
// comples response type
|
||||
return [client dictionary:requestUrl
|
||||
method:@"GET"
|
||||
queryParams:queryParams
|
||||
body:bodyDictionary
|
||||
headerParams:headerParams
|
||||
requestContentType:requestContentType
|
||||
responseContentType:responseContentType
|
||||
completionBlock:^(NSDictionary *data, NSError *error) {
|
||||
if (error) {
|
||||
completionBlock(nil, error);
|
||||
method:@"GET"
|
||||
queryParams:queryParams
|
||||
body:bodyDictionary
|
||||
headerParams:headerParams
|
||||
requestContentType:requestContentType
|
||||
responseContentType:responseContentType
|
||||
completionBlock:^(NSDictionary *data, NSError *error) {
|
||||
if (error) {
|
||||
completionBlock(nil, error);
|
||||
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
SWGOrder *result = nil;
|
||||
if (data) {
|
||||
result = [[SWGOrder alloc]initWithValues: data];
|
||||
}
|
||||
completionBlock(result , nil);
|
||||
SWGOrder *result = nil;
|
||||
if (data) {
|
||||
result = [[SWGOrder alloc]initWithValues: data];
|
||||
}
|
||||
completionBlock(result , nil);
|
||||
|
||||
}];
|
||||
}];
|
||||
|
||||
|
||||
}
|
||||
|
||||
-(NSNumber*) deleteOrderWithCompletionBlock:(NSString*) orderId
|
||||
|
||||
|
||||
completionHandler: (void (^)(NSError* error))completionBlock {
|
||||
|
||||
id m_body = nil;
|
||||
NSMutableString* requestUrl = [NSMutableString stringWithFormat:@"%@/store/order/{orderId}", basePath];
|
||||
|
||||
// remove format in URL if needed
|
||||
@ -232,10 +233,10 @@ static NSString * basePath = @"http://petstore.swagger.wordnik.com/v2";
|
||||
|
||||
|
||||
|
||||
// primitive response type
|
||||
|
||||
|
||||
|
||||
|
||||
// no return base type
|
||||
return [client stringWithCompletionBlock:requestUrl
|
||||
method:@"DELETE"
|
||||
queryParams:queryParams
|
||||
@ -253,6 +254,7 @@ static NSString * basePath = @"http://petstore.swagger.wordnik.com/v2";
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -7,8 +7,8 @@
|
||||
@property(nonatomic) NSNumber* _id;
|
||||
@property(nonatomic) NSString* name;
|
||||
- (id) _id: (NSNumber*) _id
|
||||
name: (NSString*) name;
|
||||
|
||||
name: (NSString*) name;
|
||||
|
||||
- (id) initWithValues: (NSDictionary*)dict;
|
||||
- (NSDictionary*) asDictionary;
|
||||
|
@ -4,20 +4,25 @@
|
||||
@implementation SWGTag
|
||||
|
||||
-(id)_id: (NSNumber*) _id
|
||||
name: (NSString*) name {
|
||||
name: (NSString*) name
|
||||
|
||||
{
|
||||
__id = _id;
|
||||
_name = name;
|
||||
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
-(id) initWithValues:(NSDictionary*)dict
|
||||
{
|
||||
self = [super init];
|
||||
if(self) {
|
||||
__id = dict[@"id"];
|
||||
|
||||
_name = dict[@"name"];
|
||||
|
||||
|
||||
}
|
||||
return self;
|
||||
}
|
||||
@ -26,14 +31,11 @@
|
||||
NSMutableDictionary* dict = [[NSMutableDictionary alloc] init];
|
||||
|
||||
|
||||
if(__id != nil)
|
||||
dict[@"id"] = __id;
|
||||
if(__id != nil) dict[@"id"] = __id ;
|
||||
|
||||
|
||||
|
||||
|
||||
if(_name != nil)
|
||||
dict[@"name"] = _name;
|
||||
if(_name != nil) dict[@"name"] = _name ;
|
||||
|
||||
|
||||
|
||||
|
@ -13,20 +13,14 @@
|
||||
@property(nonatomic) NSString* phone;
|
||||
@property(nonatomic) NSNumber* userStatus; /* User Status */
|
||||
- (id) _id: (NSNumber*) _id
|
||||
username: (NSString*) username
|
||||
firstName: (NSString*) firstName
|
||||
lastName: (NSString*) lastName
|
||||
email: (NSString*) email
|
||||
password: (NSString*) password
|
||||
phone: (NSString*) phone
|
||||
userStatus: (NSNumber*) userStatus;
|
||||
|
||||
username: (NSString*) username
|
||||
|
||||
firstName: (NSString*) firstName
|
||||
|
||||
lastName: (NSString*) lastName
|
||||
|
||||
email: (NSString*) email
|
||||
|
||||
password: (NSString*) password
|
||||
|
||||
phone: (NSString*) phone
|
||||
|
||||
userStatus: (NSNumber*) userStatus;
|
||||
|
||||
- (id) initWithValues: (NSDictionary*)dict;
|
||||
- (NSDictionary*) asDictionary;
|
||||
|
@ -10,8 +10,9 @@
|
||||
email: (NSString*) email
|
||||
password: (NSString*) password
|
||||
phone: (NSString*) phone
|
||||
userStatus: (NSNumber*) userStatus {
|
||||
userStatus: (NSNumber*) userStatus
|
||||
|
||||
{
|
||||
__id = _id;
|
||||
_username = username;
|
||||
_firstName = firstName;
|
||||
@ -21,21 +22,31 @@
|
||||
_phone = phone;
|
||||
_userStatus = userStatus;
|
||||
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
-(id) initWithValues:(NSDictionary*)dict
|
||||
{
|
||||
self = [super init];
|
||||
if(self) {
|
||||
__id = dict[@"id"];
|
||||
|
||||
_username = dict[@"username"];
|
||||
|
||||
_firstName = dict[@"firstName"];
|
||||
|
||||
_lastName = dict[@"lastName"];
|
||||
|
||||
_email = dict[@"email"];
|
||||
|
||||
_password = dict[@"password"];
|
||||
|
||||
_phone = dict[@"phone"];
|
||||
|
||||
_userStatus = dict[@"userStatus"];
|
||||
|
||||
|
||||
}
|
||||
return self;
|
||||
}
|
||||
@ -44,50 +55,35 @@
|
||||
NSMutableDictionary* dict = [[NSMutableDictionary alloc] init];
|
||||
|
||||
|
||||
if(__id != nil)
|
||||
dict[@"id"] = __id;
|
||||
if(__id != nil) dict[@"id"] = __id ;
|
||||
|
||||
|
||||
|
||||
|
||||
if(_username != nil)
|
||||
dict[@"username"] = _username;
|
||||
if(_username != nil) dict[@"username"] = _username ;
|
||||
|
||||
|
||||
|
||||
|
||||
if(_firstName != nil)
|
||||
dict[@"firstName"] = _firstName;
|
||||
if(_firstName != nil) dict[@"firstName"] = _firstName ;
|
||||
|
||||
|
||||
|
||||
|
||||
if(_lastName != nil)
|
||||
dict[@"lastName"] = _lastName;
|
||||
if(_lastName != nil) dict[@"lastName"] = _lastName ;
|
||||
|
||||
|
||||
|
||||
|
||||
if(_email != nil)
|
||||
dict[@"email"] = _email;
|
||||
if(_email != nil) dict[@"email"] = _email ;
|
||||
|
||||
|
||||
|
||||
|
||||
if(_password != nil)
|
||||
dict[@"password"] = _password;
|
||||
if(_password != nil) dict[@"password"] = _password ;
|
||||
|
||||
|
||||
|
||||
|
||||
if(_phone != nil)
|
||||
dict[@"phone"] = _phone;
|
||||
if(_phone != nil) dict[@"phone"] = _phone ;
|
||||
|
||||
|
||||
|
||||
|
||||
if(_userStatus != nil)
|
||||
dict[@"userStatus"] = _userStatus;
|
||||
if(_userStatus != nil) dict[@"userStatus"] = _userStatus ;
|
||||
|
||||
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
#import <Foundation/Foundation.h>
|
||||
#import "SWGUser.h"
|
||||
#import "SWGObject.h"
|
||||
|
||||
|
||||
@interface SWGUserApi: NSObject
|
||||
@ -12,92 +13,157 @@
|
||||
/**
|
||||
|
||||
Create user
|
||||
|
||||
This can only be done by the logged in user.
|
||||
|
||||
|
||||
|
||||
@param body Created user object
|
||||
|
||||
|
||||
return type:
|
||||
*/
|
||||
-(NSNumber*) createUserWithCompletionBlock : (SWGUser*) body
|
||||
-(NSNumber*) createUserWithCompletionBlock :(SWGUser*) body
|
||||
|
||||
|
||||
completionHandler: (void (^)(NSError* error))completionBlock;
|
||||
|
||||
|
||||
/**
|
||||
|
||||
Creates list of users with given input array
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@param body List of user object
|
||||
|
||||
|
||||
return type:
|
||||
*/
|
||||
-(NSNumber*) createUsersWithArrayInputWithCompletionBlock : (NSArray*) body
|
||||
-(NSNumber*) createUsersWithArrayInputWithCompletionBlock :(NSArray*) body
|
||||
|
||||
|
||||
completionHandler: (void (^)(NSError* error))completionBlock;
|
||||
|
||||
|
||||
/**
|
||||
|
||||
Creates list of users with given input array
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@param body List of user object
|
||||
|
||||
|
||||
return type:
|
||||
*/
|
||||
-(NSNumber*) createUsersWithListInputWithCompletionBlock : (NSArray*) body
|
||||
-(NSNumber*) createUsersWithListInputWithCompletionBlock :(NSArray*) body
|
||||
|
||||
|
||||
completionHandler: (void (^)(NSError* error))completionBlock;
|
||||
|
||||
|
||||
/**
|
||||
|
||||
Logs user into the system
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@param username The user name for login
|
||||
|
||||
@param password The password for login in clear text
|
||||
|
||||
|
||||
return type: NSString*
|
||||
*/
|
||||
-(NSNumber*) loginUserWithCompletionBlock : (NSString*) username
|
||||
password: (NSString*) password
|
||||
-(NSNumber*) loginUserWithCompletionBlock :(NSString*) username
|
||||
password:(NSString*) password
|
||||
|
||||
completionHandler: (void (^)(NSString* output, NSError* error))completionBlock;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
|
||||
Logs out current logged in user session
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
return type:
|
||||
*/
|
||||
-(NSNumber*) logoutUserWithCompletionBlock :
|
||||
|
||||
(void (^)(NSError* error))completionBlock;
|
||||
(void (^)(NSError* error))completionBlock;
|
||||
|
||||
|
||||
/**
|
||||
|
||||
Get user by user name
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@param username The name that needs to be fetched. Use user1 for testing.
|
||||
|
||||
|
||||
return type: SWGUser*
|
||||
*/
|
||||
-(NSNumber*) getUserByNameWithCompletionBlock : (NSString*) username
|
||||
-(NSNumber*) getUserByNameWithCompletionBlock :(NSString*) username
|
||||
|
||||
completionHandler: (void (^)(SWGUser* output, 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
|
||||
|
||||
|
||||
return type:
|
||||
*/
|
||||
-(NSNumber*) updateUserWithCompletionBlock : (NSString*) username
|
||||
body: (SWGUser*) body
|
||||
-(NSNumber*) updateUserWithCompletionBlock :(NSString*) username
|
||||
body:(SWGUser*) 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
|
||||
|
||||
|
||||
return type:
|
||||
*/
|
||||
-(NSNumber*) deleteUserWithCompletionBlock : (NSString*) username
|
||||
-(NSNumber*) deleteUserWithCompletionBlock :(NSString*) username
|
||||
|
||||
|
||||
completionHandler: (void (^)(NSError* error))completionBlock;
|
||||
|
||||
|
||||
|
||||
@end
|
@ -52,9 +52,9 @@ static NSString * basePath = @"http://petstore.swagger.wordnik.com/v2";
|
||||
|
||||
-(NSNumber*) createUserWithCompletionBlock:(SWGUser*) body
|
||||
|
||||
|
||||
completionHandler: (void (^)(NSError* error))completionBlock {
|
||||
|
||||
id m_body = body;
|
||||
NSMutableString* requestUrl = [NSMutableString stringWithFormat:@"%@/user", basePath];
|
||||
|
||||
// remove format in URL if needed
|
||||
@ -73,9 +73,11 @@ static NSString * basePath = @"http://petstore.swagger.wordnik.com/v2";
|
||||
|
||||
id bodyDictionary = nil;
|
||||
|
||||
if(m_body != nil && [m_body isKindOfClass:[NSArray class]]){
|
||||
id __body = body;
|
||||
|
||||
if(__body != nil && [__body isKindOfClass:[NSArray class]]){
|
||||
NSMutableArray * objs = [[NSMutableArray alloc] init];
|
||||
for (id dict in (NSArray*)m_body) {
|
||||
for (id dict in (NSArray*)__body) {
|
||||
if([dict respondsToSelector:@selector(asDictionary)]) {
|
||||
[objs addObject:[(SWGObject*)dict asDictionary]];
|
||||
}
|
||||
@ -85,39 +87,38 @@ static NSString * basePath = @"http://petstore.swagger.wordnik.com/v2";
|
||||
}
|
||||
bodyDictionary = objs;
|
||||
}
|
||||
else if([m_body respondsToSelector:@selector(asDictionary)]) {
|
||||
bodyDictionary = [(SWGObject*)m_body asDictionary];
|
||||
else if([__body respondsToSelector:@selector(asDictionary)]) {
|
||||
bodyDictionary = [(SWGObject*)__body asDictionary];
|
||||
}
|
||||
else if([m_body isKindOfClass:[NSString class]]) {
|
||||
else if([__body isKindOfClass:[NSString class]]) {
|
||||
// convert it to a dictionary
|
||||
NSError * error;
|
||||
NSString * str = (NSString*)m_body;
|
||||
NSString * str = (NSString*)__body;
|
||||
NSDictionary *JSON =
|
||||
[NSJSONSerialization JSONObjectWithData:[str dataUsingEncoding:NSUTF8StringEncoding]
|
||||
options:NSJSONReadingMutableContainers
|
||||
error:&error];
|
||||
bodyDictionary = JSON;
|
||||
}
|
||||
else if([m_body isKindOfClass: [SWGFile class]]) {
|
||||
else if([__body isKindOfClass: [SWGFile class]]) {
|
||||
requestContentType = @"form-data";
|
||||
bodyDictionary = m_body;
|
||||
bodyDictionary = __body;
|
||||
}
|
||||
else{
|
||||
NSLog(@"don't know what to do with %@", m_body);
|
||||
NSLog(@"don't know what to do with %@", __body);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
SWGApiClient* client = [SWGApiClient sharedClientFromPool:basePath];
|
||||
|
||||
|
||||
|
||||
// primitive response type
|
||||
|
||||
|
||||
|
||||
|
||||
// no return base type
|
||||
return [client stringWithCompletionBlock:requestUrl
|
||||
method:@"POST"
|
||||
queryParams:queryParams
|
||||
@ -135,13 +136,14 @@ static NSString * basePath = @"http://petstore.swagger.wordnik.com/v2";
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
-(NSNumber*) createUsersWithArrayInputWithCompletionBlock:(NSArray*) body
|
||||
|
||||
|
||||
completionHandler: (void (^)(NSError* error))completionBlock {
|
||||
|
||||
id m_body = body;
|
||||
NSMutableString* requestUrl = [NSMutableString stringWithFormat:@"%@/user/createWithArray", basePath];
|
||||
|
||||
// remove format in URL if needed
|
||||
@ -160,9 +162,11 @@ static NSString * basePath = @"http://petstore.swagger.wordnik.com/v2";
|
||||
|
||||
id bodyDictionary = nil;
|
||||
|
||||
if(m_body != nil && [m_body isKindOfClass:[NSArray class]]){
|
||||
id __body = body;
|
||||
|
||||
if(__body != nil && [__body isKindOfClass:[NSArray class]]){
|
||||
NSMutableArray * objs = [[NSMutableArray alloc] init];
|
||||
for (id dict in (NSArray*)m_body) {
|
||||
for (id dict in (NSArray*)__body) {
|
||||
if([dict respondsToSelector:@selector(asDictionary)]) {
|
||||
[objs addObject:[(SWGObject*)dict asDictionary]];
|
||||
}
|
||||
@ -172,39 +176,38 @@ static NSString * basePath = @"http://petstore.swagger.wordnik.com/v2";
|
||||
}
|
||||
bodyDictionary = objs;
|
||||
}
|
||||
else if([m_body respondsToSelector:@selector(asDictionary)]) {
|
||||
bodyDictionary = [(SWGObject*)m_body asDictionary];
|
||||
else if([__body respondsToSelector:@selector(asDictionary)]) {
|
||||
bodyDictionary = [(SWGObject*)__body asDictionary];
|
||||
}
|
||||
else if([m_body isKindOfClass:[NSString class]]) {
|
||||
else if([__body isKindOfClass:[NSString class]]) {
|
||||
// convert it to a dictionary
|
||||
NSError * error;
|
||||
NSString * str = (NSString*)m_body;
|
||||
NSString * str = (NSString*)__body;
|
||||
NSDictionary *JSON =
|
||||
[NSJSONSerialization JSONObjectWithData:[str dataUsingEncoding:NSUTF8StringEncoding]
|
||||
options:NSJSONReadingMutableContainers
|
||||
error:&error];
|
||||
bodyDictionary = JSON;
|
||||
}
|
||||
else if([m_body isKindOfClass: [SWGFile class]]) {
|
||||
else if([__body isKindOfClass: [SWGFile class]]) {
|
||||
requestContentType = @"form-data";
|
||||
bodyDictionary = m_body;
|
||||
bodyDictionary = __body;
|
||||
}
|
||||
else{
|
||||
NSLog(@"don't know what to do with %@", m_body);
|
||||
NSLog(@"don't know what to do with %@", __body);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
SWGApiClient* client = [SWGApiClient sharedClientFromPool:basePath];
|
||||
|
||||
|
||||
|
||||
// primitive response type
|
||||
|
||||
|
||||
|
||||
|
||||
// no return base type
|
||||
return [client stringWithCompletionBlock:requestUrl
|
||||
method:@"POST"
|
||||
queryParams:queryParams
|
||||
@ -222,13 +225,14 @@ static NSString * basePath = @"http://petstore.swagger.wordnik.com/v2";
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
-(NSNumber*) createUsersWithListInputWithCompletionBlock:(NSArray*) body
|
||||
|
||||
|
||||
completionHandler: (void (^)(NSError* error))completionBlock {
|
||||
|
||||
id m_body = body;
|
||||
NSMutableString* requestUrl = [NSMutableString stringWithFormat:@"%@/user/createWithList", basePath];
|
||||
|
||||
// remove format in URL if needed
|
||||
@ -247,9 +251,11 @@ static NSString * basePath = @"http://petstore.swagger.wordnik.com/v2";
|
||||
|
||||
id bodyDictionary = nil;
|
||||
|
||||
if(m_body != nil && [m_body isKindOfClass:[NSArray class]]){
|
||||
id __body = body;
|
||||
|
||||
if(__body != nil && [__body isKindOfClass:[NSArray class]]){
|
||||
NSMutableArray * objs = [[NSMutableArray alloc] init];
|
||||
for (id dict in (NSArray*)m_body) {
|
||||
for (id dict in (NSArray*)__body) {
|
||||
if([dict respondsToSelector:@selector(asDictionary)]) {
|
||||
[objs addObject:[(SWGObject*)dict asDictionary]];
|
||||
}
|
||||
@ -259,39 +265,38 @@ static NSString * basePath = @"http://petstore.swagger.wordnik.com/v2";
|
||||
}
|
||||
bodyDictionary = objs;
|
||||
}
|
||||
else if([m_body respondsToSelector:@selector(asDictionary)]) {
|
||||
bodyDictionary = [(SWGObject*)m_body asDictionary];
|
||||
else if([__body respondsToSelector:@selector(asDictionary)]) {
|
||||
bodyDictionary = [(SWGObject*)__body asDictionary];
|
||||
}
|
||||
else if([m_body isKindOfClass:[NSString class]]) {
|
||||
else if([__body isKindOfClass:[NSString class]]) {
|
||||
// convert it to a dictionary
|
||||
NSError * error;
|
||||
NSString * str = (NSString*)m_body;
|
||||
NSString * str = (NSString*)__body;
|
||||
NSDictionary *JSON =
|
||||
[NSJSONSerialization JSONObjectWithData:[str dataUsingEncoding:NSUTF8StringEncoding]
|
||||
options:NSJSONReadingMutableContainers
|
||||
error:&error];
|
||||
bodyDictionary = JSON;
|
||||
}
|
||||
else if([m_body isKindOfClass: [SWGFile class]]) {
|
||||
else if([__body isKindOfClass: [SWGFile class]]) {
|
||||
requestContentType = @"form-data";
|
||||
bodyDictionary = m_body;
|
||||
bodyDictionary = __body;
|
||||
}
|
||||
else{
|
||||
NSLog(@"don't know what to do with %@", m_body);
|
||||
NSLog(@"don't know what to do with %@", __body);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
SWGApiClient* client = [SWGApiClient sharedClientFromPool:basePath];
|
||||
|
||||
|
||||
|
||||
// primitive response type
|
||||
|
||||
|
||||
|
||||
|
||||
// no return base type
|
||||
return [client stringWithCompletionBlock:requestUrl
|
||||
method:@"POST"
|
||||
queryParams:queryParams
|
||||
@ -309,14 +314,15 @@ static NSString * basePath = @"http://petstore.swagger.wordnik.com/v2";
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
-(NSNumber*) loginUserWithCompletionBlock:(NSString*) username
|
||||
password:(NSString*) password
|
||||
password:(NSString*) password
|
||||
|
||||
completionHandler: (void (^)(NSString* output, NSError* error))completionBlock
|
||||
{
|
||||
|
||||
id m_body = nil;
|
||||
NSMutableString* requestUrl = [NSMutableString stringWithFormat:@"%@/user/login", basePath];
|
||||
|
||||
// remove format in URL if needed
|
||||
@ -330,8 +336,10 @@ static NSString * basePath = @"http://petstore.swagger.wordnik.com/v2";
|
||||
|
||||
NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init];
|
||||
if(username != nil)
|
||||
queryParams[@"username"] = username;if(password != nil)
|
||||
queryParams[@"username"] = username;
|
||||
if(password != nil)
|
||||
queryParams[@"password"] = password;
|
||||
|
||||
NSMutableDictionary* headerParams = [[NSMutableDictionary alloc] init];
|
||||
|
||||
|
||||
@ -344,25 +352,25 @@ static NSString * basePath = @"http://petstore.swagger.wordnik.com/v2";
|
||||
|
||||
|
||||
|
||||
// primitive response type
|
||||
return [client stringWithCompletionBlock:requestUrl
|
||||
method:@"GET"
|
||||
queryParams:queryParams
|
||||
body:bodyDictionary
|
||||
headerParams:headerParams
|
||||
requestContentType: requestContentType
|
||||
responseContentType: responseContentType
|
||||
completionBlock:^(NSString *data, NSError *error) {
|
||||
if (error) {
|
||||
completionBlock(nil, error);
|
||||
return;
|
||||
}
|
||||
NSString *result = data ? [[NSString alloc]initWithString: data] : nil;
|
||||
completionBlock(result, nil);
|
||||
}];
|
||||
|
||||
|
||||
|
||||
return [client stringWithCompletionBlock: requestUrl
|
||||
method: @"GET"
|
||||
queryParams: queryParams
|
||||
body: bodyDictionary
|
||||
headerParams: headerParams
|
||||
requestContentType: requestContentType
|
||||
responseContentType: responseContentType
|
||||
completionBlock: ^(NSString *data, NSError *error) {
|
||||
if (error) {
|
||||
completionBlock(nil, error);
|
||||
return;
|
||||
}
|
||||
NSString *result = data ? [[NSString alloc]initWithString: data] : nil;
|
||||
completionBlock(result, nil);
|
||||
}];
|
||||
|
||||
|
||||
|
||||
}
|
||||
@ -371,7 +379,6 @@ static NSString * basePath = @"http://petstore.swagger.wordnik.com/v2";
|
||||
|
||||
(void (^)(NSError* error))completionBlock {
|
||||
|
||||
id m_body = nil;
|
||||
NSMutableString* requestUrl = [NSMutableString stringWithFormat:@"%@/user/logout", basePath];
|
||||
|
||||
// remove format in URL if needed
|
||||
@ -397,10 +404,10 @@ static NSString * basePath = @"http://petstore.swagger.wordnik.com/v2";
|
||||
|
||||
|
||||
|
||||
// primitive response type
|
||||
|
||||
|
||||
|
||||
|
||||
// no return base type
|
||||
return [client stringWithCompletionBlock:requestUrl
|
||||
method:@"GET"
|
||||
queryParams:queryParams
|
||||
@ -418,13 +425,14 @@ static NSString * basePath = @"http://petstore.swagger.wordnik.com/v2";
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
-(NSNumber*) getUserByNameWithCompletionBlock:(NSString*) username
|
||||
|
||||
completionHandler: (void (^)(SWGUser* output, NSError* error))completionBlock
|
||||
{
|
||||
|
||||
id m_body = nil;
|
||||
NSMutableString* requestUrl = [NSMutableString stringWithFormat:@"%@/user/{username}", basePath];
|
||||
|
||||
// remove format in URL if needed
|
||||
@ -453,38 +461,38 @@ static NSString * basePath = @"http://petstore.swagger.wordnik.com/v2";
|
||||
|
||||
|
||||
|
||||
|
||||
// comples response type
|
||||
return [client dictionary:requestUrl
|
||||
method:@"GET"
|
||||
queryParams:queryParams
|
||||
body:bodyDictionary
|
||||
headerParams:headerParams
|
||||
requestContentType:requestContentType
|
||||
responseContentType:responseContentType
|
||||
completionBlock:^(NSDictionary *data, NSError *error) {
|
||||
if (error) {
|
||||
completionBlock(nil, error);
|
||||
method:@"GET"
|
||||
queryParams:queryParams
|
||||
body:bodyDictionary
|
||||
headerParams:headerParams
|
||||
requestContentType:requestContentType
|
||||
responseContentType:responseContentType
|
||||
completionBlock:^(NSDictionary *data, NSError *error) {
|
||||
if (error) {
|
||||
completionBlock(nil, error);
|
||||
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
SWGUser *result = nil;
|
||||
if (data) {
|
||||
result = [[SWGUser alloc]initWithValues: data];
|
||||
}
|
||||
completionBlock(result , nil);
|
||||
SWGUser *result = nil;
|
||||
if (data) {
|
||||
result = [[SWGUser alloc]initWithValues: data];
|
||||
}
|
||||
completionBlock(result , nil);
|
||||
|
||||
}];
|
||||
}];
|
||||
|
||||
|
||||
}
|
||||
|
||||
-(NSNumber*) updateUserWithCompletionBlock:(NSString*) username
|
||||
body:(SWGUser*) body
|
||||
body:(SWGUser*) body
|
||||
|
||||
|
||||
completionHandler: (void (^)(NSError* error))completionBlock {
|
||||
|
||||
id m_body = body;
|
||||
NSMutableString* requestUrl = [NSMutableString stringWithFormat:@"%@/user/{username}", basePath];
|
||||
|
||||
// remove format in URL if needed
|
||||
@ -504,9 +512,11 @@ static NSString * basePath = @"http://petstore.swagger.wordnik.com/v2";
|
||||
|
||||
id bodyDictionary = nil;
|
||||
|
||||
if(m_body != nil && [m_body isKindOfClass:[NSArray class]]){
|
||||
id __body = body;
|
||||
|
||||
if(__body != nil && [__body isKindOfClass:[NSArray class]]){
|
||||
NSMutableArray * objs = [[NSMutableArray alloc] init];
|
||||
for (id dict in (NSArray*)m_body) {
|
||||
for (id dict in (NSArray*)__body) {
|
||||
if([dict respondsToSelector:@selector(asDictionary)]) {
|
||||
[objs addObject:[(SWGObject*)dict asDictionary]];
|
||||
}
|
||||
@ -516,39 +526,38 @@ static NSString * basePath = @"http://petstore.swagger.wordnik.com/v2";
|
||||
}
|
||||
bodyDictionary = objs;
|
||||
}
|
||||
else if([m_body respondsToSelector:@selector(asDictionary)]) {
|
||||
bodyDictionary = [(SWGObject*)m_body asDictionary];
|
||||
else if([__body respondsToSelector:@selector(asDictionary)]) {
|
||||
bodyDictionary = [(SWGObject*)__body asDictionary];
|
||||
}
|
||||
else if([m_body isKindOfClass:[NSString class]]) {
|
||||
else if([__body isKindOfClass:[NSString class]]) {
|
||||
// convert it to a dictionary
|
||||
NSError * error;
|
||||
NSString * str = (NSString*)m_body;
|
||||
NSString * str = (NSString*)__body;
|
||||
NSDictionary *JSON =
|
||||
[NSJSONSerialization JSONObjectWithData:[str dataUsingEncoding:NSUTF8StringEncoding]
|
||||
options:NSJSONReadingMutableContainers
|
||||
error:&error];
|
||||
bodyDictionary = JSON;
|
||||
}
|
||||
else if([m_body isKindOfClass: [SWGFile class]]) {
|
||||
else if([__body isKindOfClass: [SWGFile class]]) {
|
||||
requestContentType = @"form-data";
|
||||
bodyDictionary = m_body;
|
||||
bodyDictionary = __body;
|
||||
}
|
||||
else{
|
||||
NSLog(@"don't know what to do with %@", m_body);
|
||||
NSLog(@"don't know what to do with %@", __body);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
SWGApiClient* client = [SWGApiClient sharedClientFromPool:basePath];
|
||||
|
||||
|
||||
|
||||
// primitive response type
|
||||
|
||||
|
||||
|
||||
|
||||
// no return base type
|
||||
return [client stringWithCompletionBlock:requestUrl
|
||||
method:@"PUT"
|
||||
queryParams:queryParams
|
||||
@ -566,13 +575,14 @@ static NSString * basePath = @"http://petstore.swagger.wordnik.com/v2";
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
-(NSNumber*) deleteUserWithCompletionBlock:(NSString*) username
|
||||
|
||||
|
||||
completionHandler: (void (^)(NSError* error))completionBlock {
|
||||
|
||||
id m_body = nil;
|
||||
NSMutableString* requestUrl = [NSMutableString stringWithFormat:@"%@/user/{username}", basePath];
|
||||
|
||||
// remove format in URL if needed
|
||||
@ -599,10 +609,10 @@ static NSString * basePath = @"http://petstore.swagger.wordnik.com/v2";
|
||||
|
||||
|
||||
|
||||
// primitive response type
|
||||
|
||||
|
||||
|
||||
|
||||
// no return base type
|
||||
return [client stringWithCompletionBlock:requestUrl
|
||||
method:@"DELETE"
|
||||
queryParams:queryParams
|
||||
@ -620,6 +630,7 @@ static NSString * basePath = @"http://petstore.swagger.wordnik.com/v2";
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user