{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://raw.githubusercontent.com/api-evangelist/td-synnex/main/json-schema/td-synnex-order-schema.json",
  "title": "TD SYNNEX StreamOne Order",
  "description": "Schema for a technology product order in the TD SYNNEX StreamOne Ion distribution platform.",
  "type": "object",
  "required": ["orderId", "customerId", "status", "items"],
  "properties": {
    "orderId": {
      "type": "string",
      "description": "Unique order identifier"
    },
    "customerId": {
      "type": "string",
      "description": "End customer identifier"
    },
    "status": {
      "type": "string",
      "enum": ["PENDING", "PROCESSING", "COMPLETED", "CANCELLED", "FAILED"],
      "description": "Current order status"
    },
    "items": {
      "type": "array",
      "description": "Products included in the order",
      "items": {
        "$ref": "#/$defs/OrderItem"
      },
      "minItems": 1
    },
    "totalAmount": {
      "type": "number",
      "format": "double",
      "description": "Total order amount",
      "minimum": 0
    },
    "currency": {
      "type": "string",
      "minLength": 3,
      "maxLength": 3,
      "description": "ISO 4217 currency code"
    },
    "notes": {
      "type": "string",
      "description": "Optional order notes"
    },
    "createdDate": {
      "type": "string",
      "format": "date-time",
      "description": "Order creation timestamp"
    },
    "modifiedDate": {
      "type": "string",
      "format": "date-time",
      "description": "Last modification timestamp"
    }
  },
  "$defs": {
    "OrderItem": {
      "type": "object",
      "description": "A product line item in an order",
      "required": ["productId", "quantity"],
      "properties": {
        "productId": {
          "type": "string",
          "description": "Product identifier from the TD SYNNEX catalog"
        },
        "quantity": {
          "type": "integer",
          "minimum": 1,
          "description": "Number of units ordered"
        },
        "unitPrice": {
          "type": "number",
          "format": "double",
          "minimum": 0,
          "description": "Price per unit"
        },
        "totalPrice": {
          "type": "number",
          "format": "double",
          "minimum": 0,
          "description": "Total price for this line item"
        }
      }
    }
  }
}
