{
  "$schema": "https://json-schema.org/draft/2020-12",
  "$id": "https://api.staplesadvantage.com/schemas/order",
  "title": "Staples Advantage Order",
  "description": "A Staples Advantage purchase order with line items, delivery address, cost center allocation, and fulfillment status.",
  "type": "object",
  "required": ["id", "status", "items"],
  "properties": {
    "id": {
      "type": "string",
      "description": "Unique order identifier"
    },
    "status": {
      "type": "string",
      "enum": ["pending", "confirmed", "shipped", "delivered", "cancelled"],
      "description": "Current order fulfillment status"
    },
    "purchaseOrderNumber": {
      "type": "string",
      "description": "Customer-provided purchase order number for accounting"
    },
    "items": {
      "type": "array",
      "minItems": 1,
      "description": "Ordered line items",
      "items": {
        "type": "object",
        "required": ["sku", "quantity"],
        "properties": {
          "sku": {
            "type": "string",
            "description": "Product SKU"
          },
          "name": {
            "type": "string",
            "description": "Product name at time of order"
          },
          "quantity": {
            "type": "integer",
            "minimum": 1,
            "description": "Quantity ordered"
          },
          "unitPrice": {
            "type": "number",
            "format": "float",
            "minimum": 0,
            "description": "Unit price at time of order"
          },
          "totalPrice": {
            "type": "number",
            "format": "float",
            "minimum": 0,
            "description": "Total line item price (quantity x unitPrice)"
          },
          "costCenter": {
            "type": "string",
            "description": "Cost center code for expense allocation"
          }
        }
      }
    },
    "deliveryAddress": {
      "type": "object",
      "required": ["street", "city", "state", "postalCode"],
      "properties": {
        "name": {"type": "string"},
        "street": {"type": "string"},
        "street2": {"type": "string"},
        "city": {"type": "string"},
        "state": {"type": "string"},
        "postalCode": {"type": "string"},
        "country": {"type": "string", "default": "US"},
        "phone": {"type": "string"}
      }
    },
    "subtotal": {
      "type": "number",
      "format": "float",
      "minimum": 0,
      "description": "Pre-tax order subtotal in USD"
    },
    "total": {
      "type": "number",
      "format": "float",
      "minimum": 0,
      "description": "Total order amount including tax in USD"
    },
    "orderedAt": {
      "type": "string",
      "format": "date-time",
      "description": "Timestamp when the order was placed"
    },
    "estimatedDelivery": {
      "type": "string",
      "format": "date",
      "description": "Estimated delivery date"
    },
    "trackingNumbers": {
      "type": "array",
      "description": "Carrier tracking numbers for shipments",
      "items": {
        "type": "string"
      }
    }
  }
}
