{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://touristtaxtools.com/schemas/resolve-request.v2.schema.json",
  "type": "object",
  "properties": {
    "countryCode": {
      "type": "string",
      "pattern": "^[A-Z]{2}$"
    },
    "mode": {
      "enum": ["policy", "quote"]
    },
    "address": {
      "type": "object",
      "properties": {
        "countryCode": {
          "type": "string",
          "pattern": "^[A-Z]{2}$"
        },
        "street": {
          "type": "string",
          "minLength": 1,
          "maxLength": 500
        },
        "city": {
          "type": "string",
          "minLength": 1,
          "maxLength": 200
        },
        "state": {
          "type": "string",
          "maxLength": 200
        },
        "postalCode": {
          "type": "string",
          "maxLength": 100
        }
      },
      "required": ["countryCode", "street", "city", "state", "postalCode"],
      "additionalProperties": false
    },
    "property": {
      "type": "object",
      "properties": {
        "accommodationType": {
          "type": "string",
          "minLength": 1,
          "maxLength": 100
        }
      },
      "required": [],
      "additionalProperties": false
    },
    "facts": {
      "type": "object",
      "properties": {
        "paidAccommodation": {
          "type": ["boolean", "null"]
        },
        "originalContractUnderSixMonths": {
          "type": ["boolean", "null"]
        },
        "basicHousingNeed": {
          "type": ["boolean", "null"]
        },
        "schoolTrip": {
          "type": ["boolean", "null"]
        },
        "registeredResidence": {
          "type": ["boolean", "null"]
        },
        "emergencyAccommodation": {
          "type": ["boolean", "null"]
        },
        "platformCollected": {
          "type": ["boolean", "null"]
        },
        "passThroughChosen": {
          "type": ["boolean", "null"]
        }
      },
      "required": [],
      "additionalProperties": false
    },
    "stay": {
      "type": "object",
      "properties": {
        "checkIn": {
          "type": "string",
          "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
        },
        "checkOut": {
          "type": "string",
          "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
        },
        "agreementOn": {
          "type": "string",
          "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
        },
        "nights": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "date": {
                "type": "string",
                "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
              },
              "netAmount": {
                "type": "string",
                "pattern": "^(0|[1-9][0-9]{0,11})(\\.[0-9]{1,2})?$"
              }
            },
            "required": ["date", "netAmount"],
            "additionalProperties": false
          },
          "minItems": 1,
          "maxItems": 366
        }
      },
      "required": [],
      "additionalProperties": false
    },
    "inputEvidence": {
      "type": "object",
      "properties": {
        "source": {
          "enum": ["operator_confirmation", "booking_record", "property_record"]
        },
        "reference": {
          "type": "string",
          "minLength": 1,
          "maxLength": 500
        },
        "recordedAt": {
          "type": "string",
          "minLength": 20,
          "maxLength": 40
        }
      },
      "required": ["source", "reference", "recordedAt"],
      "additionalProperties": false
    },
    "transaction": {
      "type": ["object", "null"],
      "properties": {
        "supplyId": {
          "type": ["string", "null"],
          "pattern": "^[A-Za-z0-9][A-Za-z0-9_.:/-]{0,63}$"
        },
        "night": {
          "type": ["string", "null"],
          "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
        },
        "accommodatedPersonCount": {
          "type": ["integer", "null"],
          "minimum": 0,
          "maximum": 1000
        },
        "accommodationSupplyCount": {
          "type": ["integer", "null"],
          "minimum": 0,
          "maximum": 1000
        },
        "nightCount": {
          "type": ["integer", "null"],
          "minimum": 0,
          "maximum": 366
        },
        "completeNight": {
          "type": ["boolean", "null"]
        },
        "directlyContracted": {
          "type": ["boolean", "null"]
        },
        "separatelyPriced": {
          "type": ["boolean", "null"]
        },
        "considerationComplete": {
          "type": ["boolean", "null"]
        },
        "depositReconciled": {
          "type": ["boolean", "null"]
        },
        "components": {
          "type": ["array", "null"],
          "items": {
            "type": "object",
            "properties": {
              "id": {
                "type": ["string", "null"],
                "pattern": "^[A-Za-z0-9][A-Za-z0-9_.:/-]{0,63}$"
              },
              "kind": {
                "type": ["string", "null"],
                "enum": [
                  "accommodation_net",
                  "taxable_direct_ancillary_net",
                  "vat",
                  "own_tourist_levy",
                  "excluded_service",
                  "deposit_payment",
                  "unknown",
                  null
                ]
              },
              "amount": {
                "type": ["string", "null"],
                "pattern": "^-?(0|[1-9][0-9]{0,11})(\\.[0-9]{1,2})?$"
              },
              "supplyId": {
                "type": ["string", "null"],
                "pattern": "^[A-Za-z0-9][A-Za-z0-9_.:/-]{0,63}$"
              },
              "night": {
                "type": ["string", "null"],
                "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
              },
              "allocation": {
                "type": ["string", "null"],
                "enum": ["direct", "shared", "one_off", "indirect", null]
              }
            },
            "required": [],
            "additionalProperties": false
          },
          "minItems": 0,
          "maxItems": 12
        }
      },
      "required": [],
      "additionalProperties": false
    }
  },
  "required": ["countryCode", "mode", "address"],
  "additionalProperties": false
}
