// tslint:disable
/**
 * OpenAPI Petstore
 * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
 *
 * OpenAPI spec version: 1.0.0
 * 
 *
 * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
 * https://openapi-generator.tech
 * Do not edit the class manually.
 */

import { Observable } from 'rxjs';
import { BaseAPI, RequiredError, HttpHeaders, HttpQuery, COLLECTION_FORMATS } from '../runtime';
import {
    ApiResponse,
    Pet,
} from '../models';

export interface AddPetRequest {
    body: Pet;
}

export interface DeletePetRequest {
    petId: number;
    apiKey?: string;
}

export interface FindPetsByStatusRequest {
    status: Array<FindPetsByStatusStatusEnum>;
}

export interface FindPetsByTagsRequest {
    tags: Array<string>;
}

export interface GetPetByIdRequest {
    petId: number;
}

export interface UpdatePetRequest {
    body: Pet;
}

export interface UpdatePetWithFormRequest {
    petId: number;
    name?: string;
    status?: string;
}

export interface UploadFileRequest {
    petId: number;
    additionalMetadata?: string;
    file?: Blob;
}

/**
 * no description
 */
export class PetApi extends BaseAPI {

    /**
     * Add a new pet to the store
     */
    addPetRaw(requestParameters: AddPetRequest): Observable<void> {
        if (requestParameters.body === null || requestParameters.body === undefined) {
            throw new RequiredError('body','Required parameter requestParameters.body was null or undefined when calling addPet.');
        }

        const queryParameters: HttpQuery = {};

        const headerParameters: HttpHeaders = {};

        headerParameters['Content-Type'] = 'application/json';

        if (this.configuration && this.configuration.accessToken) {
            // oauth required
            if (typeof this.configuration.accessToken === 'function') {
                headerParameters["Authorization"] = this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]);
            } else {
                headerParameters["Authorization"] = this.configuration.accessToken;
            }
        }

        return this.request<void>({
            path: `/pet`,
            method: 'POST',
            headers: headerParameters,
            query: queryParameters,
            body: requestParameters.body,
        });
    }

    /**
     * Add a new pet to the store
     */
    addPet(requestParameters: AddPetRequest): Observable<void> {
        return this.addPetRaw(requestParameters);
    }

    /**
     * Deletes a pet
     */
    deletePetRaw(requestParameters: DeletePetRequest): Observable<void> {
        if (requestParameters.petId === null || requestParameters.petId === undefined) {
            throw new RequiredError('petId','Required parameter requestParameters.petId was null or undefined when calling deletePet.');
        }

        const queryParameters: HttpQuery = {};

        const headerParameters: HttpHeaders = {};

        if (requestParameters.apiKey !== undefined && requestParameters.apiKey !== null) {
            headerParameters['api_key'] = String(requestParameters.apiKey);
        }

        if (this.configuration && this.configuration.accessToken) {
            // oauth required
            if (typeof this.configuration.accessToken === 'function') {
                headerParameters["Authorization"] = this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]);
            } else {
                headerParameters["Authorization"] = this.configuration.accessToken;
            }
        }

        return this.request<void>({
            path: `/pet/{petId}`.replace(`{${"petId"}}`, encodeURIComponent(String(requestParameters.petId))),
            method: 'DELETE',
            headers: headerParameters,
            query: queryParameters,
        });
    }

    /**
     * Deletes a pet
     */
    deletePet(requestParameters: DeletePetRequest): Observable<void> {
        return this.deletePetRaw(requestParameters);
    }

    /**
     * Multiple status values can be provided with comma separated strings
     * Finds Pets by status
     */
    findPetsByStatusRaw(requestParameters: FindPetsByStatusRequest): Observable<Array<Pet>> {
        if (requestParameters.status === null || requestParameters.status === undefined) {
            throw new RequiredError('status','Required parameter requestParameters.status was null or undefined when calling findPetsByStatus.');
        }

        const queryParameters: HttpQuery = {};

        if (requestParameters.status) {
            queryParameters['status'] = requestParameters.status.join(COLLECTION_FORMATS["csv"]);
        }

        const headerParameters: HttpHeaders = {};

        if (this.configuration && this.configuration.accessToken) {
            // oauth required
            if (typeof this.configuration.accessToken === 'function') {
                headerParameters["Authorization"] = this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]);
            } else {
                headerParameters["Authorization"] = this.configuration.accessToken;
            }
        }

        return this.request<Array<Pet>>({
            path: `/pet/findByStatus`,
            method: 'GET',
            headers: headerParameters,
            query: queryParameters,
        });
    }

    /**
     * Multiple status values can be provided with comma separated strings
     * Finds Pets by status
     */
    findPetsByStatus(requestParameters: FindPetsByStatusRequest): Observable<Array<Pet>> {
        return this.findPetsByStatusRaw(requestParameters);
    }

    /**
     * Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
     * Finds Pets by tags
     */
    findPetsByTagsRaw(requestParameters: FindPetsByTagsRequest): Observable<Array<Pet>> {
        if (requestParameters.tags === null || requestParameters.tags === undefined) {
            throw new RequiredError('tags','Required parameter requestParameters.tags was null or undefined when calling findPetsByTags.');
        }

        const queryParameters: HttpQuery = {};

        if (requestParameters.tags) {
            queryParameters['tags'] = requestParameters.tags.join(COLLECTION_FORMATS["csv"]);
        }

        const headerParameters: HttpHeaders = {};

        if (this.configuration && this.configuration.accessToken) {
            // oauth required
            if (typeof this.configuration.accessToken === 'function') {
                headerParameters["Authorization"] = this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]);
            } else {
                headerParameters["Authorization"] = this.configuration.accessToken;
            }
        }

        return this.request<Array<Pet>>({
            path: `/pet/findByTags`,
            method: 'GET',
            headers: headerParameters,
            query: queryParameters,
        });
    }

    /**
     * Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
     * Finds Pets by tags
     */
    findPetsByTags(requestParameters: FindPetsByTagsRequest): Observable<Array<Pet>> {
        return this.findPetsByTagsRaw(requestParameters);
    }

    /**
     * Returns a single pet
     * Find pet by ID
     */
    getPetByIdRaw(requestParameters: GetPetByIdRequest): Observable<Pet> {
        if (requestParameters.petId === null || requestParameters.petId === undefined) {
            throw new RequiredError('petId','Required parameter requestParameters.petId was null or undefined when calling getPetById.');
        }

        const queryParameters: HttpQuery = {};

        const headerParameters: HttpHeaders = {};

        if (this.configuration && this.configuration.apiKey) {
            headerParameters["api_key"] = this.configuration.apiKey("api_key"); // api_key authentication
        }

        return this.request<Pet>({
            path: `/pet/{petId}`.replace(`{${"petId"}}`, encodeURIComponent(String(requestParameters.petId))),
            method: 'GET',
            headers: headerParameters,
            query: queryParameters,
        });
    }

    /**
     * Returns a single pet
     * Find pet by ID
     */
    getPetById(requestParameters: GetPetByIdRequest): Observable<Pet> {
        return this.getPetByIdRaw(requestParameters);
    }

    /**
     * Update an existing pet
     */
    updatePetRaw(requestParameters: UpdatePetRequest): Observable<void> {
        if (requestParameters.body === null || requestParameters.body === undefined) {
            throw new RequiredError('body','Required parameter requestParameters.body was null or undefined when calling updatePet.');
        }

        const queryParameters: HttpQuery = {};

        const headerParameters: HttpHeaders = {};

        headerParameters['Content-Type'] = 'application/json';

        if (this.configuration && this.configuration.accessToken) {
            // oauth required
            if (typeof this.configuration.accessToken === 'function') {
                headerParameters["Authorization"] = this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]);
            } else {
                headerParameters["Authorization"] = this.configuration.accessToken;
            }
        }

        return this.request<void>({
            path: `/pet`,
            method: 'PUT',
            headers: headerParameters,
            query: queryParameters,
            body: requestParameters.body,
        });
    }

    /**
     * Update an existing pet
     */
    updatePet(requestParameters: UpdatePetRequest): Observable<void> {
        return this.updatePetRaw(requestParameters);
    }

    /**
     * Updates a pet in the store with form data
     */
    updatePetWithFormRaw(requestParameters: UpdatePetWithFormRequest): Observable<void> {
        if (requestParameters.petId === null || requestParameters.petId === undefined) {
            throw new RequiredError('petId','Required parameter requestParameters.petId was null or undefined when calling updatePetWithForm.');
        }

        const queryParameters: HttpQuery = {};

        const headerParameters: HttpHeaders = {};

        if (this.configuration && this.configuration.accessToken) {
            // oauth required
            if (typeof this.configuration.accessToken === 'function') {
                headerParameters["Authorization"] = this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]);
            } else {
                headerParameters["Authorization"] = this.configuration.accessToken;
            }
        }

        const formData = new FormData();
        if (requestParameters.name !== undefined) {
            formData.append('name', requestParameters.name as any);
        }

        if (requestParameters.status !== undefined) {
            formData.append('status', requestParameters.status as any);
        }

        return this.request<void>({
            path: `/pet/{petId}`.replace(`{${"petId"}}`, encodeURIComponent(String(requestParameters.petId))),
            method: 'POST',
            headers: headerParameters,
            query: queryParameters,
            body: formData,
        });
    }

    /**
     * Updates a pet in the store with form data
     */
    updatePetWithForm(requestParameters: UpdatePetWithFormRequest): Observable<void> {
        return this.updatePetWithFormRaw(requestParameters);
    }

    /**
     * uploads an image
     */
    uploadFileRaw(requestParameters: UploadFileRequest): Observable<ApiResponse> {
        if (requestParameters.petId === null || requestParameters.petId === undefined) {
            throw new RequiredError('petId','Required parameter requestParameters.petId was null or undefined when calling uploadFile.');
        }

        const queryParameters: HttpQuery = {};

        const headerParameters: HttpHeaders = {};

        if (this.configuration && this.configuration.accessToken) {
            // oauth required
            if (typeof this.configuration.accessToken === 'function') {
                headerParameters["Authorization"] = this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]);
            } else {
                headerParameters["Authorization"] = this.configuration.accessToken;
            }
        }

        const formData = new FormData();
        if (requestParameters.additionalMetadata !== undefined) {
            formData.append('additionalMetadata', requestParameters.additionalMetadata as any);
        }

        if (requestParameters.file !== undefined) {
            formData.append('file', requestParameters.file as any);
        }

        return this.request<ApiResponse>({
            path: `/pet/{petId}/uploadImage`.replace(`{${"petId"}}`, encodeURIComponent(String(requestParameters.petId))),
            method: 'POST',
            headers: headerParameters,
            query: queryParameters,
            body: formData,
        });
    }

    /**
     * uploads an image
     */
    uploadFile(requestParameters: UploadFileRequest): Observable<ApiResponse> {
        return this.uploadFileRaw(requestParameters);
    }

}

/**
    * @export
    * @enum {string}
    */
export enum FindPetsByStatusStatusEnum {
    Available = 'available',
    Pending = 'pending',
    Sold = 'sold'
}
