<%
const { apiConfig, generateResponses, config } = it;
%>
import axios, { AxiosInstance, AxiosRequestConfig, AxiosResponse, ResponseType } from "axios";

export type QueryParamsType = Record<string | number, any>;

  export interface FullRequestParams extends Omit<AxiosRequestConfig, "data" | "params" | "url" | "responseType"> {
    /** set parameter to `true` for call `securityWorker` for this request */
    secure?: boolean;
    /** request path */
    path: string;
    /** content type of request body */
    type?: ContentType;
    /** query params */
    query?: QueryParamsType;
    /** format of response (i.e. response.json() -> format: "json") */
    format?: ResponseType;
    /** request body */
    body?: unknown;
    }

    export type RequestParams = Omit<FullRequestParams, "body" | "method" | "query" | "path"> & { showErrorToast?: boolean; fullResponse?: boolean };

      export interface ApiConfig<SecurityDataType=unknown> extends Omit<AxiosRequestConfig, "data" | "cancelToken"> {
          securityWorker?: (securityData: SecurityDataType | null) => Promise<AxiosRequestConfig | void> | AxiosRequestConfig | void;
            secure?: boolean;
            format?: ResponseType;
            }

            export enum ContentType {
            Json = "application/json",
            FormData = "multipart/form-data",
            UrlEncoded = "application/x-www-form-urlencoded",
            }