/* tslint:disable */
/* eslint-disable */
/**
 * ShipStation API v2
 * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
 *
 * The version of the OpenAPI document: 2.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 type { Configuration } from '../configuration';
import type { AxiosPromise, AxiosInstance, RawAxiosRequestConfig } from 'axios';
import globalAxios from 'axios';
// Some imports not used depending on template conditions
// @ts-ignore
import { DUMMY_BASE_URL, assertParamExists, setApiKeyToObject, setBasicAuthToObject, setBearerAuthToObject, setOAuthToObject, setSearchParams, serializeDataIfNeeded, toPathString, createRequestFunction } from '../common';
// @ts-ignore
import { BASE_PATH, COLLECTION_FORMATS, type RequestArgs, BaseAPI, RequiredError, operationServerMap } from '../base';
// @ts-ignore
import type { ErrorResponseBody } from '../models';
/**
 * DownloadsApi - axios parameter creator
 * @export
 */
export const DownloadsApiAxiosParamCreator = function (configuration?: Configuration) {
    return {
        /**
         * Download labels and other shipment-related documents.
         * @summary Download file
         * @param {string} subdir 
         * @param {string} filename 
         * @param {string} dir 
         * @param {string} [download] 
         * @param {number} [rotation] 
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        downloadFile: async (subdir: string, filename: string, dir: string, download?: string, rotation?: number, options: RawAxiosRequestConfig = {}): Promise<RequestArgs> => {
            // verify required parameter 'subdir' is not null or undefined
            assertParamExists('downloadFile', 'subdir', subdir)
            // verify required parameter 'filename' is not null or undefined
            assertParamExists('downloadFile', 'filename', filename)
            // verify required parameter 'dir' is not null or undefined
            assertParamExists('downloadFile', 'dir', dir)
            const localVarPath = `/v2/downloads/{dir}/{subdir}/{filename}`
                .replace(`{${"subdir"}}`, encodeURIComponent(String(subdir)))
                .replace(`{${"filename"}}`, encodeURIComponent(String(filename)))
                .replace(`{${"dir"}}`, encodeURIComponent(String(dir)));
            // use dummy base URL string because the URL constructor only accepts absolute URLs.
            const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
            let baseOptions;
            if (configuration) {
                baseOptions = configuration.baseOptions;
            }

            const localVarRequestOptions = { method: 'GET', ...baseOptions, ...options};
            const localVarHeaderParameter = {} as any;
            const localVarQueryParameter = {} as any;

            // authentication api_keys required
            await setApiKeyToObject(localVarHeaderParameter, "api-key", configuration)

            if (download !== undefined) {
                localVarQueryParameter['download'] = download;
            }

            if (rotation !== undefined) {
                localVarQueryParameter['rotation'] = rotation;
            }


    
            setSearchParams(localVarUrlObj, localVarQueryParameter);
            let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
            localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers};

            return {
                url: toPathString(localVarUrlObj),
                options: localVarRequestOptions,
            };
        },
    }
};

/**
 * DownloadsApi - functional programming interface
 * @export
 */
export const DownloadsApiFp = function(configuration?: Configuration) {
    const localVarAxiosParamCreator = DownloadsApiAxiosParamCreator(configuration)
    return {
        /**
         * Download labels and other shipment-related documents.
         * @summary Download file
         * @param {string} subdir 
         * @param {string} filename 
         * @param {string} dir 
         * @param {string} [download] 
         * @param {number} [rotation] 
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        async downloadFile(subdir: string, filename: string, dir: string, download?: string, rotation?: number, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<File>> {
            const localVarAxiosArgs = await localVarAxiosParamCreator.downloadFile(subdir, filename, dir, download, rotation, options);
            const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
            const localVarOperationServerBasePath = operationServerMap['DownloadsApi.downloadFile']?.[localVarOperationServerIndex]?.url;
            return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
        },
    }
};

/**
 * DownloadsApi - factory interface
 * @export
 */
export const DownloadsApiFactory = function (configuration?: Configuration, basePath?: string, axios?: AxiosInstance) {
    const localVarFp = DownloadsApiFp(configuration)
    return {
        /**
         * Download labels and other shipment-related documents.
         * @summary Download file
         * @param {string} subdir 
         * @param {string} filename 
         * @param {string} dir 
         * @param {string} [download] 
         * @param {number} [rotation] 
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        downloadFile(subdir: string, filename: string, dir: string, download?: string, rotation?: number, options?: RawAxiosRequestConfig): AxiosPromise<File> {
            return localVarFp.downloadFile(subdir, filename, dir, download, rotation, options).then((request) => request(axios, basePath));
        },
    };
};

/**
 * DownloadsApi - object-oriented interface
 * @export
 * @class DownloadsApi
 * @extends {BaseAPI}
 */
export class DownloadsApi extends BaseAPI {
    /**
     * Download labels and other shipment-related documents.
     * @summary Download file
     * @param {string} subdir 
     * @param {string} filename 
     * @param {string} dir 
     * @param {string} [download] 
     * @param {number} [rotation] 
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     * @memberof DownloadsApi
     */
    public downloadFile(subdir: string, filename: string, dir: string, download?: string, rotation?: number, options?: RawAxiosRequestConfig) {
        return DownloadsApiFp(this.configuration).downloadFile(subdir, filename, dir, download, rotation, options).then((request) => request(this.axios, this.basePath));
    }
}

