/* 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 { ListedPostList } from "../models";
// @ts-ignore
import { Post } from "../models";
/**
 * UcContentHaloRunV1alpha1PostApi - axios parameter creator
 * @export
 */
export const UcContentHaloRunV1alpha1PostApiAxiosParamCreator = function (
  configuration?: Configuration
) {
  return {
    /**
     * Create my post. If you want to create a post with content, please set  annotation: \"content.halo.run/content-json\" into annotations and refer  to PostRequestContent for corresponding data type.
     * @param {Post} [post]
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     */
    createMyPost: async (
      post?: Post,
      options: AxiosRequestConfig = {}
    ): Promise<RequestArgs> => {
      const localVarPath = `/apis/uc.content.halo.run/v1alpha1/posts`;
      // 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(
        post,
        localVarRequestOptions,
        configuration
      );

      return {
        url: toPathString(localVarUrlObj),
        options: localVarRequestOptions,
      };
    },
    /**
     * List posts owned by the current user.
     * @param {Array<string>} [category]
     * @param {Array<string>} [contributor]
     * @param {Array<string>} [fieldSelector] Field selector for filtering.
     * @param {string} [keyword] Posts filtered by keyword.
     * @param {Array<string>} [labelSelector] Label selector for filtering.
     * @param {number} [page] The page number. Zero indicates no page.
     * @param {'DRAFT' | 'PENDING_APPROVAL' | 'PUBLISHED' | 'FAILED'} [publishPhase]
     * @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,publishTime
     * @param {Array<string>} [tag]
     * @param {'PUBLIC' | 'INTERNAL' | 'PRIVATE'} [visible]
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     */
    listMyPosts: async (
      category?: Array<string>,
      contributor?: Array<string>,
      fieldSelector?: Array<string>,
      keyword?: string,
      labelSelector?: Array<string>,
      page?: number,
      publishPhase?: "DRAFT" | "PENDING_APPROVAL" | "PUBLISHED" | "FAILED",
      size?: number,
      sort?: Array<string>,
      tag?: Array<string>,
      visible?: "PUBLIC" | "INTERNAL" | "PRIVATE",
      options: AxiosRequestConfig = {}
    ): Promise<RequestArgs> => {
      const localVarPath = `/apis/uc.content.halo.run/v1alpha1/posts`;
      // 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 (category) {
        localVarQueryParameter["category"] = Array.from(category);
      }

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

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

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

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

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

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

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

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

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

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

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

      return {
        url: toPathString(localVarUrlObj),
        options: localVarRequestOptions,
      };
    },
    /**
     * Update my post. If you want to update a post with content, please  set annotation: \"content.halo.run/content-json\" into annotations  and refer to PostRequestContent for corresponding data type.
     * @param {string} name Post name
     * @param {Post} [post]
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     */
    updateMyPost: async (
      name: string,
      post?: Post,
      options: AxiosRequestConfig = {}
    ): Promise<RequestArgs> => {
      // verify required parameter 'name' is not null or undefined
      assertParamExists("updateMyPost", "name", name);
      const localVarPath =
        `/apis/uc.content.halo.run/v1alpha1/posts/{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: "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(
        post,
        localVarRequestOptions,
        configuration
      );

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

/**
 * UcContentHaloRunV1alpha1PostApi - functional programming interface
 * @export
 */
export const UcContentHaloRunV1alpha1PostApiFp = function (
  configuration?: Configuration
) {
  const localVarAxiosParamCreator =
    UcContentHaloRunV1alpha1PostApiAxiosParamCreator(configuration);
  return {
    /**
     * Create my post. If you want to create a post with content, please set  annotation: \"content.halo.run/content-json\" into annotations and refer  to PostRequestContent for corresponding data type.
     * @param {Post} [post]
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     */
    async createMyPost(
      post?: Post,
      options?: AxiosRequestConfig
    ): Promise<
      (axios?: AxiosInstance, basePath?: string) => AxiosPromise<Post>
    > {
      const localVarAxiosArgs = await localVarAxiosParamCreator.createMyPost(
        post,
        options
      );
      return createRequestFunction(
        localVarAxiosArgs,
        globalAxios,
        BASE_PATH,
        configuration
      );
    },
    /**
     * List posts owned by the current user.
     * @param {Array<string>} [category]
     * @param {Array<string>} [contributor]
     * @param {Array<string>} [fieldSelector] Field selector for filtering.
     * @param {string} [keyword] Posts filtered by keyword.
     * @param {Array<string>} [labelSelector] Label selector for filtering.
     * @param {number} [page] The page number. Zero indicates no page.
     * @param {'DRAFT' | 'PENDING_APPROVAL' | 'PUBLISHED' | 'FAILED'} [publishPhase]
     * @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,publishTime
     * @param {Array<string>} [tag]
     * @param {'PUBLIC' | 'INTERNAL' | 'PRIVATE'} [visible]
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     */
    async listMyPosts(
      category?: Array<string>,
      contributor?: Array<string>,
      fieldSelector?: Array<string>,
      keyword?: string,
      labelSelector?: Array<string>,
      page?: number,
      publishPhase?: "DRAFT" | "PENDING_APPROVAL" | "PUBLISHED" | "FAILED",
      size?: number,
      sort?: Array<string>,
      tag?: Array<string>,
      visible?: "PUBLIC" | "INTERNAL" | "PRIVATE",
      options?: AxiosRequestConfig
    ): Promise<
      (axios?: AxiosInstance, basePath?: string) => AxiosPromise<ListedPostList>
    > {
      const localVarAxiosArgs = await localVarAxiosParamCreator.listMyPosts(
        category,
        contributor,
        fieldSelector,
        keyword,
        labelSelector,
        page,
        publishPhase,
        size,
        sort,
        tag,
        visible,
        options
      );
      return createRequestFunction(
        localVarAxiosArgs,
        globalAxios,
        BASE_PATH,
        configuration
      );
    },
    /**
     * Update my post. If you want to update a post with content, please  set annotation: \"content.halo.run/content-json\" into annotations  and refer to PostRequestContent for corresponding data type.
     * @param {string} name Post name
     * @param {Post} [post]
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     */
    async updateMyPost(
      name: string,
      post?: Post,
      options?: AxiosRequestConfig
    ): Promise<
      (axios?: AxiosInstance, basePath?: string) => AxiosPromise<Post>
    > {
      const localVarAxiosArgs = await localVarAxiosParamCreator.updateMyPost(
        name,
        post,
        options
      );
      return createRequestFunction(
        localVarAxiosArgs,
        globalAxios,
        BASE_PATH,
        configuration
      );
    },
  };
};

/**
 * UcContentHaloRunV1alpha1PostApi - factory interface
 * @export
 */
export const UcContentHaloRunV1alpha1PostApiFactory = function (
  configuration?: Configuration,
  basePath?: string,
  axios?: AxiosInstance
) {
  const localVarFp = UcContentHaloRunV1alpha1PostApiFp(configuration);
  return {
    /**
     * Create my post. If you want to create a post with content, please set  annotation: \"content.halo.run/content-json\" into annotations and refer  to PostRequestContent for corresponding data type.
     * @param {UcContentHaloRunV1alpha1PostApiCreateMyPostRequest} requestParameters Request parameters.
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     */
    createMyPost(
      requestParameters: UcContentHaloRunV1alpha1PostApiCreateMyPostRequest = {},
      options?: AxiosRequestConfig
    ): AxiosPromise<Post> {
      return localVarFp
        .createMyPost(requestParameters.post, options)
        .then((request) => request(axios, basePath));
    },
    /**
     * List posts owned by the current user.
     * @param {UcContentHaloRunV1alpha1PostApiListMyPostsRequest} requestParameters Request parameters.
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     */
    listMyPosts(
      requestParameters: UcContentHaloRunV1alpha1PostApiListMyPostsRequest = {},
      options?: AxiosRequestConfig
    ): AxiosPromise<ListedPostList> {
      return localVarFp
        .listMyPosts(
          requestParameters.category,
          requestParameters.contributor,
          requestParameters.fieldSelector,
          requestParameters.keyword,
          requestParameters.labelSelector,
          requestParameters.page,
          requestParameters.publishPhase,
          requestParameters.size,
          requestParameters.sort,
          requestParameters.tag,
          requestParameters.visible,
          options
        )
        .then((request) => request(axios, basePath));
    },
    /**
     * Update my post. If you want to update a post with content, please  set annotation: \"content.halo.run/content-json\" into annotations  and refer to PostRequestContent for corresponding data type.
     * @param {UcContentHaloRunV1alpha1PostApiUpdateMyPostRequest} requestParameters Request parameters.
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     */
    updateMyPost(
      requestParameters: UcContentHaloRunV1alpha1PostApiUpdateMyPostRequest,
      options?: AxiosRequestConfig
    ): AxiosPromise<Post> {
      return localVarFp
        .updateMyPost(requestParameters.name, requestParameters.post, options)
        .then((request) => request(axios, basePath));
    },
  };
};

/**
 * Request parameters for createMyPost operation in UcContentHaloRunV1alpha1PostApi.
 * @export
 * @interface UcContentHaloRunV1alpha1PostApiCreateMyPostRequest
 */
export interface UcContentHaloRunV1alpha1PostApiCreateMyPostRequest {
  /**
   *
   * @type {Post}
   * @memberof UcContentHaloRunV1alpha1PostApiCreateMyPost
   */
  readonly post?: Post;
}

/**
 * Request parameters for listMyPosts operation in UcContentHaloRunV1alpha1PostApi.
 * @export
 * @interface UcContentHaloRunV1alpha1PostApiListMyPostsRequest
 */
export interface UcContentHaloRunV1alpha1PostApiListMyPostsRequest {
  /**
   *
   * @type {Array<string>}
   * @memberof UcContentHaloRunV1alpha1PostApiListMyPosts
   */
  readonly category?: Array<string>;

  /**
   *
   * @type {Array<string>}
   * @memberof UcContentHaloRunV1alpha1PostApiListMyPosts
   */
  readonly contributor?: Array<string>;

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

  /**
   * Posts filtered by keyword.
   * @type {string}
   * @memberof UcContentHaloRunV1alpha1PostApiListMyPosts
   */
  readonly keyword?: string;

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

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

  /**
   *
   * @type {'DRAFT' | 'PENDING_APPROVAL' | 'PUBLISHED' | 'FAILED'}
   * @memberof UcContentHaloRunV1alpha1PostApiListMyPosts
   */
  readonly publishPhase?: "DRAFT" | "PENDING_APPROVAL" | "PUBLISHED" | "FAILED";

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

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

  /**
   *
   * @type {Array<string>}
   * @memberof UcContentHaloRunV1alpha1PostApiListMyPosts
   */
  readonly tag?: Array<string>;

  /**
   *
   * @type {'PUBLIC' | 'INTERNAL' | 'PRIVATE'}
   * @memberof UcContentHaloRunV1alpha1PostApiListMyPosts
   */
  readonly visible?: "PUBLIC" | "INTERNAL" | "PRIVATE";
}

/**
 * Request parameters for updateMyPost operation in UcContentHaloRunV1alpha1PostApi.
 * @export
 * @interface UcContentHaloRunV1alpha1PostApiUpdateMyPostRequest
 */
export interface UcContentHaloRunV1alpha1PostApiUpdateMyPostRequest {
  /**
   * Post name
   * @type {string}
   * @memberof UcContentHaloRunV1alpha1PostApiUpdateMyPost
   */
  readonly name: string;

  /**
   *
   * @type {Post}
   * @memberof UcContentHaloRunV1alpha1PostApiUpdateMyPost
   */
  readonly post?: Post;
}

/**
 * UcContentHaloRunV1alpha1PostApi - object-oriented interface
 * @export
 * @class UcContentHaloRunV1alpha1PostApi
 * @extends {BaseAPI}
 */
export class UcContentHaloRunV1alpha1PostApi extends BaseAPI {
  /**
   * Create my post. If you want to create a post with content, please set  annotation: \"content.halo.run/content-json\" into annotations and refer  to PostRequestContent for corresponding data type.
   * @param {UcContentHaloRunV1alpha1PostApiCreateMyPostRequest} requestParameters Request parameters.
   * @param {*} [options] Override http request option.
   * @throws {RequiredError}
   * @memberof UcContentHaloRunV1alpha1PostApi
   */
  public createMyPost(
    requestParameters: UcContentHaloRunV1alpha1PostApiCreateMyPostRequest = {},
    options?: AxiosRequestConfig
  ) {
    return UcContentHaloRunV1alpha1PostApiFp(this.configuration)
      .createMyPost(requestParameters.post, options)
      .then((request) => request(this.axios, this.basePath));
  }

  /**
   * List posts owned by the current user.
   * @param {UcContentHaloRunV1alpha1PostApiListMyPostsRequest} requestParameters Request parameters.
   * @param {*} [options] Override http request option.
   * @throws {RequiredError}
   * @memberof UcContentHaloRunV1alpha1PostApi
   */
  public listMyPosts(
    requestParameters: UcContentHaloRunV1alpha1PostApiListMyPostsRequest = {},
    options?: AxiosRequestConfig
  ) {
    return UcContentHaloRunV1alpha1PostApiFp(this.configuration)
      .listMyPosts(
        requestParameters.category,
        requestParameters.contributor,
        requestParameters.fieldSelector,
        requestParameters.keyword,
        requestParameters.labelSelector,
        requestParameters.page,
        requestParameters.publishPhase,
        requestParameters.size,
        requestParameters.sort,
        requestParameters.tag,
        requestParameters.visible,
        options
      )
      .then((request) => request(this.axios, this.basePath));
  }

  /**
   * Update my post. If you want to update a post with content, please  set annotation: \"content.halo.run/content-json\" into annotations  and refer to PostRequestContent for corresponding data type.
   * @param {UcContentHaloRunV1alpha1PostApiUpdateMyPostRequest} requestParameters Request parameters.
   * @param {*} [options] Override http request option.
   * @throws {RequiredError}
   * @memberof UcContentHaloRunV1alpha1PostApi
   */
  public updateMyPost(
    requestParameters: UcContentHaloRunV1alpha1PostApiUpdateMyPostRequest,
    options?: AxiosRequestConfig
  ) {
    return UcContentHaloRunV1alpha1PostApiFp(this.configuration)
      .updateMyPost(requestParameters.name, requestParameters.post, options)
      .then((request) => request(this.axios, this.basePath));
  }
}
