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

import { lazy, object, optional, Schema } from '../schema';
import { ApplePayRequest, applePayRequestSchema } from './applePayRequest';
import {
  BancontactPaymentRequest,
  bancontactPaymentRequestSchema,
} from './bancontactPaymentRequest';
import {
  BLIKPaymentRequest,
  bLIKPaymentRequestSchema,
} from './bLIKPaymentRequest';
import { CardRequest, cardRequestSchema } from './cardRequest';
import {
  EPSPaymentRequest,
  ePSPaymentRequestSchema,
} from './ePSPaymentRequest';
import {
  GiropayPaymentRequest,
  giropayPaymentRequestSchema,
} from './giropayPaymentRequest';
import { GooglePayRequest, googlePayRequestSchema } from './googlePayRequest';
import {
  IDEALPaymentRequest,
  iDEALPaymentRequestSchema,
} from './iDEALPaymentRequest';
import {
  MyBankPaymentRequest,
  myBankPaymentRequestSchema,
} from './myBankPaymentRequest';
import {
  P24PaymentRequest,
  p24PaymentRequestSchema,
} from './p24PaymentRequest';
import { PayPalWallet, payPalWalletSchema } from './payPalWallet';
import {
  SofortPaymentRequest,
  sofortPaymentRequestSchema,
} from './sofortPaymentRequest';
import { Token, tokenSchema } from './token';
import {
  TrustlyPaymentRequest,
  trustlyPaymentRequestSchema,
} from './trustlyPaymentRequest';
import {
  VenmoWalletRequest,
  venmoWalletRequestSchema,
} from './venmoWalletRequest';

/** The payment source definition. */
export interface PaymentSource {
  /** The payment card to use to fund a payment. Can be a credit or debit card.<blockquote><strong>Note:</strong> Passing card number, cvv and expiry directly via the API requires <a href="https://www.pcisecuritystandards.org/pci_security/completing_self_assessment"> PCI SAQ D compliance</a>. <br>*PayPal offers a mechanism by which you do not have to take on the <strong>PCI SAQ D</strong> burden by using hosted fields - refer to <a href="https://developer.paypal.com/docs/checkout/advanced/integrate/">this Integration Guide</a>*.</blockquote> */
  card?: CardRequest;
  /** The tokenized payment source to fund a payment. */
  token?: Token;
  /** A resource that identifies a PayPal Wallet is used for payment. */
  paypal?: PayPalWallet;
  /** Information needed to pay using Bancontact. */
  bancontact?: BancontactPaymentRequest;
  /** Information needed to pay using BLIK. */
  blik?: BLIKPaymentRequest;
  /** Information needed to pay using eps. */
  eps?: EPSPaymentRequest;
  /** Information needed to pay using giropay. */
  giropay?: GiropayPaymentRequest;
  /** Information needed to pay using iDEAL. */
  ideal?: IDEALPaymentRequest;
  /** Information needed to pay using MyBank. */
  mybank?: MyBankPaymentRequest;
  /** Information needed to pay using P24 (Przelewy24). */
  p24?: P24PaymentRequest;
  /** Information needed to pay using Sofort. */
  sofort?: SofortPaymentRequest;
  /** Information needed to pay using Trustly. */
  trustly?: TrustlyPaymentRequest;
  /** Information needed to pay using ApplePay. */
  applePay?: ApplePayRequest;
  /** Information needed to pay using Google Pay. */
  googlePay?: GooglePayRequest;
  /** Information needed to pay using Venmo. */
  venmo?: VenmoWalletRequest;
}

export const paymentSourceSchema: Schema<PaymentSource> = object({
  card: ['card', optional(lazy(() => cardRequestSchema))],
  token: ['token', optional(lazy(() => tokenSchema))],
  paypal: ['paypal', optional(lazy(() => payPalWalletSchema))],
  bancontact: [
    'bancontact',
    optional(lazy(() => bancontactPaymentRequestSchema)),
  ],
  blik: ['blik', optional(lazy(() => bLIKPaymentRequestSchema))],
  eps: ['eps', optional(lazy(() => ePSPaymentRequestSchema))],
  giropay: ['giropay', optional(lazy(() => giropayPaymentRequestSchema))],
  ideal: ['ideal', optional(lazy(() => iDEALPaymentRequestSchema))],
  mybank: ['mybank', optional(lazy(() => myBankPaymentRequestSchema))],
  p24: ['p24', optional(lazy(() => p24PaymentRequestSchema))],
  sofort: ['sofort', optional(lazy(() => sofortPaymentRequestSchema))],
  trustly: ['trustly', optional(lazy(() => trustlyPaymentRequestSchema))],
  applePay: ['apple_pay', optional(lazy(() => applePayRequestSchema))],
  googlePay: ['google_pay', optional(lazy(() => googlePayRequestSchema))],
  venmo: ['venmo', optional(lazy(() => venmoWalletRequestSchema))],
});
