{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/buyrecord-app/json-schema/buyrecord-app-stay-outcomes-schema.json",
  "title": "StayOutcomes",
  "x-generated": "2026-11-03",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/buyrecord-app-openapi.json#/components/schemas/StayOutcomes",
  "properties": {
    "id": {
      "type": "string",
      "format": "uuid",
      "title": "Id"
    },
    "name": {
      "type": "string",
      "title": "Name",
      "description": "Property name as written in the platform's confirmation, cleaned and capped at 200 characters."
    },
    "city": {
      "type": "string",
      "title": "City"
    },
    "country": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "Country",
      "description": "ISO 3166-1 alpha-2, lowercase, when known."
    },
    "platforms": {
      "items": {
        "type": "string",
        "enum": [
          "booking",
          "airbnb",
          "accor"
        ]
      },
      "type": "array",
      "title": "Platforms",
      "description": "Platforms through which verified stays were booked."
    },
    "outcomes": {
      "$ref": "#/$defs/StayOutcomeSummary",
      "description": "Verified stays only."
    },
    "breakdown": {
      "additionalProperties": {
        "type": "integer"
      },
      "propertyNames": {
        "enum": [
          "stayed_as_described",
          "stayed_with_issues",
          "cancelled_by_property",
          "left_early"
        ]
      },
      "type": "object",
      "title": "Breakdown"
    },
    "computed_at": {
      "anyOf": [
        {
          "type": "string",
          "format": "date-time"
        },
        {
          "type": "null"
        }
      ],
      "title": "Computed At"
    }
  },
  "type": "object",
  "required": [
    "id",
    "name",
    "city",
    "country",
    "platforms",
    "outcomes",
    "breakdown",
    "computed_at"
  ],
  "$defs": {
    "StayOutcomeSummary": {
      "properties": {
        "score": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "type": "null"
            }
          ],
          "title": "Score",
          "description": "0 to 100. Null when sample_size is below min_sample."
        },
        "sample_size": {
          "type": "integer",
          "title": "Sample Size",
          "description": "Verified stays counted."
        },
        "min_sample": {
          "type": "integer",
          "title": "Min Sample"
        },
        "confidence": {
          "anyOf": [
            {
              "type": "string",
              "enum": [
                "low",
                "medium",
                "high"
              ]
            },
            {
              "type": "null"
            }
          ],
          "title": "Confidence",
          "description": "low under 10 verified stays, medium under 30, high from 30. Null when no score is shown."
        },
        "top_reasons": {
          "items": {
            "type": "string",
            "enum": [
              "not_as_described",
              "cleanliness",
              "noise",
              "check_in_problem",
              "safety",
              "overbooked",
              "other"
            ]
          },
          "type": "array",
          "title": "Top Reasons"
        }
      },
      "type": "object",
      "required": [
        "score",
        "sample_size",
        "min_sample",
        "confidence",
        "top_reasons"
      ],
      "title": "StayOutcomeSummary"
    }
  }
}