{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://objectsgrid.com/.well-known/objects-catalog/Offer/v1/schema.json",
  "title": "Offer",
  "description": "Objects Grid Offer Object. Modeled in compliance with https://schema.org/Offer.",
  "type": "object",
  "properties": {
    "at_context": {
      "description": "Schema context",
      "type": [
        "string",
        "null"
      ],
      "enum": [
        "https://schema.org"
      ]
    },
    "at_type": {
      "description": "The object type",
      "type": [
        "string",
        "null"
      ],
      "enum": [
        "Offer"
      ]
    },
    "at_id": {
      "description": "This Offer'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
    },
    "id": {
      "description": "The unique identifier for Offer",
      "type": [
        "string",
        "null"
      ],
      "minLength": 0,
      "maxLength": 50
    },
    "identifier": {
      "description": "The unique identifier for Offer",
      "type": [
        "string",
        "null"
      ],
      "minLength": 0,
      "maxLength": 50
    },
    "image": {
      "description": "image URL",
      "type": [
        "string",
        "null"
      ],
      "minLength": 0,
      "format": "uri"
    },
    "name": {
      "description": "The Offer Name",
      "type": "array",
      "items": {
        "$ref": "https://objectsgrid.com/.well-known/objects-catalog/LanguageTaggedString/v1/schema.json"
      },
      "minItems": 1
    },
    "description": {
      "description": "The Offer Description",
      "type": "array",
      "items": {
        "$ref": "https://objectsgrid.com/.well-known/objects-catalog/LanguageTaggedString/v1/schema.json"
      }
    },
    "url": {
      "description": "This Offer URL",
      "type": [
        "string",
        "null"
      ],
      "format": "uri",
      "minLength": 1
    },
    "additionalType": {
      "description": "The kind of offer: AggregateOffer for the price range of a product several sellers sell, with lowPrice, highPrice, offerCount and offers instead of a price: its JSON-LD @type. None for an Offer.",
      "anyOf": [
        {
          "type": "string",
          "enum": [
            "AggregateOffer"
          ]
        },
        {
          "type": "null"
        }
      ]
    },
    "acceptedPaymentMethod": {
      "description": "The accepted Payment Method",
      "type": [
        "array",
        "null"
      ],
      "items": {
        "type": "string"
      }
    },
    "availability": {
      "description": "item availability",
      "type": "array",
      "items": {
        "$ref": "https://objectsgrid.com/.well-known/objects-catalog/ItemAvailability/v1/schema.json"
      },
      "minItems": 1,
      "uniqueItems": true
    },
    "availabilityEnds": {
      "description": "What date the availability ends",
      "type": [
        "string",
        "null"
      ],
      "format": "date-time"
    },
    "availabilityStarts": {
      "description": "What date the availability starts",
      "type": [
        "string",
        "null"
      ],
      "format": "date-time"
    },
    "availableDeliveryMethod": {
      "description": "The available delivery method(s)",
      "type": "array",
      "items": {
        "$ref": "https://objectsgrid.com/.well-known/objects-catalog/DeliveryMethod/v1/schema.json"
      },
      "minItems": 1,
      "uniqueItems": true
    },
    "businessFunction": {
      "description": "business function",
      "type": [
        "array",
        "null"
      ],
      "items": {
        "type": "string"
      },
      "minLength": 0
    },
    "category": {
      "description": "The Offer category",
      "type": [
        "array",
        "null"
      ],
      "items": {
        "type": "string"
      },
      "minLength": 0
    },
    "checkoutPageUrlTemplate": {
      "description": "This Offer checkout Page Url Template",
      "type": [
        "string",
        "null"
      ],
      "format": "uri"
    },
    "deliveryLeadTime": {
      "description": "The delivery lead time",
      "anyOf": [
        {
          "$ref": "https://objectsgrid.com/.well-known/objects-catalog/QuantitativeValue/v1/schema.json"
        },
        {
          "type": "null"
        }
      ]
    },
    "eligibleCustomerType": {
      "description": "The eligible customer type",
      "type": [
        "array",
        "null"
      ],
      "items": {
        "type": "string"
      },
      "minLength": 0
    },
    "eligibleDuration": {
      "description": "The eligible duration",
      "anyOf": [
        {
          "$ref": "https://objectsgrid.com/.well-known/objects-catalog/QuantitativeValue/v1/schema.json"
        },
        {
          "type": "null"
        }
      ]
    },
    "eligibleQuantity": {
      "description": "The eligible quantity",
      "type": [
        "number",
        "null"
      ],
      "minimum": 0
    },
    "eligibleRegion": {
      "description": "The eligible region",
      "type": [
        "array",
        "null"
      ],
      "items": {
        "type": "string"
      },
      "minLength": 0
    },
    "hasMerchantReturnPolicy": {
      "description": "The return policy for it, when it differs from its Product's or seller's",
      "x-objectsgrid-rangeIncludes": [
        "MerchantReturnPolicy"
      ],
      "anyOf": [
        {
          "$ref": "https://objectsgrid.com/.well-known/objects-catalog/Reference/v1/schema.json"
        },
        {
          "type": "null"
        }
      ]
    },
    "itemCondition": {
      "description": "The item condition",
      "type": "array",
      "items": {
        "$ref": "https://objectsgrid.com/.well-known/objects-catalog/OfferItemCondition/v1/schema.json"
      },
      "minItems": 1,
      "uniqueItems": true
    },
    "itemOffered": {
      "description": "The item offered by whom",
      "x-objectsgrid-rangeIncludes": [
        "Product",
        "ProductGroup",
        "ProductModel",
        "Service",
        "Event",
        "Course",
        "Accommodation",
        "MenuItem"
      ],
      "anyOf": [
        {
          "$ref": "https://objectsgrid.com/.well-known/objects-catalog/Reference/v1/schema.json"
        },
        {
          "type": "null"
        }
      ]
    },
    "offeredBy": {
      "x-objectsgrid-erasure": "keep",
      "description": "The Organization, local business (Place) or Person offering it",
      "x-objectsgrid-rangeIncludes": [
        "Organization",
        "Place",
        "Person"
      ],
      "anyOf": [
        {
          "$ref": "https://objectsgrid.com/.well-known/objects-catalog/Reference/v1/schema.json"
        },
        {
          "type": "null"
        }
      ]
    },
    "price": {
      "description": "The Offer price; an AggregateOffer has lowPrice instead",
      "type": [
        "number",
        "null"
      ],
      "minimum": 0
    },
    "lowPrice": {
      "description": "AggregateOffer: the lowest price of the offers",
      "type": [
        "number",
        "null"
      ],
      "minimum": 0
    },
    "highPrice": {
      "description": "AggregateOffer: the highest price of the offers",
      "type": [
        "number",
        "null"
      ],
      "minimum": 0
    },
    "offerCount": {
      "description": "AggregateOffer: how many offers there are",
      "type": [
        "integer",
        "null"
      ],
      "minimum": 0
    },
    "offers": {
      "description": "AggregateOffer: the single Offers it sums up, those in ObjectsGrid",
      "x-objectsgrid-rangeIncludes": [
        "Offer"
      ],
      "type": [
        "array",
        "null"
      ],
      "maxItems": 100,
      "items": {
        "$ref": "https://objectsgrid.com/.well-known/objects-catalog/Reference/v1/schema.json"
      }
    },
    "priceCurrency": {
      "description": "The Offer price currency ISO 4217 codes",
      "$ref": "https://objectsgrid.com/.well-known/objects-catalog/CurrencyCodeEnumeration/v1/schema.json"
    },
    "priceSpecification": {
      "description": "More prices of the Offer, beside price: a strikethrough price before a sale, a member price (validForMemberTier), or a price per unit.",
      "type": [
        "array",
        "null"
      ],
      "maxItems": 20,
      "items": {
        "$ref": "https://objectsgrid.com/.well-known/objects-catalog/UnitPriceSpecification/v1/schema.json"
      }
    },
    "priceValidUntil": {
      "description": "The Offer price valid until date",
      "type": [
        "string",
        "null"
      ],
      "format": "date-time"
    },
    "shippingDetails": {
      "description": "The Offer Shipping Details",
      "anyOf": [
        {
          "$ref": "https://objectsgrid.com/.well-known/objects-catalog/OfferShippingDetails/v1/schema.json"
        },
        {
          "type": "null"
        }
      ]
    },
    "validFrom": {
      "description": "The Offer valid from date",
      "type": [
        "string",
        "null"
      ],
      "format": "date-time"
    },
    "validThrough": {
      "description": "The Offer valid through date",
      "type": [
        "string",
        "null"
      ],
      "format": "date-time"
    },
    "warranty": {
      "description": "The Offer Warranty",
      "anyOf": [
        {
          "$ref": "https://objectsgrid.com/.well-known/objects-catalog/WarrantyPromise/v1/schema.json"
        },
        {
          "type": "null"
        }
      ]
    },
    "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"
      }
    },
    "inventoryLevel": {
      "description": "How many are left to sell, e.g. the free rooms of a category: value, unitCode C62",
      "anyOf": [
        {
          "$ref": "https://objectsgrid.com/.well-known/objects-catalog/QuantitativeValue/v1/schema.json"
        },
        {
          "type": "null"
        }
      ]
    }
  },
  "required": [
    "name",
    "priceCurrency"
  ],
  "allOf": [
    {
      "if": {
        "required": [
          "additionalType"
        ],
        "properties": {
          "additionalType": {
            "const": "AggregateOffer"
          }
        }
      },
      "then": {
        "required": [
          "lowPrice"
        ]
      },
      "else": {
        "required": [
          "price"
        ],
        "not": {
          "anyOf": [
            {
              "required": [
                "lowPrice"
              ]
            },
            {
              "required": [
                "highPrice"
              ]
            },
            {
              "required": [
                "offerCount"
              ]
            },
            {
              "required": [
                "offers"
              ]
            }
          ]
        }
      }
    }
  ]
}
