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

import {
  array,
  lazy,
  number,
  object,
  optional,
  Schema,
  string,
} from '../schema';
import { CustomerRequest, customerRequestSchema } from './customerRequest';
import { LinkDescription, linkDescriptionSchema } from './linkDescription';
import {
  SetupTokenResponsePaymentSource,
  setupTokenResponsePaymentSourceSchema,
} from './setupTokenResponsePaymentSource';

/** Minimal representation of a cached setup token. */
export interface SetupTokenResponse {
  /** The PayPal-generated ID for the vault token. */
  id?: string;
  /** Ordinal number for sorting. */
  ordinal?: number;
  /** Customer in merchant's or partner's system of records. */
  customer?: CustomerRequest;
  /** The status of the payment token. */
  status?: string;
  /** The setup payment method details. */
  paymentSource?: SetupTokenResponsePaymentSource;
  /** An array of related [HATEOAS links](/api/rest/responses/#hateoas). */
  links?: LinkDescription[];
}

export const setupTokenResponseSchema: Schema<SetupTokenResponse> = object({
  id: ['id', optional(string())],
  ordinal: ['ordinal', optional(number())],
  customer: ['customer', optional(lazy(() => customerRequestSchema))],
  status: ['status', optional(string())],
  paymentSource: [
    'payment_source',
    optional(lazy(() => setupTokenResponsePaymentSourceSchema)),
  ],
  links: ['links', optional(array(lazy(() => linkDescriptionSchema)))],
});
