/* tslint:disable */
/* eslint-disable */
/**
 *
 * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
 *
 * The version of the OpenAPI document:
 *
 *
 * 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 { KamiApiSysUserV1TotpImageGetRes } from '../models';
// @ts-ignore
import type { KamiApiSysUserV1TotpResetReq } from '../models';
// @ts-ignore
import type { KamiApiSysUserV1TotpResetRes } from '../models';
// @ts-ignore
import type { KamiApiSysUserV1TotpSetReq } from '../models';
// @ts-ignore
import type { KamiApiSysUserV1TotpStatusGetRes } from '../models';
/**
 * TOTPApi - axios parameter creator
 */
export const TOTPApiAxiosParamCreator = function (
  configuration?: Configuration
) {
  return {
    /**
     *
     * @summary 查看两步验证图像
     * @param {string} code
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     */
    apiUserTotpImageGet: async (
      code: string,
      options: RawAxiosRequestConfig = {}
    ): Promise<RequestArgs> => {
      // verify required parameter 'code' is not null or undefined
      assertParamExists('apiUserTotpImageGet', 'code', code);
      const localVarPath = `/api/user/totp/image`;
      // 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;

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

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

      return {
        url: toPathString(localVarUrlObj),
        options: localVarRequestOptions
      };
    },
    /**
     *
     * @summary 重置两步验证
     * @param {KamiApiSysUserV1TotpResetReq} [kamiApiSysUserV1TotpResetReq]
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     */
    apiUserTotpResetPost: async (
      kamiApiSysUserV1TotpResetReq?: KamiApiSysUserV1TotpResetReq,
      options: RawAxiosRequestConfig = {}
    ): Promise<RequestArgs> => {
      const localVarPath = `/api/user/totp/reset`;
      // 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;

      localVarHeaderParameter['Content-Type'] = 'application/json';

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

      return {
        url: toPathString(localVarUrlObj),
        options: localVarRequestOptions
      };
    },
    /**
     *
     * @summary 设置二步验证
     * @param {KamiApiSysUserV1TotpSetReq} [kamiApiSysUserV1TotpSetReq]
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     */
    apiUserTotpSetPost: async (
      kamiApiSysUserV1TotpSetReq?: KamiApiSysUserV1TotpSetReq,
      options: RawAxiosRequestConfig = {}
    ): Promise<RequestArgs> => {
      const localVarPath = `/api/user/totp/set`;
      // 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;

      localVarHeaderParameter['Content-Type'] = 'application/json';

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

      return {
        url: toPathString(localVarUrlObj),
        options: localVarRequestOptions
      };
    },
    /**
     *
     * @summary 确认当前用户是否开启totp
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     */
    apiUserTotpStatusGet: async (
      options: RawAxiosRequestConfig = {}
    ): Promise<RequestArgs> => {
      const localVarPath = `/api/user/totp/status`;
      // 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;

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

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

/**
 * TOTPApi - functional programming interface
 */
export const TOTPApiFp = function (configuration?: Configuration) {
  const localVarAxiosParamCreator = TOTPApiAxiosParamCreator(configuration);
  return {
    /**
     *
     * @summary 查看两步验证图像
     * @param {string} code
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     */
    async apiUserTotpImageGet(
      code: string,
      options?: RawAxiosRequestConfig
    ): Promise<
      (
        axios?: AxiosInstance,
        basePath?: string
      ) => AxiosPromise<KamiApiSysUserV1TotpImageGetRes>
    > {
      const localVarAxiosArgs =
        await localVarAxiosParamCreator.apiUserTotpImageGet(code, options);
      const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
      const localVarOperationServerBasePath =
        operationServerMap['TOTPApi.apiUserTotpImageGet']?.[
          localVarOperationServerIndex
        ]?.url;
      return (axios, basePath) =>
        createRequestFunction(
          localVarAxiosArgs,
          globalAxios,
          BASE_PATH,
          configuration
        )(axios, localVarOperationServerBasePath || basePath);
    },
    /**
     *
     * @summary 重置两步验证
     * @param {KamiApiSysUserV1TotpResetReq} [kamiApiSysUserV1TotpResetReq]
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     */
    async apiUserTotpResetPost(
      kamiApiSysUserV1TotpResetReq?: KamiApiSysUserV1TotpResetReq,
      options?: RawAxiosRequestConfig
    ): Promise<
      (
        axios?: AxiosInstance,
        basePath?: string
      ) => AxiosPromise<KamiApiSysUserV1TotpResetRes>
    > {
      const localVarAxiosArgs =
        await localVarAxiosParamCreator.apiUserTotpResetPost(
          kamiApiSysUserV1TotpResetReq,
          options
        );
      const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
      const localVarOperationServerBasePath =
        operationServerMap['TOTPApi.apiUserTotpResetPost']?.[
          localVarOperationServerIndex
        ]?.url;
      return (axios, basePath) =>
        createRequestFunction(
          localVarAxiosArgs,
          globalAxios,
          BASE_PATH,
          configuration
        )(axios, localVarOperationServerBasePath || basePath);
    },
    /**
     *
     * @summary 设置二步验证
     * @param {KamiApiSysUserV1TotpSetReq} [kamiApiSysUserV1TotpSetReq]
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     */
    async apiUserTotpSetPost(
      kamiApiSysUserV1TotpSetReq?: KamiApiSysUserV1TotpSetReq,
      options?: RawAxiosRequestConfig
    ): Promise<
      (axios?: AxiosInstance, basePath?: string) => AxiosPromise<object>
    > {
      const localVarAxiosArgs =
        await localVarAxiosParamCreator.apiUserTotpSetPost(
          kamiApiSysUserV1TotpSetReq,
          options
        );
      const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
      const localVarOperationServerBasePath =
        operationServerMap['TOTPApi.apiUserTotpSetPost']?.[
          localVarOperationServerIndex
        ]?.url;
      return (axios, basePath) =>
        createRequestFunction(
          localVarAxiosArgs,
          globalAxios,
          BASE_PATH,
          configuration
        )(axios, localVarOperationServerBasePath || basePath);
    },
    /**
     *
     * @summary 确认当前用户是否开启totp
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     */
    async apiUserTotpStatusGet(
      options?: RawAxiosRequestConfig
    ): Promise<
      (
        axios?: AxiosInstance,
        basePath?: string
      ) => AxiosPromise<KamiApiSysUserV1TotpStatusGetRes>
    > {
      const localVarAxiosArgs =
        await localVarAxiosParamCreator.apiUserTotpStatusGet(options);
      const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
      const localVarOperationServerBasePath =
        operationServerMap['TOTPApi.apiUserTotpStatusGet']?.[
          localVarOperationServerIndex
        ]?.url;
      return (axios, basePath) =>
        createRequestFunction(
          localVarAxiosArgs,
          globalAxios,
          BASE_PATH,
          configuration
        )(axios, localVarOperationServerBasePath || basePath);
    }
  };
};

/**
 * TOTPApi - factory interface
 */
export const TOTPApiFactory = function (
  configuration?: Configuration,
  basePath?: string,
  axios?: AxiosInstance
) {
  const localVarFp = TOTPApiFp(configuration);
  return {
    /**
     *
     * @summary 查看两步验证图像
     * @param {TOTPApiApiUserTotpImageGetRequest} requestParameters Request parameters.
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     */
    apiUserTotpImageGet(
      requestParameters: TOTPApiApiUserTotpImageGetRequest,
      options?: RawAxiosRequestConfig
    ): AxiosPromise<KamiApiSysUserV1TotpImageGetRes> {
      return localVarFp
        .apiUserTotpImageGet(requestParameters.code, options)
        .then(request => request(axios, basePath));
    },
    /**
     *
     * @summary 重置两步验证
     * @param {TOTPApiApiUserTotpResetPostRequest} requestParameters Request parameters.
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     */
    apiUserTotpResetPost(
      requestParameters: TOTPApiApiUserTotpResetPostRequest = {},
      options?: RawAxiosRequestConfig
    ): AxiosPromise<KamiApiSysUserV1TotpResetRes> {
      return localVarFp
        .apiUserTotpResetPost(
          requestParameters.kamiApiSysUserV1TotpResetReq,
          options
        )
        .then(request => request(axios, basePath));
    },
    /**
     *
     * @summary 设置二步验证
     * @param {TOTPApiApiUserTotpSetPostRequest} requestParameters Request parameters.
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     */
    apiUserTotpSetPost(
      requestParameters: TOTPApiApiUserTotpSetPostRequest = {},
      options?: RawAxiosRequestConfig
    ): AxiosPromise<object> {
      return localVarFp
        .apiUserTotpSetPost(
          requestParameters.kamiApiSysUserV1TotpSetReq,
          options
        )
        .then(request => request(axios, basePath));
    },
    /**
     *
     * @summary 确认当前用户是否开启totp
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     */
    apiUserTotpStatusGet(
      options?: RawAxiosRequestConfig
    ): AxiosPromise<KamiApiSysUserV1TotpStatusGetRes> {
      return localVarFp
        .apiUserTotpStatusGet(options)
        .then(request => request(axios, basePath));
    }
  };
};

/**
 * TOTPApi - interface
 */
export interface TOTPApiInterface {
  /**
   *
   * @summary 查看两步验证图像
   * @param {TOTPApiApiUserTotpImageGetRequest} requestParameters Request parameters.
   * @param {*} [options] Override http request option.
   * @throws {RequiredError}
   */
  apiUserTotpImageGet(
    requestParameters: TOTPApiApiUserTotpImageGetRequest,
    options?: RawAxiosRequestConfig
  ): AxiosPromise<KamiApiSysUserV1TotpImageGetRes>;

  /**
   *
   * @summary 重置两步验证
   * @param {TOTPApiApiUserTotpResetPostRequest} requestParameters Request parameters.
   * @param {*} [options] Override http request option.
   * @throws {RequiredError}
   */
  apiUserTotpResetPost(
    requestParameters?: TOTPApiApiUserTotpResetPostRequest,
    options?: RawAxiosRequestConfig
  ): AxiosPromise<KamiApiSysUserV1TotpResetRes>;

  /**
   *
   * @summary 设置二步验证
   * @param {TOTPApiApiUserTotpSetPostRequest} requestParameters Request parameters.
   * @param {*} [options] Override http request option.
   * @throws {RequiredError}
   */
  apiUserTotpSetPost(
    requestParameters?: TOTPApiApiUserTotpSetPostRequest,
    options?: RawAxiosRequestConfig
  ): AxiosPromise<object>;

  /**
   *
   * @summary 确认当前用户是否开启totp
   * @param {*} [options] Override http request option.
   * @throws {RequiredError}
   */
  apiUserTotpStatusGet(
    options?: RawAxiosRequestConfig
  ): AxiosPromise<KamiApiSysUserV1TotpStatusGetRes>;
}

/**
 * Request parameters for apiUserTotpImageGet operation in TOTPApi.
 */
export interface TOTPApiApiUserTotpImageGetRequest {
  readonly code: string;
}

/**
 * Request parameters for apiUserTotpResetPost operation in TOTPApi.
 */
export interface TOTPApiApiUserTotpResetPostRequest {
  readonly kamiApiSysUserV1TotpResetReq?: KamiApiSysUserV1TotpResetReq;
}

/**
 * Request parameters for apiUserTotpSetPost operation in TOTPApi.
 */
export interface TOTPApiApiUserTotpSetPostRequest {
  readonly kamiApiSysUserV1TotpSetReq?: KamiApiSysUserV1TotpSetReq;
}

/**
 * TOTPApi - object-oriented interface
 */
export class TOTPApi extends BaseAPI implements TOTPApiInterface {
  /**
   *
   * @summary 查看两步验证图像
   * @param {TOTPApiApiUserTotpImageGetRequest} requestParameters Request parameters.
   * @param {*} [options] Override http request option.
   * @throws {RequiredError}
   */
  public apiUserTotpImageGet(
    requestParameters: TOTPApiApiUserTotpImageGetRequest,
    options?: RawAxiosRequestConfig
  ) {
    return TOTPApiFp(this.configuration)
      .apiUserTotpImageGet(requestParameters.code, options)
      .then(request => request(this.axios, this.basePath));
  }

  /**
   *
   * @summary 重置两步验证
   * @param {TOTPApiApiUserTotpResetPostRequest} requestParameters Request parameters.
   * @param {*} [options] Override http request option.
   * @throws {RequiredError}
   */
  public apiUserTotpResetPost(
    requestParameters: TOTPApiApiUserTotpResetPostRequest = {},
    options?: RawAxiosRequestConfig
  ) {
    return TOTPApiFp(this.configuration)
      .apiUserTotpResetPost(
        requestParameters.kamiApiSysUserV1TotpResetReq,
        options
      )
      .then(request => request(this.axios, this.basePath));
  }

  /**
   *
   * @summary 设置二步验证
   * @param {TOTPApiApiUserTotpSetPostRequest} requestParameters Request parameters.
   * @param {*} [options] Override http request option.
   * @throws {RequiredError}
   */
  public apiUserTotpSetPost(
    requestParameters: TOTPApiApiUserTotpSetPostRequest = {},
    options?: RawAxiosRequestConfig
  ) {
    return TOTPApiFp(this.configuration)
      .apiUserTotpSetPost(requestParameters.kamiApiSysUserV1TotpSetReq, options)
      .then(request => request(this.axios, this.basePath));
  }

  /**
   *
   * @summary 确认当前用户是否开启totp
   * @param {*} [options] Override http request option.
   * @throws {RequiredError}
   */
  public apiUserTotpStatusGet(options?: RawAxiosRequestConfig) {
    return TOTPApiFp(this.configuration)
      .apiUserTotpStatusGet(options)
      .then(request => request(this.axios, this.basePath));
  }
}
