/* tslint:disable */
/* eslint-disable */
/**
 * Signal Cli REST API
 * This is the Signal Cli REST API documentation.
 *
 * The version of the OpenAPI document: 1.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 * as runtime from "../runtime.js";
import type {
  ApiAddStickerPackRequest,
  ApiError,
  ClientListInstalledStickerPacksResponse,
} from "../models/index.js";
import {
  ApiAddStickerPackRequestFromJSON,
  ApiAddStickerPackRequestToJSON,
  ApiErrorFromJSON,
  ApiErrorToJSON,
  ClientListInstalledStickerPacksResponseFromJSON,
  ClientListInstalledStickerPacksResponseToJSON,
} from "../models/index.js";

export interface V1StickerPacksNumberGetRequest {
  number: string;
}

export interface V1StickerPacksNumberPostRequest {
  number: string;
  data: ApiAddStickerPackRequest;
}

/**
 *
 */
export class StickerPacksApi extends runtime.BaseAPI {
  /**
   * List Installed Sticker Packs.
   * List Installed Sticker Packs.
   */
  async v1StickerPacksNumberGetRaw(
    requestParameters: V1StickerPacksNumberGetRequest,
    initOverrides?: RequestInit | runtime.InitOverrideFunction,
  ): Promise<
    runtime.ApiResponse<Array<ClientListInstalledStickerPacksResponse>>
  > {
    if (requestParameters["number"] == null) {
      throw new runtime.RequiredError(
        "number",
        'Required parameter "number" was null or undefined when calling v1StickerPacksNumberGet().',
      );
    }

    const queryParameters: any = {};

    const headerParameters: runtime.HTTPHeaders = {};

    const response = await this.request(
      {
        path: `/v1/sticker-packs/{number}`.replace(
          `{${"number"}}`,
          encodeURIComponent(String(requestParameters["number"])),
        ),
        method: "GET",
        headers: headerParameters,
        query: queryParameters,
      },
      initOverrides,
    );

    return new runtime.JSONApiResponse(response, (jsonValue) =>
      jsonValue.map(ClientListInstalledStickerPacksResponseFromJSON),
    );
  }

  /**
   * List Installed Sticker Packs.
   * List Installed Sticker Packs.
   */
  async v1StickerPacksNumberGet(
    requestParameters: V1StickerPacksNumberGetRequest,
    initOverrides?: RequestInit | runtime.InitOverrideFunction,
  ): Promise<
    Array<ClientListInstalledStickerPacksResponse> | null | undefined
  > {
    const response = await this.v1StickerPacksNumberGetRaw(
      requestParameters,
      initOverrides,
    );
    switch (response.raw.status) {
      case 200:
        return await response.value();
      case 204:
        return null;
      default:
        return await response.value();
    }
  }

  /**
   * In order to add a sticker pack, browse to https://signalstickers.org/ and select the sticker pack you want to add. Then, press the \"Add to Signal\" button. If you look at the address bar in your browser you should see an URL in this format: https://signal.art/addstickers/#pack_id=XXX&pack_key=YYY, where XXX is the pack_id and YYY is the pack_key.
   * Add Sticker Pack.
   */
  async v1StickerPacksNumberPostRaw(
    requestParameters: V1StickerPacksNumberPostRequest,
    initOverrides?: RequestInit | runtime.InitOverrideFunction,
  ): Promise<runtime.ApiResponse<void>> {
    if (requestParameters["number"] == null) {
      throw new runtime.RequiredError(
        "number",
        'Required parameter "number" was null or undefined when calling v1StickerPacksNumberPost().',
      );
    }

    if (requestParameters["data"] == null) {
      throw new runtime.RequiredError(
        "data",
        'Required parameter "data" was null or undefined when calling v1StickerPacksNumberPost().',
      );
    }

    const queryParameters: any = {};

    const headerParameters: runtime.HTTPHeaders = {};

    headerParameters["Content-Type"] = "application/json";

    const response = await this.request(
      {
        path: `/v1/sticker-packs/{number}`.replace(
          `{${"number"}}`,
          encodeURIComponent(String(requestParameters["number"])),
        ),
        method: "POST",
        headers: headerParameters,
        query: queryParameters,
        body: ApiAddStickerPackRequestToJSON(requestParameters["data"]),
      },
      initOverrides,
    );

    return new runtime.VoidApiResponse(response);
  }

  /**
   * In order to add a sticker pack, browse to https://signalstickers.org/ and select the sticker pack you want to add. Then, press the \"Add to Signal\" button. If you look at the address bar in your browser you should see an URL in this format: https://signal.art/addstickers/#pack_id=XXX&pack_key=YYY, where XXX is the pack_id and YYY is the pack_key.
   * Add Sticker Pack.
   */
  async v1StickerPacksNumberPost(
    requestParameters: V1StickerPacksNumberPostRequest,
    initOverrides?: RequestInit | runtime.InitOverrideFunction,
  ): Promise<void> {
    await this.v1StickerPacksNumberPostRaw(requestParameters, initOverrides);
  }
}
