/* 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, ApiSearchResponse } from "../models/index.js";
import {
  ApiErrorFromJSON,
  ApiErrorToJSON,
  ApiSearchResponseFromJSON,
  ApiSearchResponseToJSON,
} from "../models/index.js";

export interface V1SearchGetRequest {
  number: string;
  numbers: Array<string>;
}

/**
 *
 */
export class SearchApi extends runtime.BaseAPI {
  /**
   * Check if one or more phone numbers are registered with the Signal Service.
   * Check if one or more phone numbers are registered with the Signal Service.
   */
  async v1SearchGetRaw(
    requestParameters: V1SearchGetRequest,
    initOverrides?: RequestInit | runtime.InitOverrideFunction,
  ): Promise<runtime.ApiResponse<Array<ApiSearchResponse>>> {
    if (requestParameters["number"] == null) {
      throw new runtime.RequiredError(
        "number",
        'Required parameter "number" was null or undefined when calling v1SearchGet().',
      );
    }

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

    const queryParameters: any = {};

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

    const headerParameters: runtime.HTTPHeaders = {};

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

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

  /**
   * Check if one or more phone numbers are registered with the Signal Service.
   * Check if one or more phone numbers are registered with the Signal Service.
   */
  async v1SearchGet(
    requestParameters: V1SearchGetRequest,
    initOverrides?: RequestInit | runtime.InitOverrideFunction,
  ): Promise<Array<ApiSearchResponse>> {
    const response = await this.v1SearchGetRaw(
      requestParameters,
      initOverrides,
    );
    return await response.value();
  }
}
