/* tslint:disable */
/* eslint-disable */
/**
 * Halo
 * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
 *
 * The version of the OpenAPI document: 2.17.0-SNAPSHOT
 * 
 *
 * 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, RequestArgs, BaseAPI, RequiredError, operationServerMap } from '../base';
// @ts-ignore
import { Attachment } from '../models';
/**
 * AttachmentV1alpha1UcApi - axios parameter creator
 * @export
 */
export const AttachmentV1alpha1UcApiAxiosParamCreator = function (configuration?: Configuration) {
    return {
        /**
         * Create attachment for the given post.
         * @param {File} file 
         * @param {boolean} [waitForPermalink] Wait for permalink.
         * @param {string} [postName] Post name.
         * @param {string} [singlePageName] Single page name.
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        createAttachmentForPost: async (file: File, waitForPermalink?: boolean, postName?: string, singlePageName?: string, options: RawAxiosRequestConfig = {}): Promise<RequestArgs> => {
            // verify required parameter 'file' is not null or undefined
            assertParamExists('createAttachmentForPost', 'file', file)
            const localVarPath = `/apis/uc.api.content.halo.run/v1alpha1/attachments`;
            // 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: 'POST', ...baseOptions, ...options};
            const localVarHeaderParameter = {} as any;
            const localVarQueryParameter = {} as any;
            const localVarFormParams = new ((configuration && configuration.formDataCtor) || FormData)();

            // authentication basicAuth required
            // http basic authentication required
            setBasicAuthToObject(localVarRequestOptions, configuration)

            // authentication bearerAuth required
            // http bearer authentication required
            await setBearerAuthToObject(localVarHeaderParameter, configuration)

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


            if (file !== undefined) { 
                localVarFormParams.append('file', file as any);
            }
    
            if (postName !== undefined) { 
                localVarFormParams.append('postName', postName as any);
            }
    
            if (singlePageName !== undefined) { 
                localVarFormParams.append('singlePageName', singlePageName as any);
            }
    
    
            localVarHeaderParameter['Content-Type'] = 'multipart/form-data';
    
            setSearchParams(localVarUrlObj, localVarQueryParameter);
            let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
            localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers};
            localVarRequestOptions.data = localVarFormParams;

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

/**
 * AttachmentV1alpha1UcApi - functional programming interface
 * @export
 */
export const AttachmentV1alpha1UcApiFp = function(configuration?: Configuration) {
    const localVarAxiosParamCreator = AttachmentV1alpha1UcApiAxiosParamCreator(configuration)
    return {
        /**
         * Create attachment for the given post.
         * @param {File} file 
         * @param {boolean} [waitForPermalink] Wait for permalink.
         * @param {string} [postName] Post name.
         * @param {string} [singlePageName] Single page name.
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        async createAttachmentForPost(file: File, waitForPermalink?: boolean, postName?: string, singlePageName?: string, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<Attachment>> {
            const localVarAxiosArgs = await localVarAxiosParamCreator.createAttachmentForPost(file, waitForPermalink, postName, singlePageName, options);
            const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
            const localVarOperationServerBasePath = operationServerMap['AttachmentV1alpha1UcApi.createAttachmentForPost']?.[localVarOperationServerIndex]?.url;
            return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
        },
    }
};

/**
 * AttachmentV1alpha1UcApi - factory interface
 * @export
 */
export const AttachmentV1alpha1UcApiFactory = function (configuration?: Configuration, basePath?: string, axios?: AxiosInstance) {
    const localVarFp = AttachmentV1alpha1UcApiFp(configuration)
    return {
        /**
         * Create attachment for the given post.
         * @param {AttachmentV1alpha1UcApiCreateAttachmentForPostRequest} requestParameters Request parameters.
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        createAttachmentForPost(requestParameters: AttachmentV1alpha1UcApiCreateAttachmentForPostRequest, options?: RawAxiosRequestConfig): AxiosPromise<Attachment> {
            return localVarFp.createAttachmentForPost(requestParameters.file, requestParameters.waitForPermalink, requestParameters.postName, requestParameters.singlePageName, options).then((request) => request(axios, basePath));
        },
    };
};

/**
 * Request parameters for createAttachmentForPost operation in AttachmentV1alpha1UcApi.
 * @export
 * @interface AttachmentV1alpha1UcApiCreateAttachmentForPostRequest
 */
export interface AttachmentV1alpha1UcApiCreateAttachmentForPostRequest {
    /**
     * 
     * @type {File}
     * @memberof AttachmentV1alpha1UcApiCreateAttachmentForPost
     */
    readonly file: File

    /**
     * Wait for permalink.
     * @type {boolean}
     * @memberof AttachmentV1alpha1UcApiCreateAttachmentForPost
     */
    readonly waitForPermalink?: boolean

    /**
     * Post name.
     * @type {string}
     * @memberof AttachmentV1alpha1UcApiCreateAttachmentForPost
     */
    readonly postName?: string

    /**
     * Single page name.
     * @type {string}
     * @memberof AttachmentV1alpha1UcApiCreateAttachmentForPost
     */
    readonly singlePageName?: string
}

/**
 * AttachmentV1alpha1UcApi - object-oriented interface
 * @export
 * @class AttachmentV1alpha1UcApi
 * @extends {BaseAPI}
 */
export class AttachmentV1alpha1UcApi extends BaseAPI {
    /**
     * Create attachment for the given post.
     * @param {AttachmentV1alpha1UcApiCreateAttachmentForPostRequest} requestParameters Request parameters.
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     * @memberof AttachmentV1alpha1UcApi
     */
    public createAttachmentForPost(requestParameters: AttachmentV1alpha1UcApiCreateAttachmentForPostRequest, options?: RawAxiosRequestConfig) {
        return AttachmentV1alpha1UcApiFp(this.configuration).createAttachmentForPost(requestParameters.file, requestParameters.waitForPermalink, requestParameters.postName, requestParameters.singlePageName, options).then((request) => request(this.axios, this.basePath));
    }
}

