/**
 * Generated by orval v7.21.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,
  CreateOnrampSession201,
  GetOnrampOrderById200,
  GetOnrampUserLimits200,
  GetOnrampUserLimitsBody,
  InitiateOnrampVerificationRequest,
  OnrampLimitUpgradeRequest,
  OnrampSessionRequest,
  OnrampVerificationConfirmation,
  OnrampVerificationId,
  OnrampVerificationInitiation,
  SubmitOnrampVerificationRequest,
} from "../coinbaseDeveloperPlatformAPIs.schemas.js";

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

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

/**
 * Initiates OTP verification by sending a 6-digit code to the user via the specified channel (SMS or email). Returns a `verificationId` that must be passed to the Submit Onramp Verification endpoint along with the OTP code within 10 minutes.

**Access to this API requires allowlisting.** During Onramp Headless API onboarding, contact the Onramp team to enable Onramp-managed verification for your application.
 * @summary Initiate onramp verification
 */
export const initiateOnrampVerification = (
  initiateOnrampVerificationRequest: InitiateOnrampVerificationRequest,
  options?: SecondParameter<typeof cdpApiClient<OnrampVerificationInitiation>>,
) => {
  return cdpApiClient<OnrampVerificationInitiation>(
    {
      url: `/v2/onramp/verifications`,
      method: "POST",
      headers: { "Content-Type": "application/json" },
      data: initiateOnrampVerificationRequest,
    },
    options,
  );
};
/**
 * Submits the OTP code to complete verification. On success, marks the verification as verified and returns the same `verificationId`. The destination does not need to be re-sent. Onramp uses the value captured at initiation time.

The returned `verificationId` should be stored on the user's device and passed to the Create Onramp Order endpoint. It is valid for 60 days.

**Access to this API requires allowlisting.** During Onramp Headless API onboarding, contact the Onramp team to enable Onramp-managed verification for your application.
 * @summary Submit onramp verification
 */
export const submitOnrampVerification = (
  verificationId: OnrampVerificationId,
  submitOnrampVerificationRequest: SubmitOnrampVerificationRequest,
  options?: SecondParameter<typeof cdpApiClient<OnrampVerificationConfirmation>>,
) => {
  return cdpApiClient<OnrampVerificationConfirmation>(
    {
      url: `/v2/onramp/verifications/${verificationId}/submit`,
      method: "POST",
      headers: { "Content-Type": "application/json" },
      data: submitOnrampVerificationRequest,
    },
    options,
  );
};
/**
 * 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`.

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<CreateOnrampOrder201>>,
) => {
  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<GetOnrampOrderById200>>,
) => {
  return cdpApiClient<GetOnrampOrderById200>(
    { url: `/v2/onramp/orders/${orderId}`, method: "GET" },
    options,
  );
};
/**
 * Returns a single-use URL for an Onramp session. This API provides flexible  functionality based on the parameters provided, supporting three cases:

**Important**: The returned URL is single-use only. Once a user visits the URL,  no one else can access it.
## Use Cases
### 1. Basic Session (Minimum Parameters)
**Required**: `destinationAddress`, `purchaseCurrency`, `destinationNetwork`

**Returns**: Basic single-use onramp URL. The `quote` object will not be included in the response.
### 2. One-Click Onramp URL
**Required**: Basic parameters + (`paymentAmount` OR `purchaseAmount`), `paymentCurrency`

**Returns**: One-click onramp URL for streamlined checkout. The `quote` object will not be included in the response.
### 3. One-Click Onramp URL with Quote
**Required**: One-Click Onramp parameters + `paymentMethod`, `country`, `subdivision`

**Returns**: Complete pricing quote and one-click onramp URL. Both `session` and `quote` objects will be included in the response.

**Note**: Only one of `paymentAmount` or `purchaseAmount` should be provided, not both. Providing both will result in an error. When `paymentAmount` is provided, the quote shows how much crypto the user will receive for the specified fiat amount (fee-inclusive). When `purchaseAmount` is provided, the quote shows how much fiat the user needs to pay for the specified crypto amount (fee-exclusive).
 * @summary Create an onramp session
 */
export const createOnrampSession = (
  onrampSessionRequest: OnrampSessionRequest,
  options?: SecondParameter<typeof cdpApiClient<CreateOnrampSession201>>,
) => {
  return cdpApiClient<CreateOnrampSession201>(
    {
      url: `/v2/onramp/sessions`,
      method: "POST",
      headers: { "Content-Type": "application/json" },
      data: onrampSessionRequest,
    },
    options,
  );
};
/**
 * Returns the transaction limits for an onramp user based on their payment method and user identifier. Use this API to show users their remaining purchase capacity before initiating an onramp transaction.
Currently supports `GUEST_CHECKOUT_APPLE_PAY` payment method with phone number identification. The phone number must have been previously verified via OTP.
 * @summary Get onramp user limits
 */
export const getOnrampUserLimits = (
  getOnrampUserLimitsBody: GetOnrampUserLimitsBody,
  options?: SecondParameter<typeof cdpApiClient<GetOnrampUserLimits200>>,
) => {
  return cdpApiClient<GetOnrampUserLimits200>(
    {
      url: `/v2/onramp/limits`,
      method: "POST",
      headers: { "Content-Type": "application/json" },
      data: getOnrampUserLimitsBody,
    },
    options,
  );
};
/**
 * Requests a limit upgrade for an onramp user by submitting identity information. Only phone number is currently supported as a userId. 

The verification process is asynchronous. After calling this endpoint, use the [Get Onramp User Limits](https://docs.cdp.coinbase.com/api-reference/v2/rest-api/onramp/get-onramp-user-limits) endpoint to check the status in the `limitUpgradeOptions` array.

**Prerequisites:**
- The phone number must have been previously verified by your app via OTP. - Upgrades may not be available until a certain number of successful transactions by the user.

**Supported fields:**
- `ssnLast4`: Last 4 digits of the Social Security Number (no dashes or spaces).
- `dateOfBirth`: Date of birth (day, month, year as zero-padded strings).
 * @summary Request limit upgrade
 */
export const requestLimitsUpgrade = (
  onrampLimitUpgradeRequest: OnrampLimitUpgradeRequest,
  options?: SecondParameter<typeof cdpApiClient<void>>,
) => {
  return cdpApiClient<void>(
    {
      url: `/v2/onramp/limits/upgrade`,
      method: "POST",
      headers: { "Content-Type": "application/json" },
      data: onrampLimitUpgradeRequest,
    },
    options,
  );
};
export type InitiateOnrampVerificationResult = NonNullable<
  Awaited<ReturnType<typeof initiateOnrampVerification>>
>;
export type SubmitOnrampVerificationResult = NonNullable<
  Awaited<ReturnType<typeof submitOnrampVerification>>
>;
export type CreateOnrampOrderResult = NonNullable<Awaited<ReturnType<typeof createOnrampOrder>>>;
export type GetOnrampOrderByIdResult = NonNullable<Awaited<ReturnType<typeof getOnrampOrderById>>>;
export type CreateOnrampSessionResult = NonNullable<
  Awaited<ReturnType<typeof createOnrampSession>>
>;
export type GetOnrampUserLimitsResult = NonNullable<
  Awaited<ReturnType<typeof getOnrampUserLimits>>
>;
export type RequestLimitsUpgradeResult = NonNullable<
  Awaited<ReturnType<typeof requestLimitsUpgrade>>
>;
