import { z } from 'zod';
import { OrderTypeSchema } from './base-schemas';

const CanAddPriceSchema = z.object({
  value: z

    .object({
      value: z.number().describe('Value').optional(),
      currency: z.string().describe('Currency code').optional(),
      currencySymbol: z.string().describe('Currency symbol').optional(),
    })
    .describe('Value')
    .optional(),
  vat: z

    .object({
      inPercent: z.number().describe('In percent').optional(),
      label: z.string().describe('Label').optional(),
      value: z.number().describe('Value').optional(),
      vatType: z.number().describe('VAT type').optional(),
    })
    .describe('Value Added Tax')
    .optional(),
});

const CanAddOLAAvailabilitySchema = z.object({
  altAt: z.string().describe('Alt at').optional(),
  at: z.string().describe('At').optional(),
  ean: z.string().describe('European Article Number barcode').optional(),
  format: z.string().describe('Format').optional(),
  isPrebooked: z.boolean().describe('Whether prebooked').optional(),
  itemId: z.number().int().describe('Unique item identifier').optional(),
  logistician: z.string().describe('Logistician information').optional(),
  logisticianId: z.number().int().describe('Logistician identifier').optional(),
  preferred: z.number().int().describe('Preferred').optional(),
  price: CanAddPriceSchema.describe('Price information').optional(),
  qty: z.number().int().describe('Qty').optional(),
  shop: z.number().int().describe('Shop').optional(),
  ssc: z.string().describe('Ssc').optional(),
  sscText: z.string().describe('Ssc text').optional(),
  status: z.number().int().describe('Current status'),
  supplier: z.string().describe('Supplier information').optional(),
  supplierId: z.number().int().describe('Supplier identifier').optional(),
  supplierProductNumber: z
    .string()
    .describe('SupplierProduct number')
    .optional(),
});

const CanAddItemPayloadSchema = z.object({
  availabilities: z
    .array(CanAddOLAAvailabilitySchema)
    .describe('Availabilities'),
  customerFeatures: z
    .record(z.string().optional())
    .describe('Customer features'),
  orderType: OrderTypeSchema.describe('Order type'),
  id: z.string().describe('Unique identifier'),
});

export const CanAddItemsToShoppingCartParamsSchema = z.object({
  shoppingCartId: z
    .number()
    .int()
    .positive()
    .describe('Shopping cart identifier'),
  payload: z.array(CanAddItemPayloadSchema).min(1).describe('Payload'),
});

export type CanAddItemsToShoppingCartParams = z.infer<
  typeof CanAddItemsToShoppingCartParamsSchema
>;
