/**
 * Paypal Server SDKLib
 *
 * This file was automatically generated by APIMATIC v3.0 ( https://www.apimatic.io ).
 */

import { lazy, object, optional, Schema } from '../schema';
import {
  OrderConfirmApplicationContext,
  orderConfirmApplicationContextSchema,
} from './orderConfirmApplicationContext';
import { PaymentSource, paymentSourceSchema } from './paymentSource';
import {
  ProcessingInstruction,
  processingInstructionSchema,
} from './processingInstruction';

/** Payer confirms the intent to pay for the Order using the provided payment source. */
export interface ConfirmOrderRequest {
  /** The payment source definition. */
  paymentSource: PaymentSource;
  /** The instruction to process an order. */
  processingInstruction?: ProcessingInstruction;
  /** Customizes the payer confirmation experience. */
  applicationContext?: OrderConfirmApplicationContext;
}

export const confirmOrderRequestSchema: Schema<ConfirmOrderRequest> = object({
  paymentSource: ['payment_source', lazy(() => paymentSourceSchema)],
  processingInstruction: [
    'processing_instruction',
    optional(processingInstructionSchema),
  ],
  applicationContext: [
    'application_context',
    optional(lazy(() => orderConfirmApplicationContextSchema)),
  ],
});
