{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/synchronity-app/json-schema/synchronity-app-ampsorder-schema.json",
  "title": "AMPSOrder",
  "x-generated": "2026-11-26",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/synchronity-app-openapi.yml#/components/schemas/AMPSOrder",
  "type": "object",
  "required": [
    "order_id",
    "site_id",
    "status",
    "items",
    "subtotal",
    "total",
    "currency",
    "created_at"
  ],
  "properties": {
    "order_id": {
      "type": "string"
    },
    "site_id": {
      "type": "string"
    },
    "status": {
      "type": "string",
      "enum": [
        "pending",
        "processing",
        "completed",
        "cancelled",
        "refunded"
      ]
    },
    "items": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/AMPSOrderItem"
      }
    },
    "subtotal": {
      "$ref": "#/$defs/MonetaryAmount"
    },
    "discounts": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/AMPSDiscount"
      }
    },
    "total": {
      "$ref": "#/$defs/MonetaryAmount"
    },
    "currency": {
      "type": "string",
      "pattern": "^[A-Z]{3}$"
    },
    "shipping_address": {
      "$ref": "#/$defs/AMPSAddress"
    },
    "tracking_number": {
      "type": "string"
    },
    "estimated_delivery": {
      "type": "string",
      "format": "date"
    },
    "created_at": {
      "type": "string",
      "format": "date-time"
    },
    "updated_at": {
      "type": "string",
      "format": "date-time"
    }
  },
  "$defs": {
    "AMPSAddress": {
      "type": "object",
      "required": [
        "line1",
        "city",
        "country_code"
      ],
      "properties": {
        "line1": {
          "type": "string"
        },
        "line2": {
          "type": "string"
        },
        "city": {
          "type": "string"
        },
        "state": {
          "type": "string"
        },
        "postal_code": {
          "type": "string"
        },
        "country_code": {
          "type": "string",
          "pattern": "^[A-Z]{2}$"
        },
        "phone": {
          "type": "string",
          "description": "Contact phone for this address (E.164 preferred, e.g. +233201234567)."
        }
      }
    },
    "AMPSDiscount": {
      "type": "object",
      "required": [
        "code",
        "amount"
      ],
      "properties": {
        "code": {
          "type": "string"
        },
        "description": {
          "type": "string"
        },
        "amount": {
          "$ref": "#/$defs/MonetaryAmount"
        }
      }
    },
    "AMPSOrderItem": {
      "type": "object",
      "required": [
        "item_id",
        "product_id",
        "title",
        "quantity",
        "unit_price",
        "line_total"
      ],
      "properties": {
        "item_id": {
          "type": "string"
        },
        "product_id": {
          "type": "string"
        },
        "variant_id": {
          "type": "string"
        },
        "title": {
          "type": "string"
        },
        "quantity": {
          "type": "integer",
          "minimum": 1
        },
        "unit_price": {
          "$ref": "#/$defs/MonetaryAmount"
        },
        "line_total": {
          "$ref": "#/$defs/MonetaryAmount"
        }
      }
    },
    "MonetaryAmount": {
      "type": "object",
      "required": [
        "amount",
        "currency"
      ],
      "properties": {
        "amount": {
          "type": "string",
          "pattern": "^\\d+\\.\\d{2}$",
          "description": "Decimal string with exactly 2 decimal places."
        },
        "currency": {
          "type": "string",
          "pattern": "^[A-Z]{3}$",
          "description": "ISO 4217 currency code."
        }
      }
    }
  }
}