/* 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 {
  ApiError,
  ApiSendMessageError,
  ApiSendMessageResponse,
  ApiSendMessageV1,
  ApiSendMessageV2,
  ApiTypingIndicatorRequest,
} from "../models/index.js";
import {
  ApiErrorFromJSON,
  ApiErrorToJSON,
  ApiSendMessageErrorFromJSON,
  ApiSendMessageErrorToJSON,
  ApiSendMessageResponseFromJSON,
  ApiSendMessageResponseToJSON,
  ApiSendMessageV1FromJSON,
  ApiSendMessageV1ToJSON,
  ApiSendMessageV2FromJSON,
  ApiSendMessageV2ToJSON,
  ApiTypingIndicatorRequestFromJSON,
  ApiTypingIndicatorRequestToJSON,
} from "../models/index.js";

export interface V1ReceiveNumberGetRequest {
  number: string;
  timeout?: string;
  ignoreAttachments?: string;
  ignoreStories?: string;
  maxMessages?: string;
  sendReadReceipts?: string;
}

export interface V1SendPostRequest {
  data: ApiSendMessageV1;
}

export interface V1TypingIndicatorNumberDeleteRequest {
  number: string;
  data: ApiTypingIndicatorRequest;
}

export interface V1TypingIndicatorNumberPutRequest {
  number: string;
  data: ApiTypingIndicatorRequest;
}

export interface V2SendPostRequest {
  data: ApiSendMessageV2;
}

/**
 *
 */
export class MessagesApi extends runtime.BaseAPI {
  /**
   * Receives Signal Messages from the Signal Network. If you are running the docker container in normal/native mode, this is a GET endpoint. In json-rpc mode this is a websocket endpoint.
   * Receive Signal Messages.
   */
  async v1ReceiveNumberGetRaw(
    requestParameters: V1ReceiveNumberGetRequest,
    initOverrides?: RequestInit | runtime.InitOverrideFunction,
  ): Promise<runtime.ApiResponse<Array<string>>> {
    if (requestParameters["number"] == null) {
      throw new runtime.RequiredError(
        "number",
        'Required parameter "number" was null or undefined when calling v1ReceiveNumberGet().',
      );
    }

    const queryParameters: any = {};

    if (requestParameters["timeout"] != null) {
      queryParameters["timeout"] = requestParameters["timeout"];
    }

    if (requestParameters["ignoreAttachments"] != null) {
      queryParameters["ignore_attachments"] =
        requestParameters["ignoreAttachments"];
    }

    if (requestParameters["ignoreStories"] != null) {
      queryParameters["ignore_stories"] = requestParameters["ignoreStories"];
    }

    if (requestParameters["maxMessages"] != null) {
      queryParameters["max_messages"] = requestParameters["maxMessages"];
    }

    if (requestParameters["sendReadReceipts"] != null) {
      queryParameters["send_read_receipts"] =
        requestParameters["sendReadReceipts"];
    }

    const headerParameters: runtime.HTTPHeaders = {};

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

    return new runtime.JSONApiResponse<any>(response);
  }

  /**
   * Receives Signal Messages from the Signal Network. If you are running the docker container in normal/native mode, this is a GET endpoint. In json-rpc mode this is a websocket endpoint.
   * Receive Signal Messages.
   */
  async v1ReceiveNumberGet(
    requestParameters: V1ReceiveNumberGetRequest,
    initOverrides?: RequestInit | runtime.InitOverrideFunction,
  ): Promise<Array<string>> {
    const response = await this.v1ReceiveNumberGetRaw(
      requestParameters,
      initOverrides,
    );
    return await response.value();
  }

  /**
   * Send a signal message
   * Send a signal message.
   * @deprecated
   */
  async v1SendPostRaw(
    requestParameters: V1SendPostRequest,
    initOverrides?: RequestInit | runtime.InitOverrideFunction,
  ): Promise<runtime.ApiResponse<string>> {
    if (requestParameters["data"] == null) {
      throw new runtime.RequiredError(
        "data",
        'Required parameter "data" was null or undefined when calling v1SendPost().',
      );
    }

    const queryParameters: any = {};

    const headerParameters: runtime.HTTPHeaders = {};

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

    const response = await this.request(
      {
        path: `/v1/send`,
        method: "POST",
        headers: headerParameters,
        query: queryParameters,
        body: ApiSendMessageV1ToJSON(requestParameters["data"]),
      },
      initOverrides,
    );

    if (this.isJsonMime(response.headers.get("content-type"))) {
      return new runtime.JSONApiResponse<string>(response);
    } else {
      return new runtime.TextApiResponse(response) as any;
    }
  }

  /**
   * Send a signal message
   * Send a signal message.
   * @deprecated
   */
  async v1SendPost(
    requestParameters: V1SendPostRequest,
    initOverrides?: RequestInit | runtime.InitOverrideFunction,
  ): Promise<string> {
    const response = await this.v1SendPostRaw(requestParameters, initOverrides);
    return await response.value();
  }

  /**
   * Hide Typing Indicator.
   * Hide Typing Indicator.
   */
  async v1TypingIndicatorNumberDeleteRaw(
    requestParameters: V1TypingIndicatorNumberDeleteRequest,
    initOverrides?: RequestInit | runtime.InitOverrideFunction,
  ): Promise<runtime.ApiResponse<string>> {
    if (requestParameters["number"] == null) {
      throw new runtime.RequiredError(
        "number",
        'Required parameter "number" was null or undefined when calling v1TypingIndicatorNumberDelete().',
      );
    }

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

    const queryParameters: any = {};

    const headerParameters: runtime.HTTPHeaders = {};

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

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

    if (this.isJsonMime(response.headers.get("content-type"))) {
      return new runtime.JSONApiResponse<string>(response);
    } else {
      return new runtime.TextApiResponse(response) as any;
    }
  }

  /**
   * Hide Typing Indicator.
   * Hide Typing Indicator.
   */
  async v1TypingIndicatorNumberDelete(
    requestParameters: V1TypingIndicatorNumberDeleteRequest,
    initOverrides?: RequestInit | runtime.InitOverrideFunction,
  ): Promise<string> {
    const response = await this.v1TypingIndicatorNumberDeleteRaw(
      requestParameters,
      initOverrides,
    );
    return await response.value();
  }

  /**
   * Show Typing Indicator.
   * Show Typing Indicator.
   */
  async v1TypingIndicatorNumberPutRaw(
    requestParameters: V1TypingIndicatorNumberPutRequest,
    initOverrides?: RequestInit | runtime.InitOverrideFunction,
  ): Promise<runtime.ApiResponse<string>> {
    if (requestParameters["number"] == null) {
      throw new runtime.RequiredError(
        "number",
        'Required parameter "number" was null or undefined when calling v1TypingIndicatorNumberPut().',
      );
    }

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

    const queryParameters: any = {};

    const headerParameters: runtime.HTTPHeaders = {};

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

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

    if (this.isJsonMime(response.headers.get("content-type"))) {
      return new runtime.JSONApiResponse<string>(response);
    } else {
      return new runtime.TextApiResponse(response) as any;
    }
  }

  /**
   * Show Typing Indicator.
   * Show Typing Indicator.
   */
  async v1TypingIndicatorNumberPut(
    requestParameters: V1TypingIndicatorNumberPutRequest,
    initOverrides?: RequestInit | runtime.InitOverrideFunction,
  ): Promise<string> {
    const response = await this.v1TypingIndicatorNumberPutRaw(
      requestParameters,
      initOverrides,
    );
    return await response.value();
  }

  /**
   * Send a signal message. Set the text_mode to \'styled\' in case you want to add formatting to your text message. Styling Options: *italic text*, **bold text**, ~strikethrough text~.
   * Send a signal message.
   */
  async v2SendPostRaw(
    requestParameters: V2SendPostRequest,
    initOverrides?: RequestInit | runtime.InitOverrideFunction,
  ): Promise<runtime.ApiResponse<ApiSendMessageResponse>> {
    if (requestParameters["data"] == null) {
      throw new runtime.RequiredError(
        "data",
        'Required parameter "data" was null or undefined when calling v2SendPost().',
      );
    }

    const queryParameters: any = {};

    const headerParameters: runtime.HTTPHeaders = {};

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

    const response = await this.request(
      {
        path: `/v2/send`,
        method: "POST",
        headers: headerParameters,
        query: queryParameters,
        body: ApiSendMessageV2ToJSON(requestParameters["data"]),
      },
      initOverrides,
    );

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

  /**
   * Send a signal message. Set the text_mode to \'styled\' in case you want to add formatting to your text message. Styling Options: *italic text*, **bold text**, ~strikethrough text~.
   * Send a signal message.
   */
  async v2SendPost(
    requestParameters: V2SendPostRequest,
    initOverrides?: RequestInit | runtime.InitOverrideFunction,
  ): Promise<ApiSendMessageResponse> {
    const response = await this.v2SendPostRaw(requestParameters, initOverrides);
    return await response.value();
  }
}
