/* 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, ApiUpdateContactRequest } from "../models/index.js";
import {
  ApiErrorFromJSON,
  ApiErrorToJSON,
  ApiUpdateContactRequestFromJSON,
  ApiUpdateContactRequestToJSON,
} from "../models/index.js";

export interface V1ContactsNumberPutRequest {
  number: string;
  data: ApiUpdateContactRequest;
}

export interface V1ContactsNumberSyncPostRequest {
  number: string;
}

/**
 *
 */
export class ContactsApi extends runtime.BaseAPI {
  /**
   * Updates the info associated to a number on the contact list.
   * Updates the info associated to a number on the contact list. If the contact doesn’t exist yet, it will be added.
   */
  async v1ContactsNumberPutRaw(
    requestParameters: V1ContactsNumberPutRequest,
    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 v1ContactsNumberPut().',
      );
    }

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

    const queryParameters: any = {};

    const headerParameters: runtime.HTTPHeaders = {};

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

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

    return new runtime.VoidApiResponse(response);
  }

  /**
   * Updates the info associated to a number on the contact list.
   * Updates the info associated to a number on the contact list. If the contact doesn’t exist yet, it will be added.
   */
  async v1ContactsNumberPut(
    requestParameters: V1ContactsNumberPutRequest,
    initOverrides?: RequestInit | runtime.InitOverrideFunction,
  ): Promise<void> {
    await this.v1ContactsNumberPutRaw(requestParameters, initOverrides);
  }

  /**
   * Send a synchronization message with the local contacts list to all linked devices. This command should only be used if this is the primary device.
   * Send a synchronization message with the local contacts list to all linked devices.
   */
  async v1ContactsNumberSyncPostRaw(
    requestParameters: V1ContactsNumberSyncPostRequest,
    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 v1ContactsNumberSyncPost().',
      );
    }

    const queryParameters: any = {};

    const headerParameters: runtime.HTTPHeaders = {};

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

    return new runtime.VoidApiResponse(response);
  }

  /**
   * Send a synchronization message with the local contacts list to all linked devices. This command should only be used if this is the primary device.
   * Send a synchronization message with the local contacts list to all linked devices.
   */
  async v1ContactsNumberSyncPost(
    requestParameters: V1ContactsNumberSyncPostRequest,
    initOverrides?: RequestInit | runtime.InitOverrideFunction,
  ): Promise<void> {
    await this.v1ContactsNumberSyncPostRaw(requestParameters, initOverrides);
  }
}
