/* tslint:disable */
/* eslint-disable */
/**
 * Vitron API
 * API documentation for Vitron backend
 *
 * The version of the OpenAPI document: v1
 * Contact: support@yourcompany.com
 *
 * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
 * https://openapi-generator.tech
 * Do not edit the class manually.
 */


import * as runtime from '../runtime';
import type {
  ProductTryOnRequestCreate,
} from '../models';

export interface ApiAifitV1TryOnProductCreateRequest {
    productId: string;
    image: Blob;
}

/**
 * 
 */
export class AIFitApi extends runtime.BaseAPI {

    /**
     * AI virtual try-on (product)
     */
    async apiAifitV1TryOnProductCreateRaw(requestParameters: ApiAifitV1TryOnProductCreateRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<ProductTryOnRequestCreate>> {
        if (requestParameters.productId === null || requestParameters.productId === undefined) {
            throw new runtime.RequiredError('productId','Required parameter requestParameters.productId was null or undefined when calling apiAifitV1TryOnProductCreate.');
        }

        if (requestParameters.image === null || requestParameters.image === undefined) {
            throw new runtime.RequiredError('image','Required parameter requestParameters.image was null or undefined when calling apiAifitV1TryOnProductCreate.');
        }

        const queryParameters: any = {};

        const headerParameters: runtime.HTTPHeaders = {};

        if (this.configuration && (this.configuration.username !== undefined || this.configuration.password !== undefined)) {
            headerParameters["Authorization"] = "Basic " + btoa(this.configuration.username + ":" + this.configuration.password);
        }
        const consumes: runtime.Consume[] = [
            { contentType: 'multipart/form-data' },
        ];
        // @ts-ignore: canConsumeForm may be unused
        const canConsumeForm = runtime.canConsumeForm(consumes);

        let formParams: { append(param: string, value: any): any };
        let useForm = false;
        // use FormData to transmit files using content-type "multipart/form-data"
        useForm = canConsumeForm;
        if (useForm) {
            formParams = new FormData();
        } else {
            formParams = new URLSearchParams();
        }

        if (requestParameters.productId !== undefined) {
            formParams.append('product_id', requestParameters.productId as any);
        }

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

        const response = await this.request({
            path: `/api/aifit/v1/try-on/product/`,
            method: 'POST',
            headers: headerParameters,
            query: queryParameters,
            body: formParams,
        }, initOverrides);

        return new runtime.JSONApiResponse(response);
    }

    /**
     * AI virtual try-on (product)
     */
    async apiAifitV1TryOnProductCreate(requestParameters: ApiAifitV1TryOnProductCreateRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<ProductTryOnRequestCreate> {
        const response = await this.apiAifitV1TryOnProductCreateRaw(requestParameters, initOverrides);
        return await response.value();
    }

}
