forked from loafle/openapi-generator-original
541 lines
18 KiB
Objective-C
541 lines
18 KiB
Objective-C
#import "SWGStoreApi.h"
|
|
#import "SWGQueryParamCollection.h"
|
|
#import "SWGOrder.h"
|
|
|
|
|
|
@interface SWGStoreApi ()
|
|
@property (readwrite, nonatomic, strong) NSMutableDictionary *defaultHeaders;
|
|
@end
|
|
|
|
@implementation SWGStoreApi
|
|
|
|
static SWGStoreApi* singletonAPI = nil;
|
|
|
|
#pragma mark - Initialize methods
|
|
|
|
- (id) init {
|
|
self = [super init];
|
|
if (self) {
|
|
SWGConfiguration *config = [SWGConfiguration sharedConfig];
|
|
if (config.apiClient == nil) {
|
|
config.apiClient = [[SWGApiClient alloc] init];
|
|
}
|
|
self.apiClient = config.apiClient;
|
|
self.defaultHeaders = [NSMutableDictionary dictionary];
|
|
}
|
|
return self;
|
|
}
|
|
|
|
- (id) initWithApiClient:(SWGApiClient *)apiClient {
|
|
self = [super init];
|
|
if (self) {
|
|
self.apiClient = apiClient;
|
|
self.defaultHeaders = [NSMutableDictionary dictionary];
|
|
}
|
|
return self;
|
|
}
|
|
|
|
#pragma mark -
|
|
|
|
+(SWGStoreApi*) apiWithHeader:(NSString*)headerValue key:(NSString*)key {
|
|
|
|
if (singletonAPI == nil) {
|
|
singletonAPI = [[SWGStoreApi alloc] init];
|
|
[singletonAPI addHeader:headerValue forKey:key];
|
|
}
|
|
return singletonAPI;
|
|
}
|
|
|
|
+(SWGStoreApi*) sharedAPI {
|
|
|
|
if (singletonAPI == nil) {
|
|
singletonAPI = [[SWGStoreApi alloc] init];
|
|
}
|
|
return singletonAPI;
|
|
}
|
|
|
|
-(void) addHeader:(NSString*)value forKey:(NSString*)key {
|
|
[self.defaultHeaders setValue:value forKey:key];
|
|
}
|
|
|
|
-(void) setHeaderValue:(NSString*) value
|
|
forKey:(NSString*)key {
|
|
[self.defaultHeaders setValue:value forKey:key];
|
|
}
|
|
|
|
-(unsigned long) requestQueueSize {
|
|
return [SWGApiClient requestQueueSize];
|
|
}
|
|
|
|
#pragma mark - Api Methods
|
|
|
|
///
|
|
/// Delete purchase order by ID
|
|
/// For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors
|
|
/// @param orderId ID of the order that needs to be deleted
|
|
///
|
|
/// @returns void
|
|
///
|
|
-(NSNumber*) deleteOrderWithOrderId: (NSString*) orderId
|
|
completionHandler: (void (^)(NSError* error)) handler {
|
|
|
|
|
|
// verify the required parameter 'orderId' is set
|
|
if (orderId == nil) {
|
|
[NSException raise:@"Invalid parameter" format:@"Missing the required parameter `orderId` when calling `deleteOrder`"];
|
|
}
|
|
|
|
|
|
NSMutableString* resourcePath = [NSMutableString stringWithFormat:@"/store/order/{orderId}"];
|
|
|
|
// remove format in URL if needed
|
|
if ([resourcePath rangeOfString:@".{format}"].location != NSNotFound) {
|
|
[resourcePath replaceCharactersInRange: [resourcePath rangeOfString:@".{format}"] withString:@".json"];
|
|
}
|
|
|
|
NSMutableDictionary *pathParams = [[NSMutableDictionary alloc] init];
|
|
if (orderId != nil) {
|
|
pathParams[@"orderId"] = orderId;
|
|
}
|
|
|
|
|
|
NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init];
|
|
|
|
NSMutableDictionary* headerParams = [NSMutableDictionary dictionaryWithDictionary:self.defaultHeaders];
|
|
|
|
|
|
|
|
// HTTP header `Accept`
|
|
headerParams[@"Accept"] = [SWGApiClient selectHeaderAccept:@[@"application/json", @"application/xml"]];
|
|
if ([headerParams[@"Accept"] length] == 0) {
|
|
[headerParams removeObjectForKey:@"Accept"];
|
|
}
|
|
|
|
// response content type
|
|
NSString *responseContentType;
|
|
if ([headerParams objectForKey:@"Accept"]) {
|
|
responseContentType = [headerParams[@"Accept"] componentsSeparatedByString:@", "][0];
|
|
}
|
|
else {
|
|
responseContentType = @"";
|
|
}
|
|
|
|
// request content type
|
|
NSString *requestContentType = [SWGApiClient selectHeaderContentType:@[]];
|
|
|
|
// Authentication setting
|
|
NSArray *authSettings = @[];
|
|
|
|
id bodyParam = nil;
|
|
NSMutableDictionary *formParams = [[NSMutableDictionary alloc] init];
|
|
NSMutableDictionary *localVarFiles = [[NSMutableDictionary alloc] init];
|
|
|
|
|
|
|
|
|
|
|
|
return [self.apiClient requestWithPath: resourcePath
|
|
method: @"DELETE"
|
|
pathParams: pathParams
|
|
queryParams: queryParams
|
|
formParams: formParams
|
|
files: localVarFiles
|
|
body: bodyParam
|
|
headerParams: headerParams
|
|
authSettings: authSettings
|
|
requestContentType: requestContentType
|
|
responseContentType: responseContentType
|
|
responseType: nil
|
|
completionBlock: ^(id data, NSError *error) {
|
|
handler(error);
|
|
}
|
|
];
|
|
}
|
|
|
|
///
|
|
/// Finds orders by status
|
|
/// A single status value can be provided as a string
|
|
/// @param status Status value that needs to be considered for query (optional, default to placed)
|
|
///
|
|
/// @returns NSArray<SWGOrder>*
|
|
///
|
|
-(NSNumber*) findOrdersByStatusWithStatus: (NSString*) status
|
|
completionHandler: (void (^)(NSArray<SWGOrder>* output, NSError* error)) handler {
|
|
|
|
|
|
|
|
NSMutableString* resourcePath = [NSMutableString stringWithFormat:@"/store/findByStatus"];
|
|
|
|
// remove format in URL if needed
|
|
if ([resourcePath rangeOfString:@".{format}"].location != NSNotFound) {
|
|
[resourcePath replaceCharactersInRange: [resourcePath rangeOfString:@".{format}"] withString:@".json"];
|
|
}
|
|
|
|
NSMutableDictionary *pathParams = [[NSMutableDictionary alloc] init];
|
|
|
|
|
|
NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init];
|
|
if (status != nil) {
|
|
|
|
queryParams[@"status"] = status;
|
|
}
|
|
|
|
NSMutableDictionary* headerParams = [NSMutableDictionary dictionaryWithDictionary:self.defaultHeaders];
|
|
|
|
|
|
|
|
// HTTP header `Accept`
|
|
headerParams[@"Accept"] = [SWGApiClient selectHeaderAccept:@[@"application/json", @"application/xml"]];
|
|
if ([headerParams[@"Accept"] length] == 0) {
|
|
[headerParams removeObjectForKey:@"Accept"];
|
|
}
|
|
|
|
// response content type
|
|
NSString *responseContentType;
|
|
if ([headerParams objectForKey:@"Accept"]) {
|
|
responseContentType = [headerParams[@"Accept"] componentsSeparatedByString:@", "][0];
|
|
}
|
|
else {
|
|
responseContentType = @"";
|
|
}
|
|
|
|
// request content type
|
|
NSString *requestContentType = [SWGApiClient selectHeaderContentType:@[]];
|
|
|
|
// Authentication setting
|
|
NSArray *authSettings = @[@"test_api_client_id", @"test_api_client_secret"];
|
|
|
|
id bodyParam = nil;
|
|
NSMutableDictionary *formParams = [[NSMutableDictionary alloc] init];
|
|
NSMutableDictionary *localVarFiles = [[NSMutableDictionary alloc] init];
|
|
|
|
|
|
|
|
|
|
|
|
return [self.apiClient requestWithPath: resourcePath
|
|
method: @"GET"
|
|
pathParams: pathParams
|
|
queryParams: queryParams
|
|
formParams: formParams
|
|
files: localVarFiles
|
|
body: bodyParam
|
|
headerParams: headerParams
|
|
authSettings: authSettings
|
|
requestContentType: requestContentType
|
|
responseContentType: responseContentType
|
|
responseType: @"NSArray<SWGOrder>*"
|
|
completionBlock: ^(id data, NSError *error) {
|
|
handler((NSArray<SWGOrder>*)data, error);
|
|
}
|
|
];
|
|
}
|
|
|
|
///
|
|
/// Returns pet inventories by status
|
|
/// Returns a map of status codes to quantities
|
|
/// @returns NSDictionary* /* NSString, NSNumber */
|
|
///
|
|
-(NSNumber*) getInventoryWithCompletionHandler:
|
|
(void (^)(NSDictionary* /* NSString, NSNumber */ output, NSError* error)) handler {
|
|
|
|
|
|
|
|
NSMutableString* resourcePath = [NSMutableString stringWithFormat:@"/store/inventory"];
|
|
|
|
// remove format in URL if needed
|
|
if ([resourcePath rangeOfString:@".{format}"].location != NSNotFound) {
|
|
[resourcePath replaceCharactersInRange: [resourcePath rangeOfString:@".{format}"] withString:@".json"];
|
|
}
|
|
|
|
NSMutableDictionary *pathParams = [[NSMutableDictionary alloc] init];
|
|
|
|
|
|
NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init];
|
|
|
|
NSMutableDictionary* headerParams = [NSMutableDictionary dictionaryWithDictionary:self.defaultHeaders];
|
|
|
|
|
|
|
|
// HTTP header `Accept`
|
|
headerParams[@"Accept"] = [SWGApiClient selectHeaderAccept:@[@"application/json", @"application/xml"]];
|
|
if ([headerParams[@"Accept"] length] == 0) {
|
|
[headerParams removeObjectForKey:@"Accept"];
|
|
}
|
|
|
|
// response content type
|
|
NSString *responseContentType;
|
|
if ([headerParams objectForKey:@"Accept"]) {
|
|
responseContentType = [headerParams[@"Accept"] componentsSeparatedByString:@", "][0];
|
|
}
|
|
else {
|
|
responseContentType = @"";
|
|
}
|
|
|
|
// request content type
|
|
NSString *requestContentType = [SWGApiClient selectHeaderContentType:@[]];
|
|
|
|
// Authentication setting
|
|
NSArray *authSettings = @[@"api_key"];
|
|
|
|
id bodyParam = nil;
|
|
NSMutableDictionary *formParams = [[NSMutableDictionary alloc] init];
|
|
NSMutableDictionary *localVarFiles = [[NSMutableDictionary alloc] init];
|
|
|
|
|
|
|
|
|
|
|
|
return [self.apiClient requestWithPath: resourcePath
|
|
method: @"GET"
|
|
pathParams: pathParams
|
|
queryParams: queryParams
|
|
formParams: formParams
|
|
files: localVarFiles
|
|
body: bodyParam
|
|
headerParams: headerParams
|
|
authSettings: authSettings
|
|
requestContentType: requestContentType
|
|
responseContentType: responseContentType
|
|
responseType: @"NSDictionary* /* NSString, NSNumber */"
|
|
completionBlock: ^(id data, NSError *error) {
|
|
handler((NSDictionary* /* NSString, NSNumber */)data, error);
|
|
}
|
|
];
|
|
}
|
|
|
|
///
|
|
/// Fake endpoint to test arbitrary object return by 'Get inventory'
|
|
/// Returns an arbitrary object which is actually a map of status codes to quantities
|
|
/// @returns NSObject*
|
|
///
|
|
-(NSNumber*) getInventoryInObjectWithCompletionHandler:
|
|
(void (^)(NSObject* output, NSError* error)) handler {
|
|
|
|
|
|
|
|
NSMutableString* resourcePath = [NSMutableString stringWithFormat:@"/store/inventory?response=arbitrary_object"];
|
|
|
|
// remove format in URL if needed
|
|
if ([resourcePath rangeOfString:@".{format}"].location != NSNotFound) {
|
|
[resourcePath replaceCharactersInRange: [resourcePath rangeOfString:@".{format}"] withString:@".json"];
|
|
}
|
|
|
|
NSMutableDictionary *pathParams = [[NSMutableDictionary alloc] init];
|
|
|
|
|
|
NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init];
|
|
|
|
NSMutableDictionary* headerParams = [NSMutableDictionary dictionaryWithDictionary:self.defaultHeaders];
|
|
|
|
|
|
|
|
// HTTP header `Accept`
|
|
headerParams[@"Accept"] = [SWGApiClient selectHeaderAccept:@[@"application/json", @"application/xml"]];
|
|
if ([headerParams[@"Accept"] length] == 0) {
|
|
[headerParams removeObjectForKey:@"Accept"];
|
|
}
|
|
|
|
// response content type
|
|
NSString *responseContentType;
|
|
if ([headerParams objectForKey:@"Accept"]) {
|
|
responseContentType = [headerParams[@"Accept"] componentsSeparatedByString:@", "][0];
|
|
}
|
|
else {
|
|
responseContentType = @"";
|
|
}
|
|
|
|
// request content type
|
|
NSString *requestContentType = [SWGApiClient selectHeaderContentType:@[]];
|
|
|
|
// Authentication setting
|
|
NSArray *authSettings = @[@"api_key"];
|
|
|
|
id bodyParam = nil;
|
|
NSMutableDictionary *formParams = [[NSMutableDictionary alloc] init];
|
|
NSMutableDictionary *localVarFiles = [[NSMutableDictionary alloc] init];
|
|
|
|
|
|
|
|
|
|
|
|
return [self.apiClient requestWithPath: resourcePath
|
|
method: @"GET"
|
|
pathParams: pathParams
|
|
queryParams: queryParams
|
|
formParams: formParams
|
|
files: localVarFiles
|
|
body: bodyParam
|
|
headerParams: headerParams
|
|
authSettings: authSettings
|
|
requestContentType: requestContentType
|
|
responseContentType: responseContentType
|
|
responseType: @"NSObject*"
|
|
completionBlock: ^(id data, NSError *error) {
|
|
handler((NSObject*)data, error);
|
|
}
|
|
];
|
|
}
|
|
|
|
///
|
|
/// Find purchase order by ID
|
|
/// For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions
|
|
/// @param orderId ID of pet that needs to be fetched
|
|
///
|
|
/// @returns SWGOrder*
|
|
///
|
|
-(NSNumber*) getOrderByIdWithOrderId: (NSString*) orderId
|
|
completionHandler: (void (^)(SWGOrder* output, NSError* error)) handler {
|
|
|
|
|
|
// verify the required parameter 'orderId' is set
|
|
if (orderId == nil) {
|
|
[NSException raise:@"Invalid parameter" format:@"Missing the required parameter `orderId` when calling `getOrderById`"];
|
|
}
|
|
|
|
|
|
NSMutableString* resourcePath = [NSMutableString stringWithFormat:@"/store/order/{orderId}"];
|
|
|
|
// remove format in URL if needed
|
|
if ([resourcePath rangeOfString:@".{format}"].location != NSNotFound) {
|
|
[resourcePath replaceCharactersInRange: [resourcePath rangeOfString:@".{format}"] withString:@".json"];
|
|
}
|
|
|
|
NSMutableDictionary *pathParams = [[NSMutableDictionary alloc] init];
|
|
if (orderId != nil) {
|
|
pathParams[@"orderId"] = orderId;
|
|
}
|
|
|
|
|
|
NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init];
|
|
|
|
NSMutableDictionary* headerParams = [NSMutableDictionary dictionaryWithDictionary:self.defaultHeaders];
|
|
|
|
|
|
|
|
// HTTP header `Accept`
|
|
headerParams[@"Accept"] = [SWGApiClient selectHeaderAccept:@[@"application/json", @"application/xml"]];
|
|
if ([headerParams[@"Accept"] length] == 0) {
|
|
[headerParams removeObjectForKey:@"Accept"];
|
|
}
|
|
|
|
// response content type
|
|
NSString *responseContentType;
|
|
if ([headerParams objectForKey:@"Accept"]) {
|
|
responseContentType = [headerParams[@"Accept"] componentsSeparatedByString:@", "][0];
|
|
}
|
|
else {
|
|
responseContentType = @"";
|
|
}
|
|
|
|
// request content type
|
|
NSString *requestContentType = [SWGApiClient selectHeaderContentType:@[]];
|
|
|
|
// Authentication setting
|
|
NSArray *authSettings = @[@"test_api_key_header", @"test_api_key_query"];
|
|
|
|
id bodyParam = nil;
|
|
NSMutableDictionary *formParams = [[NSMutableDictionary alloc] init];
|
|
NSMutableDictionary *localVarFiles = [[NSMutableDictionary alloc] init];
|
|
|
|
|
|
|
|
|
|
|
|
return [self.apiClient requestWithPath: resourcePath
|
|
method: @"GET"
|
|
pathParams: pathParams
|
|
queryParams: queryParams
|
|
formParams: formParams
|
|
files: localVarFiles
|
|
body: bodyParam
|
|
headerParams: headerParams
|
|
authSettings: authSettings
|
|
requestContentType: requestContentType
|
|
responseContentType: responseContentType
|
|
responseType: @"SWGOrder*"
|
|
completionBlock: ^(id data, NSError *error) {
|
|
handler((SWGOrder*)data, error);
|
|
}
|
|
];
|
|
}
|
|
|
|
///
|
|
/// Place an order for a pet
|
|
///
|
|
/// @param body order placed for purchasing the pet (optional)
|
|
///
|
|
/// @returns SWGOrder*
|
|
///
|
|
-(NSNumber*) placeOrderWithBody: (SWGOrder*) body
|
|
completionHandler: (void (^)(SWGOrder* output, NSError* error)) handler {
|
|
|
|
|
|
|
|
NSMutableString* resourcePath = [NSMutableString stringWithFormat:@"/store/order"];
|
|
|
|
// remove format in URL if needed
|
|
if ([resourcePath rangeOfString:@".{format}"].location != NSNotFound) {
|
|
[resourcePath replaceCharactersInRange: [resourcePath rangeOfString:@".{format}"] withString:@".json"];
|
|
}
|
|
|
|
NSMutableDictionary *pathParams = [[NSMutableDictionary alloc] init];
|
|
|
|
|
|
NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init];
|
|
|
|
NSMutableDictionary* headerParams = [NSMutableDictionary dictionaryWithDictionary:self.defaultHeaders];
|
|
|
|
|
|
|
|
// HTTP header `Accept`
|
|
headerParams[@"Accept"] = [SWGApiClient selectHeaderAccept:@[@"application/json", @"application/xml"]];
|
|
if ([headerParams[@"Accept"] length] == 0) {
|
|
[headerParams removeObjectForKey:@"Accept"];
|
|
}
|
|
|
|
// response content type
|
|
NSString *responseContentType;
|
|
if ([headerParams objectForKey:@"Accept"]) {
|
|
responseContentType = [headerParams[@"Accept"] componentsSeparatedByString:@", "][0];
|
|
}
|
|
else {
|
|
responseContentType = @"";
|
|
}
|
|
|
|
// request content type
|
|
NSString *requestContentType = [SWGApiClient selectHeaderContentType:@[]];
|
|
|
|
// Authentication setting
|
|
NSArray *authSettings = @[@"test_api_client_id", @"test_api_client_secret"];
|
|
|
|
id bodyParam = nil;
|
|
NSMutableDictionary *formParams = [[NSMutableDictionary alloc] init];
|
|
NSMutableDictionary *localVarFiles = [[NSMutableDictionary alloc] init];
|
|
|
|
bodyParam = body;
|
|
|
|
|
|
|
|
return [self.apiClient requestWithPath: resourcePath
|
|
method: @"POST"
|
|
pathParams: pathParams
|
|
queryParams: queryParams
|
|
formParams: formParams
|
|
files: localVarFiles
|
|
body: bodyParam
|
|
headerParams: headerParams
|
|
authSettings: authSettings
|
|
requestContentType: requestContentType
|
|
responseContentType: responseContentType
|
|
responseType: @"SWGOrder*"
|
|
completionBlock: ^(id data, NSError *error) {
|
|
handler((SWGOrder*)data, error);
|
|
}
|
|
];
|
|
}
|
|
|
|
|
|
|
|
@end
|