{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "oneOf": [
    {
      "type": "object",
      "properties": {
        "id": {
          "type": "string",
          "minLength": 1,
          "maxLength": 100,
          "pattern": "^[a-zA-Z0-9_-]+$"
        },
        "offer": {
          "type": "string",
          "minLength": 1,
          "maxLength": 100,
          "pattern": "^[a-zA-Z0-9_-]+$"
        },
        "member": {
          "type": "string",
          "minLength": 1,
          "maxLength": 100,
          "pattern": "^[a-zA-Z0-9_-]+$"
        },
        "reservation": {
          "type": "string",
          "minLength": 1,
          "maxLength": 100,
          "pattern": "^[a-zA-Z0-9_-]+$"
        },
        "price": {
          "type": "object",
          "properties": {
            "kind": {
              "default": "points",
              "type": "string",
              "const": "points"
            },
            "balance": {
              "type": "string",
              "minLength": 1,
              "maxLength": 100,
              "pattern": "^[a-zA-Z0-9_-]+$"
            },
            "amount": {
              "type": "integer",
              "exclusiveMinimum": 0,
              "maximum": 9007199254740991
            }
          },
          "required": ["kind", "balance", "amount"]
        },
        "reward": {
          "type": "object",
          "properties": {
            "kind": {
              "type": "string",
              "const": "tier"
            },
            "reward": {
              "type": "object",
              "properties": {
                "badge": {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 100,
                  "pattern": "^[a-zA-Z0-9_-]+$"
                },
                "group": {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 100,
                  "pattern": "^[a-zA-Z0-9_-]+$"
                },
                "id": {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 100,
                  "pattern": "^[a-zA-Z0-9_-]+$"
                },
                "title": {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 120
                },
                "tiers": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "properties": {
                      "id": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 100,
                        "pattern": "^[a-zA-Z0-9_-]+$"
                      },
                      "title": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 120
                      }
                    },
                    "required": ["id", "title"]
                  }
                },
                "inventory": {
                  "type": "object",
                  "properties": {
                    "kind": {
                      "type": "string",
                      "const": "untracked"
                    }
                  },
                  "required": ["kind"]
                },
                "fulfillment": {
                  "oneOf": [
                    {
                      "type": "object",
                      "properties": {
                        "kind": {
                          "type": "string",
                          "const": "staff-handover"
                        }
                      },
                      "required": ["kind"],
                      "additionalProperties": false
                    },
                    {
                      "type": "object",
                      "properties": {
                        "kind": {
                          "type": "string",
                          "const": "automatic"
                        }
                      },
                      "required": ["kind"],
                      "additionalProperties": false
                    }
                  ]
                }
              },
              "required": ["id", "title", "tiers", "inventory", "fulfillment"]
            },
            "tier": {
              "type": "string",
              "minLength": 1,
              "maxLength": 100,
              "pattern": "^[a-zA-Z0-9_-]+$"
            }
          },
          "required": ["kind", "reward", "tier"]
        },
        "entitlement": {
          "type": "string",
          "minLength": 1,
          "maxLength": 100,
          "pattern": "^[a-zA-Z0-9_-]+$"
        },
        "revision": {
          "type": "integer",
          "exclusiveMinimum": 0,
          "maximum": 9007199254740991
        },
        "redeemedAt": {
          "type": "integer",
          "minimum": 0,
          "maximum": 9007199254740991
        },
        "status": {
          "type": "string",
          "const": "fulfilled"
        }
      },
      "required": [
        "id",
        "offer",
        "member",
        "reservation",
        "price",
        "reward",
        "entitlement",
        "revision",
        "redeemedAt",
        "status"
      ],
      "additionalProperties": false
    },
    {
      "type": "object",
      "properties": {
        "id": {
          "type": "string",
          "minLength": 1,
          "maxLength": 100,
          "pattern": "^[a-zA-Z0-9_-]+$"
        },
        "offer": {
          "type": "string",
          "minLength": 1,
          "maxLength": 100,
          "pattern": "^[a-zA-Z0-9_-]+$"
        },
        "member": {
          "type": "string",
          "minLength": 1,
          "maxLength": 100,
          "pattern": "^[a-zA-Z0-9_-]+$"
        },
        "reservation": {
          "type": "string",
          "minLength": 1,
          "maxLength": 100,
          "pattern": "^[a-zA-Z0-9_-]+$"
        },
        "price": {
          "type": "object",
          "properties": {
            "kind": {
              "default": "points",
              "type": "string",
              "const": "points"
            },
            "balance": {
              "type": "string",
              "minLength": 1,
              "maxLength": 100,
              "pattern": "^[a-zA-Z0-9_-]+$"
            },
            "amount": {
              "type": "integer",
              "exclusiveMinimum": 0,
              "maximum": 9007199254740991
            }
          },
          "required": ["kind", "balance", "amount"]
        },
        "reward": {
          "type": "object",
          "properties": {
            "kind": {
              "type": "string",
              "const": "tier"
            },
            "reward": {
              "type": "object",
              "properties": {
                "badge": {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 100,
                  "pattern": "^[a-zA-Z0-9_-]+$"
                },
                "group": {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 100,
                  "pattern": "^[a-zA-Z0-9_-]+$"
                },
                "id": {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 100,
                  "pattern": "^[a-zA-Z0-9_-]+$"
                },
                "title": {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 120
                },
                "tiers": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "properties": {
                      "id": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 100,
                        "pattern": "^[a-zA-Z0-9_-]+$"
                      },
                      "title": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 120
                      }
                    },
                    "required": ["id", "title"]
                  }
                },
                "inventory": {
                  "type": "object",
                  "properties": {
                    "kind": {
                      "type": "string",
                      "const": "untracked"
                    }
                  },
                  "required": ["kind"]
                },
                "fulfillment": {
                  "oneOf": [
                    {
                      "type": "object",
                      "properties": {
                        "kind": {
                          "type": "string",
                          "const": "staff-handover"
                        }
                      },
                      "required": ["kind"],
                      "additionalProperties": false
                    },
                    {
                      "type": "object",
                      "properties": {
                        "kind": {
                          "type": "string",
                          "const": "automatic"
                        }
                      },
                      "required": ["kind"],
                      "additionalProperties": false
                    }
                  ]
                }
              },
              "required": ["id", "title", "tiers", "inventory", "fulfillment"]
            },
            "tier": {
              "type": "string",
              "minLength": 1,
              "maxLength": 100,
              "pattern": "^[a-zA-Z0-9_-]+$"
            }
          },
          "required": ["kind", "reward", "tier"]
        },
        "entitlement": {
          "type": "string",
          "minLength": 1,
          "maxLength": 100,
          "pattern": "^[a-zA-Z0-9_-]+$"
        },
        "revision": {
          "type": "integer",
          "exclusiveMinimum": 0,
          "maximum": 9007199254740991
        },
        "redeemedAt": {
          "type": "integer",
          "minimum": 0,
          "maximum": 9007199254740991
        },
        "status": {
          "type": "string",
          "const": "canceled"
        },
        "canceledAt": {
          "type": "integer",
          "minimum": 0,
          "maximum": 9007199254740991
        },
        "reason": {
          "type": "string",
          "minLength": 1,
          "maxLength": 500
        }
      },
      "required": [
        "id",
        "offer",
        "member",
        "reservation",
        "price",
        "reward",
        "entitlement",
        "revision",
        "redeemedAt",
        "status",
        "canceledAt",
        "reason"
      ],
      "additionalProperties": false
    }
  ]
}
