{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "title": "Order",
  "type": "object",
  "additionalProperties": false,
  "description": "Analytics-v4 .. Commerce Order object",
  "properties": {
    "log_context": {
      "$ref": "/resources/schema/analytics/client/v4/LogContext.json",
      "description": "Required Log Context Reference"
    },
    "event_name": {
      "type": "string",
      "enum": [
        "ORDER"
      ]
    },
    "schema_definition": {
      "type": "string",
      "enum": [
        "Order"
      ]
    },
    "order_id": {
      "type": "string",
      "description": "A unique id for the order from commerce service"
    },
    "merchant_order_id": {
      "type": "string",
      "description": "External order id from merchant"
    },
    "category": {
      "$ref": "/resources/schema/analytics/client/v4/type/CategoryType.json",
      "description": "The type of order like Food, Parking and others"
    },
    "order_items": {
      "type": "array",
      "items": {
        "$ref": "/resources/schema/analytics/client/v4/item/OrderItem.json"
      },
      "minItems": 1,
      "uniqueItems": true,
      "description": "The list of order items, modifiers, quantity and price"
    },
    "payment_id": {
      "type": "string",
      "description": "The payment transaction id"
    },
    "entity_store_id": {
      "type": "string",
      "description": "The entity id of the store at which order was placed"
    },
    "merchant_store_id": {
      "type": "string",
      "description": "The merchant id of the store at which order was placed"
    },
    "price": {
      "type": "object",
      "additionalProperties": false,
      "description": "Price details of all products/items in order",
      "properties": {
        "total": {
          "type": "number",
          "description": "Total with taxes in specified currency"
        },
        "tax": {
          "type": "number",
          "description": "Taxes in specified currency"
        },
        "total_before_tax": {
          "type": "number",
          "description": "Total before taxes in specified currency"
        },
        "currency": {
          "type": "string",
          "enum": [
            "USD",
            "EUR"
          ],
          "description": "Currency"
        }
      }
    },
    "status": {
      "$ref": "/resources/schema/analytics/client/v4/type/OrderStatusValues.json",
      "description": "The order status"
    },
    "merchant_name": {
      "$ref": "/resources/schema/analytics/client/v4/type/OrderMerchantValues.json",
      "description": "The merchant name"
    },
    "commerce_service": {
      "type": "object",
      "additionalProperties": true,
      "description": "Commerce service specific details",
      "properties": {
        "cs_event_type": {
          "enum": [
            "CREATE_ORDER"
          ],
          "description": "Event name as defined in commerce service"
        },
        "cs_event_version": {
          "type": "string",
          "description": "Commerce service event version"
        }
      }
    }
  },
  "required": [
    "log_context",
    "event_name",
    "schema_definition",
    "order_id",
    "order_items",
    "entity_store_id",
    "payment_id",
    "status",
    "merchant_name"
  ]
}