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

import {
  array,
  boolean,
  lazy,
  number,
  object,
  optional,
  Schema,
  string,
} from '../schema';
import { Address, addressSchema } from './address';
import { CutOffTime, cutOffTimeSchema } from './cutOffTime';
import { OptionEnum, optionEnumSchema } from './optionEnum';

export interface CheckoutRequest {
  /** The order date of the shipment. Format dd-MM-YYYY HH:mm:ss */
  orderDate: string;
  /** The amount of days it takes for a parcel to be received by PostN. If you delivery the parcel the same day as the order is placed on the webshop, please use the value of 1. A value of 2 means the parcel will arrive at PostNL a day later etc. */
  shippingDuration?: number;
  /** Array of CutOffTimes */
  cutOffTimes: CutOffTime[];
  /** Specifies whether you are available to ship parcels to PostNL during holidays */
  holidaySorting?: boolean;
  /** Specifies the delivery and pickup options. */
  options: OptionEnum[];
  /** Specifies the number of locations you want returned. This can be a value of 1-3 */
  locations: number;
  /** Specifies the number of days for which the timeframes are returned. This can be a value of 1-9 */
  days: number;
  /** Array of addresses */
  addresses: Address[];
}

export const checkoutRequestSchema: Schema<CheckoutRequest> = object({
  orderDate: ['OrderDate', string()],
  shippingDuration: ['ShippingDuration', optional(number())],
  cutOffTimes: ['CutOffTimes', array(lazy(() => cutOffTimeSchema))],
  holidaySorting: ['HolidaySorting', optional(boolean())],
  options: ['Options', array(optionEnumSchema)],
  locations: ['Locations', number()],
  days: ['Days', number()],
  addresses: ['Addresses', array(lazy(() => addressSchema))],
});
