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'
|
platform :ios, '6.0'
|
||||||
xcodeproj '/.xcodeproj'
|
xcodeproj 'swaggerClient/swaggerClient.xcodeproj'
|
||||||
pod 'AFNetworking', '~> 1.0'
|
pod 'AFNetworking', '~> 2.1'
|
||||||
|
@ -1,7 +1,15 @@
|
|||||||
#import <Foundation/Foundation.h>
|
#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) NSURLRequestCachePolicy cachePolicy;
|
||||||
@property(nonatomic, assign) NSTimeInterval timeoutInterval;
|
@property(nonatomic, assign) NSTimeInterval timeoutInterval;
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
#import "SWGApiClient.h"
|
#import "SWGApiClient.h"
|
||||||
#import "SWGFile.h"
|
#import "SWGFile.h"
|
||||||
|
|
||||||
#import "AFJSONRequestOperation.h"
|
|
||||||
|
|
||||||
@implementation SWGApiClient
|
@implementation SWGApiClient
|
||||||
|
|
||||||
|
NSString *const SWGResponseObjectErrorKey = @"SWGResponseObject";
|
||||||
|
|
||||||
static long requestId = 0;
|
static long requestId = 0;
|
||||||
static bool offlineState = false;
|
static bool offlineState = false;
|
||||||
static NSMutableSet * queuedRequests = nil;
|
static NSMutableSet * queuedRequests = nil;
|
||||||
@ -68,8 +68,6 @@ static bool loggingEnabled = false;
|
|||||||
SWGApiClient * client = [_pool objectForKey:baseUrl];
|
SWGApiClient * client = [_pool objectForKey:baseUrl];
|
||||||
if (client == nil) {
|
if (client == nil) {
|
||||||
client = [[SWGApiClient alloc] initWithBaseURL:[NSURL URLWithString:baseUrl]];
|
client = [[SWGApiClient alloc] initWithBaseURL:[NSURL URLWithString:baseUrl]];
|
||||||
[client registerHTTPOperationClass:[AFJSONRequestOperation class]];
|
|
||||||
client.parameterEncoding = AFJSONParameterEncoding;
|
|
||||||
[_pool setValue:client forKey:baseUrl ];
|
[_pool setValue:client forKey:baseUrl ];
|
||||||
if(loggingEnabled)
|
if(loggingEnabled)
|
||||||
NSLog(@"new client for path %@", baseUrl);
|
NSLog(@"new client for path %@", baseUrl);
|
||||||
@ -82,7 +80,7 @@ static bool loggingEnabled = false;
|
|||||||
|
|
||||||
-(void)setHeaderValue:(NSString*) value
|
-(void)setHeaderValue:(NSString*) value
|
||||||
forKey:(NSString*) forKey {
|
forKey:(NSString*) forKey {
|
||||||
[self setDefaultHeader:forKey value:value];
|
[self.requestSerializer setValue:value forHTTPHeaderField:forKey];
|
||||||
}
|
}
|
||||||
|
|
||||||
+(unsigned long)requestQueueSize {
|
+(unsigned long)requestQueueSize {
|
||||||
@ -142,6 +140,8 @@ static bool loggingEnabled = false;
|
|||||||
|
|
||||||
-(id)initWithBaseURL:(NSURL *)url {
|
-(id)initWithBaseURL:(NSURL *)url {
|
||||||
self = [super initWithBaseURL:url];
|
self = [super initWithBaseURL:url];
|
||||||
|
self.requestSerializer = [AFJSONRequestSerializer serializer];
|
||||||
|
self.responseSerializer = [AFJSONResponseSerializer serializer];
|
||||||
if (!self)
|
if (!self)
|
||||||
return nil;
|
return nil;
|
||||||
return self;
|
return self;
|
||||||
@ -160,7 +160,7 @@ static bool loggingEnabled = false;
|
|||||||
}
|
}
|
||||||
|
|
||||||
+(void) configureCacheReachibilityForHost:(NSString*)host {
|
+(void) configureCacheReachibilityForHost:(NSString*)host {
|
||||||
[[SWGApiClient sharedClientFromPool:host ] setReachabilityStatusChangeBlock:^(AFNetworkReachabilityStatus status) {
|
[[SWGApiClient sharedClientFromPool:host].reachabilityManager setReachabilityStatusChangeBlock:^(AFNetworkReachabilityStatus status) {
|
||||||
reachabilityStatus = status;
|
reachabilityStatus = status;
|
||||||
switch (status) {
|
switch (status) {
|
||||||
case AFNetworkReachabilityStatusUnknown:
|
case AFNetworkReachabilityStatusUnknown:
|
||||||
@ -194,6 +194,7 @@ static bool loggingEnabled = false;
|
|||||||
reachabilityChangeBlock(status);
|
reachabilityChangeBlock(status);
|
||||||
}
|
}
|
||||||
}];
|
}];
|
||||||
|
[[SWGApiClient sharedClientFromPool:host].reachabilityManager startMonitoring];
|
||||||
}
|
}
|
||||||
|
|
||||||
-(NSString*) pathWithQueryParamsToString:(NSString*) path
|
-(NSString*) pathWithQueryParamsToString:(NSString*) path
|
||||||
@ -247,21 +248,27 @@ static bool loggingEnabled = false;
|
|||||||
|
|
||||||
if ([body isKindOfClass:[SWGFile class]]){
|
if ([body isKindOfClass:[SWGFile class]]){
|
||||||
SWGFile * file = (SWGFile*) body;
|
SWGFile * file = (SWGFile*) body;
|
||||||
|
NSString * urlString = [[NSURL URLWithString:path relativeToURL:self.baseURL] absoluteString];
|
||||||
|
|
||||||
request = [self multipartFormRequestWithMethod:@"POST"
|
request = [self.requestSerializer multipartFormRequestWithMethod:@"POST"
|
||||||
path:path
|
URLString:urlString
|
||||||
parameters:nil
|
parameters:nil
|
||||||
constructingBodyWithBlock: ^(id <AFMultipartFormData> formData) {
|
constructingBodyWithBlock:^(id<AFMultipartFormData> formData) {
|
||||||
[formData appendPartWithFileData:[file data]
|
[formData appendPartWithFileData:[file data]
|
||||||
name:@"image"
|
name:@"image"
|
||||||
fileName:[file name]
|
fileName:[file name]
|
||||||
mimeType:[file mimeType]];
|
mimeType:[file mimeType]];
|
||||||
}];
|
}
|
||||||
|
error:nil];
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
request = [self requestWithMethod:method
|
NSString * pathWithQueryParams = [self pathWithQueryParamsToString:path queryParams:queryParams];
|
||||||
path:[self pathWithQueryParamsToString:path queryParams:queryParams]
|
NSString * urlString = [[NSURL URLWithString:pathWithQueryParams relativeToURL:self.baseURL] absoluteString];
|
||||||
parameters:body];
|
|
||||||
|
request = [self.requestSerializer requestWithMethod:method
|
||||||
|
URLString:urlString
|
||||||
|
parameters:body
|
||||||
|
error:nil];
|
||||||
}
|
}
|
||||||
BOOL hasHeaderParams = false;
|
BOOL hasHeaderParams = false;
|
||||||
if(headerParams != nil && [headerParams count] > 0)
|
if(headerParams != nil && [headerParams count] > 0)
|
||||||
@ -304,25 +311,31 @@ static bool loggingEnabled = false;
|
|||||||
}
|
}
|
||||||
|
|
||||||
NSNumber* requestId = [SWGApiClient queueRequest];
|
NSNumber* requestId = [SWGApiClient queueRequest];
|
||||||
AFJSONRequestOperation *op =
|
AFHTTPRequestOperation *op =
|
||||||
[AFJSONRequestOperation
|
[self HTTPRequestOperationWithRequest:request
|
||||||
JSONRequestOperationWithRequest:request
|
success:^(AFHTTPRequestOperation *operation, id JSON) {
|
||||||
success:^(NSURLRequest *request, NSHTTPURLResponse *response, id JSON) {
|
|
||||||
if([self executeRequestWithId:requestId]) {
|
if([self executeRequestWithId:requestId]) {
|
||||||
if(self.logServerResponses)
|
if(self.logServerResponses)
|
||||||
[self logResponse:JSON forRequest:request error:nil];
|
[self logResponse:JSON forRequest:request error:nil];
|
||||||
completionBlock(JSON, nil);
|
completionBlock(JSON, nil);
|
||||||
}
|
}
|
||||||
} failure:^(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error, id data) {
|
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
|
||||||
if([self executeRequestWithId:requestId]) {
|
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)
|
if(self.logServerResponses)
|
||||||
[self logResponse:nil forRequest:request error:error];
|
[self logResponse:nil forRequest:request error:augmentedError];
|
||||||
completionBlock(nil, error);
|
completionBlock(nil, augmentedError);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
[self enqueueHTTPRequestOperation:op];
|
[self.operationQueue addOperation:op];
|
||||||
return requestId;
|
return requestId;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -334,30 +347,32 @@ static bool loggingEnabled = false;
|
|||||||
requestContentType:(NSString*) requestContentType
|
requestContentType:(NSString*) requestContentType
|
||||||
responseContentType:(NSString*) responseContentType
|
responseContentType:(NSString*) responseContentType
|
||||||
completionBlock:(void (^)(NSString*, NSError *))completionBlock {
|
completionBlock:(void (^)(NSString*, NSError *))completionBlock {
|
||||||
AFHTTPClient *client = self;
|
|
||||||
client.parameterEncoding = AFJSONParameterEncoding;
|
|
||||||
|
|
||||||
NSMutableURLRequest * request = nil;
|
NSMutableURLRequest * request = nil;
|
||||||
|
|
||||||
if ([body isKindOfClass:[SWGFile class]]){
|
if ([body isKindOfClass:[SWGFile class]]){
|
||||||
SWGFile * file = (SWGFile*) body;
|
SWGFile * file = (SWGFile*) body;
|
||||||
|
NSString * urlString = [[NSURL URLWithString:path relativeToURL:self.baseURL] absoluteString];
|
||||||
|
|
||||||
request = [self multipartFormRequestWithMethod:@"POST"
|
request = [self.requestSerializer multipartFormRequestWithMethod:@"POST"
|
||||||
path:path
|
URLString:urlString
|
||||||
parameters:nil
|
parameters:nil
|
||||||
constructingBodyWithBlock: ^(id <AFMultipartFormData> formData) {
|
constructingBodyWithBlock:^(id<AFMultipartFormData> formData) {
|
||||||
[formData appendPartWithFileData:[file data]
|
[formData appendPartWithFileData:[file data]
|
||||||
name:@"image"
|
name:@"image"
|
||||||
fileName:[file name]
|
fileName:[file name]
|
||||||
mimeType:[file mimeType]];
|
mimeType:[file mimeType]];
|
||||||
}];
|
}
|
||||||
|
error:nil];
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
request = [self requestWithMethod:method
|
NSString * pathWithQueryParams = [self pathWithQueryParamsToString:path queryParams:queryParams];
|
||||||
path:[self pathWithQueryParamsToString:path queryParams:queryParams]
|
NSString * urlString = [[NSURL URLWithString:pathWithQueryParams relativeToURL:self.baseURL] absoluteString];
|
||||||
parameters:body];
|
|
||||||
|
request = [self.requestSerializer requestWithMethod:method
|
||||||
|
URLString:urlString
|
||||||
|
parameters:body
|
||||||
|
error:nil];
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL hasHeaderParams = false;
|
BOOL hasHeaderParams = false;
|
||||||
if(headerParams != nil && [headerParams count] > 0)
|
if(headerParams != nil && [headerParams count] > 0)
|
||||||
hasHeaderParams = true;
|
hasHeaderParams = true;
|
||||||
@ -394,11 +409,9 @@ static bool loggingEnabled = false;
|
|||||||
[request setHTTPShouldHandleCookies:NO];
|
[request setHTTPShouldHandleCookies:NO];
|
||||||
|
|
||||||
NSNumber* requestId = [SWGApiClient queueRequest];
|
NSNumber* requestId = [SWGApiClient queueRequest];
|
||||||
AFHTTPRequestOperation *op = [[AFHTTPRequestOperation alloc] initWithRequest:request];
|
AFHTTPRequestOperation *op = [self HTTPRequestOperationWithRequest:request
|
||||||
[op setCompletionBlockWithSuccess:
|
success:^(AFHTTPRequestOperation *operation, id responseObject) {
|
||||||
^(AFHTTPRequestOperation *resp,
|
NSString *response = [operation responseString];
|
||||||
id responseObject) {
|
|
||||||
NSString *response = [resp responseString];
|
|
||||||
if([self executeRequestWithId:requestId]) {
|
if([self executeRequestWithId:requestId]) {
|
||||||
if(self.logServerResponses)
|
if(self.logServerResponses)
|
||||||
[self logResponse:responseObject forRequest:request error:nil];
|
[self logResponse:responseObject forRequest:request error:nil];
|
||||||
@ -406,13 +419,20 @@ static bool loggingEnabled = false;
|
|||||||
}
|
}
|
||||||
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
|
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
|
||||||
if([self executeRequestWithId:requestId]) {
|
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)
|
if(self.logServerResponses)
|
||||||
[self logResponse:nil forRequest:request error:error];
|
[self logResponse:nil forRequest:request error:augmentedError];
|
||||||
completionBlock(nil, error);
|
completionBlock(nil, augmentedError);
|
||||||
}
|
}
|
||||||
}];
|
}];
|
||||||
|
|
||||||
[self enqueueHTTPRequestOperation:op];
|
[self.operationQueue addOperation:op];
|
||||||
return requestId;
|
return requestId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,10 +6,10 @@
|
|||||||
|
|
||||||
@property(nonatomic) NSNumber* _id;
|
@property(nonatomic) NSNumber* _id;
|
||||||
@property(nonatomic) NSString* name;
|
@property(nonatomic) NSString* name;
|
||||||
- (id) _id: (NSNumber*) _id
|
- (id) _id: (NSNumber*) _id
|
||||||
|
name: (NSString*) name;
|
||||||
name: (NSString*) name;
|
|
||||||
|
|
||||||
- (id) initWithValues: (NSDictionary*)dict;
|
- (id) initWithValues: (NSDictionary*)dict;
|
||||||
- (NSDictionary*) asDictionary;
|
- (NSDictionary*) asDictionary;
|
||||||
|
|
||||||
|
@ -4,20 +4,25 @@
|
|||||||
@implementation SWGCategory
|
@implementation SWGCategory
|
||||||
|
|
||||||
-(id)_id: (NSNumber*) _id
|
-(id)_id: (NSNumber*) _id
|
||||||
name: (NSString*) name {
|
name: (NSString*) name
|
||||||
|
|
||||||
|
{
|
||||||
__id = _id;
|
__id = _id;
|
||||||
_name = name;
|
_name = name;
|
||||||
|
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
-(id) initWithValues:(NSDictionary*)dict
|
-(id) initWithValues:(NSDictionary*)dict
|
||||||
{
|
{
|
||||||
self = [super init];
|
self = [super init];
|
||||||
if(self) {
|
if(self) {
|
||||||
__id = dict[@"id"];
|
__id = dict[@"id"];
|
||||||
|
|
||||||
_name = dict[@"name"];
|
_name = dict[@"name"];
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
@ -26,17 +31,14 @@
|
|||||||
NSMutableDictionary* dict = [[NSMutableDictionary alloc] init];
|
NSMutableDictionary* dict = [[NSMutableDictionary alloc] init];
|
||||||
|
|
||||||
|
|
||||||
if(__id != nil)
|
if(__id != nil) dict[@"id"] = __id ;
|
||||||
dict[@"id"] = __id;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if(_name != nil)
|
|
||||||
dict[@"name"] = _name;
|
|
||||||
|
|
||||||
|
|
||||||
|
if(_name != nil) dict[@"name"] = _name ;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
NSDictionary* output = [dict copy];
|
NSDictionary* output = [dict copy];
|
||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
|
@ -11,18 +11,14 @@
|
|||||||
@property(nonatomic) SWGDate* shipDate;
|
@property(nonatomic) SWGDate* shipDate;
|
||||||
@property(nonatomic) NSString* status; /* Order Status */
|
@property(nonatomic) NSString* status; /* Order Status */
|
||||||
@property(nonatomic) NSNumber* complete;
|
@property(nonatomic) NSNumber* complete;
|
||||||
- (id) _id: (NSNumber*) _id
|
- (id) _id: (NSNumber*) _id
|
||||||
|
petId: (NSNumber*) petId
|
||||||
petId: (NSNumber*) petId
|
quantity: (NSNumber*) quantity
|
||||||
|
shipDate: (SWGDate*) shipDate
|
||||||
quantity: (NSNumber*) quantity
|
status: (NSString*) status
|
||||||
|
complete: (NSNumber*) complete;
|
||||||
shipDate: (SWGDate*) shipDate
|
|
||||||
|
|
||||||
status: (NSString*) status
|
|
||||||
|
|
||||||
complete: (NSNumber*) complete;
|
|
||||||
|
|
||||||
- (id) initWithValues: (NSDictionary*)dict;
|
- (id) initWithValues: (NSDictionary*)dict;
|
||||||
- (NSDictionary*) asDictionary;
|
- (NSDictionary*) asDictionary;
|
||||||
|
|
||||||
|
@ -8,8 +8,9 @@
|
|||||||
quantity: (NSNumber*) quantity
|
quantity: (NSNumber*) quantity
|
||||||
shipDate: (SWGDate*) shipDate
|
shipDate: (SWGDate*) shipDate
|
||||||
status: (NSString*) status
|
status: (NSString*) status
|
||||||
complete: (NSNumber*) complete {
|
complete: (NSNumber*) complete
|
||||||
|
|
||||||
|
{
|
||||||
__id = _id;
|
__id = _id;
|
||||||
_petId = petId;
|
_petId = petId;
|
||||||
_quantity = quantity;
|
_quantity = quantity;
|
||||||
@ -17,23 +18,33 @@
|
|||||||
_status = status;
|
_status = status;
|
||||||
_complete = complete;
|
_complete = complete;
|
||||||
|
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
-(id) initWithValues:(NSDictionary*)dict
|
-(id) initWithValues:(NSDictionary*)dict
|
||||||
{
|
{
|
||||||
self = [super init];
|
self = [super init];
|
||||||
if(self) {
|
if(self) {
|
||||||
__id = dict[@"id"];
|
__id = dict[@"id"];
|
||||||
|
|
||||||
_petId = dict[@"petId"];
|
_petId = dict[@"petId"];
|
||||||
|
|
||||||
_quantity = dict[@"quantity"];
|
_quantity = dict[@"quantity"];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
id shipDate_dict = dict[@"shipDate"];
|
id shipDate_dict = dict[@"shipDate"];
|
||||||
|
|
||||||
if(shipDate_dict != nil)
|
if(shipDate_dict != nil)
|
||||||
_shipDate = [[SWGDate alloc]initWithValues:shipDate_dict];
|
_shipDate = [[SWGDate alloc]initWithValues:shipDate_dict];
|
||||||
|
|
||||||
|
|
||||||
_status = dict[@"status"];
|
_status = dict[@"status"];
|
||||||
|
|
||||||
_complete = dict[@"complete"];
|
_complete = dict[@"complete"];
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
@ -42,52 +53,49 @@
|
|||||||
NSMutableDictionary* dict = [[NSMutableDictionary alloc] init];
|
NSMutableDictionary* dict = [[NSMutableDictionary alloc] init];
|
||||||
|
|
||||||
|
|
||||||
if(__id != nil)
|
if(__id != nil) dict[@"id"] = __id ;
|
||||||
dict[@"id"] = __id;
|
|
||||||
|
|
||||||
|
|
||||||
|
if(_petId != nil) dict[@"petId"] = _petId ;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if(_petId != nil)
|
if(_quantity != nil) dict[@"quantity"] = _quantity ;
|
||||||
dict[@"petId"] = _petId;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if(_quantity != nil)
|
|
||||||
dict[@"quantity"] = _quantity;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if(_shipDate != nil){
|
if(_shipDate != nil){
|
||||||
|
if([_shipDate isKindOfClass:[NSArray class]]){
|
||||||
|
NSMutableArray * array = [[NSMutableArray alloc] init];
|
||||||
if(_shipDate && [_shipDate isKindOfClass:[SWGDate class]]) {
|
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];
|
NSString * dateString = [(SWGDate*)_shipDate toString];
|
||||||
if(dateString){
|
if(dateString){
|
||||||
dict[@"shipDate"] = dateString;
|
dict[@"shipDate"] = dateString;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if(_shipDate != nil)
|
|
||||||
dict[@"shipDate"] = [(SWGObject*)_shipDate asDictionary];
|
|
||||||
}
|
|
||||||
|
|
||||||
|
if(_shipDate != nil) dict[@"shipDate"] = [(SWGObject*)_shipDate asDictionary];
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if(_status != nil)
|
if(_status != nil) dict[@"status"] = _status ;
|
||||||
dict[@"status"] = _status;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if(_complete != nil)
|
|
||||||
dict[@"complete"] = _complete;
|
|
||||||
|
|
||||||
|
|
||||||
|
if(_complete != nil) dict[@"complete"] = _complete ;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
NSDictionary* output = [dict copy];
|
NSDictionary* output = [dict copy];
|
||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
|
@ -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
|
|
@ -12,18 +12,14 @@
|
|||||||
@property(nonatomic) NSArray* photoUrls;
|
@property(nonatomic) NSArray* photoUrls;
|
||||||
@property(nonatomic) NSArray* tags;
|
@property(nonatomic) NSArray* tags;
|
||||||
@property(nonatomic) NSString* status; /* pet status in the store */
|
@property(nonatomic) NSString* status; /* pet status in the store */
|
||||||
- (id) _id: (NSNumber*) _id
|
- (id) _id: (NSNumber*) _id
|
||||||
|
category: (SWGCategory*) category
|
||||||
category: (SWGCategory*) category
|
name: (NSString*) name
|
||||||
|
photoUrls: (NSArray*) photoUrls
|
||||||
name: (NSString*) name
|
tags: (NSArray*) tags
|
||||||
|
status: (NSString*) status;
|
||||||
photoUrls: (NSArray*) photoUrls
|
|
||||||
|
|
||||||
tags: (NSArray*) tags
|
|
||||||
|
|
||||||
status: (NSString*) status;
|
|
||||||
|
|
||||||
- (id) initWithValues: (NSDictionary*)dict;
|
- (id) initWithValues: (NSDictionary*)dict;
|
||||||
- (NSDictionary*) asDictionary;
|
- (NSDictionary*) asDictionary;
|
||||||
|
|
||||||
|
@ -8,8 +8,9 @@
|
|||||||
name: (NSString*) name
|
name: (NSString*) name
|
||||||
photoUrls: (NSArray*) photoUrls
|
photoUrls: (NSArray*) photoUrls
|
||||||
tags: (NSArray*) tags
|
tags: (NSArray*) tags
|
||||||
status: (NSString*) status {
|
status: (NSString*) status
|
||||||
|
|
||||||
|
{
|
||||||
__id = _id;
|
__id = _id;
|
||||||
_category = category;
|
_category = category;
|
||||||
_name = name;
|
_name = name;
|
||||||
@ -17,41 +18,52 @@
|
|||||||
_tags = tags;
|
_tags = tags;
|
||||||
_status = status;
|
_status = status;
|
||||||
|
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
-(id) initWithValues:(NSDictionary*)dict
|
-(id) initWithValues:(NSDictionary*)dict
|
||||||
{
|
{
|
||||||
self = [super init];
|
self = [super init];
|
||||||
if(self) {
|
if(self) {
|
||||||
__id = dict[@"id"];
|
__id = dict[@"id"];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
id category_dict = dict[@"category"];
|
id category_dict = dict[@"category"];
|
||||||
|
|
||||||
if(category_dict != nil)
|
if(category_dict != nil)
|
||||||
_category = [[SWGCategory alloc]initWithValues:category_dict];
|
_category = [[SWGCategory alloc]initWithValues:category_dict];
|
||||||
|
|
||||||
|
|
||||||
_name = dict[@"name"];
|
_name = dict[@"name"];
|
||||||
|
|
||||||
_photoUrls = dict[@"photoUrls"];
|
_photoUrls = dict[@"photoUrls"];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
id tags_dict = dict[@"tags"];
|
id tags_dict = dict[@"tags"];
|
||||||
|
|
||||||
if([tags_dict isKindOfClass:[NSArray class]]) {
|
if([tags_dict isKindOfClass:[NSArray class]]) {
|
||||||
NSMutableArray * objs = [[NSMutableArray alloc] initWithCapacity:[(NSArray*)tags_dict count]];
|
NSMutableArray * objs = [[NSMutableArray alloc] initWithCapacity:[(NSArray*)tags_dict count]];
|
||||||
if([(NSArray*)tags_dict count] > 0) {
|
if([(NSArray*)tags_dict count] > 0) {
|
||||||
for (NSDictionary* dict in (NSArray*)tags_dict) {
|
for (NSDictionary* dict in (NSArray*)tags_dict) {
|
||||||
SWGTag* d = [[SWGTag alloc] initWithValues:dict];
|
SWGTag* d = [[SWGTag alloc] initWithValues:dict];
|
||||||
[objs addObject:d];
|
[objs addObject:d];
|
||||||
}
|
}
|
||||||
_tags = [[NSArray alloc] initWithArray:objs];
|
_tags = [[NSArray alloc] initWithArray:objs];
|
||||||
}
|
}
|
||||||
else {
|
else
|
||||||
_tags = [[NSArray alloc] init];
|
_tags = [[NSArray alloc] init];
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
_tags = [[NSArray alloc] init];
|
_tags = [[NSArray alloc] init];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
_status = dict[@"status"];
|
_status = dict[@"status"];
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
@ -60,66 +72,68 @@
|
|||||||
NSMutableDictionary* dict = [[NSMutableDictionary alloc] init];
|
NSMutableDictionary* dict = [[NSMutableDictionary alloc] init];
|
||||||
|
|
||||||
|
|
||||||
if(__id != nil)
|
if(__id != nil) dict[@"id"] = __id ;
|
||||||
dict[@"id"] = __id;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if(_category != nil){
|
if(_category != nil){
|
||||||
|
if([_category isKindOfClass:[NSArray class]]){
|
||||||
|
NSMutableArray * array = [[NSMutableArray alloc] init];
|
||||||
if(_category && [_category isKindOfClass:[SWGDate class]]) {
|
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];
|
NSString * dateString = [(SWGDate*)_category toString];
|
||||||
if(dateString){
|
if(dateString){
|
||||||
dict[@"category"] = dateString;
|
dict[@"category"] = dateString;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
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 != nil){
|
||||||
|
|
||||||
if([_tags isKindOfClass:[NSArray class]]){
|
if([_tags isKindOfClass:[NSArray class]]){
|
||||||
NSMutableArray * array = [[NSMutableArray alloc] init];
|
NSMutableArray * array = [[NSMutableArray alloc] init];
|
||||||
for( SWGTag *tags in _tags) {
|
for( SWGTag *tags in (NSArray*)_tags) {
|
||||||
[array addObject:[(SWGObject*)tags asDictionary]];
|
[array addObject:[(SWGObject*)tags asDictionary]];
|
||||||
}
|
}
|
||||||
dict[@"tags"] = array;
|
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)
|
if(_status != nil) dict[@"status"] = _status ;
|
||||||
dict[@"status"] = _status;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
NSDictionary* output = [dict copy];
|
NSDictionary* output = [dict copy];
|
||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
#import <Foundation/Foundation.h>
|
#import <Foundation/Foundation.h>
|
||||||
#import "SWGPet.h"
|
#import "SWGPet.h"
|
||||||
|
#import "SWGFile.h"
|
||||||
|
#import "SWGObject.h"
|
||||||
|
|
||||||
|
|
||||||
@interface SWGPetApi: NSObject
|
@interface SWGPetApi: NSObject
|
||||||
@ -13,83 +15,160 @@
|
|||||||
|
|
||||||
Update an existing pet
|
Update an existing pet
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@param body Pet object that needs to be added to the store
|
@param body Pet object that needs to be added to the store
|
||||||
|
|
||||||
*/
|
|
||||||
-(NSNumber*) updatePetWithCompletionBlock : (SWGPet*) body
|
|
||||||
|
|
||||||
|
return type:
|
||||||
|
*/
|
||||||
|
-(NSNumber*) updatePetWithCompletionBlock :(SWGPet*) body
|
||||||
|
|
||||||
|
|
||||||
completionHandler: (void (^)(NSError* error))completionBlock;
|
completionHandler: (void (^)(NSError* error))completionBlock;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
||||||
Add a new pet to the store
|
Add a new pet to the store
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@param pet Pet object that needs to be added to the store
|
@param pet Pet object that needs to be added to the store
|
||||||
|
|
||||||
*/
|
|
||||||
-(NSNumber*) addPetWithCompletionBlock : (SWGPet*) pet
|
|
||||||
|
|
||||||
|
return type:
|
||||||
|
*/
|
||||||
|
-(NSNumber*) addPetWithCompletionBlock :(SWGPet*) pet
|
||||||
|
|
||||||
|
|
||||||
completionHandler: (void (^)(NSError* error))completionBlock;
|
completionHandler: (void (^)(NSError* error))completionBlock;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
||||||
Finds Pets by status
|
Finds Pets by status
|
||||||
|
|
||||||
Multiple status values can be provided with comma seperated strings
|
Multiple status values can be provided with comma seperated strings
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@param status Status values that need to be considered for filter
|
@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;
|
completionHandler: (void (^)(NSArray* output, NSError* error))completionBlock;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
||||||
Finds Pets by tags
|
Finds Pets by tags
|
||||||
|
|
||||||
Muliple tags can be provided with comma seperated strings. Use tag1, tag2, tag3 for testing.
|
Muliple tags can be provided with comma seperated strings. Use tag1, tag2, tag3 for testing.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@param tags Tags to filter by
|
@param tags Tags to filter by
|
||||||
|
|
||||||
|
|
||||||
|
return type: NSArray*
|
||||||
*/
|
*/
|
||||||
-(NSNumber*) findPetsByTagsWithCompletionBlock : (NSArray*) tags
|
-(NSNumber*) findPetsByTagsWithCompletionBlock :(NSArray*) tags
|
||||||
|
|
||||||
completionHandler: (void (^)(NSArray* output, NSError* error))completionBlock;
|
completionHandler: (void (^)(NSArray* output, NSError* error))completionBlock;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
||||||
Find pet by ID
|
Find pet by ID
|
||||||
|
|
||||||
Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions
|
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
|
@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;
|
completionHandler: (void (^)(SWGPet* output, NSError* error))completionBlock;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
||||||
Updates a pet in the store with form data
|
Updates a pet in the store with form data
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@param petId ID of pet that needs to be updated
|
@param petId ID of pet that needs to be updated
|
||||||
|
|
||||||
@param name Updated name of the pet
|
@param name Updated name of the pet
|
||||||
|
|
||||||
@param status Updated status of the pet
|
@param status Updated status of the pet
|
||||||
|
|
||||||
*/
|
|
||||||
-(NSNumber*) updatePetWithFormWithCompletionBlock : (NSString*) petId
|
|
||||||
name: (NSString*) name
|
|
||||||
status: (NSString*) status
|
|
||||||
|
|
||||||
|
return type:
|
||||||
|
*/
|
||||||
|
-(NSNumber*) updatePetWithFormWithCompletionBlock :(NSString*) petId
|
||||||
|
name:(NSString*) name
|
||||||
|
status:(NSString*) status
|
||||||
|
|
||||||
|
|
||||||
completionHandler: (void (^)(NSError* error))completionBlock;
|
completionHandler: (void (^)(NSError* error))completionBlock;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
||||||
Deletes a pet
|
Deletes a pet
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@param api_key
|
@param api_key
|
||||||
|
|
||||||
@param petId Pet id to delete
|
@param petId Pet id to delete
|
||||||
|
|
||||||
*/
|
|
||||||
-(NSNumber*) deletePetWithCompletionBlock : (NSString*) api_key
|
|
||||||
petId: (NSNumber*) petId
|
|
||||||
|
|
||||||
|
return type:
|
||||||
|
*/
|
||||||
|
-(NSNumber*) deletePetWithCompletionBlock :(NSString*) api_key
|
||||||
|
petId:(NSNumber*) petId
|
||||||
|
|
||||||
|
|
||||||
completionHandler: (void (^)(NSError* error))completionBlock;
|
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
|
@end
|
@ -2,6 +2,7 @@
|
|||||||
#import "SWGFile.h"
|
#import "SWGFile.h"
|
||||||
#import "SWGApiClient.h"
|
#import "SWGApiClient.h"
|
||||||
#import "SWGPet.h"
|
#import "SWGPet.h"
|
||||||
|
#import "SWGFile.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -50,11 +51,11 @@ static NSString * basePath = @"http://petstore.swagger.wordnik.com/v2";
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
-(NSNumber*) updatePetWithCompletionBlock:(SWGPet*) body
|
-(NSNumber*) updatePetWithCompletionBlock:(SWGPet*) body
|
||||||
|
|
||||||
|
|
||||||
completionHandler: (void (^)(NSError* error))completionBlock {
|
completionHandler: (void (^)(NSError* error))completionBlock {
|
||||||
|
|
||||||
id m_body = body;
|
|
||||||
NSMutableString* requestUrl = [NSMutableString stringWithFormat:@"%@/pet", basePath];
|
NSMutableString* requestUrl = [NSMutableString stringWithFormat:@"%@/pet", basePath];
|
||||||
|
|
||||||
// remove format in URL if needed
|
// remove format in URL if needed
|
||||||
@ -73,9 +74,11 @@ static NSString * basePath = @"http://petstore.swagger.wordnik.com/v2";
|
|||||||
|
|
||||||
id bodyDictionary = nil;
|
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];
|
NSMutableArray * objs = [[NSMutableArray alloc] init];
|
||||||
for (id dict in (NSArray*)m_body) {
|
for (id dict in (NSArray*)__body) {
|
||||||
if([dict respondsToSelector:@selector(asDictionary)]) {
|
if([dict respondsToSelector:@selector(asDictionary)]) {
|
||||||
[objs addObject:[(SWGObject*)dict asDictionary]];
|
[objs addObject:[(SWGObject*)dict asDictionary]];
|
||||||
}
|
}
|
||||||
@ -85,27 +88,26 @@ static NSString * basePath = @"http://petstore.swagger.wordnik.com/v2";
|
|||||||
}
|
}
|
||||||
bodyDictionary = objs;
|
bodyDictionary = objs;
|
||||||
}
|
}
|
||||||
else if([m_body respondsToSelector:@selector(asDictionary)]) {
|
else if([__body respondsToSelector:@selector(asDictionary)]) {
|
||||||
bodyDictionary = [(SWGObject*)m_body asDictionary];
|
bodyDictionary = [(SWGObject*)__body asDictionary];
|
||||||
}
|
}
|
||||||
else if([m_body isKindOfClass:[NSString class]]) {
|
else if([__body isKindOfClass:[NSString class]]) {
|
||||||
// convert it to a dictionary
|
// convert it to a dictionary
|
||||||
NSError * error;
|
NSError * error;
|
||||||
NSString * str = (NSString*)m_body;
|
NSString * str = (NSString*)__body;
|
||||||
NSDictionary *JSON =
|
NSDictionary *JSON =
|
||||||
[NSJSONSerialization JSONObjectWithData:[str dataUsingEncoding:NSUTF8StringEncoding]
|
[NSJSONSerialization JSONObjectWithData:[str dataUsingEncoding:NSUTF8StringEncoding]
|
||||||
options:NSJSONReadingMutableContainers
|
options:NSJSONReadingMutableContainers
|
||||||
error:&error];
|
error:&error];
|
||||||
bodyDictionary = JSON;
|
bodyDictionary = JSON;
|
||||||
}
|
}
|
||||||
else if([m_body isKindOfClass: [SWGFile class]]) {
|
else if([__body isKindOfClass: [SWGFile class]]) {
|
||||||
requestContentType = @"form-data";
|
requestContentType = @"form-data";
|
||||||
bodyDictionary = m_body;
|
bodyDictionary = __body;
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
NSLog(@"don't know what to do with %@", m_body);
|
NSLog(@"don't know what to do with %@", __body);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -113,11 +115,11 @@ static NSString * basePath = @"http://petstore.swagger.wordnik.com/v2";
|
|||||||
SWGApiClient* client = [SWGApiClient sharedClientFromPool:basePath];
|
SWGApiClient* client = [SWGApiClient sharedClientFromPool:basePath];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// primitive response type
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// no return base type
|
||||||
return [client stringWithCompletionBlock:requestUrl
|
return [client stringWithCompletionBlock:requestUrl
|
||||||
method:@"PUT"
|
method:@"PUT"
|
||||||
queryParams:queryParams
|
queryParams:queryParams
|
||||||
@ -134,14 +136,15 @@ static NSString * basePath = @"http://petstore.swagger.wordnik.com/v2";
|
|||||||
}];
|
}];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
-(NSNumber*) addPetWithCompletionBlock:(SWGPet*) pet
|
-(NSNumber*) addPetWithCompletionBlock:(SWGPet*) pet
|
||||||
|
|
||||||
|
|
||||||
completionHandler: (void (^)(NSError* error))completionBlock {
|
completionHandler: (void (^)(NSError* error))completionBlock {
|
||||||
|
|
||||||
id m_body = pet;
|
|
||||||
NSMutableString* requestUrl = [NSMutableString stringWithFormat:@"%@/pet", basePath];
|
NSMutableString* requestUrl = [NSMutableString stringWithFormat:@"%@/pet", basePath];
|
||||||
|
|
||||||
// remove format in URL if needed
|
// remove format in URL if needed
|
||||||
@ -160,9 +163,11 @@ static NSString * basePath = @"http://petstore.swagger.wordnik.com/v2";
|
|||||||
|
|
||||||
id bodyDictionary = nil;
|
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];
|
NSMutableArray * objs = [[NSMutableArray alloc] init];
|
||||||
for (id dict in (NSArray*)m_body) {
|
for (id dict in (NSArray*)__body) {
|
||||||
if([dict respondsToSelector:@selector(asDictionary)]) {
|
if([dict respondsToSelector:@selector(asDictionary)]) {
|
||||||
[objs addObject:[(SWGObject*)dict asDictionary]];
|
[objs addObject:[(SWGObject*)dict asDictionary]];
|
||||||
}
|
}
|
||||||
@ -172,27 +177,26 @@ static NSString * basePath = @"http://petstore.swagger.wordnik.com/v2";
|
|||||||
}
|
}
|
||||||
bodyDictionary = objs;
|
bodyDictionary = objs;
|
||||||
}
|
}
|
||||||
else if([m_body respondsToSelector:@selector(asDictionary)]) {
|
else if([__body respondsToSelector:@selector(asDictionary)]) {
|
||||||
bodyDictionary = [(SWGObject*)m_body asDictionary];
|
bodyDictionary = [(SWGObject*)__body asDictionary];
|
||||||
}
|
}
|
||||||
else if([m_body isKindOfClass:[NSString class]]) {
|
else if([__body isKindOfClass:[NSString class]]) {
|
||||||
// convert it to a dictionary
|
// convert it to a dictionary
|
||||||
NSError * error;
|
NSError * error;
|
||||||
NSString * str = (NSString*)m_body;
|
NSString * str = (NSString*)__body;
|
||||||
NSDictionary *JSON =
|
NSDictionary *JSON =
|
||||||
[NSJSONSerialization JSONObjectWithData:[str dataUsingEncoding:NSUTF8StringEncoding]
|
[NSJSONSerialization JSONObjectWithData:[str dataUsingEncoding:NSUTF8StringEncoding]
|
||||||
options:NSJSONReadingMutableContainers
|
options:NSJSONReadingMutableContainers
|
||||||
error:&error];
|
error:&error];
|
||||||
bodyDictionary = JSON;
|
bodyDictionary = JSON;
|
||||||
}
|
}
|
||||||
else if([m_body isKindOfClass: [SWGFile class]]) {
|
else if([__body isKindOfClass: [SWGFile class]]) {
|
||||||
requestContentType = @"form-data";
|
requestContentType = @"form-data";
|
||||||
bodyDictionary = m_body;
|
bodyDictionary = __body;
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
NSLog(@"don't know what to do with %@", m_body);
|
NSLog(@"don't know what to do with %@", __body);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -200,11 +204,11 @@ static NSString * basePath = @"http://petstore.swagger.wordnik.com/v2";
|
|||||||
SWGApiClient* client = [SWGApiClient sharedClientFromPool:basePath];
|
SWGApiClient* client = [SWGApiClient sharedClientFromPool:basePath];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// primitive response type
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// no return base type
|
||||||
return [client stringWithCompletionBlock:requestUrl
|
return [client stringWithCompletionBlock:requestUrl
|
||||||
method:@"POST"
|
method:@"POST"
|
||||||
queryParams:queryParams
|
queryParams:queryParams
|
||||||
@ -221,14 +225,15 @@ static NSString * basePath = @"http://petstore.swagger.wordnik.com/v2";
|
|||||||
}];
|
}];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
-(NSNumber*) findPetsByStatusWithCompletionBlock:(NSArray*) status
|
-(NSNumber*) findPetsByStatusWithCompletionBlock:(NSArray*) status
|
||||||
|
|
||||||
completionHandler: (void (^)(NSArray* output, NSError* error))completionBlock
|
completionHandler: (void (^)(NSArray* output, NSError* error))completionBlock
|
||||||
{
|
{
|
||||||
|
|
||||||
id m_body = nil;
|
|
||||||
NSMutableString* requestUrl = [NSMutableString stringWithFormat:@"%@/pet/findByStatus", basePath];
|
NSMutableString* requestUrl = [NSMutableString stringWithFormat:@"%@/pet/findByStatus", basePath];
|
||||||
|
|
||||||
// remove format in URL if needed
|
// remove format in URL if needed
|
||||||
@ -243,6 +248,7 @@ static NSString * basePath = @"http://petstore.swagger.wordnik.com/v2";
|
|||||||
NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init];
|
NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init];
|
||||||
if(status != nil)
|
if(status != nil)
|
||||||
queryParams[@"status"] = status;
|
queryParams[@"status"] = status;
|
||||||
|
|
||||||
NSMutableDictionary* headerParams = [[NSMutableDictionary alloc] init];
|
NSMutableDictionary* headerParams = [[NSMutableDictionary alloc] init];
|
||||||
|
|
||||||
|
|
||||||
@ -253,48 +259,45 @@ static NSString * basePath = @"http://petstore.swagger.wordnik.com/v2";
|
|||||||
|
|
||||||
SWGApiClient* client = [SWGApiClient sharedClientFromPool:basePath];
|
SWGApiClient* client = [SWGApiClient sharedClientFromPool:basePath];
|
||||||
|
|
||||||
|
// array container response type
|
||||||
return [client dictionary: requestUrl
|
return [client dictionary: requestUrl
|
||||||
method: @"GET"
|
method: @"GET"
|
||||||
queryParams: queryParams
|
queryParams: queryParams
|
||||||
body: bodyDictionary
|
body: bodyDictionary
|
||||||
headerParams: headerParams
|
headerParams: headerParams
|
||||||
requestContentType: requestContentType
|
requestContentType: requestContentType
|
||||||
responseContentType: responseContentType
|
responseContentType: responseContentType
|
||||||
completionBlock: ^(NSDictionary *data, NSError *error) {
|
completionBlock: ^(NSDictionary *data, NSError *error) {
|
||||||
if (error) {
|
if (error) {
|
||||||
completionBlock(nil, error);
|
completionBlock(nil, error);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if([data isKindOfClass:[NSArray class]]){
|
||||||
if([data isKindOfClass:[NSArray class]]){
|
NSMutableArray * objs = [[NSMutableArray alloc] initWithCapacity:[data count]];
|
||||||
NSMutableArray * objs = [[NSMutableArray alloc] initWithCapacity:[data count]];
|
for (NSDictionary* dict in (NSArray*)data) {
|
||||||
for (NSDictionary* dict in (NSArray*)data) {
|
|
||||||
|
|
||||||
|
|
||||||
SWGPet* d = [[SWGPet alloc]initWithValues: dict];
|
|
||||||
|
|
||||||
[objs addObject:d];
|
|
||||||
}
|
|
||||||
completionBlock(objs, nil);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
SWGPet* d = [[SWGPet alloc]initWithValues: dict];
|
||||||
|
|
||||||
|
[objs addObject:d];
|
||||||
|
}
|
||||||
|
completionBlock(objs, nil);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}];
|
}];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
-(NSNumber*) findPetsByTagsWithCompletionBlock:(NSArray*) tags
|
-(NSNumber*) findPetsByTagsWithCompletionBlock:(NSArray*) tags
|
||||||
|
|
||||||
completionHandler: (void (^)(NSArray* output, NSError* error))completionBlock
|
completionHandler: (void (^)(NSArray* output, NSError* error))completionBlock
|
||||||
{
|
{
|
||||||
|
|
||||||
id m_body = nil;
|
|
||||||
NSMutableString* requestUrl = [NSMutableString stringWithFormat:@"%@/pet/findByTags", basePath];
|
NSMutableString* requestUrl = [NSMutableString stringWithFormat:@"%@/pet/findByTags", basePath];
|
||||||
|
|
||||||
// remove format in URL if needed
|
// remove format in URL if needed
|
||||||
@ -309,6 +312,7 @@ static NSString * basePath = @"http://petstore.swagger.wordnik.com/v2";
|
|||||||
NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init];
|
NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init];
|
||||||
if(tags != nil)
|
if(tags != nil)
|
||||||
queryParams[@"tags"] = tags;
|
queryParams[@"tags"] = tags;
|
||||||
|
|
||||||
NSMutableDictionary* headerParams = [[NSMutableDictionary alloc] init];
|
NSMutableDictionary* headerParams = [[NSMutableDictionary alloc] init];
|
||||||
|
|
||||||
|
|
||||||
@ -319,48 +323,45 @@ static NSString * basePath = @"http://petstore.swagger.wordnik.com/v2";
|
|||||||
|
|
||||||
SWGApiClient* client = [SWGApiClient sharedClientFromPool:basePath];
|
SWGApiClient* client = [SWGApiClient sharedClientFromPool:basePath];
|
||||||
|
|
||||||
|
// array container response type
|
||||||
return [client dictionary: requestUrl
|
return [client dictionary: requestUrl
|
||||||
method: @"GET"
|
method: @"GET"
|
||||||
queryParams: queryParams
|
queryParams: queryParams
|
||||||
body: bodyDictionary
|
body: bodyDictionary
|
||||||
headerParams: headerParams
|
headerParams: headerParams
|
||||||
requestContentType: requestContentType
|
requestContentType: requestContentType
|
||||||
responseContentType: responseContentType
|
responseContentType: responseContentType
|
||||||
completionBlock: ^(NSDictionary *data, NSError *error) {
|
completionBlock: ^(NSDictionary *data, NSError *error) {
|
||||||
if (error) {
|
if (error) {
|
||||||
completionBlock(nil, error);
|
completionBlock(nil, error);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if([data isKindOfClass:[NSArray class]]){
|
||||||
if([data isKindOfClass:[NSArray class]]){
|
NSMutableArray * objs = [[NSMutableArray alloc] initWithCapacity:[data count]];
|
||||||
NSMutableArray * objs = [[NSMutableArray alloc] initWithCapacity:[data count]];
|
for (NSDictionary* dict in (NSArray*)data) {
|
||||||
for (NSDictionary* dict in (NSArray*)data) {
|
|
||||||
|
|
||||||
|
|
||||||
SWGPet* d = [[SWGPet alloc]initWithValues: dict];
|
|
||||||
|
|
||||||
[objs addObject:d];
|
|
||||||
}
|
|
||||||
completionBlock(objs, nil);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
SWGPet* d = [[SWGPet alloc]initWithValues: dict];
|
||||||
|
|
||||||
|
[objs addObject:d];
|
||||||
|
}
|
||||||
|
completionBlock(objs, nil);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}];
|
}];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
-(NSNumber*) getPetByIdWithCompletionBlock:(NSNumber*) petId
|
-(NSNumber*) getPetByIdWithCompletionBlock:(NSNumber*) petId
|
||||||
|
|
||||||
completionHandler: (void (^)(SWGPet* output, NSError* error))completionBlock
|
completionHandler: (void (^)(SWGPet* output, NSError* error))completionBlock
|
||||||
{
|
{
|
||||||
|
|
||||||
id m_body = nil;
|
|
||||||
NSMutableString* requestUrl = [NSMutableString stringWithFormat:@"%@/pet/{petId}", basePath];
|
NSMutableString* requestUrl = [NSMutableString stringWithFormat:@"%@/pet/{petId}", basePath];
|
||||||
|
|
||||||
// remove format in URL if needed
|
// remove format in URL if needed
|
||||||
@ -386,42 +387,42 @@ static NSString * basePath = @"http://petstore.swagger.wordnik.com/v2";
|
|||||||
SWGApiClient* client = [SWGApiClient sharedClientFromPool:basePath];
|
SWGApiClient* client = [SWGApiClient sharedClientFromPool:basePath];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// comples response type
|
||||||
return [client dictionary:requestUrl
|
return [client dictionary:requestUrl
|
||||||
method:@"GET"
|
method:@"GET"
|
||||||
queryParams:queryParams
|
queryParams:queryParams
|
||||||
body:bodyDictionary
|
body:bodyDictionary
|
||||||
headerParams:headerParams
|
headerParams:headerParams
|
||||||
requestContentType:requestContentType
|
requestContentType:requestContentType
|
||||||
responseContentType:responseContentType
|
responseContentType:responseContentType
|
||||||
completionBlock:^(NSDictionary *data, NSError *error) {
|
completionBlock:^(NSDictionary *data, NSError *error) {
|
||||||
if (error) {
|
if (error) {
|
||||||
completionBlock(nil, error);
|
completionBlock(nil, error);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
SWGPet *result = nil;
|
SWGPet *result = nil;
|
||||||
if (data) {
|
if (data) {
|
||||||
result = [[SWGPet alloc]initWithValues: data];
|
result = [[SWGPet alloc]initWithValues: data];
|
||||||
}
|
}
|
||||||
completionBlock(result , nil);
|
completionBlock(result , nil);
|
||||||
|
|
||||||
}];
|
}];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
-(NSNumber*) updatePetWithFormWithCompletionBlock:(NSString*) petId
|
-(NSNumber*) updatePetWithFormWithCompletionBlock:(NSString*) petId
|
||||||
name:(NSString*) name
|
name:(NSString*) name
|
||||||
status:(NSString*) status
|
status:(NSString*) status
|
||||||
|
|
||||||
|
|
||||||
completionHandler: (void (^)(NSError* error))completionBlock {
|
completionHandler: (void (^)(NSError* error))completionBlock {
|
||||||
|
|
||||||
id m_body = nil;
|
|
||||||
NSMutableString* requestUrl = [NSMutableString stringWithFormat:@"%@/pet/{petId}", basePath];
|
NSMutableString* requestUrl = [NSMutableString stringWithFormat:@"%@/pet/{petId}", basePath];
|
||||||
|
|
||||||
// remove format in URL if needed
|
// remove format in URL if needed
|
||||||
@ -447,11 +448,11 @@ static NSString * basePath = @"http://petstore.swagger.wordnik.com/v2";
|
|||||||
SWGApiClient* client = [SWGApiClient sharedClientFromPool:basePath];
|
SWGApiClient* client = [SWGApiClient sharedClientFromPool:basePath];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// primitive response type
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// no return base type
|
||||||
return [client stringWithCompletionBlock:requestUrl
|
return [client stringWithCompletionBlock:requestUrl
|
||||||
method:@"POST"
|
method:@"POST"
|
||||||
queryParams:queryParams
|
queryParams:queryParams
|
||||||
@ -468,15 +469,16 @@ static NSString * basePath = @"http://petstore.swagger.wordnik.com/v2";
|
|||||||
}];
|
}];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
-(NSNumber*) deletePetWithCompletionBlock:(NSString*) api_key
|
-(NSNumber*) deletePetWithCompletionBlock:(NSString*) api_key
|
||||||
petId:(NSNumber*) petId
|
petId:(NSNumber*) petId
|
||||||
|
|
||||||
|
|
||||||
completionHandler: (void (^)(NSError* error))completionBlock {
|
completionHandler: (void (^)(NSError* error))completionBlock {
|
||||||
|
|
||||||
id m_body = nil;
|
|
||||||
NSMutableString* requestUrl = [NSMutableString stringWithFormat:@"%@/pet/{petId}", basePath];
|
NSMutableString* requestUrl = [NSMutableString stringWithFormat:@"%@/pet/{petId}", basePath];
|
||||||
|
|
||||||
// remove format in URL if needed
|
// remove format in URL if needed
|
||||||
@ -494,6 +496,7 @@ static NSString * basePath = @"http://petstore.swagger.wordnik.com/v2";
|
|||||||
NSMutableDictionary* headerParams = [[NSMutableDictionary alloc] init];
|
NSMutableDictionary* headerParams = [[NSMutableDictionary alloc] init];
|
||||||
if(api_key != nil)
|
if(api_key != nil)
|
||||||
headerParams[@"api_key"] = api_key;
|
headerParams[@"api_key"] = api_key;
|
||||||
|
|
||||||
|
|
||||||
id bodyDictionary = nil;
|
id bodyDictionary = nil;
|
||||||
|
|
||||||
@ -503,11 +506,11 @@ static NSString * basePath = @"http://petstore.swagger.wordnik.com/v2";
|
|||||||
SWGApiClient* client = [SWGApiClient sharedClientFromPool:basePath];
|
SWGApiClient* client = [SWGApiClient sharedClientFromPool:basePath];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// primitive response type
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// no return base type
|
||||||
return [client stringWithCompletionBlock:requestUrl
|
return [client stringWithCompletionBlock:requestUrl
|
||||||
method:@"DELETE"
|
method:@"DELETE"
|
||||||
queryParams:queryParams
|
queryParams:queryParams
|
||||||
@ -524,7 +527,62 @@ 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 <Foundation/Foundation.h>
|
||||||
#import "SWGOrder.h"
|
#import "SWGOrder.h"
|
||||||
|
#import "SWGObject.h"
|
||||||
|
|
||||||
|
|
||||||
@interface SWGStoreApi: NSObject
|
@interface SWGStoreApi: NSObject
|
||||||
@ -13,33 +14,58 @@
|
|||||||
|
|
||||||
Place an order for a pet
|
Place an order for a pet
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@param body order placed for purchasing the 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;
|
completionHandler: (void (^)(SWGOrder* output, NSError* error))completionBlock;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
||||||
Find purchase order by ID
|
Find purchase order by ID
|
||||||
|
|
||||||
For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions
|
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
|
@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;
|
completionHandler: (void (^)(SWGOrder* output, NSError* error))completionBlock;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
||||||
Delete purchase order by ID
|
Delete purchase order by ID
|
||||||
|
|
||||||
For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors
|
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
|
@param orderId ID of the order that needs to be deleted
|
||||||
|
|
||||||
*/
|
|
||||||
-(NSNumber*) deleteOrderWithCompletionBlock : (NSString*) orderId
|
|
||||||
|
|
||||||
|
return type:
|
||||||
|
*/
|
||||||
|
-(NSNumber*) deleteOrderWithCompletionBlock :(NSString*) orderId
|
||||||
|
|
||||||
|
|
||||||
completionHandler: (void (^)(NSError* error))completionBlock;
|
completionHandler: (void (^)(NSError* error))completionBlock;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@end
|
@end
|
@ -50,11 +50,11 @@ static NSString * basePath = @"http://petstore.swagger.wordnik.com/v2";
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
-(NSNumber*) placeOrderWithCompletionBlock:(SWGOrder*) body
|
-(NSNumber*) placeOrderWithCompletionBlock:(SWGOrder*) body
|
||||||
|
|
||||||
completionHandler: (void (^)(SWGOrder* output, NSError* error))completionBlock
|
completionHandler: (void (^)(SWGOrder* output, NSError* error))completionBlock
|
||||||
{
|
{
|
||||||
|
|
||||||
id m_body = body;
|
|
||||||
NSMutableString* requestUrl = [NSMutableString stringWithFormat:@"%@/store/order", basePath];
|
NSMutableString* requestUrl = [NSMutableString stringWithFormat:@"%@/store/order", basePath];
|
||||||
|
|
||||||
// remove format in URL if needed
|
// remove format in URL if needed
|
||||||
@ -73,9 +73,11 @@ static NSString * basePath = @"http://petstore.swagger.wordnik.com/v2";
|
|||||||
|
|
||||||
id bodyDictionary = nil;
|
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];
|
NSMutableArray * objs = [[NSMutableArray alloc] init];
|
||||||
for (id dict in (NSArray*)m_body) {
|
for (id dict in (NSArray*)__body) {
|
||||||
if([dict respondsToSelector:@selector(asDictionary)]) {
|
if([dict respondsToSelector:@selector(asDictionary)]) {
|
||||||
[objs addObject:[(SWGObject*)dict asDictionary]];
|
[objs addObject:[(SWGObject*)dict asDictionary]];
|
||||||
}
|
}
|
||||||
@ -85,27 +87,26 @@ static NSString * basePath = @"http://petstore.swagger.wordnik.com/v2";
|
|||||||
}
|
}
|
||||||
bodyDictionary = objs;
|
bodyDictionary = objs;
|
||||||
}
|
}
|
||||||
else if([m_body respondsToSelector:@selector(asDictionary)]) {
|
else if([__body respondsToSelector:@selector(asDictionary)]) {
|
||||||
bodyDictionary = [(SWGObject*)m_body asDictionary];
|
bodyDictionary = [(SWGObject*)__body asDictionary];
|
||||||
}
|
}
|
||||||
else if([m_body isKindOfClass:[NSString class]]) {
|
else if([__body isKindOfClass:[NSString class]]) {
|
||||||
// convert it to a dictionary
|
// convert it to a dictionary
|
||||||
NSError * error;
|
NSError * error;
|
||||||
NSString * str = (NSString*)m_body;
|
NSString * str = (NSString*)__body;
|
||||||
NSDictionary *JSON =
|
NSDictionary *JSON =
|
||||||
[NSJSONSerialization JSONObjectWithData:[str dataUsingEncoding:NSUTF8StringEncoding]
|
[NSJSONSerialization JSONObjectWithData:[str dataUsingEncoding:NSUTF8StringEncoding]
|
||||||
options:NSJSONReadingMutableContainers
|
options:NSJSONReadingMutableContainers
|
||||||
error:&error];
|
error:&error];
|
||||||
bodyDictionary = JSON;
|
bodyDictionary = JSON;
|
||||||
}
|
}
|
||||||
else if([m_body isKindOfClass: [SWGFile class]]) {
|
else if([__body isKindOfClass: [SWGFile class]]) {
|
||||||
requestContentType = @"form-data";
|
requestContentType = @"form-data";
|
||||||
bodyDictionary = m_body;
|
bodyDictionary = __body;
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
NSLog(@"don't know what to do with %@", m_body);
|
NSLog(@"don't know what to do with %@", __body);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -113,40 +114,40 @@ static NSString * basePath = @"http://petstore.swagger.wordnik.com/v2";
|
|||||||
SWGApiClient* client = [SWGApiClient sharedClientFromPool:basePath];
|
SWGApiClient* client = [SWGApiClient sharedClientFromPool:basePath];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// comples response type
|
||||||
return [client dictionary:requestUrl
|
return [client dictionary:requestUrl
|
||||||
method:@"POST"
|
method:@"POST"
|
||||||
queryParams:queryParams
|
queryParams:queryParams
|
||||||
body:bodyDictionary
|
body:bodyDictionary
|
||||||
headerParams:headerParams
|
headerParams:headerParams
|
||||||
requestContentType:requestContentType
|
requestContentType:requestContentType
|
||||||
responseContentType:responseContentType
|
responseContentType:responseContentType
|
||||||
completionBlock:^(NSDictionary *data, NSError *error) {
|
completionBlock:^(NSDictionary *data, NSError *error) {
|
||||||
if (error) {
|
if (error) {
|
||||||
completionBlock(nil, error);
|
completionBlock(nil, error);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
SWGOrder *result = nil;
|
SWGOrder *result = nil;
|
||||||
if (data) {
|
if (data) {
|
||||||
result = [[SWGOrder alloc]initWithValues: data];
|
result = [[SWGOrder alloc]initWithValues: data];
|
||||||
}
|
}
|
||||||
completionBlock(result , nil);
|
completionBlock(result , nil);
|
||||||
|
|
||||||
}];
|
}];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
-(NSNumber*) getOrderByIdWithCompletionBlock:(NSString*) orderId
|
-(NSNumber*) getOrderByIdWithCompletionBlock:(NSString*) orderId
|
||||||
|
|
||||||
completionHandler: (void (^)(SWGOrder* output, NSError* error))completionBlock
|
completionHandler: (void (^)(SWGOrder* output, NSError* error))completionBlock
|
||||||
{
|
{
|
||||||
|
|
||||||
id m_body = nil;
|
|
||||||
NSMutableString* requestUrl = [NSMutableString stringWithFormat:@"%@/store/order/{orderId}", basePath];
|
NSMutableString* requestUrl = [NSMutableString stringWithFormat:@"%@/store/order/{orderId}", basePath];
|
||||||
|
|
||||||
// remove format in URL if needed
|
// remove format in URL if needed
|
||||||
@ -172,40 +173,40 @@ static NSString * basePath = @"http://petstore.swagger.wordnik.com/v2";
|
|||||||
SWGApiClient* client = [SWGApiClient sharedClientFromPool:basePath];
|
SWGApiClient* client = [SWGApiClient sharedClientFromPool:basePath];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// comples response type
|
||||||
return [client dictionary:requestUrl
|
return [client dictionary:requestUrl
|
||||||
method:@"GET"
|
method:@"GET"
|
||||||
queryParams:queryParams
|
queryParams:queryParams
|
||||||
body:bodyDictionary
|
body:bodyDictionary
|
||||||
headerParams:headerParams
|
headerParams:headerParams
|
||||||
requestContentType:requestContentType
|
requestContentType:requestContentType
|
||||||
responseContentType:responseContentType
|
responseContentType:responseContentType
|
||||||
completionBlock:^(NSDictionary *data, NSError *error) {
|
completionBlock:^(NSDictionary *data, NSError *error) {
|
||||||
if (error) {
|
if (error) {
|
||||||
completionBlock(nil, error);
|
completionBlock(nil, error);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
SWGOrder *result = nil;
|
SWGOrder *result = nil;
|
||||||
if (data) {
|
if (data) {
|
||||||
result = [[SWGOrder alloc]initWithValues: data];
|
result = [[SWGOrder alloc]initWithValues: data];
|
||||||
}
|
}
|
||||||
completionBlock(result , nil);
|
completionBlock(result , nil);
|
||||||
|
|
||||||
}];
|
}];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
-(NSNumber*) deleteOrderWithCompletionBlock:(NSString*) orderId
|
-(NSNumber*) deleteOrderWithCompletionBlock:(NSString*) orderId
|
||||||
|
|
||||||
|
|
||||||
completionHandler: (void (^)(NSError* error))completionBlock {
|
completionHandler: (void (^)(NSError* error))completionBlock {
|
||||||
|
|
||||||
id m_body = nil;
|
|
||||||
NSMutableString* requestUrl = [NSMutableString stringWithFormat:@"%@/store/order/{orderId}", basePath];
|
NSMutableString* requestUrl = [NSMutableString stringWithFormat:@"%@/store/order/{orderId}", basePath];
|
||||||
|
|
||||||
// remove format in URL if needed
|
// remove format in URL if needed
|
||||||
@ -231,11 +232,11 @@ static NSString * basePath = @"http://petstore.swagger.wordnik.com/v2";
|
|||||||
SWGApiClient* client = [SWGApiClient sharedClientFromPool:basePath];
|
SWGApiClient* client = [SWGApiClient sharedClientFromPool:basePath];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// primitive response type
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// no return base type
|
||||||
return [client stringWithCompletionBlock:requestUrl
|
return [client stringWithCompletionBlock:requestUrl
|
||||||
method:@"DELETE"
|
method:@"DELETE"
|
||||||
queryParams:queryParams
|
queryParams:queryParams
|
||||||
@ -252,7 +253,8 @@ static NSString * basePath = @"http://petstore.swagger.wordnik.com/v2";
|
|||||||
}];
|
}];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -6,10 +6,10 @@
|
|||||||
|
|
||||||
@property(nonatomic) NSNumber* _id;
|
@property(nonatomic) NSNumber* _id;
|
||||||
@property(nonatomic) NSString* name;
|
@property(nonatomic) NSString* name;
|
||||||
- (id) _id: (NSNumber*) _id
|
- (id) _id: (NSNumber*) _id
|
||||||
|
name: (NSString*) name;
|
||||||
name: (NSString*) name;
|
|
||||||
|
|
||||||
- (id) initWithValues: (NSDictionary*)dict;
|
- (id) initWithValues: (NSDictionary*)dict;
|
||||||
- (NSDictionary*) asDictionary;
|
- (NSDictionary*) asDictionary;
|
||||||
|
|
||||||
|
@ -4,20 +4,25 @@
|
|||||||
@implementation SWGTag
|
@implementation SWGTag
|
||||||
|
|
||||||
-(id)_id: (NSNumber*) _id
|
-(id)_id: (NSNumber*) _id
|
||||||
name: (NSString*) name {
|
name: (NSString*) name
|
||||||
|
|
||||||
|
{
|
||||||
__id = _id;
|
__id = _id;
|
||||||
_name = name;
|
_name = name;
|
||||||
|
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
-(id) initWithValues:(NSDictionary*)dict
|
-(id) initWithValues:(NSDictionary*)dict
|
||||||
{
|
{
|
||||||
self = [super init];
|
self = [super init];
|
||||||
if(self) {
|
if(self) {
|
||||||
__id = dict[@"id"];
|
__id = dict[@"id"];
|
||||||
|
|
||||||
_name = dict[@"name"];
|
_name = dict[@"name"];
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
@ -26,17 +31,14 @@
|
|||||||
NSMutableDictionary* dict = [[NSMutableDictionary alloc] init];
|
NSMutableDictionary* dict = [[NSMutableDictionary alloc] init];
|
||||||
|
|
||||||
|
|
||||||
if(__id != nil)
|
if(__id != nil) dict[@"id"] = __id ;
|
||||||
dict[@"id"] = __id;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if(_name != nil)
|
|
||||||
dict[@"name"] = _name;
|
|
||||||
|
|
||||||
|
|
||||||
|
if(_name != nil) dict[@"name"] = _name ;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
NSDictionary* output = [dict copy];
|
NSDictionary* output = [dict copy];
|
||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
|
@ -12,22 +12,16 @@
|
|||||||
@property(nonatomic) NSString* password;
|
@property(nonatomic) NSString* password;
|
||||||
@property(nonatomic) NSString* phone;
|
@property(nonatomic) NSString* phone;
|
||||||
@property(nonatomic) NSNumber* userStatus; /* User Status */
|
@property(nonatomic) NSNumber* userStatus; /* User Status */
|
||||||
- (id) _id: (NSNumber*) _id
|
- (id) _id: (NSNumber*) _id
|
||||||
|
username: (NSString*) username
|
||||||
username: (NSString*) username
|
firstName: (NSString*) firstName
|
||||||
|
lastName: (NSString*) lastName
|
||||||
firstName: (NSString*) firstName
|
email: (NSString*) email
|
||||||
|
password: (NSString*) password
|
||||||
lastName: (NSString*) lastName
|
phone: (NSString*) phone
|
||||||
|
userStatus: (NSNumber*) userStatus;
|
||||||
email: (NSString*) email
|
|
||||||
|
|
||||||
password: (NSString*) password
|
|
||||||
|
|
||||||
phone: (NSString*) phone
|
|
||||||
|
|
||||||
userStatus: (NSNumber*) userStatus;
|
|
||||||
|
|
||||||
- (id) initWithValues: (NSDictionary*)dict;
|
- (id) initWithValues: (NSDictionary*)dict;
|
||||||
- (NSDictionary*) asDictionary;
|
- (NSDictionary*) asDictionary;
|
||||||
|
|
||||||
|
@ -10,8 +10,9 @@
|
|||||||
email: (NSString*) email
|
email: (NSString*) email
|
||||||
password: (NSString*) password
|
password: (NSString*) password
|
||||||
phone: (NSString*) phone
|
phone: (NSString*) phone
|
||||||
userStatus: (NSNumber*) userStatus {
|
userStatus: (NSNumber*) userStatus
|
||||||
|
|
||||||
|
{
|
||||||
__id = _id;
|
__id = _id;
|
||||||
_username = username;
|
_username = username;
|
||||||
_firstName = firstName;
|
_firstName = firstName;
|
||||||
@ -21,21 +22,31 @@
|
|||||||
_phone = phone;
|
_phone = phone;
|
||||||
_userStatus = userStatus;
|
_userStatus = userStatus;
|
||||||
|
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
-(id) initWithValues:(NSDictionary*)dict
|
-(id) initWithValues:(NSDictionary*)dict
|
||||||
{
|
{
|
||||||
self = [super init];
|
self = [super init];
|
||||||
if(self) {
|
if(self) {
|
||||||
__id = dict[@"id"];
|
__id = dict[@"id"];
|
||||||
|
|
||||||
_username = dict[@"username"];
|
_username = dict[@"username"];
|
||||||
|
|
||||||
_firstName = dict[@"firstName"];
|
_firstName = dict[@"firstName"];
|
||||||
|
|
||||||
_lastName = dict[@"lastName"];
|
_lastName = dict[@"lastName"];
|
||||||
|
|
||||||
_email = dict[@"email"];
|
_email = dict[@"email"];
|
||||||
|
|
||||||
_password = dict[@"password"];
|
_password = dict[@"password"];
|
||||||
|
|
||||||
_phone = dict[@"phone"];
|
_phone = dict[@"phone"];
|
||||||
|
|
||||||
_userStatus = dict[@"userStatus"];
|
_userStatus = dict[@"userStatus"];
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
@ -44,53 +55,38 @@
|
|||||||
NSMutableDictionary* dict = [[NSMutableDictionary alloc] init];
|
NSMutableDictionary* dict = [[NSMutableDictionary alloc] init];
|
||||||
|
|
||||||
|
|
||||||
if(__id != nil)
|
if(__id != nil) dict[@"id"] = __id ;
|
||||||
dict[@"id"] = __id;
|
|
||||||
|
|
||||||
|
|
||||||
|
if(_username != nil) dict[@"username"] = _username ;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if(_username != nil)
|
if(_firstName != nil) dict[@"firstName"] = _firstName ;
|
||||||
dict[@"username"] = _username;
|
|
||||||
|
|
||||||
|
|
||||||
|
if(_lastName != nil) dict[@"lastName"] = _lastName ;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if(_firstName != nil)
|
if(_email != nil) dict[@"email"] = _email ;
|
||||||
dict[@"firstName"] = _firstName;
|
|
||||||
|
|
||||||
|
|
||||||
|
if(_password != nil) dict[@"password"] = _password ;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if(_lastName != nil)
|
if(_phone != nil) dict[@"phone"] = _phone ;
|
||||||
dict[@"lastName"] = _lastName;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if(_email != nil)
|
|
||||||
dict[@"email"] = _email;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if(_password != nil)
|
|
||||||
dict[@"password"] = _password;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if(_phone != nil)
|
|
||||||
dict[@"phone"] = _phone;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if(_userStatus != nil)
|
|
||||||
dict[@"userStatus"] = _userStatus;
|
|
||||||
|
|
||||||
|
|
||||||
|
if(_userStatus != nil) dict[@"userStatus"] = _userStatus ;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
NSDictionary* output = [dict copy];
|
NSDictionary* output = [dict copy];
|
||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
#import <Foundation/Foundation.h>
|
#import <Foundation/Foundation.h>
|
||||||
#import "SWGUser.h"
|
#import "SWGUser.h"
|
||||||
|
#import "SWGObject.h"
|
||||||
|
|
||||||
|
|
||||||
@interface SWGUserApi: NSObject
|
@interface SWGUserApi: NSObject
|
||||||
@ -12,92 +13,157 @@
|
|||||||
/**
|
/**
|
||||||
|
|
||||||
Create user
|
Create user
|
||||||
|
|
||||||
This can only be done by the logged in user.
|
This can only be done by the logged in user.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@param body Created user object
|
@param body Created user object
|
||||||
|
|
||||||
*/
|
|
||||||
-(NSNumber*) createUserWithCompletionBlock : (SWGUser*) body
|
|
||||||
|
|
||||||
|
return type:
|
||||||
|
*/
|
||||||
|
-(NSNumber*) createUserWithCompletionBlock :(SWGUser*) body
|
||||||
|
|
||||||
|
|
||||||
completionHandler: (void (^)(NSError* error))completionBlock;
|
completionHandler: (void (^)(NSError* error))completionBlock;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
||||||
Creates list of users with given input array
|
Creates list of users with given input array
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@param body List of user object
|
@param body List of user object
|
||||||
|
|
||||||
*/
|
|
||||||
-(NSNumber*) createUsersWithArrayInputWithCompletionBlock : (NSArray*) body
|
|
||||||
|
|
||||||
|
return type:
|
||||||
|
*/
|
||||||
|
-(NSNumber*) createUsersWithArrayInputWithCompletionBlock :(NSArray*) body
|
||||||
|
|
||||||
|
|
||||||
completionHandler: (void (^)(NSError* error))completionBlock;
|
completionHandler: (void (^)(NSError* error))completionBlock;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
||||||
Creates list of users with given input array
|
Creates list of users with given input array
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@param body List of user object
|
@param body List of user object
|
||||||
|
|
||||||
*/
|
|
||||||
-(NSNumber*) createUsersWithListInputWithCompletionBlock : (NSArray*) body
|
|
||||||
|
|
||||||
|
return type:
|
||||||
|
*/
|
||||||
|
-(NSNumber*) createUsersWithListInputWithCompletionBlock :(NSArray*) body
|
||||||
|
|
||||||
|
|
||||||
completionHandler: (void (^)(NSError* error))completionBlock;
|
completionHandler: (void (^)(NSError* error))completionBlock;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
||||||
Logs user into the system
|
Logs user into the system
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@param username The user name for login
|
@param username The user name for login
|
||||||
|
|
||||||
@param password The password for login in clear text
|
@param password The password for login in clear text
|
||||||
|
|
||||||
|
|
||||||
|
return type: NSString*
|
||||||
*/
|
*/
|
||||||
-(NSNumber*) loginUserWithCompletionBlock : (NSString*) username
|
-(NSNumber*) loginUserWithCompletionBlock :(NSString*) username
|
||||||
password: (NSString*) password
|
password:(NSString*) password
|
||||||
|
|
||||||
completionHandler: (void (^)(NSString* output, NSError* error))completionBlock;
|
completionHandler: (void (^)(NSString* output, NSError* error))completionBlock;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
||||||
Logs out current logged in user session
|
Logs out current logged in user session
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
return type:
|
||||||
*/
|
*/
|
||||||
-(NSNumber*) logoutUserWithCompletionBlock :
|
-(NSNumber*) logoutUserWithCompletionBlock :
|
||||||
|
|
||||||
|
(void (^)(NSError* error))completionBlock;
|
||||||
|
|
||||||
|
|
||||||
(void (^)(NSError* error))completionBlock;
|
|
||||||
/**
|
/**
|
||||||
|
|
||||||
Get user by user name
|
Get user by user name
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@param username The name that needs to be fetched. Use user1 for testing.
|
@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;
|
completionHandler: (void (^)(SWGUser* output, NSError* error))completionBlock;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
||||||
Updated user
|
Updated user
|
||||||
|
|
||||||
This can only be done by the logged in user.
|
This can only be done by the logged in user.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@param username name that need to be deleted
|
@param username name that need to be deleted
|
||||||
|
|
||||||
@param body Updated user object
|
@param body Updated user object
|
||||||
|
|
||||||
*/
|
|
||||||
-(NSNumber*) updateUserWithCompletionBlock : (NSString*) username
|
|
||||||
body: (SWGUser*) body
|
|
||||||
|
|
||||||
|
return type:
|
||||||
|
*/
|
||||||
|
-(NSNumber*) updateUserWithCompletionBlock :(NSString*) username
|
||||||
|
body:(SWGUser*) body
|
||||||
|
|
||||||
|
|
||||||
completionHandler: (void (^)(NSError* error))completionBlock;
|
completionHandler: (void (^)(NSError* error))completionBlock;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
||||||
Delete user
|
Delete user
|
||||||
|
|
||||||
This can only be done by the logged in user.
|
This can only be done by the logged in user.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@param username The name that needs to be deleted
|
@param username The name that needs to be deleted
|
||||||
|
|
||||||
*/
|
|
||||||
-(NSNumber*) deleteUserWithCompletionBlock : (NSString*) username
|
|
||||||
|
|
||||||
|
return type:
|
||||||
|
*/
|
||||||
|
-(NSNumber*) deleteUserWithCompletionBlock :(NSString*) username
|
||||||
|
|
||||||
|
|
||||||
completionHandler: (void (^)(NSError* error))completionBlock;
|
completionHandler: (void (^)(NSError* error))completionBlock;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@end
|
@end
|
@ -50,11 +50,11 @@ static NSString * basePath = @"http://petstore.swagger.wordnik.com/v2";
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
-(NSNumber*) createUserWithCompletionBlock:(SWGUser*) body
|
-(NSNumber*) createUserWithCompletionBlock:(SWGUser*) body
|
||||||
|
|
||||||
|
|
||||||
completionHandler: (void (^)(NSError* error))completionBlock {
|
completionHandler: (void (^)(NSError* error))completionBlock {
|
||||||
|
|
||||||
id m_body = body;
|
|
||||||
NSMutableString* requestUrl = [NSMutableString stringWithFormat:@"%@/user", basePath];
|
NSMutableString* requestUrl = [NSMutableString stringWithFormat:@"%@/user", basePath];
|
||||||
|
|
||||||
// remove format in URL if needed
|
// remove format in URL if needed
|
||||||
@ -73,9 +73,11 @@ static NSString * basePath = @"http://petstore.swagger.wordnik.com/v2";
|
|||||||
|
|
||||||
id bodyDictionary = nil;
|
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];
|
NSMutableArray * objs = [[NSMutableArray alloc] init];
|
||||||
for (id dict in (NSArray*)m_body) {
|
for (id dict in (NSArray*)__body) {
|
||||||
if([dict respondsToSelector:@selector(asDictionary)]) {
|
if([dict respondsToSelector:@selector(asDictionary)]) {
|
||||||
[objs addObject:[(SWGObject*)dict asDictionary]];
|
[objs addObject:[(SWGObject*)dict asDictionary]];
|
||||||
}
|
}
|
||||||
@ -85,27 +87,26 @@ static NSString * basePath = @"http://petstore.swagger.wordnik.com/v2";
|
|||||||
}
|
}
|
||||||
bodyDictionary = objs;
|
bodyDictionary = objs;
|
||||||
}
|
}
|
||||||
else if([m_body respondsToSelector:@selector(asDictionary)]) {
|
else if([__body respondsToSelector:@selector(asDictionary)]) {
|
||||||
bodyDictionary = [(SWGObject*)m_body asDictionary];
|
bodyDictionary = [(SWGObject*)__body asDictionary];
|
||||||
}
|
}
|
||||||
else if([m_body isKindOfClass:[NSString class]]) {
|
else if([__body isKindOfClass:[NSString class]]) {
|
||||||
// convert it to a dictionary
|
// convert it to a dictionary
|
||||||
NSError * error;
|
NSError * error;
|
||||||
NSString * str = (NSString*)m_body;
|
NSString * str = (NSString*)__body;
|
||||||
NSDictionary *JSON =
|
NSDictionary *JSON =
|
||||||
[NSJSONSerialization JSONObjectWithData:[str dataUsingEncoding:NSUTF8StringEncoding]
|
[NSJSONSerialization JSONObjectWithData:[str dataUsingEncoding:NSUTF8StringEncoding]
|
||||||
options:NSJSONReadingMutableContainers
|
options:NSJSONReadingMutableContainers
|
||||||
error:&error];
|
error:&error];
|
||||||
bodyDictionary = JSON;
|
bodyDictionary = JSON;
|
||||||
}
|
}
|
||||||
else if([m_body isKindOfClass: [SWGFile class]]) {
|
else if([__body isKindOfClass: [SWGFile class]]) {
|
||||||
requestContentType = @"form-data";
|
requestContentType = @"form-data";
|
||||||
bodyDictionary = m_body;
|
bodyDictionary = __body;
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
NSLog(@"don't know what to do with %@", m_body);
|
NSLog(@"don't know what to do with %@", __body);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -113,11 +114,11 @@ static NSString * basePath = @"http://petstore.swagger.wordnik.com/v2";
|
|||||||
SWGApiClient* client = [SWGApiClient sharedClientFromPool:basePath];
|
SWGApiClient* client = [SWGApiClient sharedClientFromPool:basePath];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// primitive response type
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// no return base type
|
||||||
return [client stringWithCompletionBlock:requestUrl
|
return [client stringWithCompletionBlock:requestUrl
|
||||||
method:@"POST"
|
method:@"POST"
|
||||||
queryParams:queryParams
|
queryParams:queryParams
|
||||||
@ -134,14 +135,15 @@ static NSString * basePath = @"http://petstore.swagger.wordnik.com/v2";
|
|||||||
}];
|
}];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
-(NSNumber*) createUsersWithArrayInputWithCompletionBlock:(NSArray*) body
|
-(NSNumber*) createUsersWithArrayInputWithCompletionBlock:(NSArray*) body
|
||||||
|
|
||||||
|
|
||||||
completionHandler: (void (^)(NSError* error))completionBlock {
|
completionHandler: (void (^)(NSError* error))completionBlock {
|
||||||
|
|
||||||
id m_body = body;
|
|
||||||
NSMutableString* requestUrl = [NSMutableString stringWithFormat:@"%@/user/createWithArray", basePath];
|
NSMutableString* requestUrl = [NSMutableString stringWithFormat:@"%@/user/createWithArray", basePath];
|
||||||
|
|
||||||
// remove format in URL if needed
|
// remove format in URL if needed
|
||||||
@ -160,9 +162,11 @@ static NSString * basePath = @"http://petstore.swagger.wordnik.com/v2";
|
|||||||
|
|
||||||
id bodyDictionary = nil;
|
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];
|
NSMutableArray * objs = [[NSMutableArray alloc] init];
|
||||||
for (id dict in (NSArray*)m_body) {
|
for (id dict in (NSArray*)__body) {
|
||||||
if([dict respondsToSelector:@selector(asDictionary)]) {
|
if([dict respondsToSelector:@selector(asDictionary)]) {
|
||||||
[objs addObject:[(SWGObject*)dict asDictionary]];
|
[objs addObject:[(SWGObject*)dict asDictionary]];
|
||||||
}
|
}
|
||||||
@ -172,27 +176,26 @@ static NSString * basePath = @"http://petstore.swagger.wordnik.com/v2";
|
|||||||
}
|
}
|
||||||
bodyDictionary = objs;
|
bodyDictionary = objs;
|
||||||
}
|
}
|
||||||
else if([m_body respondsToSelector:@selector(asDictionary)]) {
|
else if([__body respondsToSelector:@selector(asDictionary)]) {
|
||||||
bodyDictionary = [(SWGObject*)m_body asDictionary];
|
bodyDictionary = [(SWGObject*)__body asDictionary];
|
||||||
}
|
}
|
||||||
else if([m_body isKindOfClass:[NSString class]]) {
|
else if([__body isKindOfClass:[NSString class]]) {
|
||||||
// convert it to a dictionary
|
// convert it to a dictionary
|
||||||
NSError * error;
|
NSError * error;
|
||||||
NSString * str = (NSString*)m_body;
|
NSString * str = (NSString*)__body;
|
||||||
NSDictionary *JSON =
|
NSDictionary *JSON =
|
||||||
[NSJSONSerialization JSONObjectWithData:[str dataUsingEncoding:NSUTF8StringEncoding]
|
[NSJSONSerialization JSONObjectWithData:[str dataUsingEncoding:NSUTF8StringEncoding]
|
||||||
options:NSJSONReadingMutableContainers
|
options:NSJSONReadingMutableContainers
|
||||||
error:&error];
|
error:&error];
|
||||||
bodyDictionary = JSON;
|
bodyDictionary = JSON;
|
||||||
}
|
}
|
||||||
else if([m_body isKindOfClass: [SWGFile class]]) {
|
else if([__body isKindOfClass: [SWGFile class]]) {
|
||||||
requestContentType = @"form-data";
|
requestContentType = @"form-data";
|
||||||
bodyDictionary = m_body;
|
bodyDictionary = __body;
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
NSLog(@"don't know what to do with %@", m_body);
|
NSLog(@"don't know what to do with %@", __body);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -200,11 +203,11 @@ static NSString * basePath = @"http://petstore.swagger.wordnik.com/v2";
|
|||||||
SWGApiClient* client = [SWGApiClient sharedClientFromPool:basePath];
|
SWGApiClient* client = [SWGApiClient sharedClientFromPool:basePath];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// primitive response type
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// no return base type
|
||||||
return [client stringWithCompletionBlock:requestUrl
|
return [client stringWithCompletionBlock:requestUrl
|
||||||
method:@"POST"
|
method:@"POST"
|
||||||
queryParams:queryParams
|
queryParams:queryParams
|
||||||
@ -221,14 +224,15 @@ static NSString * basePath = @"http://petstore.swagger.wordnik.com/v2";
|
|||||||
}];
|
}];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
-(NSNumber*) createUsersWithListInputWithCompletionBlock:(NSArray*) body
|
-(NSNumber*) createUsersWithListInputWithCompletionBlock:(NSArray*) body
|
||||||
|
|
||||||
|
|
||||||
completionHandler: (void (^)(NSError* error))completionBlock {
|
completionHandler: (void (^)(NSError* error))completionBlock {
|
||||||
|
|
||||||
id m_body = body;
|
|
||||||
NSMutableString* requestUrl = [NSMutableString stringWithFormat:@"%@/user/createWithList", basePath];
|
NSMutableString* requestUrl = [NSMutableString stringWithFormat:@"%@/user/createWithList", basePath];
|
||||||
|
|
||||||
// remove format in URL if needed
|
// remove format in URL if needed
|
||||||
@ -247,9 +251,11 @@ static NSString * basePath = @"http://petstore.swagger.wordnik.com/v2";
|
|||||||
|
|
||||||
id bodyDictionary = nil;
|
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];
|
NSMutableArray * objs = [[NSMutableArray alloc] init];
|
||||||
for (id dict in (NSArray*)m_body) {
|
for (id dict in (NSArray*)__body) {
|
||||||
if([dict respondsToSelector:@selector(asDictionary)]) {
|
if([dict respondsToSelector:@selector(asDictionary)]) {
|
||||||
[objs addObject:[(SWGObject*)dict asDictionary]];
|
[objs addObject:[(SWGObject*)dict asDictionary]];
|
||||||
}
|
}
|
||||||
@ -259,27 +265,26 @@ static NSString * basePath = @"http://petstore.swagger.wordnik.com/v2";
|
|||||||
}
|
}
|
||||||
bodyDictionary = objs;
|
bodyDictionary = objs;
|
||||||
}
|
}
|
||||||
else if([m_body respondsToSelector:@selector(asDictionary)]) {
|
else if([__body respondsToSelector:@selector(asDictionary)]) {
|
||||||
bodyDictionary = [(SWGObject*)m_body asDictionary];
|
bodyDictionary = [(SWGObject*)__body asDictionary];
|
||||||
}
|
}
|
||||||
else if([m_body isKindOfClass:[NSString class]]) {
|
else if([__body isKindOfClass:[NSString class]]) {
|
||||||
// convert it to a dictionary
|
// convert it to a dictionary
|
||||||
NSError * error;
|
NSError * error;
|
||||||
NSString * str = (NSString*)m_body;
|
NSString * str = (NSString*)__body;
|
||||||
NSDictionary *JSON =
|
NSDictionary *JSON =
|
||||||
[NSJSONSerialization JSONObjectWithData:[str dataUsingEncoding:NSUTF8StringEncoding]
|
[NSJSONSerialization JSONObjectWithData:[str dataUsingEncoding:NSUTF8StringEncoding]
|
||||||
options:NSJSONReadingMutableContainers
|
options:NSJSONReadingMutableContainers
|
||||||
error:&error];
|
error:&error];
|
||||||
bodyDictionary = JSON;
|
bodyDictionary = JSON;
|
||||||
}
|
}
|
||||||
else if([m_body isKindOfClass: [SWGFile class]]) {
|
else if([__body isKindOfClass: [SWGFile class]]) {
|
||||||
requestContentType = @"form-data";
|
requestContentType = @"form-data";
|
||||||
bodyDictionary = m_body;
|
bodyDictionary = __body;
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
NSLog(@"don't know what to do with %@", m_body);
|
NSLog(@"don't know what to do with %@", __body);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -287,11 +292,11 @@ static NSString * basePath = @"http://petstore.swagger.wordnik.com/v2";
|
|||||||
SWGApiClient* client = [SWGApiClient sharedClientFromPool:basePath];
|
SWGApiClient* client = [SWGApiClient sharedClientFromPool:basePath];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// primitive response type
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// no return base type
|
||||||
return [client stringWithCompletionBlock:requestUrl
|
return [client stringWithCompletionBlock:requestUrl
|
||||||
method:@"POST"
|
method:@"POST"
|
||||||
queryParams:queryParams
|
queryParams:queryParams
|
||||||
@ -308,15 +313,16 @@ static NSString * basePath = @"http://petstore.swagger.wordnik.com/v2";
|
|||||||
}];
|
}];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
-(NSNumber*) loginUserWithCompletionBlock:(NSString*) username
|
-(NSNumber*) loginUserWithCompletionBlock:(NSString*) username
|
||||||
password:(NSString*) password
|
password:(NSString*) password
|
||||||
|
|
||||||
completionHandler: (void (^)(NSString* output, NSError* error))completionBlock
|
completionHandler: (void (^)(NSString* output, NSError* error))completionBlock
|
||||||
{
|
{
|
||||||
|
|
||||||
id m_body = nil;
|
|
||||||
NSMutableString* requestUrl = [NSMutableString stringWithFormat:@"%@/user/login", basePath];
|
NSMutableString* requestUrl = [NSMutableString stringWithFormat:@"%@/user/login", basePath];
|
||||||
|
|
||||||
// remove format in URL if needed
|
// remove format in URL if needed
|
||||||
@ -330,8 +336,10 @@ static NSString * basePath = @"http://petstore.swagger.wordnik.com/v2";
|
|||||||
|
|
||||||
NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init];
|
NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init];
|
||||||
if(username != nil)
|
if(username != nil)
|
||||||
queryParams[@"username"] = username;if(password != nil)
|
queryParams[@"username"] = username;
|
||||||
|
if(password != nil)
|
||||||
queryParams[@"password"] = password;
|
queryParams[@"password"] = password;
|
||||||
|
|
||||||
NSMutableDictionary* headerParams = [[NSMutableDictionary alloc] init];
|
NSMutableDictionary* headerParams = [[NSMutableDictionary alloc] init];
|
||||||
|
|
||||||
|
|
||||||
@ -343,35 +351,34 @@ static NSString * basePath = @"http://petstore.swagger.wordnik.com/v2";
|
|||||||
SWGApiClient* client = [SWGApiClient sharedClientFromPool:basePath];
|
SWGApiClient* client = [SWGApiClient sharedClientFromPool:basePath];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// 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);
|
|
||||||
}];
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
-(NSNumber*) logoutUserWithCompletionBlock:
|
-(NSNumber*) logoutUserWithCompletionBlock:
|
||||||
|
|
||||||
(void (^)(NSError* error))completionBlock {
|
(void (^)(NSError* error))completionBlock {
|
||||||
|
|
||||||
id m_body = nil;
|
|
||||||
NSMutableString* requestUrl = [NSMutableString stringWithFormat:@"%@/user/logout", basePath];
|
NSMutableString* requestUrl = [NSMutableString stringWithFormat:@"%@/user/logout", basePath];
|
||||||
|
|
||||||
// remove format in URL if needed
|
// remove format in URL if needed
|
||||||
@ -396,11 +403,11 @@ static NSString * basePath = @"http://petstore.swagger.wordnik.com/v2";
|
|||||||
SWGApiClient* client = [SWGApiClient sharedClientFromPool:basePath];
|
SWGApiClient* client = [SWGApiClient sharedClientFromPool:basePath];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// primitive response type
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// no return base type
|
||||||
return [client stringWithCompletionBlock:requestUrl
|
return [client stringWithCompletionBlock:requestUrl
|
||||||
method:@"GET"
|
method:@"GET"
|
||||||
queryParams:queryParams
|
queryParams:queryParams
|
||||||
@ -417,14 +424,15 @@ static NSString * basePath = @"http://petstore.swagger.wordnik.com/v2";
|
|||||||
}];
|
}];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
-(NSNumber*) getUserByNameWithCompletionBlock:(NSString*) username
|
-(NSNumber*) getUserByNameWithCompletionBlock:(NSString*) username
|
||||||
|
|
||||||
completionHandler: (void (^)(SWGUser* output, NSError* error))completionBlock
|
completionHandler: (void (^)(SWGUser* output, NSError* error))completionBlock
|
||||||
{
|
{
|
||||||
|
|
||||||
id m_body = nil;
|
|
||||||
NSMutableString* requestUrl = [NSMutableString stringWithFormat:@"%@/user/{username}", basePath];
|
NSMutableString* requestUrl = [NSMutableString stringWithFormat:@"%@/user/{username}", basePath];
|
||||||
|
|
||||||
// remove format in URL if needed
|
// remove format in URL if needed
|
||||||
@ -450,41 +458,41 @@ static NSString * basePath = @"http://petstore.swagger.wordnik.com/v2";
|
|||||||
SWGApiClient* client = [SWGApiClient sharedClientFromPool:basePath];
|
SWGApiClient* client = [SWGApiClient sharedClientFromPool:basePath];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// comples response type
|
||||||
return [client dictionary:requestUrl
|
return [client dictionary:requestUrl
|
||||||
method:@"GET"
|
method:@"GET"
|
||||||
queryParams:queryParams
|
queryParams:queryParams
|
||||||
body:bodyDictionary
|
body:bodyDictionary
|
||||||
headerParams:headerParams
|
headerParams:headerParams
|
||||||
requestContentType:requestContentType
|
requestContentType:requestContentType
|
||||||
responseContentType:responseContentType
|
responseContentType:responseContentType
|
||||||
completionBlock:^(NSDictionary *data, NSError *error) {
|
completionBlock:^(NSDictionary *data, NSError *error) {
|
||||||
if (error) {
|
if (error) {
|
||||||
completionBlock(nil, error);
|
completionBlock(nil, error);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
SWGUser *result = nil;
|
SWGUser *result = nil;
|
||||||
if (data) {
|
if (data) {
|
||||||
result = [[SWGUser alloc]initWithValues: data];
|
result = [[SWGUser alloc]initWithValues: data];
|
||||||
}
|
}
|
||||||
completionBlock(result , nil);
|
completionBlock(result , nil);
|
||||||
|
|
||||||
}];
|
}];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
-(NSNumber*) updateUserWithCompletionBlock:(NSString*) username
|
-(NSNumber*) updateUserWithCompletionBlock:(NSString*) username
|
||||||
body:(SWGUser*) body
|
body:(SWGUser*) body
|
||||||
|
|
||||||
|
|
||||||
completionHandler: (void (^)(NSError* error))completionBlock {
|
completionHandler: (void (^)(NSError* error))completionBlock {
|
||||||
|
|
||||||
id m_body = body;
|
|
||||||
NSMutableString* requestUrl = [NSMutableString stringWithFormat:@"%@/user/{username}", basePath];
|
NSMutableString* requestUrl = [NSMutableString stringWithFormat:@"%@/user/{username}", basePath];
|
||||||
|
|
||||||
// remove format in URL if needed
|
// remove format in URL if needed
|
||||||
@ -504,9 +512,11 @@ static NSString * basePath = @"http://petstore.swagger.wordnik.com/v2";
|
|||||||
|
|
||||||
id bodyDictionary = nil;
|
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];
|
NSMutableArray * objs = [[NSMutableArray alloc] init];
|
||||||
for (id dict in (NSArray*)m_body) {
|
for (id dict in (NSArray*)__body) {
|
||||||
if([dict respondsToSelector:@selector(asDictionary)]) {
|
if([dict respondsToSelector:@selector(asDictionary)]) {
|
||||||
[objs addObject:[(SWGObject*)dict asDictionary]];
|
[objs addObject:[(SWGObject*)dict asDictionary]];
|
||||||
}
|
}
|
||||||
@ -516,27 +526,26 @@ static NSString * basePath = @"http://petstore.swagger.wordnik.com/v2";
|
|||||||
}
|
}
|
||||||
bodyDictionary = objs;
|
bodyDictionary = objs;
|
||||||
}
|
}
|
||||||
else if([m_body respondsToSelector:@selector(asDictionary)]) {
|
else if([__body respondsToSelector:@selector(asDictionary)]) {
|
||||||
bodyDictionary = [(SWGObject*)m_body asDictionary];
|
bodyDictionary = [(SWGObject*)__body asDictionary];
|
||||||
}
|
}
|
||||||
else if([m_body isKindOfClass:[NSString class]]) {
|
else if([__body isKindOfClass:[NSString class]]) {
|
||||||
// convert it to a dictionary
|
// convert it to a dictionary
|
||||||
NSError * error;
|
NSError * error;
|
||||||
NSString * str = (NSString*)m_body;
|
NSString * str = (NSString*)__body;
|
||||||
NSDictionary *JSON =
|
NSDictionary *JSON =
|
||||||
[NSJSONSerialization JSONObjectWithData:[str dataUsingEncoding:NSUTF8StringEncoding]
|
[NSJSONSerialization JSONObjectWithData:[str dataUsingEncoding:NSUTF8StringEncoding]
|
||||||
options:NSJSONReadingMutableContainers
|
options:NSJSONReadingMutableContainers
|
||||||
error:&error];
|
error:&error];
|
||||||
bodyDictionary = JSON;
|
bodyDictionary = JSON;
|
||||||
}
|
}
|
||||||
else if([m_body isKindOfClass: [SWGFile class]]) {
|
else if([__body isKindOfClass: [SWGFile class]]) {
|
||||||
requestContentType = @"form-data";
|
requestContentType = @"form-data";
|
||||||
bodyDictionary = m_body;
|
bodyDictionary = __body;
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
NSLog(@"don't know what to do with %@", m_body);
|
NSLog(@"don't know what to do with %@", __body);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -544,11 +553,11 @@ static NSString * basePath = @"http://petstore.swagger.wordnik.com/v2";
|
|||||||
SWGApiClient* client = [SWGApiClient sharedClientFromPool:basePath];
|
SWGApiClient* client = [SWGApiClient sharedClientFromPool:basePath];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// primitive response type
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// no return base type
|
||||||
return [client stringWithCompletionBlock:requestUrl
|
return [client stringWithCompletionBlock:requestUrl
|
||||||
method:@"PUT"
|
method:@"PUT"
|
||||||
queryParams:queryParams
|
queryParams:queryParams
|
||||||
@ -565,14 +574,15 @@ static NSString * basePath = @"http://petstore.swagger.wordnik.com/v2";
|
|||||||
}];
|
}];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
-(NSNumber*) deleteUserWithCompletionBlock:(NSString*) username
|
-(NSNumber*) deleteUserWithCompletionBlock:(NSString*) username
|
||||||
|
|
||||||
|
|
||||||
completionHandler: (void (^)(NSError* error))completionBlock {
|
completionHandler: (void (^)(NSError* error))completionBlock {
|
||||||
|
|
||||||
id m_body = nil;
|
|
||||||
NSMutableString* requestUrl = [NSMutableString stringWithFormat:@"%@/user/{username}", basePath];
|
NSMutableString* requestUrl = [NSMutableString stringWithFormat:@"%@/user/{username}", basePath];
|
||||||
|
|
||||||
// remove format in URL if needed
|
// remove format in URL if needed
|
||||||
@ -598,11 +608,11 @@ static NSString * basePath = @"http://petstore.swagger.wordnik.com/v2";
|
|||||||
SWGApiClient* client = [SWGApiClient sharedClientFromPool:basePath];
|
SWGApiClient* client = [SWGApiClient sharedClientFromPool:basePath];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// primitive response type
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// no return base type
|
||||||
return [client stringWithCompletionBlock:requestUrl
|
return [client stringWithCompletionBlock:requestUrl
|
||||||
method:@"DELETE"
|
method:@"DELETE"
|
||||||
queryParams:queryParams
|
queryParams:queryParams
|
||||||
@ -619,7 +629,8 @@ static NSString * basePath = @"http://petstore.swagger.wordnik.com/v2";
|
|||||||
}];
|
}];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user