/* tslint:disable */
/* eslint-disable */
/**
 * Halo Next API
 * 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, AxiosRequestConfig } 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,
} from "../base";
/**
 * ApiConsoleHaloRunV1alpha1NotifierApi - axios parameter creator
 * @export
 */
export const ApiConsoleHaloRunV1alpha1NotifierApiAxiosParamCreator = function (
  configuration?: Configuration
) {
  return {
    /**
     * Fetch sender config of notifier
     * @param {string} name Notifier name
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     */
    fetchSenderConfig: async (
      name: string,
      options: AxiosRequestConfig = {}
    ): Promise<RequestArgs> => {
      // verify required parameter 'name' is not null or undefined
      assertParamExists("fetchSenderConfig", "name", name);
      const localVarPath =
        `/apis/api.console.halo.run/v1alpha1/notifiers/{name}/sender-config`.replace(
          `{${"name"}}`,
          encodeURIComponent(String(name))
        );
      // 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 BasicAuth required
      // http basic authentication required
      setBasicAuthToObject(localVarRequestOptions, configuration);

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

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

      return {
        url: toPathString(localVarUrlObj),
        options: localVarRequestOptions,
      };
    },
    /**
     * Save sender config of notifier
     * @param {string} name Notifier name
     * @param {object} body
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     */
    saveSenderConfig: async (
      name: string,
      body: object,
      options: AxiosRequestConfig = {}
    ): Promise<RequestArgs> => {
      // verify required parameter 'name' is not null or undefined
      assertParamExists("saveSenderConfig", "name", name);
      // verify required parameter 'body' is not null or undefined
      assertParamExists("saveSenderConfig", "body", body);
      const localVarPath =
        `/apis/api.console.halo.run/v1alpha1/notifiers/{name}/sender-config`.replace(
          `{${"name"}}`,
          encodeURIComponent(String(name))
        );
      // 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;

      // authentication BasicAuth required
      // http basic authentication required
      setBasicAuthToObject(localVarRequestOptions, configuration);

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

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

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

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

/**
 * ApiConsoleHaloRunV1alpha1NotifierApi - functional programming interface
 * @export
 */
export const ApiConsoleHaloRunV1alpha1NotifierApiFp = function (
  configuration?: Configuration
) {
  const localVarAxiosParamCreator =
    ApiConsoleHaloRunV1alpha1NotifierApiAxiosParamCreator(configuration);
  return {
    /**
     * Fetch sender config of notifier
     * @param {string} name Notifier name
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     */
    async fetchSenderConfig(
      name: string,
      options?: AxiosRequestConfig
    ): Promise<
      (axios?: AxiosInstance, basePath?: string) => AxiosPromise<object>
    > {
      const localVarAxiosArgs =
        await localVarAxiosParamCreator.fetchSenderConfig(name, options);
      return createRequestFunction(
        localVarAxiosArgs,
        globalAxios,
        BASE_PATH,
        configuration
      );
    },
    /**
     * Save sender config of notifier
     * @param {string} name Notifier name
     * @param {object} body
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     */
    async saveSenderConfig(
      name: string,
      body: object,
      options?: AxiosRequestConfig
    ): Promise<
      (axios?: AxiosInstance, basePath?: string) => AxiosPromise<void>
    > {
      const localVarAxiosArgs =
        await localVarAxiosParamCreator.saveSenderConfig(name, body, options);
      return createRequestFunction(
        localVarAxiosArgs,
        globalAxios,
        BASE_PATH,
        configuration
      );
    },
  };
};

/**
 * ApiConsoleHaloRunV1alpha1NotifierApi - factory interface
 * @export
 */
export const ApiConsoleHaloRunV1alpha1NotifierApiFactory = function (
  configuration?: Configuration,
  basePath?: string,
  axios?: AxiosInstance
) {
  const localVarFp = ApiConsoleHaloRunV1alpha1NotifierApiFp(configuration);
  return {
    /**
     * Fetch sender config of notifier
     * @param {ApiConsoleHaloRunV1alpha1NotifierApiFetchSenderConfigRequest} requestParameters Request parameters.
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     */
    fetchSenderConfig(
      requestParameters: ApiConsoleHaloRunV1alpha1NotifierApiFetchSenderConfigRequest,
      options?: AxiosRequestConfig
    ): AxiosPromise<object> {
      return localVarFp
        .fetchSenderConfig(requestParameters.name, options)
        .then((request) => request(axios, basePath));
    },
    /**
     * Save sender config of notifier
     * @param {ApiConsoleHaloRunV1alpha1NotifierApiSaveSenderConfigRequest} requestParameters Request parameters.
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     */
    saveSenderConfig(
      requestParameters: ApiConsoleHaloRunV1alpha1NotifierApiSaveSenderConfigRequest,
      options?: AxiosRequestConfig
    ): AxiosPromise<void> {
      return localVarFp
        .saveSenderConfig(
          requestParameters.name,
          requestParameters.body,
          options
        )
        .then((request) => request(axios, basePath));
    },
  };
};

/**
 * Request parameters for fetchSenderConfig operation in ApiConsoleHaloRunV1alpha1NotifierApi.
 * @export
 * @interface ApiConsoleHaloRunV1alpha1NotifierApiFetchSenderConfigRequest
 */
export interface ApiConsoleHaloRunV1alpha1NotifierApiFetchSenderConfigRequest {
  /**
   * Notifier name
   * @type {string}
   * @memberof ApiConsoleHaloRunV1alpha1NotifierApiFetchSenderConfig
   */
  readonly name: string;
}

/**
 * Request parameters for saveSenderConfig operation in ApiConsoleHaloRunV1alpha1NotifierApi.
 * @export
 * @interface ApiConsoleHaloRunV1alpha1NotifierApiSaveSenderConfigRequest
 */
export interface ApiConsoleHaloRunV1alpha1NotifierApiSaveSenderConfigRequest {
  /**
   * Notifier name
   * @type {string}
   * @memberof ApiConsoleHaloRunV1alpha1NotifierApiSaveSenderConfig
   */
  readonly name: string;

  /**
   *
   * @type {object}
   * @memberof ApiConsoleHaloRunV1alpha1NotifierApiSaveSenderConfig
   */
  readonly body: object;
}

/**
 * ApiConsoleHaloRunV1alpha1NotifierApi - object-oriented interface
 * @export
 * @class ApiConsoleHaloRunV1alpha1NotifierApi
 * @extends {BaseAPI}
 */
export class ApiConsoleHaloRunV1alpha1NotifierApi extends BaseAPI {
  /**
   * Fetch sender config of notifier
   * @param {ApiConsoleHaloRunV1alpha1NotifierApiFetchSenderConfigRequest} requestParameters Request parameters.
   * @param {*} [options] Override http request option.
   * @throws {RequiredError}
   * @memberof ApiConsoleHaloRunV1alpha1NotifierApi
   */
  public fetchSenderConfig(
    requestParameters: ApiConsoleHaloRunV1alpha1NotifierApiFetchSenderConfigRequest,
    options?: AxiosRequestConfig
  ) {
    return ApiConsoleHaloRunV1alpha1NotifierApiFp(this.configuration)
      .fetchSenderConfig(requestParameters.name, options)
      .then((request) => request(this.axios, this.basePath));
  }

  /**
   * Save sender config of notifier
   * @param {ApiConsoleHaloRunV1alpha1NotifierApiSaveSenderConfigRequest} requestParameters Request parameters.
   * @param {*} [options] Override http request option.
   * @throws {RequiredError}
   * @memberof ApiConsoleHaloRunV1alpha1NotifierApi
   */
  public saveSenderConfig(
    requestParameters: ApiConsoleHaloRunV1alpha1NotifierApiSaveSenderConfigRequest,
    options?: AxiosRequestConfig
  ) {
    return ApiConsoleHaloRunV1alpha1NotifierApiFp(this.configuration)
      .saveSenderConfig(requestParameters.name, requestParameters.body, options)
      .then((request) => request(this.axios, this.basePath));
  }
}
