{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://objectsgrid.com/.well-known/objects-catalog/Order/v1/schema.json",
  "title": "Order",
  "description": "Objects Grid Order Object",
  "x-objectsgrid-jsonLd": false,
  "type": "object",
  "properties": {
    "id": {
      "description": "The unique identifier for Order",
      "type": [
        "string",
        "null"
      ],
      "minLength": 0,
      "maxLength": 50
    },
    "at_context": {
      "description": "Schema context",
      "anyOf": [
        {
          "type": "string",
          "enum": [
            "https://schema.org"
          ]
        },
        {
          "type": "null"
        }
      ]
    },
    "at_type": {
      "description": "The object type",
      "anyOf": [
        {
          "type": "string",
          "enum": [
            "Order"
          ]
        },
        {
          "type": "null"
        }
      ]
    },
    "at_id": {
      "description": "This Order's ObjectsGrid URL, https://apis.objectsgrid.com/<path>/<id>: its JSON-LD @id, which References point to. Set by the service.",
      "type": [
        "string",
        "null"
      ],
      "format": "uri",
      "readOnly": true
    },
    "identifier": {
      "description": "The unique identifier for Order",
      "type": [
        "string",
        "null"
      ],
      "minLength": 0,
      "maxLength": 50
    },
    "image": {
      "description": "image URL",
      "type": [
        "string",
        "null"
      ],
      "minLength": 0,
      "format": "uri"
    },
    "name": {
      "description": "The Product Name",
      "type": "array",
      "items": {
        "$ref": "https://objectsgrid.com/.well-known/objects-catalog/LanguageTaggedString/v1/schema.json"
      },
      "minItems": 1
    },
    "description": {
      "description": "The Product Description",
      "type": "array",
      "items": {
        "$ref": "https://objectsgrid.com/.well-known/objects-catalog/LanguageTaggedString/v1/schema.json"
      }
    },
    "url": {
      "description": "This Product URL",
      "type": [
        "string",
        "null"
      ],
      "format": "uri",
      "minLength": 1
    },
    "acceptedOffer": {
      "description": "A pointer to an Offer that has been accepted as a valid offer for this item. A checkout writes <url>?version=<objectVersion>: the version, and so the price, when the cart was checked out.",
      "x-objectsgrid-rangeIncludes": [
        "Offer"
      ],
      "type": "array",
      "minItems": 1,
      "items": {
        "$ref": "https://objectsgrid.com/.well-known/objects-catalog/Reference/v1/schema.json"
      }
    },
    "billingAddress": {
      "x-objectsgrid-personal": "customer",
      "description": "The billing address. Personal: encrypted with the key of the customer's pinned Person version, so it is kept and erased with it.",
      "anyOf": [
        {
          "$ref": "https://objectsgrid.com/.well-known/objects-catalog/PostalAddress/v1/schema.json"
        },
        {
          "type": "null"
        }
      ]
    },
    "broker": {
      "x-objectsgrid-erasure": "keep",
      "description": "An entity that arranges for an exchange between a buyer and a seller.",
      "x-objectsgrid-rangeIncludes": [
        "Organization",
        "Person"
      ],
      "anyOf": [
        {
          "$ref": "https://objectsgrid.com/.well-known/objects-catalog/Reference/v1/schema.json"
        },
        {
          "type": "null"
        }
      ]
    },
    "confirmationNumber": {
      "description": "A number that confirms the given order or payment has been received.",
      "type": [
        "string",
        "null"
      ]
    },
    "customer": {
      "x-objectsgrid-erasure": "keep",
      "x-objectsgrid-version": "pinned",
      "description": "Party placing the order or paying the invoice: the URL of a Person or Organization, stored as <url>?version=<objectVersion>, the version that was newest when the Order was written, so the Order shows the customer as they were.",
      "x-objectsgrid-rangeIncludes": [
        "Person",
        "Organization"
      ],
      "$ref": "https://objectsgrid.com/.well-known/objects-catalog/Reference/v1/schema.json"
    },
    "discount": {
      "description": "Any discount applied (to an Order, Invoice, etc.).",
      "type": [
        "number",
        "null"
      ]
    },
    "discountCode": {
      "description": "Code used to redeem a discount.",
      "type": [
        "string",
        "null"
      ]
    },
    "discountCurrency": {
      "description": "The currency (in 3-letter ISO 4217 format) of the discount.",
      "anyOf": [
        {
          "$ref": "https://objectsgrid.com/.well-known/objects-catalog/CurrencyCodeEnumeration/v1/schema.json"
        },
        {
          "type": "null"
        }
      ]
    },
    "isGift": {
      "description": "Whether the order is a gift.",
      "type": [
        "boolean",
        "null"
      ]
    },
    "orderDelivery": {
      "x-objectsgrid-personal": "customer",
      "description": "The parcels sent for the order, with their tracking and delivery addresses. Personal: encrypted with the key of the customer's pinned Person version, as billingAddress is, so it is kept and erased with it, and never in events or search.",
      "type": [
        "array",
        "null"
      ],
      "maxItems": 50,
      "items": {
        "$ref": "https://objectsgrid.com/.well-known/objects-catalog/ParcelDelivery/v1/schema.json"
      }
    },
    "orderDate": {
      "description": "The date that the order was placed.",
      "type": "string",
      "format": "date-time"
    },
    "orderNumber": {
      "description": "The identifier of the order.",
      "type": [
        "string",
        "null"
      ]
    },
    "orderStatus": {
      "description": "The current status of the order.",
      "anyOf": [
        {
          "$ref": "https://objectsgrid.com/.well-known/objects-catalog/OrderStatus/v1/schema.json"
        },
        {
          "type": "null"
        }
      ]
    },
    "orderItem": {
      "description": "The lines of the order: what was ordered, how many, and each line's status.",
      "type": "array",
      "minItems": 1,
      "maxItems": 100,
      "items": {
        "$ref": "https://objectsgrid.com/.well-known/objects-catalog/OrderItem/v1/schema.json"
      }
    },
    "partOfInvoice": {
      "description": "The order is being paid as part of the referenced Invoice.",
      "x-objectsgrid-rangeIncludes": [
        "Invoice"
      ],
      "anyOf": [
        {
          "$ref": "https://objectsgrid.com/.well-known/objects-catalog/Reference/v1/schema.json"
        },
        {
          "type": "null"
        }
      ]
    },
    "returnActions": {
      "description": "The returns of the Order's lines. ObjectsGrid's own field. Computed, read-only: the objects whose ReturnAction.object points to this object, listed from that type; never stored or written.",
      "x-objectsgrid-inverseOf": "ReturnAction.object",
      "readOnly": true
    },
    "paymentDueDate": {
      "description": "The date that payment is due.",
      "type": [
        "string",
        "null"
      ],
      "format": "date-time"
    },
    "paymentMethod": {
      "description": "The name of the payment method used (e.g. 'Credit Card', 'PayPal').",
      "type": [
        "string",
        "null"
      ]
    },
    "paymentMethodId": {
      "description": "An identifier for the method of payment used (e.g. the last 4 digits of the credit card).",
      "type": [
        "string",
        "null"
      ]
    },
    "paymentUrl": {
      "description": "A URL that can be used to pay for the order.",
      "type": [
        "string",
        "null"
      ],
      "format": "uri"
    },
    "seller": {
      "x-objectsgrid-erasure": "keep",
      "description": "An entity which offers (sells / leases / licenses etc.) the services / goods.  A seller may also be a provider.",
      "x-objectsgrid-rangeIncludes": [
        "Organization",
        "Person"
      ],
      "$ref": "https://objectsgrid.com/.well-known/objects-catalog/Reference/v1/schema.json"
    },
    "tags": {
      "description": "Tags an ABAC policy can decide on. A name may repeat; the same name and value appear once. Every stored object has them: created empty when not sent, kept by a replacement (PUT) that does not mention them, unchanged by a patch that does not mention them, cleared by null or [].",
      "type": "array",
      "default": [],
      "uniqueItems": true,
      "maxItems": 50,
      "items": {
        "$ref": "https://objectsgrid.com/.well-known/objects-catalog/Tag/v1/schema.json"
      }
    },
    "payments": {
      "description": "The payments and refunds of it. ObjectsGrid's own field. Computed, read-only: the objects whose PayAction.object points to this object, listed from that type; never stored or written.",
      "x-objectsgrid-inverseOf": "PayAction.object",
      "readOnly": true
    }
  },
  "required": [
    "acceptedOffer",
    "customer",
    "orderDate",
    "orderItem",
    "seller"
  ]
}
