/* 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, ApiReceipt } from "../models/index.js";
import {
  ApiErrorFromJSON,
  ApiErrorToJSON,
  ApiReceiptFromJSON,
  ApiReceiptToJSON,
} from "../models/index.js";

export interface V1ReceiptsNumberPostRequest {
  data: ApiReceipt;
}

/**
 *
 */
export class ReceiptsApi extends runtime.BaseAPI {
  /**
   * Send a read or viewed receipt
   * Send a receipt.
   */
  async v1ReceiptsNumberPostRaw(
    requestParameters: V1ReceiptsNumberPostRequest,
    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 v1ReceiptsNumberPost().',
      );
    }

    const queryParameters: any = {};

    const headerParameters: runtime.HTTPHeaders = {};

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

    const response = await this.request(
      {
        path: `/v1/receipts/{number}`,
        method: "POST",
        headers: headerParameters,
        query: queryParameters,
        body: ApiReceiptToJSON(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 read or viewed receipt
   * Send a receipt.
   */
  async v1ReceiptsNumberPost(
    requestParameters: V1ReceiptsNumberPostRequest,
    initOverrides?: RequestInit | runtime.InitOverrideFunction,
  ): Promise<string> {
    const response = await this.v1ReceiptsNumberPostRaw(
      requestParameters,
      initOverrides,
    );
    return await response.value();
  }
}
