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

import {
  array,
  lazy,
  object,
  optional,
  Schema,
  string,
  unknown,
} from '../schema';
import { Address8, address8Schema } from './address8';
import { Amount2, amount2Schema } from './amount2';
import { Contact1, contact1Schema } from './contact1';
import { Dimension, dimensionSchema } from './dimension';
import { ExtraField, extraFieldSchema } from './extraField';
import { Group, groupSchema } from './group';
import { HazardousMaterial, hazardousMaterialSchema } from './hazardousMaterial';
import { ProductOptions2, productOptions2Schema } from './productOptions2';

export interface Shipment3 {
  /** List of 1 or more Address type elements. At least 1 address type is mandatory. See [Address types](#tag/Reference-codes/Address-types) for the available types. */
  addresses: Address8[];
  /** List of amount types. An amount represents a value of the shipment. Amount type 01 mandatory for COD-shipments, Amount type 02 mandatory for domestic insured shipments. Please see [Amount types](#tag/Reference-codes/Amount-types) for the available types. */
  amounts?: Amount2[];
  /** Barcode of the shipment. This is a unique value. Note: If you leave this attribute out of your request an unique barcode will be generated automatically. */
  barcode: string;
  /** Code used for logistic purposes (usually generated by the service itself and returned in the response). Please note that this must be provided when  using the Confirm API to confirm shipments where coding texts are required (e.g. letterbox parcels). */
  codingText?: string;
  /** Starting date/time of the collection of the shipment. Format: dd-MM-yyyy hh:mm:ss */
  collectionTimeStampStart?: string;
  /** Ending date/time of the collection of the shipment. Format: dd-MM-yyyy hh:mm:ss */
  collectionTimeStampEnd?: string;
  /** One or more ContactType elements belonging to a shipment. Mandatory in some cases. Please refer to the available [Contact types](#tag/Reference-codes/Contact-types) for the possible values. */
  contacts?: Contact1[];
  /** Content of the shipment. Mandatory for Extra@Home shipments */
  content?: string;
  /** Cost center of the shipment. This value will appear on your invoice */
  costCenter?: string;
  /** Order number of the customer */
  customerOrderNumber?: string;
  /** The Customs type is mandatory for non-EU shipments and not allowed for any other shipment types. */
  customs?: unknown;
  required?: unknown;
  properties?: unknown;
  /** Delivery address specification. This field is mandatory when AddressType on the Address is 09. */
  deliveryAddress?: string;
  /** Mandatory when using Mailbox Parcels (for generation of the coding rule) and delivery options like Evening/Morning/Sameday delivery etc. */
  deliveryDate?: string;
  /** Note: Length, Width, Height values are about the order of the size and need to be filled in from the longest to the shortest value. For example: shipment’s official height is 700mm, width 500mm, length 300mm. The longest side (highest value) of 700mm needs to be entered at Length. Width value becomes 500mm, Height value: 300mm (the lowest). Entering the dimensions in the wrong order may result in incorrect shipping labels and longer delivery times. The maximum dimensions can be found in your PostNL contract. */
  dimension: Dimension;
  /** Barcode of the downstream network partner of PostNL Parcels. Madatory for requesting Parcels Non-EU combilabel product codes. */
  downPartnerBarcode?: string;
  /** Identification of the downstream network partner of PostNL Pakketten. */
  downPartnerID?: string;
  /** Identification of the location of the downstream network partner of PostNL Pakketten. */
  downPartnerLocation?: string;
  /** List of 0 or more Group types with data, grouping multiple shipments together. Mandatory for multicollo shipments. Please see [Guidelines](https://developer.postnl.nl/browse-apis/send-and-track/labelling-webservice/) (Multiple shipments) for more information. */
  groups?: Group[];
  /** Array of hazardous materials contained in the shipment */
  hazardousMaterial?: HazardousMaterial[];
  /** Deprecated. Collection product code of a shipment. */
  productCodeCollect?: string;
  /** Product code of the shipment. See the [Products page](#tag/Product-codes) for possible products. */
  productCodeDelivery: string;
  /** Product options for the shipment, mandatory for certain products, see the [Products page](#tag/Product-codes). */
  productOptions?: ProductOptions2[];
  /** Date of birth. Mandatory for Age check products */
  receiverDateOfBirth?: string;
  /** Your own reference of the shipment. Mandatory for Extra@Home shipments; for E@H this is used to create your order number, so this should be unique for each request. */
  reference?: string;
  /** Additional reference of the collect order of the shipment */
  referenceCollect?: string;
  /** Remark of the shipment. */
  remark?: string;
  /** Return barcode of the shipment. PostNL will provide you with a separate customer code specifically for generating the returnBarcode. Mandatory for Label in the Box (return label) shipments. */
  returnBarcode?: string;
  /** Return reference of the shipment */
  returnReference?: string;
  /** Deprecated. ID of the chosen timeslot as returned by the timeslot webservice */
  timeslotID?: string;
  /** Possibility to provide extra key-value pairs to the webservice. Not used at the moment. */
  extraFields?: ExtraField[];
}

export const shipment3Schema: Schema<Shipment3> = object({
  addresses: ['Addresses', array(lazy(() => address8Schema))],
  amounts: ['Amounts', optional(array(lazy(() => amount2Schema)))],
  barcode: ['Barcode', string()],
  codingText: ['CodingText', optional(string())],
  collectionTimeStampStart: ['CollectionTimeStampStart', optional(string())],
  collectionTimeStampEnd: ['CollectionTimeStampEnd', optional(string())],
  contacts: ['Contacts', optional(array(lazy(() => contact1Schema)))],
  content: ['Content', optional(string())],
  costCenter: ['CostCenter', optional(string())],
  customerOrderNumber: ['CustomerOrderNumber', optional(string())],
  customs: ['Customs', optional(unknown())],
  required: ['required', optional(unknown())],
  properties: ['properties', optional(unknown())],
  deliveryAddress: ['DeliveryAddress', optional(string())],
  deliveryDate: ['DeliveryDate', optional(string())],
  dimension: ['Dimension', lazy(() => dimensionSchema)],
  downPartnerBarcode: ['DownPartnerBarcode', optional(string())],
  downPartnerID: ['DownPartnerID', optional(string())],
  downPartnerLocation: ['DownPartnerLocation', optional(string())],
  groups: ['Groups', optional(array(lazy(() => groupSchema)))],
  hazardousMaterial: [
    'HazardousMaterial',
    optional(array(lazy(() => hazardousMaterialSchema))),
  ],
  productCodeCollect: ['ProductCodeCollect', optional(string())],
  productCodeDelivery: ['ProductCodeDelivery', string()],
  productOptions: [
    'ProductOptions',
    optional(array(lazy(() => productOptions2Schema))),
  ],
  receiverDateOfBirth: ['ReceiverDateOfBirth', optional(string())],
  reference: ['Reference', optional(string())],
  referenceCollect: ['ReferenceCollect', optional(string())],
  remark: ['Remark', optional(string())],
  returnBarcode: ['ReturnBarcode', optional(string())],
  returnReference: ['ReturnReference', optional(string())],
  timeslotID: ['TimeslotID', optional(string())],
  extraFields: ['ExtraFields', optional(array(lazy(() => extraFieldSchema)))],
});
