/* tslint:disable */
/* eslint-disable */
/**
 * esa API v1
 * チームのナレッジ共有サービス[esa.io](https://esa.io/)のAPI v1の仕様書
 *
 * The version of the OpenAPI document: 1.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 globalAxios, { AxiosPromise, AxiosInstance } from "axios";
import { Configuration } from "../configuration";
// 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 { PaginatedWatchers } from "../models";
/**
 * WatchApi - axios parameter creator
 * @export
 */
export const WatchApiAxiosParamCreator = function (
  configuration?: Configuration,
) {
  return {
    /**
     * 指定された記事にWatchをしたユーザ一覧を取得します。
     * @summary Watchしたユーザー一覧を取得する
     * @param {string} teamName チーム名
     * @param {number} postNumber 記事ID
     * @param {number} [page] ページ番号
     * @param {number} [perPage] 1ページあたりに含まれる要素数
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     */
    getWatchers: async (
      teamName: string,
      postNumber: number,
      page?: number,
      perPage?: number,
      options: any = {},
    ): Promise<RequestArgs> => {
      // verify required parameter 'teamName' is not null or undefined
      assertParamExists("getWatchers", "teamName", teamName);
      // verify required parameter 'postNumber' is not null or undefined
      assertParamExists("getWatchers", "postNumber", postNumber);
      const localVarPath = `/teams/{team_name}/posts/{post_number}/watchers`
        .replace(`{${"team_name"}}`, encodeURIComponent(String(teamName)))
        .replace(`{${"post_number"}}`, encodeURIComponent(String(postNumber)));
      // 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 AccessTokenHeader required
      // http bearer authentication required
      await setBearerAuthToObject(localVarHeaderParameter, configuration);

      // authentication AccessTokenQueryParam required
      await setApiKeyToObject(
        localVarQueryParameter,
        "access_token",
        configuration,
      );

      // authentication OAuth2 required
      // oauth required
      await setOAuthToObject(
        localVarHeaderParameter,
        "OAuth2",
        ["read"],
        configuration,
      );

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

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

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

      return {
        url: toPathString(localVarUrlObj),
        options: localVarRequestOptions,
      };
    },
    /**
     * 指定された記事へのWatchを取り消します。
     * @summary 記事のWatchを取り消す
     * @param {string} teamName チーム名
     * @param {number} postNumber 記事ID
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     */
    unwachPost: async (
      teamName: string,
      postNumber: number,
      options: any = {},
    ): Promise<RequestArgs> => {
      // verify required parameter 'teamName' is not null or undefined
      assertParamExists("unwachPost", "teamName", teamName);
      // verify required parameter 'postNumber' is not null or undefined
      assertParamExists("unwachPost", "postNumber", postNumber);
      const localVarPath = `/teams/{team_name}/posts/{post_number}/watch`
        .replace(`{${"team_name"}}`, encodeURIComponent(String(teamName)))
        .replace(`{${"post_number"}}`, encodeURIComponent(String(postNumber)));
      // 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: "DELETE",
        ...baseOptions,
        ...options,
      };
      const localVarHeaderParameter = {} as any;
      const localVarQueryParameter = {} as any;

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

      // authentication AccessTokenQueryParam required
      await setApiKeyToObject(
        localVarQueryParameter,
        "access_token",
        configuration,
      );

      // authentication OAuth2 required
      // oauth required
      await setOAuthToObject(
        localVarHeaderParameter,
        "OAuth2",
        ["write"],
        configuration,
      );

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

      return {
        url: toPathString(localVarUrlObj),
        options: localVarRequestOptions,
      };
    },
    /**
     * 指定された記事にWatchをします。
     * @summary 記事をWatchする
     * @param {string} teamName チーム名
     * @param {number} postNumber 記事ID
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     */
    watchPost: async (
      teamName: string,
      postNumber: number,
      options: any = {},
    ): Promise<RequestArgs> => {
      // verify required parameter 'teamName' is not null or undefined
      assertParamExists("watchPost", "teamName", teamName);
      // verify required parameter 'postNumber' is not null or undefined
      assertParamExists("watchPost", "postNumber", postNumber);
      const localVarPath = `/teams/{team_name}/posts/{post_number}/watch`
        .replace(`{${"team_name"}}`, encodeURIComponent(String(teamName)))
        .replace(`{${"post_number"}}`, encodeURIComponent(String(postNumber)));
      // 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 AccessTokenHeader required
      // http bearer authentication required
      await setBearerAuthToObject(localVarHeaderParameter, configuration);

      // authentication AccessTokenQueryParam required
      await setApiKeyToObject(
        localVarQueryParameter,
        "access_token",
        configuration,
      );

      // authentication OAuth2 required
      // oauth required
      await setOAuthToObject(
        localVarHeaderParameter,
        "OAuth2",
        ["write"],
        configuration,
      );

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

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

/**
 * WatchApi - functional programming interface
 * @export
 */
export const WatchApiFp = function (configuration?: Configuration) {
  const localVarAxiosParamCreator = WatchApiAxiosParamCreator(configuration);
  return {
    /**
     * 指定された記事にWatchをしたユーザ一覧を取得します。
     * @summary Watchしたユーザー一覧を取得する
     * @param {string} teamName チーム名
     * @param {number} postNumber 記事ID
     * @param {number} [page] ページ番号
     * @param {number} [perPage] 1ページあたりに含まれる要素数
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     */
    async getWatchers(
      teamName: string,
      postNumber: number,
      page?: number,
      perPage?: number,
      options?: any,
    ): Promise<
      (
        axios?: AxiosInstance,
        basePath?: string,
      ) => AxiosPromise<PaginatedWatchers>
    > {
      const localVarAxiosArgs = await localVarAxiosParamCreator.getWatchers(
        teamName,
        postNumber,
        page,
        perPage,
        options,
      );
      return createRequestFunction(
        localVarAxiosArgs,
        globalAxios,
        BASE_PATH,
        configuration,
      );
    },
    /**
     * 指定された記事へのWatchを取り消します。
     * @summary 記事のWatchを取り消す
     * @param {string} teamName チーム名
     * @param {number} postNumber 記事ID
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     */
    async unwachPost(
      teamName: string,
      postNumber: number,
      options?: any,
    ): Promise<
      (axios?: AxiosInstance, basePath?: string) => AxiosPromise<void>
    > {
      const localVarAxiosArgs = await localVarAxiosParamCreator.unwachPost(
        teamName,
        postNumber,
        options,
      );
      return createRequestFunction(
        localVarAxiosArgs,
        globalAxios,
        BASE_PATH,
        configuration,
      );
    },
    /**
     * 指定された記事にWatchをします。
     * @summary 記事をWatchする
     * @param {string} teamName チーム名
     * @param {number} postNumber 記事ID
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     */
    async watchPost(
      teamName: string,
      postNumber: number,
      options?: any,
    ): Promise<
      (axios?: AxiosInstance, basePath?: string) => AxiosPromise<void>
    > {
      const localVarAxiosArgs = await localVarAxiosParamCreator.watchPost(
        teamName,
        postNumber,
        options,
      );
      return createRequestFunction(
        localVarAxiosArgs,
        globalAxios,
        BASE_PATH,
        configuration,
      );
    },
  };
};

/**
 * WatchApi - factory interface
 * @export
 */
export const WatchApiFactory = function (
  configuration?: Configuration,
  basePath?: string,
  axios?: AxiosInstance,
) {
  const localVarFp = WatchApiFp(configuration);
  return {
    /**
     * 指定された記事にWatchをしたユーザ一覧を取得します。
     * @summary Watchしたユーザー一覧を取得する
     * @param {string} teamName チーム名
     * @param {number} postNumber 記事ID
     * @param {number} [page] ページ番号
     * @param {number} [perPage] 1ページあたりに含まれる要素数
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     */
    getWatchers(
      teamName: string,
      postNumber: number,
      page?: number,
      perPage?: number,
      options?: any,
    ): AxiosPromise<PaginatedWatchers> {
      return localVarFp
        .getWatchers(teamName, postNumber, page, perPage, options)
        .then((request) => request(axios, basePath));
    },
    /**
     * 指定された記事へのWatchを取り消します。
     * @summary 記事のWatchを取り消す
     * @param {string} teamName チーム名
     * @param {number} postNumber 記事ID
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     */
    unwachPost(
      teamName: string,
      postNumber: number,
      options?: any,
    ): AxiosPromise<void> {
      return localVarFp
        .unwachPost(teamName, postNumber, options)
        .then((request) => request(axios, basePath));
    },
    /**
     * 指定された記事にWatchをします。
     * @summary 記事をWatchする
     * @param {string} teamName チーム名
     * @param {number} postNumber 記事ID
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     */
    watchPost(
      teamName: string,
      postNumber: number,
      options?: any,
    ): AxiosPromise<void> {
      return localVarFp
        .watchPost(teamName, postNumber, options)
        .then((request) => request(axios, basePath));
    },
  };
};

/**
 * Request parameters for getWatchers operation in WatchApi.
 * @export
 * @interface WatchApiGetWatchersRequest
 */
export interface WatchApiGetWatchersRequest {
  /**
   * チーム名
   * @type {string}
   * @memberof WatchApiGetWatchers
   */
  readonly teamName: string;

  /**
   * 記事ID
   * @type {number}
   * @memberof WatchApiGetWatchers
   */
  readonly postNumber: number;

  /**
   * ページ番号
   * @type {number}
   * @memberof WatchApiGetWatchers
   */
  readonly page?: number;

  /**
   * 1ページあたりに含まれる要素数
   * @type {number}
   * @memberof WatchApiGetWatchers
   */
  readonly perPage?: number;
}

/**
 * Request parameters for unwachPost operation in WatchApi.
 * @export
 * @interface WatchApiUnwachPostRequest
 */
export interface WatchApiUnwachPostRequest {
  /**
   * チーム名
   * @type {string}
   * @memberof WatchApiUnwachPost
   */
  readonly teamName: string;

  /**
   * 記事ID
   * @type {number}
   * @memberof WatchApiUnwachPost
   */
  readonly postNumber: number;
}

/**
 * Request parameters for watchPost operation in WatchApi.
 * @export
 * @interface WatchApiWatchPostRequest
 */
export interface WatchApiWatchPostRequest {
  /**
   * チーム名
   * @type {string}
   * @memberof WatchApiWatchPost
   */
  readonly teamName: string;

  /**
   * 記事ID
   * @type {number}
   * @memberof WatchApiWatchPost
   */
  readonly postNumber: number;
}

/**
 * WatchApi - object-oriented interface
 * @export
 * @class WatchApi
 * @extends {BaseAPI}
 */
export class WatchApi extends BaseAPI {
  /**
   * 指定された記事にWatchをしたユーザ一覧を取得します。
   * @summary Watchしたユーザー一覧を取得する
   * @param {WatchApiGetWatchersRequest} requestParameters Request parameters.
   * @param {*} [options] Override http request option.
   * @throws {RequiredError}
   * @memberof WatchApi
   */
  public getWatchers(
    requestParameters: WatchApiGetWatchersRequest,
    options?: any,
  ) {
    return WatchApiFp(this.configuration)
      .getWatchers(
        requestParameters.teamName,
        requestParameters.postNumber,
        requestParameters.page,
        requestParameters.perPage,
        options,
      )
      .then((request) => request(this.axios, this.basePath));
  }

  /**
   * 指定された記事へのWatchを取り消します。
   * @summary 記事のWatchを取り消す
   * @param {WatchApiUnwachPostRequest} requestParameters Request parameters.
   * @param {*} [options] Override http request option.
   * @throws {RequiredError}
   * @memberof WatchApi
   */
  public unwachPost(
    requestParameters: WatchApiUnwachPostRequest,
    options?: any,
  ) {
    return WatchApiFp(this.configuration)
      .unwachPost(
        requestParameters.teamName,
        requestParameters.postNumber,
        options,
      )
      .then((request) => request(this.axios, this.basePath));
  }

  /**
   * 指定された記事にWatchをします。
   * @summary 記事をWatchする
   * @param {WatchApiWatchPostRequest} requestParameters Request parameters.
   * @param {*} [options] Override http request option.
   * @throws {RequiredError}
   * @memberof WatchApi
   */
  public watchPost(requestParameters: WatchApiWatchPostRequest, options?: any) {
    return WatchApiFp(this.configuration)
      .watchPost(
        requestParameters.teamName,
        requestParameters.postNumber,
        options,
      )
      .then((request) => request(this.axios, this.basePath));
  }
}
