/* 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 {
  ApiConfiguration,
  ApiError,
  ApiTrustModeRequest,
  ApiTrustModeResponse,
  ClientAbout,
} from "../models/index.js";
import {
  ApiConfigurationFromJSON,
  ApiConfigurationToJSON,
  ApiErrorFromJSON,
  ApiErrorToJSON,
  ApiTrustModeRequestFromJSON,
  ApiTrustModeRequestToJSON,
  ApiTrustModeResponseFromJSON,
  ApiTrustModeResponseToJSON,
  ClientAboutFromJSON,
  ClientAboutToJSON,
} from "../models/index.js";

export interface V1ConfigurationNumberSettingsGetRequest {
  number: string;
  data: ApiTrustModeResponse;
}

export interface V1ConfigurationNumberSettingsPostRequest {
  number: string;
  data: ApiTrustModeRequest;
}

export interface V1ConfigurationPostRequest {
  data: ApiConfiguration;
}

/**
 *
 */
export class GeneralApi extends runtime.BaseAPI {
  /**
   * Returns the supported API versions and the internal build nr
   * Lists general information about the API
   */
  async v1AboutGetRaw(
    initOverrides?: RequestInit | runtime.InitOverrideFunction,
  ): Promise<runtime.ApiResponse<ClientAbout>> {
    const queryParameters: any = {};

    const headerParameters: runtime.HTTPHeaders = {};

    const response = await this.request(
      {
        path: `/v1/about`,
        method: "GET",
        headers: headerParameters,
        query: queryParameters,
      },
      initOverrides,
    );

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

  /**
   * Returns the supported API versions and the internal build nr
   * Lists general information about the API
   */
  async v1AboutGet(
    initOverrides?: RequestInit | runtime.InitOverrideFunction,
  ): Promise<ClientAbout> {
    const response = await this.v1AboutGetRaw(initOverrides);
    return await response.value();
  }

  /**
   * List the REST API configuration.
   * List the REST API configuration.
   */
  async v1ConfigurationGetRaw(
    initOverrides?: RequestInit | runtime.InitOverrideFunction,
  ): Promise<runtime.ApiResponse<ApiConfiguration>> {
    const queryParameters: any = {};

    const headerParameters: runtime.HTTPHeaders = {};

    const response = await this.request(
      {
        path: `/v1/configuration`,
        method: "GET",
        headers: headerParameters,
        query: queryParameters,
      },
      initOverrides,
    );

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

  /**
   * List the REST API configuration.
   * List the REST API configuration.
   */
  async v1ConfigurationGet(
    initOverrides?: RequestInit | runtime.InitOverrideFunction,
  ): Promise<ApiConfiguration> {
    const response = await this.v1ConfigurationGetRaw(initOverrides);
    return await response.value();
  }

  /**
   * List account specific settings.
   * List account specific settings.
   */
  async v1ConfigurationNumberSettingsGetRaw(
    requestParameters: V1ConfigurationNumberSettingsGetRequest,
    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 v1ConfigurationNumberSettingsGet().',
      );
    }

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

    const queryParameters: any = {};

    const headerParameters: runtime.HTTPHeaders = {};

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

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

    return new runtime.VoidApiResponse(response);
  }

  /**
   * List account specific settings.
   * List account specific settings.
   */
  async v1ConfigurationNumberSettingsGet(
    requestParameters: V1ConfigurationNumberSettingsGetRequest,
    initOverrides?: RequestInit | runtime.InitOverrideFunction,
  ): Promise<void> {
    await this.v1ConfigurationNumberSettingsGetRaw(
      requestParameters,
      initOverrides,
    );
  }

  /**
   * Set account specific settings.
   * Set account specific settings.
   */
  async v1ConfigurationNumberSettingsPostRaw(
    requestParameters: V1ConfigurationNumberSettingsPostRequest,
    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 v1ConfigurationNumberSettingsPost().',
      );
    }

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

    const queryParameters: any = {};

    const headerParameters: runtime.HTTPHeaders = {};

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

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

    return new runtime.VoidApiResponse(response);
  }

  /**
   * Set account specific settings.
   * Set account specific settings.
   */
  async v1ConfigurationNumberSettingsPost(
    requestParameters: V1ConfigurationNumberSettingsPostRequest,
    initOverrides?: RequestInit | runtime.InitOverrideFunction,
  ): Promise<void> {
    await this.v1ConfigurationNumberSettingsPostRaw(
      requestParameters,
      initOverrides,
    );
  }

  /**
   * Set the REST API configuration.
   * Set the REST API configuration.
   */
  async v1ConfigurationPostRaw(
    requestParameters: V1ConfigurationPostRequest,
    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 v1ConfigurationPost().',
      );
    }

    const queryParameters: any = {};

    const headerParameters: runtime.HTTPHeaders = {};

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

    const response = await this.request(
      {
        path: `/v1/configuration`,
        method: "POST",
        headers: headerParameters,
        query: queryParameters,
        body: ApiConfigurationToJSON(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;
    }
  }

  /**
   * Set the REST API configuration.
   * Set the REST API configuration.
   */
  async v1ConfigurationPost(
    requestParameters: V1ConfigurationPostRequest,
    initOverrides?: RequestInit | runtime.InitOverrideFunction,
  ): Promise<string> {
    const response = await this.v1ConfigurationPostRaw(
      requestParameters,
      initOverrides,
    );
    return await response.value();
  }

  /**
   * Internally used by the docker container to perform the health check.
   * API Health Check
   */
  async v1HealthGetRaw(
    initOverrides?: RequestInit | runtime.InitOverrideFunction,
  ): Promise<runtime.ApiResponse<string>> {
    const queryParameters: any = {};

    const headerParameters: runtime.HTTPHeaders = {};

    const response = await this.request(
      {
        path: `/v1/health`,
        method: "GET",
        headers: headerParameters,
        query: queryParameters,
      },
      initOverrides,
    );

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

  /**
   * Internally used by the docker container to perform the health check.
   * API Health Check
   */
  async v1HealthGet(
    initOverrides?: RequestInit | runtime.InitOverrideFunction,
  ): Promise<string> {
    const response = await this.v1HealthGetRaw(initOverrides);
    return await response.value();
  }
}
