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

import { lazy, object, optional, Schema, string } from '../schema';
import {
  BLIKExperienceContext,
  bLIKExperienceContextSchema,
} from './bLIKExperienceContext';
import {
  BLIKLevel0PaymentObject,
  bLIKLevel0PaymentObjectSchema,
} from './bLIKLevel0PaymentObject';
import {
  BLIKOneClickPaymentRequest,
  bLIKOneClickPaymentRequestSchema,
} from './bLIKOneClickPaymentRequest';

/** Information needed to pay using BLIK. */
export interface BLIKPaymentRequest {
  /** The full name representation like Mr J Smith. */
  name: string;
  /** The [two-character ISO 3166-1 code](/api/rest/reference/country-codes/) that identifies the country or region.<blockquote><strong>Note:</strong> The country code for Great Britain is <code>GB</code> and not <code>UK</code> as used in the top-level domain names for that country. Use the `C2` country code for China worldwide for comparable uncontrolled price (CUP) method, bank card, and cross-border transactions.</blockquote> */
  countryCode: string;
  /** The internationalized email address.<blockquote><strong>Note:</strong> Up to 64 characters are allowed before and 255 characters are allowed after the <code>@</code> sign. However, the generally accepted maximum length for an email address is 254 characters. The pattern verifies that an unquoted <code>@</code> sign exists.</blockquote> */
  email?: string;
  /** Customizes the payer experience during the approval process for the BLIK payment. */
  experienceContext?: BLIKExperienceContext;
  /** Information used to pay using BLIK level_0 flow. */
  level0?: BLIKLevel0PaymentObject;
  /** Information used to pay using BLIK one-click flow. */
  oneClick?: BLIKOneClickPaymentRequest;
}

export const bLIKPaymentRequestSchema: Schema<BLIKPaymentRequest> = object({
  name: ['name', string()],
  countryCode: ['country_code', string()],
  email: ['email', optional(string())],
  experienceContext: [
    'experience_context',
    optional(lazy(() => bLIKExperienceContextSchema)),
  ],
  level0: ['level_0', optional(lazy(() => bLIKLevel0PaymentObjectSchema))],
  oneClick: [
    'one_click',
    optional(lazy(() => bLIKOneClickPaymentRequestSchema)),
  ],
});
