/* tslint:disable */
/* eslint-disable */
/* prettier-ignore */
// @ts-nocheck
// noinspection JSUnusedGlobalSymbols
/* link: https://github.com/OpenAPITools/openapi-generator/blob/master/modules/openapi-generator/src/main/resources/typescript-fetch/apis.mustache */
{{>licenseInfo}}


import * as runtime from '../runtime{{importFileExtension}}';
{{#imports.0}}
import type {
  {{#imports}}
  {{className}},
  {{/imports}}
} from '../models/index{{importFileExtension}}';
{{^withoutRuntimeChecks}}
import {
    {{#imports}}
    {{className}}FromJSON,
    {{className}}ToJSON,
    {{/imports}}
} from '../models/index{{importFileExtension}}';
{{/withoutRuntimeChecks}}
{{/imports.0}}

{{#operations}}
{{#operation}}
{{#allParams.0}}
/**
 * {{&notes}}Request parameters
 */
export interface {{#prefixParameterInterfaces}}{{classname}}{{/prefixParameterInterfaces}}{{operationIdCamelCase}}Request {
{{#allParams}}
/**
```
{{{jsonSchema}}}
```
     * {{#lambda.indented_star_4}}{{{unescapedDescription}}}{{/lambda.indented_star_4}}
     * @type {{#isEnum}}{{{datatypeWithEnum}}}{{/isEnum}}{{^isEnum}}{{{dataType}}}{{#isNullable}} | null{{/isNullable}}{{/isEnum}}
    {{#deprecated}}
     * @deprecated
    {{/deprecated}}
*/
    {{paramName}}{{^required}}?{{/required}}: {{#isEnum}}{{{datatypeWithEnum}}}{{/isEnum}}{{^isEnum}}{{#hasReadOnly}}Omit<{{{dataType}}}, {{#readOnlyVars}}'{{baseName}}'{{^-last}}|{{/-last}}{{/readOnlyVars}}>{{/hasReadOnly}}{{^hasReadOnly}}{{{dataType}}}{{/hasReadOnly}}{{#isNullable}} | null{{/isNullable}}{{/isEnum}};
{{/allParams}}
}

{{/allParams.0}}
{{/operation}}
{{/operations}}
{{#withInterfaces}}
{{#operations}}
/**
 * {{classname}} - interface
 * {{#lambda.indented_1}}{{{unescapedDescription}}}{{/lambda.indented_1}}
 * @export
 * @interface {{classname}}Interface
 */
export interface {{classname}}Interface {
{{#operation}}
    /**
     * Creates request options for {{nickname}} without sending the request
     {{#allParams}}
     * @param {{=<% %>=}}{<%&dataType%>}<%={{ }}=%> {{^required}}[{{/required}}{{paramName}}{{^required}}]{{/required}} {{description}}
     {{/allParams}}
    {{#isDeprecated}}
     * @deprecated
    {{/isDeprecated}}
     * @throws {RequiredError}
     * @memberof {{classname}}Interface
     */
    {{nickname}}RequestOpts({{#allParams.0}}requestParameters: {{#prefixParameterInterfaces}}{{classname}}{{/prefixParameterInterfaces}}{{operationIdCamelCase}}Request{{/allParams.0}}): Promise<runtime.RequestOpts>;

    /**
     * {{&notes}}
     {{#summary}}
     * @summary {{&summary}}
     {{/summary}}
     {{#allParams}}
     * @param {{=<% %>=}}{<%&dataType%>}<%={{ }}=%> {{^required}}[{{/required}}{{paramName}}{{^required}}]{{/required}} {{description}}
     {{/allParams}}
     * @param {*} [options] Override http request option.
    {{#isDeprecated}}
     * @deprecated
    {{/isDeprecated}}
     * @throws {RequiredError}
     * @memberof {{classname}}Interface
     */
    {{nickname}}Raw({{#allParams.0}}requestParameters: {{#prefixParameterInterfaces}}{{classname}}{{/prefixParameterInterfaces}}{{operationIdCamelCase}}Request, {{/allParams.0}}initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<{{{returnType}}}{{^returnType}}void{{/returnType}}>>;

    /**
     {{#notes}}
     * {{&notes}}
     {{/notes}}
     {{#summary}}
     * {{&summary}}
     {{/summary}}
     {{#isDeprecated}}
     * @deprecated
     {{/isDeprecated}}
     */
    {{#hasBodyParam}}
    {{nickname}}({{#allParams}}{{paramName}}{{^required}}?{{/required}}: {{#isEnum}}{{{datatypeWithEnum}}}{{/isEnum}}{{^isEnum}}{{{dataType}}}{{#isNullable}} | null{{/isNullable}}{{/isEnum}}, {{/allParams}}initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<{{{returnType}}}{{#returnType}}{{#isResponseOptional}} | null | undefined {{/isResponseOptional}}{{/returnType}}{{^returnType}}void{{/returnType}}>;
    {{/hasBodyParam}}
    {{^hasBodyParam}}
    {{nickname}}({{#allParams.0}}requestParameters: {{#prefixParameterInterfaces}}{{classname}}{{/prefixParameterInterfaces}}{{operationIdCamelCase}}Request, {{/allParams.0}}initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<{{{returnType}}}{{#returnType}}{{#isResponseOptional}} | null | undefined {{/isResponseOptional}}{{/returnType}}{{^returnType}}void{{/returnType}}>;
    {{/hasBodyParam}}

{{/operation}}
}

{{/operations}}
{{/withInterfaces}}
{{#operations}}
/**
 * {{#lambda.indented_star_1}}{{{unescapedDescription}}}{{/lambda.indented_star_1}}
 */
{{#withInterfaces}}
// @ts-ignore
export class {{classname}} extends runtime.BaseAPI implements {{classname}}Interface {
{{/withInterfaces}}
{{^withInterfaces}}
export class {{classname}} extends runtime.BaseAPI {
{{/withInterfaces}}

    {{#operation}}
    /**
     {{#notes}}
     * {{&notes}}
     {{/notes}}
     {{#summary}}
     * {{&summary}}
     {{/summary}}
     * Creates request options for {{nickname}} without sending the request
      {{#isDeprecated}}
     * @deprecated
     {{/isDeprecated}}
     */
    private async {{nickname}}RequestOpts({{#allParams.0}}requestParameters: {{#prefixParameterInterfaces}}{{classname}}{{/prefixParameterInterfaces}}{{operationIdCamelCase}}Request{{/allParams.0}}): Promise<runtime.RequestOpts> {
        {{#allParams}}
        {{#required}}
        if (requestParameters['{{paramName}}'] == null) {
            throw new runtime.RequiredError(
                '{{paramName}}',
                'Required parameter "{{paramName}}" was null or undefined when calling {{nickname}}().'
            );
        }

        {{/required}}
        {{/allParams}}
        const queryParameters: any = {};

        {{#queryParams}}
        {{#isArray}}
        if (requestParameters['{{paramName}}'] != null) {
            {{#isCollectionFormatMulti}}
            const queryArray = requestParameters['{{paramName}}'].filter(element =>
                element != null && element !== ""
            );
            if (queryArray.length > 0) {
              queryParameters['{{baseName}}'] = queryArray;
            }
            {{/isCollectionFormatMulti}}
            {{^isCollectionFormatMulti}}
            queryParameters['{{baseName}}'] = {{#uniqueItems}}Array.from({{/uniqueItems}}requestParameters['{{paramName}}']{{#uniqueItems}}){{/uniqueItems}}!.join(runtime.COLLECTION_FORMATS["{{collectionFormat}}"]);
            {{/isCollectionFormatMulti}}
        }

        {{/isArray}}
        {{^isArray}}
        if (requestParameters['{{paramName}}'] != null && requestParameters['{{paramName}}'] !== '') {
            {{#isExplode}}
            {{#isContainer}}
            for (let key of Object.keys(requestParameters['{{paramName}}'])) {
                queryParameters[key] = requestParameters['{{paramName}}'][key];
            }
            {{/isContainer}}
            {{^isContainer}}
{{>apisAssignQueryParam}}
            {{/isContainer}}
            {{/isExplode}}
            {{^isExplode}}
{{>apisAssignQueryParam}}
            {{/isExplode}}
        }

        {{/isArray}}
        {{/queryParams}}
        const headerParameters: runtime.HTTPHeaders = {};

        {{#bodyParam}}
        {{^consumes}}
        headerParameters['Content-Type'] = 'application/json';

        {{/consumes}}
        {{#consumes.0}}
        headerParameters['Content-Type'] = '{{{mediaType}}}';

        {{/consumes.0}}
        {{/bodyParam}}
        {{#headerParams}}
        {{#isArray}}
        if (requestParameters['{{paramName}}'] != null) {
            headerParameters['{{baseName}}'] = {{#uniqueItems}}Array.from({{/uniqueItems}}requestParameters['{{paramName}}']{{#uniqueItems}}){{/uniqueItems}}!.join(runtime.COLLECTION_FORMATS["{{collectionFormat}}"]);
        }

        {{/isArray}}
        {{^isArray}}
        if (requestParameters['{{paramName}}'] != null) {
            headerParameters['{{baseName}}'] = String(requestParameters['{{paramName}}']);
        }

        {{/isArray}}
        {{/headerParams}}
        {{#authMethods}}
        {{#isBasic}}
        {{#isBasicBasic}}
        if (this.configuration && (this.configuration.username !== undefined || this.configuration.password !== undefined)) {
            headerParameters["Authorization"] = "Basic " + btoa(this.configuration.username + ":" + this.configuration.password);
        }
        {{/isBasicBasic}}
        {{#isBasicBearer}}
        if (this.configuration && this.configuration.accessToken) {
            const token = this.configuration.accessToken;
            const tokenString = await token("{{name}}", [{{#scopes}}"{{{scope}}}"{{^-last}}, {{/-last}}{{/scopes}}]);

            if (tokenString) {
                headerParameters["Authorization"] = `Bearer ${tokenString}`;
            }
        }
        {{/isBasicBearer}}
        {{/isBasic}}
        {{#isApiKey}}
        {{#isKeyInHeader}}
        if (this.configuration && this.configuration.apiKey) {
            headerParameters["{{keyParamName}}"] = await this.configuration.apiKey("{{keyParamName}}"); // {{name}} authentication
        }

        {{/isKeyInHeader}}
        {{#isKeyInQuery}}
        if (this.configuration && this.configuration.apiKey) {
            queryParameters["{{keyParamName}}"] = await this.configuration.apiKey("{{keyParamName}}"); // {{name}} authentication
        }

        {{/isKeyInQuery}}
        {{/isApiKey}}
        {{#isOAuth}}
        if (this.configuration && this.configuration.accessToken) {
            // oauth required
            headerParameters["Authorization"] = await this.configuration.accessToken("{{name}}", [{{#scopes}}"{{{scope}}}"{{^-last}}, {{/-last}}{{/scopes}}]);
        }

        {{/isOAuth}}
        {{/authMethods}}
        {{#hasFormParams}}
        const consumes: runtime.Consume[] = [
            {{#consumes}}
            { contentType: '{{{mediaType}}}' },
            {{/consumes}}
        ];
        // @ts-ignore: canConsumeForm may be unused
        const canConsumeForm = runtime.canConsumeForm(consumes);

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

        {{#formParams}}
        {{#isArray}}
        if (requestParameters['{{paramName}}'] != null) {
            {{#isCollectionFormatMulti}}
            requestParameters['{{paramName}}'].forEach((element) => {
                formParams.append('{{baseName}}{{#useSquareBracketsInArrayNames}}[]{{/useSquareBracketsInArrayNames}}', element as any);
            })
            {{/isCollectionFormatMulti}}
            {{^isCollectionFormatMulti}}
            formParams.append('{{baseName}}{{#useSquareBracketsInArrayNames}}[]{{/useSquareBracketsInArrayNames}}', {{#uniqueItems}}Array.from({{/uniqueItems}}requestParameters['{{paramName}}']{{#uniqueItems}}){{/uniqueItems}}!.join(runtime.COLLECTION_FORMATS["{{collectionFormat}}"]));
            {{/isCollectionFormatMulti}}
        }

        {{/isArray}}
        {{^isArray}}
        if (requestParameters['{{paramName}}'] != null) {
            {{#isDateTimeType}}
            formParams.append('{{baseName}}', (requestParameters['{{paramName}}'] as any).toISOString());
            {{/isDateTimeType}}
            {{^isDateTimeType}}
            {{#isPrimitiveType}}
            formParams.append('{{baseName}}', requestParameters['{{paramName}}'] as any);
            {{/isPrimitiveType}}
            {{^isPrimitiveType}}
            {{#isEnumRef}}
            formParams.append('{{baseName}}', requestParameters['{{paramName}}'] as any);
            {{/isEnumRef}}
            {{^isEnumRef}}
            {{^withoutRuntimeChecks}}
            formParams.append('{{baseName}}', new Blob([JSON.stringify({{{dataType}}}ToJSON(requestParameters['{{paramName}}']))], { type: "application/json", }));
            {{/withoutRuntimeChecks}}{{#withoutRuntimeChecks}}
            formParams.append('{{baseName}}', new Blob([JSON.stringify(requestParameters['{{paramName}}'])], { type: "application/json", }));
            {{/withoutRuntimeChecks}}
            {{/isEnumRef}}
            {{/isPrimitiveType}}
            {{/isDateTimeType}}
        }

        {{/isArray}}
        {{/formParams}}
        {{/hasFormParams}}

        let urlPath = `{{{path}}}`;
        {{#pathParams}}
        {{#isDateTimeType}}
        if (requestParameters['{{paramName}}'] instanceof Date) {
            urlPath = urlPath.replace(`{${"{{baseName}}"}}`, encodeURIComponent(requestParameters['{{paramName}}'].toISOString()));
        } else {
            urlPath = urlPath.replace(`{${"{{baseName}}"}}`, encodeURIComponent(String(requestParameters['{{paramName}}'])));
        }
        {{/isDateTimeType}}
        {{^isDateTimeType}}
        {{#isDateType}}
        if (requestParameters['{{paramName}}'] instanceof Date) {
            urlPath = urlPath.replace(`{${"{{baseName}}"}}`, encodeURIComponent(requestParameters['{{paramName}}'].toISOString().substring(0,10)));
        } else {
            urlPath = urlPath.replace(`{${"{{baseName}}"}}`, encodeURIComponent(String(requestParameters['{{paramName}}'])));
        }
        {{/isDateType}}
        {{^isDateType}}
        urlPath = urlPath.replace(`{${"{{baseName}}"}}`, encodeURIComponent(String(requestParameters['{{paramName}}'])));
        {{/isDateType}}
        {{/isDateTimeType}}
        {{/pathParams}}

        return {
            path: urlPath,
            method: '{{httpMethod}}',
            headers: headerParameters,
            query: queryParameters,
            {{#hasBodyParam}}
            {{#bodyParam}}
            {{#isContainer}}
            {{^withoutRuntimeChecks}}
            body: requestParameters['{{paramName}}']{{#isArray}}{{#items}}{{^isPrimitiveType}}!.map({{datatype}}ToJSON){{/isPrimitiveType}}{{/items}}{{/isArray}},
            {{/withoutRuntimeChecks}}
            {{#withoutRuntimeChecks}}
            body: requestParameters['{{paramName}}'],
            {{/withoutRuntimeChecks}}
            {{/isContainer}}
            {{^isContainer}}
            {{^isPrimitiveType}}
            {{^withoutRuntimeChecks}}
            body: {{dataType}}ToJSON(requestParameters['{{paramName}}']),
            {{/withoutRuntimeChecks}}
            {{#withoutRuntimeChecks}}
            body: requestParameters['{{paramName}}'],
            {{/withoutRuntimeChecks}}
            {{/isPrimitiveType}}
            {{#isPrimitiveType}}
            body: requestParameters['{{paramName}}'] as any,
            {{/isPrimitiveType}}
            {{/isContainer}}
            {{/bodyParam}}
            {{/hasBodyParam}}
            {{#hasFormParams}}
            body: formParams,
            {{/hasFormParams}}
        };
    }

    /**
     {{#notes}}
     * {{&notes}}
     {{/notes}}
     {{#summary}}
     * {{&summary}}
     {{/summary}}
     {{#isDeprecated}}
     * @deprecated
     {{/isDeprecated}}
     */
    private async {{nickname}}Raw({{#allParams.0}}requestParameters: {{#prefixParameterInterfaces}}{{classname}}{{/prefixParameterInterfaces}}{{operationIdCamelCase}}Request, {{/allParams.0}}initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<{{{returnType}}}{{^returnType}}void{{/returnType}}>> {
        const requestOptions = await this.{{nickname}}RequestOpts({{#allParams.0}}requestParameters{{/allParams.0}});
        const response = await this.request(requestOptions, initOverrides);

        {{#returnType}}
        {{#isResponseFile}}
        return new runtime.BlobApiResponse(response);
        {{/isResponseFile}}
        {{^isResponseFile}}
        {{#returnTypeIsPrimitive}}
        {{#isMap}}
        return new runtime.JSONApiResponse<any>(response);
        {{/isMap}}
        {{#isArray}}
        return new runtime.JSONApiResponse<any>(response);
        {{/isArray}}
        {{#returnSimpleType}}
        if (this.isJsonMime(response.headers.get('content-type'))) {
            return new runtime.JSONApiResponse<{{returnType}}>(response);
        } else {
            return new runtime.TextApiResponse(response) as any;
        }
        {{/returnSimpleType}}
        {{/returnTypeIsPrimitive}}
        {{^returnTypeIsPrimitive}}
        {{#isArray}}
        // return new runtime.JSONApiResponse(response{{^withoutRuntimeChecks}}, (jsonValue) => {{#uniqueItems}}new Set({{/uniqueItems}}jsonValue.map({{returnBaseType}}FromJSON){{/withoutRuntimeChecks}}){{#uniqueItems}}){{/uniqueItems}};
        return new runtime.JSONApiResponse(response{{^withoutRuntimeChecks}}, (jsonValue) => {{#uniqueItems}}new Set({{/uniqueItems}}jsonValue{{/withoutRuntimeChecks}}){{#uniqueItems}}){{/uniqueItems}};
        {{/isArray}}
        {{^isArray}}
        {{#isMap}}
        // return new runtime.JSONApiResponse(response{{^withoutRuntimeChecks}}, (jsonValue) => runtime.mapValues(jsonValue, {{returnBaseType}}FromJSON){{/withoutRuntimeChecks}});
        return new runtime.JSONApiResponse(response{{^withoutRuntimeChecks}}, (jsonValue) => runtime{{/withoutRuntimeChecks}});
        {{/isMap}}
        {{^isMap}}
        // return new runtime.JSONApiResponse(response{{^withoutRuntimeChecks}}, (jsonValue) => {{returnBaseType}}FromJSON(jsonValue){{/withoutRuntimeChecks}});
        return new runtime.JSONApiResponse(response{{^withoutRuntimeChecks}}, (jsonValue) => jsonValue{{/withoutRuntimeChecks}});
        {{/isMap}}
        {{/isArray}}
        {{/returnTypeIsPrimitive}}
        {{/isResponseFile}}
        {{/returnType}}
        {{^returnType}}
        return new runtime.VoidApiResponse(response);
        {{/returnType}}
    }

    /**
     {{#notes}}
     * {{&notes}}
     {{/notes}}
     {{#summary}}
     * {{&summary}}
     {{/summary}}
     {{#isDeprecated}}
     * @deprecated
     {{/isDeprecated}}
     */
    {{#hasBodyParam}}
    async {{nickname}}({{#allParams}}{{paramName}}{{^required}}?{{/required}}: {{#isEnum}}{{{datatypeWithEnum}}}{{/isEnum}}{{^isEnum}}{{{dataType}}}{{#isNullable}} | null{{/isNullable}}{{/isEnum}}, {{/allParams}}initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<{{{returnType}}}{{#returnType}}{{#isResponseOptional}} | null | undefined {{/isResponseOptional}}{{/returnType}}{{^returnType}}void{{/returnType}}> {
        {{#returnType}}
        const response = await this.{{nickname}}Raw({{#allParams.0}}{ {{#allParams}}{{paramName}}: {{paramName}}{{^-last}}, {{/-last}}{{/allParams}} }, {{/allParams.0}}initOverrides);
        {{#isResponseOptional}}
        switch (response.raw.status) {
            {{#responses}}
            {{#is2xx}}
            case {{code}}:
                return {{#dataType}}await response.value(){{/dataType}}{{^dataType}}null{{/dataType}};
            {{/is2xx}}
            {{/responses}}
            default:
                return await response.value();
        }
        {{/isResponseOptional}}
        {{^isResponseOptional}}
        return await response.value();
        {{/isResponseOptional}}
        {{/returnType}}
        {{^returnType}}
        await this.{{nickname}}Raw({{#allParams.0}}{ {{#allParams}}{{paramName}}: {{paramName}}{{^-last}}, {{/-last}}{{/allParams}} }, {{/allParams.0}}initOverrides);
        {{/returnType}}
    }
    {{/hasBodyParam}}
    {{^hasBodyParam}}
    async {{nickname}}({{#allParams.0}}requestParameters: {{#prefixParameterInterfaces}}{{classname}}{{/prefixParameterInterfaces}}{{operationIdCamelCase}}Request{{^hasRequiredParams}} = {}{{/hasRequiredParams}}, {{/allParams.0}}initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<{{{returnType}}}{{#returnType}}{{#isResponseOptional}} | null | undefined {{/isResponseOptional}}{{/returnType}}{{^returnType}}void{{/returnType}}> {
        {{#returnType}}
        const response = await this.{{nickname}}Raw({{#allParams.0}}requestParameters, {{/allParams.0}}initOverrides);
        {{#isResponseOptional}}
        switch (response.raw.status) {
            {{#responses}}
            {{#is2xx}}
            case {{code}}:
                return {{#dataType}}await response.value(){{/dataType}}{{^dataType}}null{{/dataType}};
            {{/is2xx}}
            {{/responses}}
            default:
                return await response.value();
        }
        {{/isResponseOptional}}
        {{^isResponseOptional}}
        return await response.value();
        {{/isResponseOptional}}
        {{/returnType}}
        {{^returnType}}
        await this.{{nickname}}Raw({{#allParams.0}}requestParameters, {{/allParams.0}}initOverrides);
        {{/returnType}}
    }
    {{/hasBodyParam}}

    {{/operation}}
}
{{/operations}}
{{#hasEnums}}

{{#operations}}
{{#operation}}
{{#allParams}}
{{#isEnum}}
{{#stringEnums}}
/**
  * @export
  * @enum {string}
  */
export enum {{operationIdCamelCase}}{{enumName}} {
{{#allowableValues}}
    {{#enumVars}}
    {{{name}}} = {{{value}}}{{^-last}},{{/-last}}
    {{/enumVars}}
{{/allowableValues}}
}
{{/stringEnums}}
{{^stringEnums}}
/**
 * {{{unescapedDescription}}}
 * @export
 */
export const {{operationIdCamelCase}}{{enumName}}Const = {
{{#allowableValues}}
    {{#enumVars}}
    {{{name}}}: {{{value}}}{{^-last}},{{/-last}}
    {{/enumVars}}
{{/allowableValues}}
} as const;
export type {{operationIdCamelCase}}{{enumName}} = typeof {{operationIdCamelCase}}{{enumName}}Const[keyof typeof {{operationIdCamelCase}}{{enumName}}Const];
{{/stringEnums}}
{{/isEnum}}
{{/allParams}}
{{/operation}}
{{/operations}}
{{/hasEnums}}
