import Joi from 'joi';
import { BaseResponseSchema } from './base-response-schema';
import { BillingLineItemSchema } from '../models/billing/billing-line-item-schema';
import { DocumentSchema } from '../models/documents/document-schema';
import { IdentifierSchema } from '../models/identifier-schema';
import { FormDownloadSchema } from '../models/labels/form-download-schema';
import { LabelDownloadSchema } from '../models/labels/label-download-schema';
import { LabelPackageSchema } from '../models/labels/label-package-schema';
import { RelayPointDetailsSchema } from '../models/relay-points/relay-point-details-schema';
import { TimeWindowSchema } from '../models/time-window-schema';
import { PaperlessDetailsSchema } from '../models/labels/paperless-details-schema';

export const CreateLabelResponseSchema = BaseResponseSchema.keys({
  transaction_id: Joi.string().required(),
  label_download: LabelDownloadSchema.optional(),
  form_download: FormDownloadSchema.optional(),
  paperless_details: PaperlessDetailsSchema.optional(),
  documents: Joi.array().optional().items(DocumentSchema),
  packages: Joi.array().optional().items(LabelPackageSchema),
  billing_line_items: Joi.array().optional().items(BillingLineItemSchema),
  tracking_number: Joi.string().optional().empty(),
  tracking_url: Joi.string().optional().empty(),
  trackable: Joi.boolean().optional(),
  alternative_identifiers: Joi.array().optional().items(IdentifierSchema),
  estimated_delivery_datetime: Joi.string().optional().empty().isoDate(),
  consolidator_service_code: Joi.string().optional().empty(),
  carrier_pickup_window: TimeWindowSchema.optional(),
  delivery_window: TimeWindowSchema.optional(),
  relay_points: RelayPointDetailsSchema.optional(),
});
