/* generated using openapi-typescript-codegen -- do not edit */
/* istanbul ignore file */
/* tslint:disable */
/* eslint-disable */
import type { PlaceOrderDto } from "../models/PlaceOrderDto";
import type { CancelablePromise } from "../core/CancelablePromise";
import { OpenAPI } from "../core/OpenAPI";
import { request as __request } from "../core/request";
export class OrdersService {
  /**
   * @param requestBody
   * @returns any
   * @throws ApiError
   */
  public static ordersControllerPlaceOrder(
    requestBody: PlaceOrderDto,
  ): CancelablePromise<any> {
    return __request(OpenAPI, {
      method: "POST",
      url: "/v1/orders",
      body: requestBody,
      mediaType: "application/json",
    });
  }

  /**
   * @param requestBody
   * @returns any
   * @throws ApiError
   */
  public static ordersControllerPlaceConsolidatedOrder(
    requestBody: PlaceOrderDto,
  ): CancelablePromise<any> {
    return __request(OpenAPI, {
      method: "POST",
      url: "/v1/orders",
      body: requestBody,
      mediaType: "application/json",
    });
  }

  /**
   * Start payment for an order (HTTP equivalent of socket `order-payment-process`).
   * Returns payment processor payload immediately (e.g. NOWPayments deposit details).
   */
  public static ordersControllerProcessOrderPayment(
    orderId: string,
    requestBody?: { payCurrency?: string },
  ): CancelablePromise<any> {
    return __request(OpenAPI, {
      method: "POST",
      url: "/v1/orders/{orderId}/payments/process",
      path: {
        orderId: orderId,
      },
      body: requestBody,
      mediaType: "application/json",
    });
  }

  /**
   * @param page
   * @param limit
   * @param sort
   * @param sortBy
   * @param keyword
   * @returns any
   * @throws ApiError
   */
  public static ordersControllerGetOrders(
    page: number = 1,
    limit: number = 30,
    sort: string = "desc",
    sortBy: string = "createdAt",
    keyword?: string | null,
  ): CancelablePromise<any> {
    return __request(OpenAPI, {
      method: "GET",
      url: "/v1/orders",
      query: {
        page: page,
        limit: limit,
        sort: sort,
        sortBy: sortBy,
        keyword: keyword,
      },
      isServerAction: true,
    });
  }

  /**
   * Owner-only proxy for NOWPayments GET /v1/payment/{id} (rate-limited server-side).
   * @param paymentId NOWPayments payment_id
   * @returns any
   * @throws ApiError
   */
  public static ordersControllerPollNowpaymentsPayment(
    paymentId: string,
  ): CancelablePromise<any> {
    return __request(OpenAPI, {
      method: "GET",
      url: "/v1/orders/payments/nowpayments/{paymentId}",
      path: {
        paymentId: paymentId,
      },
      isServerAction: true,
    });
  }

  /**
   * Replace an expired or failed NOWPayments invoice (order must still be unpaid).
   * @param orderId Public order id
   * @param requestBody Optional payCurrency
   */
  public static ordersControllerRecreateNowpaymentsPayment(
    orderId: string,
    requestBody?: { payCurrency?: string },
  ): CancelablePromise<any> {
    return __request(OpenAPI, {
      method: "POST",
      url: "/v1/orders/{orderId}/payments/nowpayments/recreate",
      path: {
        orderId: orderId,
      },
      body: requestBody,
      mediaType: "application/json",
      isServerAction: true,
    });
  }

  /**
   * @param requestBody
   * @returns any
   * @throws ApiError
   */
  public static ordersControllerPlaceUpgradeOrder(
    requestBody: PlaceOrderDto,
  ): CancelablePromise<any> {
    return __request(OpenAPI, {
      method: "POST",
      url: "/v2/orders/upgrade",
      body: requestBody,
      mediaType: "application/json",
    });
  }
  /**
   * @param requestBody
   * @returns any
   * @throws ApiError
   */
  public static ordersControllerPlaceSmartPlaceOrder(
    requestBody: PlaceOrderDto,
  ): CancelablePromise<any> {
    return __request(OpenAPI, {
      method: "POST",
      url: "/v2/orders/smart-pay",
      body: requestBody,
      mediaType: "application/json",
    });
  }
  /**
   * @param requestBody
   * @returns any
   * @throws ApiError
   */
  public static ordersControllerPlaceGen2MigrationOrder(
    requestBody: PlaceOrderDto,
  ): CancelablePromise<any> {
    return __request(OpenAPI, {
      method: "POST",
      url: "/v2/orders/gen2-migration",
      body: requestBody,
      mediaType: "application/json",
    });
  }

  /**
   * @param id
   * @returns any
   * @throws ApiError
   */
  public static ordersControllerGetOrder(id: string): CancelablePromise<any> {
    return __request(OpenAPI, {
      method: "GET",
      url: "/v1/orders/{id}",
      path: {
        id: id,
      },
    });
  }

  /**
   * @param orderId
   * @returns any
   * @throws ApiError
   */
  public static ordersControllerGetOrderInvoice(
    orderId: string,
  ): CancelablePromise<any> {
    return __request(OpenAPI, {
      method: "GET",
      url: "/v1/orders/{orderId}/invoice",
      path: {
        orderId: orderId,
      },
    });
  }

  /**
   * @param creditNote
   * @returns any
   * @throws ApiError
   */
  public static ordersControllerGetCreditNoteInvoice(
    creditNote: string,
    type: string,
  ): CancelablePromise<any> {
    return __request(OpenAPI, {
      method: "GET",
      url: `/v1/credit-notes/{creditNote}/invoice-link?creditNoteType=${type}`,
      path: {
        creditNote: creditNote,
      },
    });
  }

  /**
   * @param requestBody
   * @returns any
   * @throws ApiError
   */
  public static ordersControllerPlaceExtensionOrder(
    requestBody: PlaceOrderDto,
  ): CancelablePromise<any> {
    return __request(OpenAPI, {
      method: "POST",
      url: "/v2/orders/extension-order",
      body: requestBody,
      mediaType: "application/json",
    });
  }
}
