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

import { array, lazy, object, optional, Schema, string } from '../schema';
import { CustomerRequest, customerRequestSchema } from './customerRequest';
import { LinkDescription, linkDescriptionSchema } from './linkDescription';
import {
  PaymentTokenResponsePaymentSource,
  paymentTokenResponsePaymentSourceSchema,
} from './paymentTokenResponsePaymentSource';

/** Full representation of a saved payment token. */
export interface PaymentTokenResponse {
  /** The PayPal-generated ID for the vault token. */
  id?: string;
  /** Customer in merchant's or partner's system of records. */
  customer?: CustomerRequest;
  /** The vaulted payment method details. */
  paymentSource?: PaymentTokenResponsePaymentSource;
  /** An array of related [HATEOAS links](/api/rest/responses/#hateoas). */
  links?: LinkDescription[];
}

export const paymentTokenResponseSchema: Schema<PaymentTokenResponse> = object({
  id: ['id', optional(string())],
  customer: ['customer', optional(lazy(() => customerRequestSchema))],
  paymentSource: [
    'payment_source',
    optional(lazy(() => paymentTokenResponsePaymentSourceSchema)),
  ],
  links: ['links', optional(array(lazy(() => linkDescriptionSchema)))],
});
