/**
 * Shell Card Management APIsLib
 *
 * This file was automatically generated by APIMATIC v3.0 ( https://www.apimatic.io ).
 */

import {
  boolean,
  lazy,
  number,
  object,
  optional,
  Schema,
  string,
} from '../schema';
import {
  UpdateCardRenewalAddress2,
  updateCardRenewalAddress2Schema,
} from './updateCardRenewalAddress2';

/** List of cards for delivery address update. Maximum number of cards that can be provided in the list is 50 */
export interface DeliveryAddressUpdate {
  /**
   * Card Id of the card.
   * Optional if  PAN is passed, else Mandatory.
   */
  cardId?: number;
  /**
   * PAN of the card.
   * Optional if CardId is passed, else Mandatory.
   * Note: -
   * PAN & ExpiryDate parameters will be considered only if CardId & PANID are not provided.
   */
  pAN?: string;
  /**
   * Expiry date of the card.
   * Mandatory if PAN is passed, else optional.
   * Format: yyyyMMdd
   */
  cardExpiryDate?: string;
  /**
   * Whether to use the default delivery address configured at customer (or card group) level as the delivery address for this card.
   * Mandatory
   * Note: If value is false then ‘UpdateCardRenewalAddress’ is mandatory. If value set to ‘True’ then
   * ‘UpdateCardRenewalAddress’ may be null/empty. It will be ignored if provided.
   */
  useCustomerDefaultAddress: boolean;
  updateCardRenewalAddress?: UpdateCardRenewalAddress2;
}

export const deliveryAddressUpdateSchema: Schema<DeliveryAddressUpdate> = object(
  {
    cardId: ['CardId', optional(number())],
    pAN: ['PAN', optional(string())],
    cardExpiryDate: ['CardExpiryDate', optional(string())],
    useCustomerDefaultAddress: ['UseCustomerDefaultAddress', boolean()],
    updateCardRenewalAddress: [
      'UpdateCardRenewalAddress',
      optional(lazy(() => updateCardRenewalAddress2Schema)),
    ],
  }
);
