/* 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";
/**
 * ApiNotificationHaloRunV1alpha1NotifierApi - axios parameter creator
 * @export
 */
export const ApiNotificationHaloRunV1alpha1NotifierApiAxiosParamCreator =
  function (configuration?: Configuration) {
    return {
      /**
       * Fetch receiver config of notifier
       * @param {string} name Notifier name
       * @param {*} [options] Override http request option.
       * @throws {RequiredError}
       */
      fetchReceiverConfig: async (
        name: string,
        options: AxiosRequestConfig = {}
      ): Promise<RequestArgs> => {
        // verify required parameter 'name' is not null or undefined
        assertParamExists("fetchReceiverConfig", "name", name);
        const localVarPath =
          `/apis/api.notification.halo.run/v1alpha1/notifiers/{name}/receiver-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 receiver config of notifier
       * @param {string} name Notifier name
       * @param {object} body
       * @param {*} [options] Override http request option.
       * @throws {RequiredError}
       */
      saveReceiverConfig: async (
        name: string,
        body: object,
        options: AxiosRequestConfig = {}
      ): Promise<RequestArgs> => {
        // verify required parameter 'name' is not null or undefined
        assertParamExists("saveReceiverConfig", "name", name);
        // verify required parameter 'body' is not null or undefined
        assertParamExists("saveReceiverConfig", "body", body);
        const localVarPath =
          `/apis/api.notification.halo.run/v1alpha1/notifiers/{name}/receiver-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,
        };
      },
    };
  };

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

/**
 * ApiNotificationHaloRunV1alpha1NotifierApi - factory interface
 * @export
 */
export const ApiNotificationHaloRunV1alpha1NotifierApiFactory = function (
  configuration?: Configuration,
  basePath?: string,
  axios?: AxiosInstance
) {
  const localVarFp = ApiNotificationHaloRunV1alpha1NotifierApiFp(configuration);
  return {
    /**
     * Fetch receiver config of notifier
     * @param {ApiNotificationHaloRunV1alpha1NotifierApiFetchReceiverConfigRequest} requestParameters Request parameters.
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     */
    fetchReceiverConfig(
      requestParameters: ApiNotificationHaloRunV1alpha1NotifierApiFetchReceiverConfigRequest,
      options?: AxiosRequestConfig
    ): AxiosPromise<object> {
      return localVarFp
        .fetchReceiverConfig(requestParameters.name, options)
        .then((request) => request(axios, basePath));
    },
    /**
     * Save receiver config of notifier
     * @param {ApiNotificationHaloRunV1alpha1NotifierApiSaveReceiverConfigRequest} requestParameters Request parameters.
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     */
    saveReceiverConfig(
      requestParameters: ApiNotificationHaloRunV1alpha1NotifierApiSaveReceiverConfigRequest,
      options?: AxiosRequestConfig
    ): AxiosPromise<void> {
      return localVarFp
        .saveReceiverConfig(
          requestParameters.name,
          requestParameters.body,
          options
        )
        .then((request) => request(axios, basePath));
    },
  };
};

/**
 * Request parameters for fetchReceiverConfig operation in ApiNotificationHaloRunV1alpha1NotifierApi.
 * @export
 * @interface ApiNotificationHaloRunV1alpha1NotifierApiFetchReceiverConfigRequest
 */
export interface ApiNotificationHaloRunV1alpha1NotifierApiFetchReceiverConfigRequest {
  /**
   * Notifier name
   * @type {string}
   * @memberof ApiNotificationHaloRunV1alpha1NotifierApiFetchReceiverConfig
   */
  readonly name: string;
}

/**
 * Request parameters for saveReceiverConfig operation in ApiNotificationHaloRunV1alpha1NotifierApi.
 * @export
 * @interface ApiNotificationHaloRunV1alpha1NotifierApiSaveReceiverConfigRequest
 */
export interface ApiNotificationHaloRunV1alpha1NotifierApiSaveReceiverConfigRequest {
  /**
   * Notifier name
   * @type {string}
   * @memberof ApiNotificationHaloRunV1alpha1NotifierApiSaveReceiverConfig
   */
  readonly name: string;

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

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

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