/* 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";
// @ts-ignore
import { MarkSpecifiedRequest } from "../models";
// @ts-ignore
import { Notification } from "../models";
// @ts-ignore
import { NotificationList } from "../models";
/**
 * ApiConsoleHaloRunV1alpha1NotificationApi - axios parameter creator
 * @export
 */
export const ApiConsoleHaloRunV1alpha1NotificationApiAxiosParamCreator =
  function (configuration?: Configuration) {
    return {
      /**
       * List notifications for the authenticated user.
       * @param {string} username Username
       * @param {Array<string>} [fieldSelector] Field selector for filtering.
       * @param {string} [keyword]
       * @param {Array<string>} [labelSelector] Label selector for filtering.
       * @param {number} [page] The page number. Zero indicates no page.
       * @param {string} [reason] Filter by notification reason
       * @param {number} [size] Size of one page. Zero indicates no limit.
       * @param {Array<string>} [sort] Sort property and direction of the list result. Supported fields: creationTimestamp
       * @param {boolean} [unRead] true for unread, false for read, null for all
       * @param {*} [options] Override http request option.
       * @throws {RequiredError}
       */
      listUserNotifications: async (
        username: string,
        fieldSelector?: Array<string>,
        keyword?: string,
        labelSelector?: Array<string>,
        page?: number,
        reason?: string,
        size?: number,
        sort?: Array<string>,
        unRead?: boolean,
        options: AxiosRequestConfig = {}
      ): Promise<RequestArgs> => {
        // verify required parameter 'username' is not null or undefined
        assertParamExists("listUserNotifications", "username", username);
        const localVarPath =
          `/apis/api.console.halo.run/v1alpha1/userspaces/{username}/notifications`.replace(
            `{${"username"}}`,
            encodeURIComponent(String(username))
          );
        // 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);

        if (fieldSelector) {
          localVarQueryParameter["fieldSelector"] = fieldSelector;
        }

        if (keyword !== undefined) {
          localVarQueryParameter["keyword"] = keyword;
        }

        if (labelSelector) {
          localVarQueryParameter["labelSelector"] = labelSelector;
        }

        if (page !== undefined) {
          localVarQueryParameter["page"] = page;
        }

        if (reason !== undefined) {
          localVarQueryParameter["reason"] = reason;
        }

        if (size !== undefined) {
          localVarQueryParameter["size"] = size;
        }

        if (sort) {
          localVarQueryParameter["sort"] = Array.from(sort);
        }

        if (unRead !== undefined) {
          localVarQueryParameter["unRead"] = unRead;
        }

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

        return {
          url: toPathString(localVarUrlObj),
          options: localVarRequestOptions,
        };
      },
      /**
       * Mark the specified notification as read.
       * @param {string} username Username
       * @param {string} name Notification name
       * @param {*} [options] Override http request option.
       * @throws {RequiredError}
       */
      markNotificationAsRead: async (
        username: string,
        name: string,
        options: AxiosRequestConfig = {}
      ): Promise<RequestArgs> => {
        // verify required parameter 'username' is not null or undefined
        assertParamExists("markNotificationAsRead", "username", username);
        // verify required parameter 'name' is not null or undefined
        assertParamExists("markNotificationAsRead", "name", name);
        const localVarPath =
          `/apis/api.console.halo.run/v1alpha1/userspaces/{username}/notifications/{name}/mark-as-read`
            .replace(`{${"username"}}`, encodeURIComponent(String(username)))
            .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: "PUT",
          ...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,
        };
      },
      /**
       * Mark the specified notifications as read.
       * @param {string} username Username
       * @param {MarkSpecifiedRequest} markSpecifiedRequest
       * @param {*} [options] Override http request option.
       * @throws {RequiredError}
       */
      markNotificationsAsRead: async (
        username: string,
        markSpecifiedRequest: MarkSpecifiedRequest,
        options: AxiosRequestConfig = {}
      ): Promise<RequestArgs> => {
        // verify required parameter 'username' is not null or undefined
        assertParamExists("markNotificationsAsRead", "username", username);
        // verify required parameter 'markSpecifiedRequest' is not null or undefined
        assertParamExists(
          "markNotificationsAsRead",
          "markSpecifiedRequest",
          markSpecifiedRequest
        );
        const localVarPath =
          `/apis/api.console.halo.run/v1alpha1/userspaces/{username}/notifications/-/mark-specified-as-read`.replace(
            `{${"username"}}`,
            encodeURIComponent(String(username))
          );
        // 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: "PUT",
          ...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(
          markSpecifiedRequest,
          localVarRequestOptions,
          configuration
        );

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

/**
 * ApiConsoleHaloRunV1alpha1NotificationApi - functional programming interface
 * @export
 */
export const ApiConsoleHaloRunV1alpha1NotificationApiFp = function (
  configuration?: Configuration
) {
  const localVarAxiosParamCreator =
    ApiConsoleHaloRunV1alpha1NotificationApiAxiosParamCreator(configuration);
  return {
    /**
     * List notifications for the authenticated user.
     * @param {string} username Username
     * @param {Array<string>} [fieldSelector] Field selector for filtering.
     * @param {string} [keyword]
     * @param {Array<string>} [labelSelector] Label selector for filtering.
     * @param {number} [page] The page number. Zero indicates no page.
     * @param {string} [reason] Filter by notification reason
     * @param {number} [size] Size of one page. Zero indicates no limit.
     * @param {Array<string>} [sort] Sort property and direction of the list result. Supported fields: creationTimestamp
     * @param {boolean} [unRead] true for unread, false for read, null for all
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     */
    async listUserNotifications(
      username: string,
      fieldSelector?: Array<string>,
      keyword?: string,
      labelSelector?: Array<string>,
      page?: number,
      reason?: string,
      size?: number,
      sort?: Array<string>,
      unRead?: boolean,
      options?: AxiosRequestConfig
    ): Promise<
      (
        axios?: AxiosInstance,
        basePath?: string
      ) => AxiosPromise<NotificationList>
    > {
      const localVarAxiosArgs =
        await localVarAxiosParamCreator.listUserNotifications(
          username,
          fieldSelector,
          keyword,
          labelSelector,
          page,
          reason,
          size,
          sort,
          unRead,
          options
        );
      return createRequestFunction(
        localVarAxiosArgs,
        globalAxios,
        BASE_PATH,
        configuration
      );
    },
    /**
     * Mark the specified notification as read.
     * @param {string} username Username
     * @param {string} name Notification name
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     */
    async markNotificationAsRead(
      username: string,
      name: string,
      options?: AxiosRequestConfig
    ): Promise<
      (axios?: AxiosInstance, basePath?: string) => AxiosPromise<Notification>
    > {
      const localVarAxiosArgs =
        await localVarAxiosParamCreator.markNotificationAsRead(
          username,
          name,
          options
        );
      return createRequestFunction(
        localVarAxiosArgs,
        globalAxios,
        BASE_PATH,
        configuration
      );
    },
    /**
     * Mark the specified notifications as read.
     * @param {string} username Username
     * @param {MarkSpecifiedRequest} markSpecifiedRequest
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     */
    async markNotificationsAsRead(
      username: string,
      markSpecifiedRequest: MarkSpecifiedRequest,
      options?: AxiosRequestConfig
    ): Promise<
      (axios?: AxiosInstance, basePath?: string) => AxiosPromise<Array<string>>
    > {
      const localVarAxiosArgs =
        await localVarAxiosParamCreator.markNotificationsAsRead(
          username,
          markSpecifiedRequest,
          options
        );
      return createRequestFunction(
        localVarAxiosArgs,
        globalAxios,
        BASE_PATH,
        configuration
      );
    },
  };
};

/**
 * ApiConsoleHaloRunV1alpha1NotificationApi - factory interface
 * @export
 */
export const ApiConsoleHaloRunV1alpha1NotificationApiFactory = function (
  configuration?: Configuration,
  basePath?: string,
  axios?: AxiosInstance
) {
  const localVarFp = ApiConsoleHaloRunV1alpha1NotificationApiFp(configuration);
  return {
    /**
     * List notifications for the authenticated user.
     * @param {ApiConsoleHaloRunV1alpha1NotificationApiListUserNotificationsRequest} requestParameters Request parameters.
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     */
    listUserNotifications(
      requestParameters: ApiConsoleHaloRunV1alpha1NotificationApiListUserNotificationsRequest,
      options?: AxiosRequestConfig
    ): AxiosPromise<NotificationList> {
      return localVarFp
        .listUserNotifications(
          requestParameters.username,
          requestParameters.fieldSelector,
          requestParameters.keyword,
          requestParameters.labelSelector,
          requestParameters.page,
          requestParameters.reason,
          requestParameters.size,
          requestParameters.sort,
          requestParameters.unRead,
          options
        )
        .then((request) => request(axios, basePath));
    },
    /**
     * Mark the specified notification as read.
     * @param {ApiConsoleHaloRunV1alpha1NotificationApiMarkNotificationAsReadRequest} requestParameters Request parameters.
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     */
    markNotificationAsRead(
      requestParameters: ApiConsoleHaloRunV1alpha1NotificationApiMarkNotificationAsReadRequest,
      options?: AxiosRequestConfig
    ): AxiosPromise<Notification> {
      return localVarFp
        .markNotificationAsRead(
          requestParameters.username,
          requestParameters.name,
          options
        )
        .then((request) => request(axios, basePath));
    },
    /**
     * Mark the specified notifications as read.
     * @param {ApiConsoleHaloRunV1alpha1NotificationApiMarkNotificationsAsReadRequest} requestParameters Request parameters.
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     */
    markNotificationsAsRead(
      requestParameters: ApiConsoleHaloRunV1alpha1NotificationApiMarkNotificationsAsReadRequest,
      options?: AxiosRequestConfig
    ): AxiosPromise<Array<string>> {
      return localVarFp
        .markNotificationsAsRead(
          requestParameters.username,
          requestParameters.markSpecifiedRequest,
          options
        )
        .then((request) => request(axios, basePath));
    },
  };
};

/**
 * Request parameters for listUserNotifications operation in ApiConsoleHaloRunV1alpha1NotificationApi.
 * @export
 * @interface ApiConsoleHaloRunV1alpha1NotificationApiListUserNotificationsRequest
 */
export interface ApiConsoleHaloRunV1alpha1NotificationApiListUserNotificationsRequest {
  /**
   * Username
   * @type {string}
   * @memberof ApiConsoleHaloRunV1alpha1NotificationApiListUserNotifications
   */
  readonly username: string;

  /**
   * Field selector for filtering.
   * @type {Array<string>}
   * @memberof ApiConsoleHaloRunV1alpha1NotificationApiListUserNotifications
   */
  readonly fieldSelector?: Array<string>;

  /**
   *
   * @type {string}
   * @memberof ApiConsoleHaloRunV1alpha1NotificationApiListUserNotifications
   */
  readonly keyword?: string;

  /**
   * Label selector for filtering.
   * @type {Array<string>}
   * @memberof ApiConsoleHaloRunV1alpha1NotificationApiListUserNotifications
   */
  readonly labelSelector?: Array<string>;

  /**
   * The page number. Zero indicates no page.
   * @type {number}
   * @memberof ApiConsoleHaloRunV1alpha1NotificationApiListUserNotifications
   */
  readonly page?: number;

  /**
   * Filter by notification reason
   * @type {string}
   * @memberof ApiConsoleHaloRunV1alpha1NotificationApiListUserNotifications
   */
  readonly reason?: string;

  /**
   * Size of one page. Zero indicates no limit.
   * @type {number}
   * @memberof ApiConsoleHaloRunV1alpha1NotificationApiListUserNotifications
   */
  readonly size?: number;

  /**
   * Sort property and direction of the list result. Supported fields: creationTimestamp
   * @type {Array<string>}
   * @memberof ApiConsoleHaloRunV1alpha1NotificationApiListUserNotifications
   */
  readonly sort?: Array<string>;

  /**
   * true for unread, false for read, null for all
   * @type {boolean}
   * @memberof ApiConsoleHaloRunV1alpha1NotificationApiListUserNotifications
   */
  readonly unRead?: boolean;
}

/**
 * Request parameters for markNotificationAsRead operation in ApiConsoleHaloRunV1alpha1NotificationApi.
 * @export
 * @interface ApiConsoleHaloRunV1alpha1NotificationApiMarkNotificationAsReadRequest
 */
export interface ApiConsoleHaloRunV1alpha1NotificationApiMarkNotificationAsReadRequest {
  /**
   * Username
   * @type {string}
   * @memberof ApiConsoleHaloRunV1alpha1NotificationApiMarkNotificationAsRead
   */
  readonly username: string;

  /**
   * Notification name
   * @type {string}
   * @memberof ApiConsoleHaloRunV1alpha1NotificationApiMarkNotificationAsRead
   */
  readonly name: string;
}

/**
 * Request parameters for markNotificationsAsRead operation in ApiConsoleHaloRunV1alpha1NotificationApi.
 * @export
 * @interface ApiConsoleHaloRunV1alpha1NotificationApiMarkNotificationsAsReadRequest
 */
export interface ApiConsoleHaloRunV1alpha1NotificationApiMarkNotificationsAsReadRequest {
  /**
   * Username
   * @type {string}
   * @memberof ApiConsoleHaloRunV1alpha1NotificationApiMarkNotificationsAsRead
   */
  readonly username: string;

  /**
   *
   * @type {MarkSpecifiedRequest}
   * @memberof ApiConsoleHaloRunV1alpha1NotificationApiMarkNotificationsAsRead
   */
  readonly markSpecifiedRequest: MarkSpecifiedRequest;
}

/**
 * ApiConsoleHaloRunV1alpha1NotificationApi - object-oriented interface
 * @export
 * @class ApiConsoleHaloRunV1alpha1NotificationApi
 * @extends {BaseAPI}
 */
export class ApiConsoleHaloRunV1alpha1NotificationApi extends BaseAPI {
  /**
   * List notifications for the authenticated user.
   * @param {ApiConsoleHaloRunV1alpha1NotificationApiListUserNotificationsRequest} requestParameters Request parameters.
   * @param {*} [options] Override http request option.
   * @throws {RequiredError}
   * @memberof ApiConsoleHaloRunV1alpha1NotificationApi
   */
  public listUserNotifications(
    requestParameters: ApiConsoleHaloRunV1alpha1NotificationApiListUserNotificationsRequest,
    options?: AxiosRequestConfig
  ) {
    return ApiConsoleHaloRunV1alpha1NotificationApiFp(this.configuration)
      .listUserNotifications(
        requestParameters.username,
        requestParameters.fieldSelector,
        requestParameters.keyword,
        requestParameters.labelSelector,
        requestParameters.page,
        requestParameters.reason,
        requestParameters.size,
        requestParameters.sort,
        requestParameters.unRead,
        options
      )
      .then((request) => request(this.axios, this.basePath));
  }

  /**
   * Mark the specified notification as read.
   * @param {ApiConsoleHaloRunV1alpha1NotificationApiMarkNotificationAsReadRequest} requestParameters Request parameters.
   * @param {*} [options] Override http request option.
   * @throws {RequiredError}
   * @memberof ApiConsoleHaloRunV1alpha1NotificationApi
   */
  public markNotificationAsRead(
    requestParameters: ApiConsoleHaloRunV1alpha1NotificationApiMarkNotificationAsReadRequest,
    options?: AxiosRequestConfig
  ) {
    return ApiConsoleHaloRunV1alpha1NotificationApiFp(this.configuration)
      .markNotificationAsRead(
        requestParameters.username,
        requestParameters.name,
        options
      )
      .then((request) => request(this.axios, this.basePath));
  }

  /**
   * Mark the specified notifications as read.
   * @param {ApiConsoleHaloRunV1alpha1NotificationApiMarkNotificationsAsReadRequest} requestParameters Request parameters.
   * @param {*} [options] Override http request option.
   * @throws {RequiredError}
   * @memberof ApiConsoleHaloRunV1alpha1NotificationApi
   */
  public markNotificationsAsRead(
    requestParameters: ApiConsoleHaloRunV1alpha1NotificationApiMarkNotificationsAsReadRequest,
    options?: AxiosRequestConfig
  ) {
    return ApiConsoleHaloRunV1alpha1NotificationApiFp(this.configuration)
      .markNotificationsAsRead(
        requestParameters.username,
        requestParameters.markSpecifiedRequest,
        options
      )
      .then((request) => request(this.axios, this.basePath));
  }
}
