/**
 * Generated by orval v7.6.0 🍺
 * Do not edit manually.
 * Coinbase Developer Platform APIs
 * The Coinbase Developer Platform APIs - leading the world's transition onchain.
 * OpenAPI spec version: 2.0.0
 */
import type {
  CreateOnrampOrder201,
  CreateOnrampOrderBody,
  GetOnrampOrderById200,
} from "../coinbaseDeveloperPlatformAPIs.schemas.js";

import { cdpApiClient } from "../../cdpApiClient.js";

type SecondParameter<T extends (...args: never) => unknown> = Parameters<T>[1];

/**
 * Create a new Onramp order or get a quote for an Onramp order. Either `paymentAmount` or `purchaseAmount` must be provided.

This API currently only supports the payment method `GUEST_CHECKOUT_APPLE_PAY`, and the `paymentLink` returned will only work in iOS apps. We do not support web integration via iframes at this time.

For detailed integration instructions and to get access to this API, refer to the  [Apple Pay Onramp API docs](https://docs.cdp.coinbase.com/onramp-&-offramp/onramp-apis/apple-pay-onramp-api).
 * @summary Create an onramp order
 */
export const createOnrampOrder = (
  createOnrampOrderBody: CreateOnrampOrderBody,
  options?: SecondParameter<typeof cdpApiClient>,
) => {
  return cdpApiClient<CreateOnrampOrder201>(
    {
      url: `/v2/onramp/orders`,
      method: "POST",
      headers: { "Content-Type": "application/json" },
      data: createOnrampOrderBody,
    },
    options,
  );
};
/**
 * Get an onramp order by ID.
 * @summary Get an onramp order by ID
 */
export const getOnrampOrderById = (
  orderId: string,
  options?: SecondParameter<typeof cdpApiClient>,
) => {
  return cdpApiClient<GetOnrampOrderById200>(
    { url: `/v2/onramp/orders/${orderId}`, method: "GET" },
    options,
  );
};
export type CreateOnrampOrderResult = NonNullable<Awaited<ReturnType<typeof createOnrampOrder>>>;
export type GetOnrampOrderByIdResult = NonNullable<Awaited<ReturnType<typeof getOnrampOrderById>>>;
