mirror of
https://github.com/valitydev/openapi-generator.git
synced 2024-11-08 11:23:58 +00:00
rebuilt client
This commit is contained in:
parent
bc974e6514
commit
73425fe582
@ -6,7 +6,7 @@
|
||||
@implementation SWGApiClient
|
||||
|
||||
static long requestId = 0;
|
||||
static bool offlineState = true;
|
||||
static bool offlineState = false;
|
||||
static NSMutableSet * queuedRequests = nil;
|
||||
static bool cacheEnabled = false;
|
||||
static AFNetworkReachabilityStatus reachabilityStatus = AFNetworkReachabilityStatusNotReachable;
|
||||
|
@ -10,7 +10,6 @@
|
||||
|
||||
name: (NSString*) name;
|
||||
|
||||
|
||||
- (id) initWithValues: (NSDictionary*)dict;
|
||||
- (NSDictionary*) asDictionary;
|
||||
|
||||
|
@ -11,7 +11,6 @@
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
-(id) initWithValues:(NSDictionary*)dict
|
||||
{
|
||||
self = [super init];
|
||||
@ -25,10 +24,18 @@
|
||||
|
||||
-(NSDictionary*) asDictionary {
|
||||
NSMutableDictionary* dict = [[NSMutableDictionary alloc] init];
|
||||
|
||||
|
||||
if(__id != nil)
|
||||
dict[@"id"] = [(SWGObject*)__id asDictionary];
|
||||
dict[@"id"] = __id;
|
||||
|
||||
|
||||
|
||||
|
||||
if(_name != nil)
|
||||
dict[@"name"] = [(SWGObject*)_name asDictionary];
|
||||
dict[@"name"] = _name;
|
||||
|
||||
|
||||
|
||||
NSDictionary* output = [dict copy];
|
||||
return output;
|
||||
|
@ -1,7 +1,6 @@
|
||||
#import <Foundation/Foundation.h>
|
||||
#import "SWGObject.h"
|
||||
#import "SWGDate.h"
|
||||
#import "SWGMap.h"
|
||||
|
||||
|
||||
@interface SWGOrder : SWGObject
|
||||
@ -10,9 +9,8 @@
|
||||
@property(nonatomic) NSNumber* petId;
|
||||
@property(nonatomic) NSNumber* quantity;
|
||||
@property(nonatomic) SWGDate* shipDate;
|
||||
@property(nonatomic) NSString* status;
|
||||
@property(nonatomic) NSString* status; /* Order Status */
|
||||
@property(nonatomic) NSNumber* complete;
|
||||
@property(nonatomic) SWGMap* keyValuePairs;
|
||||
- (id) _id: (NSNumber*) _id
|
||||
|
||||
petId: (NSNumber*) petId
|
||||
@ -23,11 +21,8 @@
|
||||
|
||||
status: (NSString*) status
|
||||
|
||||
complete: (NSNumber*) complete
|
||||
|
||||
keyValuePairs: (SWGMap*) keyValuePairs;
|
||||
complete: (NSNumber*) complete;
|
||||
|
||||
|
||||
- (id) initWithValues: (NSDictionary*)dict;
|
||||
- (NSDictionary*) asDictionary;
|
||||
|
||||
|
@ -8,8 +8,7 @@
|
||||
quantity: (NSNumber*) quantity
|
||||
shipDate: (SWGDate*) shipDate
|
||||
status: (NSString*) status
|
||||
complete: (NSNumber*) complete
|
||||
keyValuePairs: (SWGMap*) keyValuePairs {
|
||||
complete: (NSNumber*) complete {
|
||||
|
||||
__id = _id;
|
||||
_petId = petId;
|
||||
@ -17,11 +16,9 @@
|
||||
_shipDate = shipDate;
|
||||
_status = status;
|
||||
_complete = complete;
|
||||
_keyValuePairs = keyValuePairs;
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
-(id) initWithValues:(NSDictionary*)dict
|
||||
{
|
||||
self = [super init];
|
||||
@ -30,26 +27,66 @@
|
||||
_petId = dict[@"petId"];
|
||||
_quantity = dict[@"quantity"];
|
||||
|
||||
id shipDate_dict = dict[@"shipDate"];
|
||||
if(shipDate_dict != nil)
|
||||
_shipDate = [[SWGDate alloc]initWithValues:shipDate_dict];
|
||||
|
||||
_status = dict[@"status"];
|
||||
_complete = dict[@"complete"];
|
||||
|
||||
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
-(NSDictionary*) asDictionary {
|
||||
NSMutableDictionary* dict = [[NSMutableDictionary alloc] init];
|
||||
|
||||
|
||||
if(__id != nil)
|
||||
dict[@"id"] = [(SWGObject*)__id asDictionary];
|
||||
dict[@"id"] = __id;
|
||||
|
||||
|
||||
|
||||
|
||||
if(_petId != nil)
|
||||
dict[@"petId"] = [(SWGObject*)_petId asDictionary];
|
||||
dict[@"petId"] = _petId;
|
||||
|
||||
|
||||
|
||||
|
||||
if(_quantity != nil)
|
||||
dict[@"quantity"] = [(SWGObject*)_quantity asDictionary];
|
||||
dict[@"quantity"] = _quantity;
|
||||
|
||||
|
||||
|
||||
if(_shipDate != nil){
|
||||
|
||||
|
||||
if(_shipDate && [_shipDate isKindOfClass:[SWGDate class]]) {
|
||||
NSString * dateString = [(SWGDate*)_shipDate toString];
|
||||
if(dateString){
|
||||
dict[@"shipDate"] = dateString;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if(_shipDate != nil)
|
||||
dict[@"shipDate"] = [(SWGObject*)_shipDate asDictionary];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
if(_status != nil)
|
||||
dict[@"status"] = [(SWGObject*)_status asDictionary];
|
||||
dict[@"status"] = _status;
|
||||
|
||||
|
||||
|
||||
|
||||
if(_complete != nil)
|
||||
dict[@"complete"] = [(SWGObject*)_complete asDictionary];
|
||||
dict[@"complete"] = _complete;
|
||||
|
||||
|
||||
|
||||
NSDictionary* output = [dict copy];
|
||||
return output;
|
||||
|
@ -6,12 +6,12 @@
|
||||
|
||||
@interface SWGPet : SWGObject
|
||||
|
||||
@property(nonatomic) NSNumber* _id; /* the identifier for the pet */
|
||||
@property(nonatomic) NSNumber* _id;
|
||||
@property(nonatomic) SWGCategory* category;
|
||||
@property(nonatomic) NSString* name;
|
||||
@property(nonatomic) NSArray* photoUrls;
|
||||
@property(nonatomic) NSArray* tags;
|
||||
@property(nonatomic) NSString* status;
|
||||
@property(nonatomic) NSString* status; /* pet status in the store */
|
||||
- (id) _id: (NSNumber*) _id
|
||||
|
||||
category: (SWGCategory*) category
|
||||
@ -24,7 +24,6 @@
|
||||
|
||||
status: (NSString*) status;
|
||||
|
||||
|
||||
- (id) initWithValues: (NSDictionary*)dict;
|
||||
- (NSDictionary*) asDictionary;
|
||||
|
||||
|
@ -19,27 +19,27 @@
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
-(id) initWithValues:(NSDictionary*)dict
|
||||
{
|
||||
self = [super init];
|
||||
if(self) {
|
||||
__id = dict[@"id"];
|
||||
|
||||
id category_dict = dict[@"category"];
|
||||
if(category_dict != nil)
|
||||
_category = [[SWGCategory alloc]initWithValues:category_dict];
|
||||
|
||||
_name = dict[@"name"];
|
||||
|
||||
|
||||
_photoUrls = dict[@"photoUrls"];
|
||||
|
||||
id tags_dict = dict[@"tags"];
|
||||
if([tags_dict isKindOfClass:[NSArray class]]) {
|
||||
NSMutableArray * objs = [[NSMutableArray alloc] initWithCapacity:[(NSArray*)tags_dict count]];
|
||||
|
||||
if([(NSArray*)tags_dict count] > 0) {
|
||||
for (NSDictionary* dict in (NSArray*)tags_dict) {
|
||||
SWGTag* d = [[SWGTag alloc] initWithValues:dict];
|
||||
[objs addObject:d];
|
||||
}
|
||||
|
||||
_tags = [[NSArray alloc] initWithArray:objs];
|
||||
}
|
||||
else {
|
||||
@ -58,30 +58,67 @@
|
||||
|
||||
-(NSDictionary*) asDictionary {
|
||||
NSMutableDictionary* dict = [[NSMutableDictionary alloc] init];
|
||||
|
||||
|
||||
if(__id != nil)
|
||||
dict[@"id"] = [(SWGObject*)__id asDictionary];
|
||||
dict[@"id"] = __id;
|
||||
|
||||
|
||||
|
||||
if(_category != nil){
|
||||
|
||||
|
||||
if(_category && [_category isKindOfClass:[SWGDate class]]) {
|
||||
NSString * dateString = [(SWGDate*)_category toString];
|
||||
if(dateString){
|
||||
dict[@"category"] = dateString;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if(_category != nil)
|
||||
dict[@"category"] = [(SWGObject*)_category asDictionary];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
if(_name != nil)
|
||||
dict[@"name"] = [(SWGObject*)_name asDictionary];
|
||||
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(_tags != nil){
|
||||
|
||||
if([_tags isKindOfClass:[NSArray class]]){
|
||||
NSMutableArray * array = [[NSMutableArray alloc] init];
|
||||
for( SWGTag *tags in (NSArray*)_tags) {
|
||||
NSMutableArray * array = [[NSMutableArray alloc] init];
|
||||
for( SWGTag *tags in _tags) {
|
||||
[array addObject:[(SWGObject*)tags asDictionary]];
|
||||
}
|
||||
dict[@"tags"] = array;
|
||||
}
|
||||
else if(_tags && [_tags isKindOfClass:[SWGDate class]]) {
|
||||
NSString * dateString = [(SWGDate*)_tags toString];
|
||||
if(dateString){
|
||||
dict[@"tags"] = dateString;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if(_tags != nil) dict[@"tags"] = [(SWGObject*)_tags asDictionary];
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
if(_status != nil)
|
||||
dict[@"status"] = [(SWGObject*)_status asDictionary];
|
||||
dict[@"status"] = _status;
|
||||
|
||||
|
||||
|
||||
NSDictionary* output = [dict copy];
|
||||
return output;
|
||||
|
@ -64,15 +64,32 @@
|
||||
-(NSNumber*) getPetByIdWithCompletionBlock : (NSNumber*) petId
|
||||
completionHandler: (void (^)(SWGPet* output, NSError* error))completionBlock;
|
||||
|
||||
/**
|
||||
|
||||
Updates a pet in the store with form data
|
||||
|
||||
|
||||
@param petId ID of pet that needs to be updated
|
||||
@param name Updated name of the pet
|
||||
@param status Updated status of the pet
|
||||
|
||||
*/
|
||||
-(NSNumber*) updatePetWithFormWithCompletionBlock : (NSString*) petId
|
||||
name: (NSString*) name
|
||||
status: (NSString*) status
|
||||
|
||||
completionHandler: (void (^)(NSError* error))completionBlock;
|
||||
/**
|
||||
|
||||
Deletes a pet
|
||||
|
||||
|
||||
@param api_key
|
||||
@param petId Pet id to delete
|
||||
|
||||
*/
|
||||
-(NSNumber*) deletePetWithCompletionBlock : (NSNumber*) petId
|
||||
-(NSNumber*) deletePetWithCompletionBlock : (NSString*) api_key
|
||||
petId: (NSNumber*) petId
|
||||
|
||||
completionHandler: (void (^)(NSError* error))completionBlock;
|
||||
@end
|
@ -6,7 +6,7 @@
|
||||
|
||||
|
||||
@implementation SWGPetApi
|
||||
static NSString * basePath = @"";
|
||||
static NSString * basePath = @"http://petstore.swagger.wordnik.com/v2";
|
||||
|
||||
+(SWGPetApi*) apiWithHeader:(NSString*)headerValue key:(NSString*)key {
|
||||
static SWGPetApi* singletonAPI = nil;
|
||||
@ -72,6 +72,40 @@ static NSString * basePath = @"";
|
||||
|
||||
id bodyDictionary = nil;
|
||||
|
||||
if(body != nil && [body isKindOfClass:[NSArray class]]){
|
||||
NSMutableArray * objs = [[NSMutableArray alloc] init];
|
||||
for (id dict in (NSArray*)body) {
|
||||
if([dict respondsToSelector:@selector(asDictionary)]) {
|
||||
[objs addObject:[(SWGObject*)dict asDictionary]];
|
||||
}
|
||||
else{
|
||||
[objs addObject:dict];
|
||||
}
|
||||
}
|
||||
bodyDictionary = objs;
|
||||
}
|
||||
else if([body respondsToSelector:@selector(asDictionary)]) {
|
||||
bodyDictionary = [(SWGObject*)body asDictionary];
|
||||
}
|
||||
else if([body isKindOfClass:[NSString class]]) {
|
||||
// convert it to a dictionary
|
||||
NSError * error;
|
||||
NSString * str = (NSString*)body;
|
||||
NSDictionary *JSON =
|
||||
[NSJSONSerialization JSONObjectWithData:[str dataUsingEncoding:NSUTF8StringEncoding]
|
||||
options:NSJSONReadingMutableContainers
|
||||
error:&error];
|
||||
bodyDictionary = JSON;
|
||||
}
|
||||
else if([body isKindOfClass: [SWGFile class]]) {
|
||||
requestContentType = @"form-data";
|
||||
bodyDictionary = body;
|
||||
}
|
||||
else{
|
||||
NSLog(@"don't know what to do with %@", body);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -124,6 +158,40 @@ static NSString * basePath = @"";
|
||||
|
||||
id bodyDictionary = nil;
|
||||
|
||||
if(body != nil && [body isKindOfClass:[NSArray class]]){
|
||||
NSMutableArray * objs = [[NSMutableArray alloc] init];
|
||||
for (id dict in (NSArray*)body) {
|
||||
if([dict respondsToSelector:@selector(asDictionary)]) {
|
||||
[objs addObject:[(SWGObject*)dict asDictionary]];
|
||||
}
|
||||
else{
|
||||
[objs addObject:dict];
|
||||
}
|
||||
}
|
||||
bodyDictionary = objs;
|
||||
}
|
||||
else if([body respondsToSelector:@selector(asDictionary)]) {
|
||||
bodyDictionary = [(SWGObject*)body asDictionary];
|
||||
}
|
||||
else if([body isKindOfClass:[NSString class]]) {
|
||||
// convert it to a dictionary
|
||||
NSError * error;
|
||||
NSString * str = (NSString*)body;
|
||||
NSDictionary *JSON =
|
||||
[NSJSONSerialization JSONObjectWithData:[str dataUsingEncoding:NSUTF8StringEncoding]
|
||||
options:NSJSONReadingMutableContainers
|
||||
error:&error];
|
||||
bodyDictionary = JSON;
|
||||
}
|
||||
else if([body isKindOfClass: [SWGFile class]]) {
|
||||
requestContentType = @"form-data";
|
||||
bodyDictionary = body;
|
||||
}
|
||||
else{
|
||||
NSLog(@"don't know what to do with %@", body);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -342,7 +410,9 @@ static NSString * basePath = @"";
|
||||
|
||||
}
|
||||
|
||||
-(NSNumber*) deletePetWithCompletionBlock:(NSNumber*) petId
|
||||
-(NSNumber*) updatePetWithFormWithCompletionBlock:(NSString*) petId
|
||||
name:(NSString*) name
|
||||
status:(NSString*) status
|
||||
|
||||
completionHandler: (void (^)(NSError* error))completionBlock {
|
||||
|
||||
@ -376,6 +446,61 @@ static NSString * basePath = @"";
|
||||
|
||||
|
||||
|
||||
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);
|
||||
}];
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
-(NSNumber*) deletePetWithCompletionBlock:(NSString*) api_key
|
||||
petId:(NSNumber*) petId
|
||||
|
||||
completionHandler: (void (^)(NSError* error))completionBlock {
|
||||
|
||||
NSMutableString* requestUrl = [NSMutableString stringWithFormat:@"%@/pet/{petId}", basePath];
|
||||
|
||||
// remove format in URL if needed
|
||||
if ([requestUrl rangeOfString:@".{format}"].location != NSNotFound)
|
||||
[requestUrl replaceCharactersInRange: [requestUrl rangeOfString:@".{format}"] withString:@".json"];
|
||||
|
||||
[requestUrl replaceCharactersInRange: [requestUrl rangeOfString:[NSString stringWithFormat:@"%@%@%@", @"{", @"petId", @"}"]] withString: [SWGApiClient escape:petId]];
|
||||
|
||||
|
||||
NSString* requestContentType = @"application/json";
|
||||
NSString* responseContentType = @"application/json";
|
||||
|
||||
NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init];
|
||||
|
||||
NSMutableDictionary* headerParams = [[NSMutableDictionary alloc] init];
|
||||
if(api_key != nil)
|
||||
headerParams[@"api_key"] = api_key;
|
||||
|
||||
id bodyDictionary = nil;
|
||||
|
||||
|
||||
|
||||
|
||||
SWGApiClient* client = [SWGApiClient sharedClientFromPool:basePath];
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
return [client stringWithCompletionBlock:requestUrl
|
||||
method:@"DELETE"
|
||||
queryParams:queryParams
|
||||
|
@ -18,8 +18,8 @@
|
||||
|
||||
*/
|
||||
-(NSNumber*) placeOrderWithCompletionBlock : (SWGOrder*) body
|
||||
completionHandler: (void (^)(SWGOrder* output, NSError* error))completionBlock;
|
||||
|
||||
completionHandler: (void (^)(NSError* error))completionBlock;
|
||||
/**
|
||||
|
||||
Find purchase order by ID
|
||||
|
@ -6,7 +6,7 @@
|
||||
|
||||
|
||||
@implementation SWGStoreApi
|
||||
static NSString * basePath = @"";
|
||||
static NSString * basePath = @"http://petstore.swagger.wordnik.com/v2";
|
||||
|
||||
+(SWGStoreApi*) apiWithHeader:(NSString*)headerValue key:(NSString*)key {
|
||||
static SWGStoreApi* singletonAPI = nil;
|
||||
@ -51,8 +51,8 @@ static NSString * basePath = @"";
|
||||
|
||||
|
||||
-(NSNumber*) placeOrderWithCompletionBlock:(SWGOrder*) body
|
||||
|
||||
completionHandler: (void (^)(NSError* error))completionBlock {
|
||||
completionHandler: (void (^)(SWGOrder* output, NSError* error))completionBlock
|
||||
{
|
||||
|
||||
NSMutableString* requestUrl = [NSMutableString stringWithFormat:@"%@/store/order", basePath];
|
||||
|
||||
@ -72,6 +72,40 @@ static NSString * basePath = @"";
|
||||
|
||||
id bodyDictionary = nil;
|
||||
|
||||
if(body != nil && [body isKindOfClass:[NSArray class]]){
|
||||
NSMutableArray * objs = [[NSMutableArray alloc] init];
|
||||
for (id dict in (NSArray*)body) {
|
||||
if([dict respondsToSelector:@selector(asDictionary)]) {
|
||||
[objs addObject:[(SWGObject*)dict asDictionary]];
|
||||
}
|
||||
else{
|
||||
[objs addObject:dict];
|
||||
}
|
||||
}
|
||||
bodyDictionary = objs;
|
||||
}
|
||||
else if([body respondsToSelector:@selector(asDictionary)]) {
|
||||
bodyDictionary = [(SWGObject*)body asDictionary];
|
||||
}
|
||||
else if([body isKindOfClass:[NSString class]]) {
|
||||
// convert it to a dictionary
|
||||
NSError * error;
|
||||
NSString * str = (NSString*)body;
|
||||
NSDictionary *JSON =
|
||||
[NSJSONSerialization JSONObjectWithData:[str dataUsingEncoding:NSUTF8StringEncoding]
|
||||
options:NSJSONReadingMutableContainers
|
||||
error:&error];
|
||||
bodyDictionary = JSON;
|
||||
}
|
||||
else if([body isKindOfClass: [SWGFile class]]) {
|
||||
requestContentType = @"form-data";
|
||||
bodyDictionary = body;
|
||||
}
|
||||
else{
|
||||
NSLog(@"don't know what to do with %@", body);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -82,23 +116,28 @@ static NSString * basePath = @"";
|
||||
|
||||
|
||||
|
||||
|
||||
return [client stringWithCompletionBlock:requestUrl
|
||||
method:@"POST"
|
||||
queryParams:queryParams
|
||||
body:bodyDictionary
|
||||
headerParams:headerParams
|
||||
requestContentType: requestContentType
|
||||
responseContentType: responseContentType
|
||||
completionBlock:^(NSString *data, NSError *error) {
|
||||
return [client dictionary:requestUrl
|
||||
method:@"POST"
|
||||
queryParams:queryParams
|
||||
body:bodyDictionary
|
||||
headerParams:headerParams
|
||||
requestContentType:requestContentType
|
||||
responseContentType:responseContentType
|
||||
completionBlock:^(NSDictionary *data, NSError *error) {
|
||||
if (error) {
|
||||
completionBlock(error);
|
||||
completionBlock(nil, error);
|
||||
|
||||
return;
|
||||
}
|
||||
completionBlock(nil);
|
||||
|
||||
SWGOrder *result = nil;
|
||||
if (data) {
|
||||
result = [[SWGOrder alloc]initWithValues: data];
|
||||
}
|
||||
completionBlock(result , nil);
|
||||
|
||||
}];
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
@ -10,7 +10,6 @@
|
||||
|
||||
name: (NSString*) name;
|
||||
|
||||
|
||||
- (id) initWithValues: (NSDictionary*)dict;
|
||||
- (NSDictionary*) asDictionary;
|
||||
|
||||
|
@ -11,7 +11,6 @@
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
-(id) initWithValues:(NSDictionary*)dict
|
||||
{
|
||||
self = [super init];
|
||||
@ -25,10 +24,18 @@
|
||||
|
||||
-(NSDictionary*) asDictionary {
|
||||
NSMutableDictionary* dict = [[NSMutableDictionary alloc] init];
|
||||
|
||||
|
||||
if(__id != nil)
|
||||
dict[@"id"] = [(SWGObject*)__id asDictionary];
|
||||
dict[@"id"] = __id;
|
||||
|
||||
|
||||
|
||||
|
||||
if(_name != nil)
|
||||
dict[@"name"] = [(SWGObject*)_name asDictionary];
|
||||
dict[@"name"] = _name;
|
||||
|
||||
|
||||
|
||||
NSDictionary* output = [dict copy];
|
||||
return output;
|
||||
|
@ -11,7 +11,7 @@
|
||||
@property(nonatomic) NSString* email;
|
||||
@property(nonatomic) NSString* password;
|
||||
@property(nonatomic) NSString* phone;
|
||||
@property(nonatomic) NSNumber* userStatus;
|
||||
@property(nonatomic) NSNumber* userStatus; /* User Status */
|
||||
- (id) _id: (NSNumber*) _id
|
||||
|
||||
username: (NSString*) username
|
||||
@ -28,7 +28,6 @@
|
||||
|
||||
userStatus: (NSNumber*) userStatus;
|
||||
|
||||
|
||||
- (id) initWithValues: (NSDictionary*)dict;
|
||||
- (NSDictionary*) asDictionary;
|
||||
|
||||
|
@ -23,7 +23,6 @@
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
-(id) initWithValues:(NSDictionary*)dict
|
||||
{
|
||||
self = [super init];
|
||||
@ -43,22 +42,54 @@
|
||||
|
||||
-(NSDictionary*) asDictionary {
|
||||
NSMutableDictionary* dict = [[NSMutableDictionary alloc] init];
|
||||
|
||||
|
||||
if(__id != nil)
|
||||
dict[@"id"] = [(SWGObject*)__id asDictionary];
|
||||
dict[@"id"] = __id;
|
||||
|
||||
|
||||
|
||||
|
||||
if(_username != nil)
|
||||
dict[@"username"] = [(SWGObject*)_username asDictionary];
|
||||
dict[@"username"] = _username;
|
||||
|
||||
|
||||
|
||||
|
||||
if(_firstName != nil)
|
||||
dict[@"firstName"] = [(SWGObject*)_firstName asDictionary];
|
||||
dict[@"firstName"] = _firstName;
|
||||
|
||||
|
||||
|
||||
|
||||
if(_lastName != nil)
|
||||
dict[@"lastName"] = [(SWGObject*)_lastName asDictionary];
|
||||
dict[@"lastName"] = _lastName;
|
||||
|
||||
|
||||
|
||||
|
||||
if(_email != nil)
|
||||
dict[@"email"] = [(SWGObject*)_email asDictionary];
|
||||
dict[@"email"] = _email;
|
||||
|
||||
|
||||
|
||||
|
||||
if(_password != nil)
|
||||
dict[@"password"] = [(SWGObject*)_password asDictionary];
|
||||
dict[@"password"] = _password;
|
||||
|
||||
|
||||
|
||||
|
||||
if(_phone != nil)
|
||||
dict[@"phone"] = [(SWGObject*)_phone asDictionary];
|
||||
dict[@"phone"] = _phone;
|
||||
|
||||
|
||||
|
||||
|
||||
if(_userStatus != nil)
|
||||
dict[@"userStatus"] = [(SWGObject*)_userStatus asDictionary];
|
||||
dict[@"userStatus"] = _userStatus;
|
||||
|
||||
|
||||
|
||||
NSDictionary* output = [dict copy];
|
||||
return output;
|
||||
|
@ -6,7 +6,7 @@
|
||||
|
||||
|
||||
@implementation SWGUserApi
|
||||
static NSString * basePath = @"";
|
||||
static NSString * basePath = @"http://petstore.swagger.wordnik.com/v2";
|
||||
|
||||
+(SWGUserApi*) apiWithHeader:(NSString*)headerValue key:(NSString*)key {
|
||||
static SWGUserApi* singletonAPI = nil;
|
||||
@ -72,6 +72,40 @@ static NSString * basePath = @"";
|
||||
|
||||
id bodyDictionary = nil;
|
||||
|
||||
if(body != nil && [body isKindOfClass:[NSArray class]]){
|
||||
NSMutableArray * objs = [[NSMutableArray alloc] init];
|
||||
for (id dict in (NSArray*)body) {
|
||||
if([dict respondsToSelector:@selector(asDictionary)]) {
|
||||
[objs addObject:[(SWGObject*)dict asDictionary]];
|
||||
}
|
||||
else{
|
||||
[objs addObject:dict];
|
||||
}
|
||||
}
|
||||
bodyDictionary = objs;
|
||||
}
|
||||
else if([body respondsToSelector:@selector(asDictionary)]) {
|
||||
bodyDictionary = [(SWGObject*)body asDictionary];
|
||||
}
|
||||
else if([body isKindOfClass:[NSString class]]) {
|
||||
// convert it to a dictionary
|
||||
NSError * error;
|
||||
NSString * str = (NSString*)body;
|
||||
NSDictionary *JSON =
|
||||
[NSJSONSerialization JSONObjectWithData:[str dataUsingEncoding:NSUTF8StringEncoding]
|
||||
options:NSJSONReadingMutableContainers
|
||||
error:&error];
|
||||
bodyDictionary = JSON;
|
||||
}
|
||||
else if([body isKindOfClass: [SWGFile class]]) {
|
||||
requestContentType = @"form-data";
|
||||
bodyDictionary = body;
|
||||
}
|
||||
else{
|
||||
NSLog(@"don't know what to do with %@", body);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -124,6 +158,40 @@ static NSString * basePath = @"";
|
||||
|
||||
id bodyDictionary = nil;
|
||||
|
||||
if(body != nil && [body isKindOfClass:[NSArray class]]){
|
||||
NSMutableArray * objs = [[NSMutableArray alloc] init];
|
||||
for (id dict in (NSArray*)body) {
|
||||
if([dict respondsToSelector:@selector(asDictionary)]) {
|
||||
[objs addObject:[(SWGObject*)dict asDictionary]];
|
||||
}
|
||||
else{
|
||||
[objs addObject:dict];
|
||||
}
|
||||
}
|
||||
bodyDictionary = objs;
|
||||
}
|
||||
else if([body respondsToSelector:@selector(asDictionary)]) {
|
||||
bodyDictionary = [(SWGObject*)body asDictionary];
|
||||
}
|
||||
else if([body isKindOfClass:[NSString class]]) {
|
||||
// convert it to a dictionary
|
||||
NSError * error;
|
||||
NSString * str = (NSString*)body;
|
||||
NSDictionary *JSON =
|
||||
[NSJSONSerialization JSONObjectWithData:[str dataUsingEncoding:NSUTF8StringEncoding]
|
||||
options:NSJSONReadingMutableContainers
|
||||
error:&error];
|
||||
bodyDictionary = JSON;
|
||||
}
|
||||
else if([body isKindOfClass: [SWGFile class]]) {
|
||||
requestContentType = @"form-data";
|
||||
bodyDictionary = body;
|
||||
}
|
||||
else{
|
||||
NSLog(@"don't know what to do with %@", body);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -176,6 +244,40 @@ static NSString * basePath = @"";
|
||||
|
||||
id bodyDictionary = nil;
|
||||
|
||||
if(body != nil && [body isKindOfClass:[NSArray class]]){
|
||||
NSMutableArray * objs = [[NSMutableArray alloc] init];
|
||||
for (id dict in (NSArray*)body) {
|
||||
if([dict respondsToSelector:@selector(asDictionary)]) {
|
||||
[objs addObject:[(SWGObject*)dict asDictionary]];
|
||||
}
|
||||
else{
|
||||
[objs addObject:dict];
|
||||
}
|
||||
}
|
||||
bodyDictionary = objs;
|
||||
}
|
||||
else if([body respondsToSelector:@selector(asDictionary)]) {
|
||||
bodyDictionary = [(SWGObject*)body asDictionary];
|
||||
}
|
||||
else if([body isKindOfClass:[NSString class]]) {
|
||||
// convert it to a dictionary
|
||||
NSError * error;
|
||||
NSString * str = (NSString*)body;
|
||||
NSDictionary *JSON =
|
||||
[NSJSONSerialization JSONObjectWithData:[str dataUsingEncoding:NSUTF8StringEncoding]
|
||||
options:NSJSONReadingMutableContainers
|
||||
error:&error];
|
||||
bodyDictionary = JSON;
|
||||
}
|
||||
else if([body isKindOfClass: [SWGFile class]]) {
|
||||
requestContentType = @"form-data";
|
||||
bodyDictionary = body;
|
||||
}
|
||||
else{
|
||||
NSLog(@"don't know what to do with %@", body);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -395,6 +497,40 @@ static NSString * basePath = @"";
|
||||
|
||||
id bodyDictionary = nil;
|
||||
|
||||
if(body != nil && [body isKindOfClass:[NSArray class]]){
|
||||
NSMutableArray * objs = [[NSMutableArray alloc] init];
|
||||
for (id dict in (NSArray*)body) {
|
||||
if([dict respondsToSelector:@selector(asDictionary)]) {
|
||||
[objs addObject:[(SWGObject*)dict asDictionary]];
|
||||
}
|
||||
else{
|
||||
[objs addObject:dict];
|
||||
}
|
||||
}
|
||||
bodyDictionary = objs;
|
||||
}
|
||||
else if([body respondsToSelector:@selector(asDictionary)]) {
|
||||
bodyDictionary = [(SWGObject*)body asDictionary];
|
||||
}
|
||||
else if([body isKindOfClass:[NSString class]]) {
|
||||
// convert it to a dictionary
|
||||
NSError * error;
|
||||
NSString * str = (NSString*)body;
|
||||
NSDictionary *JSON =
|
||||
[NSJSONSerialization JSONObjectWithData:[str dataUsingEncoding:NSUTF8StringEncoding]
|
||||
options:NSJSONReadingMutableContainers
|
||||
error:&error];
|
||||
bodyDictionary = JSON;
|
||||
}
|
||||
else if([body isKindOfClass: [SWGFile class]]) {
|
||||
requestContentType = @"form-data";
|
||||
bodyDictionary = body;
|
||||
}
|
||||
else{
|
||||
NSLog(@"don't know what to do with %@", body);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user