#import "SWGPetApi.h" #import "SWGQueryParamCollection.h" #import "SWGPet.h" #import "SWGInlineResponse200.h" @interface SWGPetApi () @property (readwrite, nonatomic, strong) NSMutableDictionary *defaultHeaders; @end @implementation SWGPetApi static SWGPetApi* 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 - +(SWGPetApi*) apiWithHeader:(NSString*)headerValue key:(NSString*)key { if (singletonAPI == nil) { singletonAPI = [[SWGPetApi alloc] init]; [singletonAPI addHeader:headerValue forKey:key]; } return singletonAPI; } +(SWGPetApi*) sharedAPI { if (singletonAPI == nil) { singletonAPI = [[SWGPetApi 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 /// /// Add a new pet to the store /// /// @param body Pet object that needs to be added to the store (optional) /// /// @returns void /// -(NSNumber*) addPetWithBody: (SWGPet*) body completionHandler: (void (^)(NSError* error)) handler { NSMutableString* resourcePath = [NSMutableString stringWithFormat:@"/pet"]; // 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:@[@"application/json", @"application/xml"]]; // Authentication setting NSArray *authSettings = @[@"petstore_auth"]; 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: nil completionBlock: ^(id data, NSError *error) { handler(error); } ]; } /// /// Fake endpoint to test byte array in body parameter for adding a new pet to the store /// /// @param body Pet object in the form of byte array (optional) /// /// @returns void /// -(NSNumber*) addPetUsingByteArrayWithBody: (NSString*) body completionHandler: (void (^)(NSError* error)) handler { NSMutableString* resourcePath = [NSMutableString stringWithFormat:@"/pet?testing_byte_array=true"]; // 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:@[@"application/json", @"application/xml"]]; // Authentication setting NSArray *authSettings = @[@"petstore_auth"]; 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: nil completionBlock: ^(id data, NSError *error) { handler(error); } ]; } /// /// Deletes a pet /// /// @param petId Pet id to delete /// /// @param apiKey (optional) /// /// @returns void /// -(NSNumber*) deletePetWithPetId: (NSNumber*) petId apiKey: (NSString*) apiKey completionHandler: (void (^)(NSError* error)) handler { // verify the required parameter 'petId' is set if (petId == nil) { [NSException raise:@"Invalid parameter" format:@"Missing the required parameter `petId` when calling `deletePet`"]; } NSMutableString* resourcePath = [NSMutableString stringWithFormat:@"/pet/{petId}"]; // 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 (petId != nil) { pathParams[@"petId"] = petId; } NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init]; NSMutableDictionary* headerParams = [NSMutableDictionary dictionaryWithDictionary:self.defaultHeaders]; if (apiKey != nil) { headerParams[@"api_key"] = apiKey; } // 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 = @[@"petstore_auth"]; 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 Pets by status /// Multiple status values can be provided with comma separated strings /// @param status Status values that need to be considered for query (optional, default to available) /// /// @returns NSArray* /// -(NSNumber*) findPetsByStatusWithStatus: (NSArray* /* NSString */) status completionHandler: (void (^)(NSArray* output, NSError* error)) handler { NSMutableString* resourcePath = [NSMutableString stringWithFormat:@"/pet/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"] = [[SWGQueryParamCollection alloc] initWithValuesAndFormat: status format: @"multi"]; } 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 = @[@"petstore_auth"]; 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*" completionBlock: ^(id data, NSError *error) { handler((NSArray*)data, error); } ]; } /// /// Finds Pets by tags /// Muliple tags can be provided with comma seperated strings. Use tag1, tag2, tag3 for testing. /// @param tags Tags to filter by (optional) /// /// @returns NSArray* /// -(NSNumber*) findPetsByTagsWithTags: (NSArray* /* NSString */) tags completionHandler: (void (^)(NSArray* output, NSError* error)) handler { NSMutableString* resourcePath = [NSMutableString stringWithFormat:@"/pet/findByTags"]; // 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 (tags != nil) { queryParams[@"tags"] = [[SWGQueryParamCollection alloc] initWithValuesAndFormat: tags format: @"multi"]; } 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 = @[@"petstore_auth"]; 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*" completionBlock: ^(id data, NSError *error) { handler((NSArray*)data, error); } ]; } /// /// Find pet by ID /// Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions /// @param petId ID of pet that needs to be fetched /// /// @returns SWGPet* /// -(NSNumber*) getPetByIdWithPetId: (NSNumber*) petId completionHandler: (void (^)(SWGPet* output, NSError* error)) handler { // verify the required parameter 'petId' is set if (petId == nil) { [NSException raise:@"Invalid parameter" format:@"Missing the required parameter `petId` when calling `getPetById`"]; } NSMutableString* resourcePath = [NSMutableString stringWithFormat:@"/pet/{petId}"]; // 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 (petId != nil) { pathParams[@"petId"] = petId; } 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", @"petstore_auth"]; 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: @"SWGPet*" completionBlock: ^(id data, NSError *error) { handler((SWGPet*)data, error); } ]; } /// /// Fake endpoint to test inline arbitrary object return by 'Find pet by ID' /// Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions /// @param petId ID of pet that needs to be fetched /// /// @returns SWGInlineResponse200* /// -(NSNumber*) getPetByIdInObjectWithPetId: (NSNumber*) petId completionHandler: (void (^)(SWGInlineResponse200* output, NSError* error)) handler { // verify the required parameter 'petId' is set if (petId == nil) { [NSException raise:@"Invalid parameter" format:@"Missing the required parameter `petId` when calling `getPetByIdInObject`"]; } NSMutableString* resourcePath = [NSMutableString stringWithFormat:@"/pet/{petId}?response=inline_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]; if (petId != nil) { pathParams[@"petId"] = petId; } 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", @"petstore_auth"]; 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: @"SWGInlineResponse200*" completionBlock: ^(id data, NSError *error) { handler((SWGInlineResponse200*)data, error); } ]; } /// /// Fake endpoint to test byte array return by 'Find pet by ID' /// Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions /// @param petId ID of pet that needs to be fetched /// /// @returns NSString* /// -(NSNumber*) petPetIdtestingByteArraytrueGetWithPetId: (NSNumber*) petId completionHandler: (void (^)(NSString* output, NSError* error)) handler { // verify the required parameter 'petId' is set if (petId == nil) { [NSException raise:@"Invalid parameter" format:@"Missing the required parameter `petId` when calling `petPetIdtestingByteArraytrueGet`"]; } NSMutableString* resourcePath = [NSMutableString stringWithFormat:@"/pet/{petId}?testing_byte_array=true"]; // 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 (petId != nil) { pathParams[@"petId"] = petId; } 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", @"petstore_auth"]; 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: @"NSString*" completionBlock: ^(id data, NSError *error) { handler((NSString*)data, error); } ]; } /// /// Update an existing pet /// /// @param body Pet object that needs to be added to the store (optional) /// /// @returns void /// -(NSNumber*) updatePetWithBody: (SWGPet*) body completionHandler: (void (^)(NSError* error)) handler { NSMutableString* resourcePath = [NSMutableString stringWithFormat:@"/pet"]; // 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:@[@"application/json", @"application/xml"]]; // Authentication setting NSArray *authSettings = @[@"petstore_auth"]; id bodyParam = nil; NSMutableDictionary *formParams = [[NSMutableDictionary alloc] init]; NSMutableDictionary *localVarFiles = [[NSMutableDictionary alloc] init]; bodyParam = body; return [self.apiClient requestWithPath: resourcePath method: @"PUT" 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); } ]; } /// /// 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 (optional) /// /// @param status Updated status of the pet (optional) /// /// @returns void /// -(NSNumber*) updatePetWithFormWithPetId: (NSString*) petId name: (NSString*) name status: (NSString*) status completionHandler: (void (^)(NSError* error)) handler { // verify the required parameter 'petId' is set if (petId == nil) { [NSException raise:@"Invalid parameter" format:@"Missing the required parameter `petId` when calling `updatePetWithForm`"]; } NSMutableString* resourcePath = [NSMutableString stringWithFormat:@"/pet/{petId}"]; // 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 (petId != nil) { pathParams[@"petId"] = petId; } 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:@[@"application/x-www-form-urlencoded"]]; // Authentication setting NSArray *authSettings = @[@"petstore_auth"]; id bodyParam = nil; NSMutableDictionary *formParams = [[NSMutableDictionary alloc] init]; NSMutableDictionary *localVarFiles = [[NSMutableDictionary alloc] init]; if (name) { formParams[@"name"] = name; } if (status) { formParams[@"status"] = status; } 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: nil completionBlock: ^(id data, NSError *error) { handler(error); } ]; } /// /// uploads an image /// /// @param petId ID of pet to update /// /// @param additionalMetadata Additional data to pass to server (optional) /// /// @param file file to upload (optional) /// /// @returns void /// -(NSNumber*) uploadFileWithPetId: (NSNumber*) petId additionalMetadata: (NSString*) additionalMetadata file: (NSURL*) file completionHandler: (void (^)(NSError* error)) handler { // verify the required parameter 'petId' is set if (petId == nil) { [NSException raise:@"Invalid parameter" format:@"Missing the required parameter `petId` when calling `uploadFile`"]; } NSMutableString* resourcePath = [NSMutableString stringWithFormat:@"/pet/{petId}/uploadImage"]; // 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 (petId != nil) { pathParams[@"petId"] = petId; } 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:@[@"multipart/form-data"]]; // Authentication setting NSArray *authSettings = @[@"petstore_auth"]; id bodyParam = nil; NSMutableDictionary *formParams = [[NSMutableDictionary alloc] init]; NSMutableDictionary *localVarFiles = [[NSMutableDictionary alloc] init]; if (additionalMetadata) { formParams[@"additionalMetadata"] = additionalMetadata; } localVarFiles[@"file"] = file; 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: nil completionBlock: ^(id data, NSError *error) { handler(error); } ]; } @end