/* 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 { CategoryVo } from "../models";
// @ts-ignore
import { CategoryVoList } from "../models";
// @ts-ignore
import { ListedPostVoList } from "../models";
/**
 * ApiContentHaloRunV1alpha1CategoryApi - axios parameter creator
 * @export
 */
export const ApiContentHaloRunV1alpha1CategoryApiAxiosParamCreator = function (
  configuration?: Configuration
) {
  return {
    /**
     * Lists categories.
     * @param {Array<string>} [fieldSelector] Field selector for filtering.
     * @param {Array<string>} [labelSelector] Label selector for filtering.
     * @param {number} [page] The page number. Zero indicates no page.
     * @param {number} [size] Size of one page. Zero indicates no limit.
     * @param {Array<string>} [sort] Sort property and direction of the list result. Support sorting based on attribute name path.
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     */
    queryCategories: async (
      fieldSelector?: Array<string>,
      labelSelector?: Array<string>,
      page?: number,
      size?: number,
      sort?: Array<string>,
      options: AxiosRequestConfig = {}
    ): Promise<RequestArgs> => {
      const localVarPath = `/apis/api.content.halo.run/v1alpha1/categories`;
      // 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 (labelSelector) {
        localVarQueryParameter["labelSelector"] = labelSelector;
      }

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

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

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

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

      return {
        url: toPathString(localVarUrlObj),
        options: localVarRequestOptions,
      };
    },
    /**
     * Gets category by name.
     * @param {string} name Category name
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     */
    queryCategoryByName: async (
      name: string,
      options: AxiosRequestConfig = {}
    ): Promise<RequestArgs> => {
      // verify required parameter 'name' is not null or undefined
      assertParamExists("queryCategoryByName", "name", name);
      const localVarPath =
        `/apis/api.content.halo.run/v1alpha1/categories/{name}`.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,
      };
    },
    /**
     * Lists posts by category name.
     * @param {string} name Category name
     * @param {Array<string>} [fieldSelector] Field selector for filtering.
     * @param {Array<string>} [labelSelector] Label selector for filtering.
     * @param {number} [page] The page number. Zero indicates no page.
     * @param {number} [size] Size of one page. Zero indicates no limit.
     * @param {Array<string>} [sort] Sort property and direction of the list result. Support sorting based on attribute name path.
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     */
    queryPostsByCategoryName: async (
      name: string,
      fieldSelector?: Array<string>,
      labelSelector?: Array<string>,
      page?: number,
      size?: number,
      sort?: Array<string>,
      options: AxiosRequestConfig = {}
    ): Promise<RequestArgs> => {
      // verify required parameter 'name' is not null or undefined
      assertParamExists("queryPostsByCategoryName", "name", name);
      const localVarPath =
        `/apis/api.content.halo.run/v1alpha1/categories/{name}/posts`.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);

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

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

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

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

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

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

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

/**
 * ApiContentHaloRunV1alpha1CategoryApi - functional programming interface
 * @export
 */
export const ApiContentHaloRunV1alpha1CategoryApiFp = function (
  configuration?: Configuration
) {
  const localVarAxiosParamCreator =
    ApiContentHaloRunV1alpha1CategoryApiAxiosParamCreator(configuration);
  return {
    /**
     * Lists categories.
     * @param {Array<string>} [fieldSelector] Field selector for filtering.
     * @param {Array<string>} [labelSelector] Label selector for filtering.
     * @param {number} [page] The page number. Zero indicates no page.
     * @param {number} [size] Size of one page. Zero indicates no limit.
     * @param {Array<string>} [sort] Sort property and direction of the list result. Support sorting based on attribute name path.
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     */
    async queryCategories(
      fieldSelector?: Array<string>,
      labelSelector?: Array<string>,
      page?: number,
      size?: number,
      sort?: Array<string>,
      options?: AxiosRequestConfig
    ): Promise<
      (axios?: AxiosInstance, basePath?: string) => AxiosPromise<CategoryVoList>
    > {
      const localVarAxiosArgs = await localVarAxiosParamCreator.queryCategories(
        fieldSelector,
        labelSelector,
        page,
        size,
        sort,
        options
      );
      return createRequestFunction(
        localVarAxiosArgs,
        globalAxios,
        BASE_PATH,
        configuration
      );
    },
    /**
     * Gets category by name.
     * @param {string} name Category name
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     */
    async queryCategoryByName(
      name: string,
      options?: AxiosRequestConfig
    ): Promise<
      (axios?: AxiosInstance, basePath?: string) => AxiosPromise<CategoryVo>
    > {
      const localVarAxiosArgs =
        await localVarAxiosParamCreator.queryCategoryByName(name, options);
      return createRequestFunction(
        localVarAxiosArgs,
        globalAxios,
        BASE_PATH,
        configuration
      );
    },
    /**
     * Lists posts by category name.
     * @param {string} name Category name
     * @param {Array<string>} [fieldSelector] Field selector for filtering.
     * @param {Array<string>} [labelSelector] Label selector for filtering.
     * @param {number} [page] The page number. Zero indicates no page.
     * @param {number} [size] Size of one page. Zero indicates no limit.
     * @param {Array<string>} [sort] Sort property and direction of the list result. Support sorting based on attribute name path.
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     */
    async queryPostsByCategoryName(
      name: string,
      fieldSelector?: Array<string>,
      labelSelector?: Array<string>,
      page?: number,
      size?: number,
      sort?: Array<string>,
      options?: AxiosRequestConfig
    ): Promise<
      (
        axios?: AxiosInstance,
        basePath?: string
      ) => AxiosPromise<ListedPostVoList>
    > {
      const localVarAxiosArgs =
        await localVarAxiosParamCreator.queryPostsByCategoryName(
          name,
          fieldSelector,
          labelSelector,
          page,
          size,
          sort,
          options
        );
      return createRequestFunction(
        localVarAxiosArgs,
        globalAxios,
        BASE_PATH,
        configuration
      );
    },
  };
};

/**
 * ApiContentHaloRunV1alpha1CategoryApi - factory interface
 * @export
 */
export const ApiContentHaloRunV1alpha1CategoryApiFactory = function (
  configuration?: Configuration,
  basePath?: string,
  axios?: AxiosInstance
) {
  const localVarFp = ApiContentHaloRunV1alpha1CategoryApiFp(configuration);
  return {
    /**
     * Lists categories.
     * @param {ApiContentHaloRunV1alpha1CategoryApiQueryCategoriesRequest} requestParameters Request parameters.
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     */
    queryCategories(
      requestParameters: ApiContentHaloRunV1alpha1CategoryApiQueryCategoriesRequest = {},
      options?: AxiosRequestConfig
    ): AxiosPromise<CategoryVoList> {
      return localVarFp
        .queryCategories(
          requestParameters.fieldSelector,
          requestParameters.labelSelector,
          requestParameters.page,
          requestParameters.size,
          requestParameters.sort,
          options
        )
        .then((request) => request(axios, basePath));
    },
    /**
     * Gets category by name.
     * @param {ApiContentHaloRunV1alpha1CategoryApiQueryCategoryByNameRequest} requestParameters Request parameters.
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     */
    queryCategoryByName(
      requestParameters: ApiContentHaloRunV1alpha1CategoryApiQueryCategoryByNameRequest,
      options?: AxiosRequestConfig
    ): AxiosPromise<CategoryVo> {
      return localVarFp
        .queryCategoryByName(requestParameters.name, options)
        .then((request) => request(axios, basePath));
    },
    /**
     * Lists posts by category name.
     * @param {ApiContentHaloRunV1alpha1CategoryApiQueryPostsByCategoryNameRequest} requestParameters Request parameters.
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     */
    queryPostsByCategoryName(
      requestParameters: ApiContentHaloRunV1alpha1CategoryApiQueryPostsByCategoryNameRequest,
      options?: AxiosRequestConfig
    ): AxiosPromise<ListedPostVoList> {
      return localVarFp
        .queryPostsByCategoryName(
          requestParameters.name,
          requestParameters.fieldSelector,
          requestParameters.labelSelector,
          requestParameters.page,
          requestParameters.size,
          requestParameters.sort,
          options
        )
        .then((request) => request(axios, basePath));
    },
  };
};

/**
 * Request parameters for queryCategories operation in ApiContentHaloRunV1alpha1CategoryApi.
 * @export
 * @interface ApiContentHaloRunV1alpha1CategoryApiQueryCategoriesRequest
 */
export interface ApiContentHaloRunV1alpha1CategoryApiQueryCategoriesRequest {
  /**
   * Field selector for filtering.
   * @type {Array<string>}
   * @memberof ApiContentHaloRunV1alpha1CategoryApiQueryCategories
   */
  readonly fieldSelector?: Array<string>;

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

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

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

  /**
   * Sort property and direction of the list result. Support sorting based on attribute name path.
   * @type {Array<string>}
   * @memberof ApiContentHaloRunV1alpha1CategoryApiQueryCategories
   */
  readonly sort?: Array<string>;
}

/**
 * Request parameters for queryCategoryByName operation in ApiContentHaloRunV1alpha1CategoryApi.
 * @export
 * @interface ApiContentHaloRunV1alpha1CategoryApiQueryCategoryByNameRequest
 */
export interface ApiContentHaloRunV1alpha1CategoryApiQueryCategoryByNameRequest {
  /**
   * Category name
   * @type {string}
   * @memberof ApiContentHaloRunV1alpha1CategoryApiQueryCategoryByName
   */
  readonly name: string;
}

/**
 * Request parameters for queryPostsByCategoryName operation in ApiContentHaloRunV1alpha1CategoryApi.
 * @export
 * @interface ApiContentHaloRunV1alpha1CategoryApiQueryPostsByCategoryNameRequest
 */
export interface ApiContentHaloRunV1alpha1CategoryApiQueryPostsByCategoryNameRequest {
  /**
   * Category name
   * @type {string}
   * @memberof ApiContentHaloRunV1alpha1CategoryApiQueryPostsByCategoryName
   */
  readonly name: string;

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

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

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

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

  /**
   * Sort property and direction of the list result. Support sorting based on attribute name path.
   * @type {Array<string>}
   * @memberof ApiContentHaloRunV1alpha1CategoryApiQueryPostsByCategoryName
   */
  readonly sort?: Array<string>;
}

/**
 * ApiContentHaloRunV1alpha1CategoryApi - object-oriented interface
 * @export
 * @class ApiContentHaloRunV1alpha1CategoryApi
 * @extends {BaseAPI}
 */
export class ApiContentHaloRunV1alpha1CategoryApi extends BaseAPI {
  /**
   * Lists categories.
   * @param {ApiContentHaloRunV1alpha1CategoryApiQueryCategoriesRequest} requestParameters Request parameters.
   * @param {*} [options] Override http request option.
   * @throws {RequiredError}
   * @memberof ApiContentHaloRunV1alpha1CategoryApi
   */
  public queryCategories(
    requestParameters: ApiContentHaloRunV1alpha1CategoryApiQueryCategoriesRequest = {},
    options?: AxiosRequestConfig
  ) {
    return ApiContentHaloRunV1alpha1CategoryApiFp(this.configuration)
      .queryCategories(
        requestParameters.fieldSelector,
        requestParameters.labelSelector,
        requestParameters.page,
        requestParameters.size,
        requestParameters.sort,
        options
      )
      .then((request) => request(this.axios, this.basePath));
  }

  /**
   * Gets category by name.
   * @param {ApiContentHaloRunV1alpha1CategoryApiQueryCategoryByNameRequest} requestParameters Request parameters.
   * @param {*} [options] Override http request option.
   * @throws {RequiredError}
   * @memberof ApiContentHaloRunV1alpha1CategoryApi
   */
  public queryCategoryByName(
    requestParameters: ApiContentHaloRunV1alpha1CategoryApiQueryCategoryByNameRequest,
    options?: AxiosRequestConfig
  ) {
    return ApiContentHaloRunV1alpha1CategoryApiFp(this.configuration)
      .queryCategoryByName(requestParameters.name, options)
      .then((request) => request(this.axios, this.basePath));
  }

  /**
   * Lists posts by category name.
   * @param {ApiContentHaloRunV1alpha1CategoryApiQueryPostsByCategoryNameRequest} requestParameters Request parameters.
   * @param {*} [options] Override http request option.
   * @throws {RequiredError}
   * @memberof ApiContentHaloRunV1alpha1CategoryApi
   */
  public queryPostsByCategoryName(
    requestParameters: ApiContentHaloRunV1alpha1CategoryApiQueryPostsByCategoryNameRequest,
    options?: AxiosRequestConfig
  ) {
    return ApiContentHaloRunV1alpha1CategoryApiFp(this.configuration)
      .queryPostsByCategoryName(
        requestParameters.name,
        requestParameters.fieldSelector,
        requestParameters.labelSelector,
        requestParameters.page,
        requestParameters.size,
        requestParameters.sort,
        options
      )
      .then((request) => request(this.axios, this.basePath));
  }
}
