{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://golfdata.online/schema/card-v1.json",
  "title": "golfdata.card/v1",
  "type": "object",
  "required": [
    "card_version",
    "id",
    "slug",
    "identity",
    "location",
    "contact",
    "course",
    "play",
    "booking",
    "hours",
    "facilities",
    "status",
    "provenance",
    "licence",
    "links"
  ],
  "properties": {
    "card_version": {
      "type": "string",
      "const": "1.2"
    },
    "id": {
      "type": [
        "string",
        "null"
      ]
    },
    "slug": {
      "type": [
        "string",
        "null"
      ]
    },
    "generated_at": {
      "type": "string"
    },
    "identity": {
      "type": "object",
      "required": [
        "name",
        "website",
        "federation_id",
        "external_ids"
      ],
      "properties": {
        "name": {
          "type": [
            "string",
            "null"
          ]
        },
        "website": {
          "type": [
            "string",
            "null"
          ]
        },
        "federation_id": {
          "type": [
            "string",
            "null"
          ]
        },
        "external_ids": {
          "type": "object",
          "properties": {
            "osm": {
              "type": [
                "string",
                "null"
              ]
            }
          },
          "required": [
            "osm"
          ]
        }
      }
    },
    "location": {
      "type": "object",
      "required": [
        "country",
        "region",
        "island",
        "municipality",
        "address",
        "postcode",
        "lat",
        "lng"
      ],
      "properties": {
        "country": {
          "type": [
            "string",
            "null"
          ]
        },
        "region": {
          "type": [
            "string",
            "null"
          ]
        },
        "island": {
          "type": [
            "string",
            "null"
          ]
        },
        "municipality": {
          "type": [
            "string",
            "null"
          ]
        },
        "address": {
          "type": [
            "string",
            "null"
          ]
        },
        "postcode": {
          "type": [
            "string",
            "null"
          ]
        },
        "lat": {
          "type": [
            "number",
            "null"
          ]
        },
        "lng": {
          "type": [
            "number",
            "null"
          ]
        }
      }
    },
    "contact": {
      "type": "object",
      "required": [
        "phone_e164",
        "email",
        "languages"
      ],
      "properties": {
        "phone_e164": {
          "type": [
            "string",
            "null"
          ]
        },
        "email": {
          "type": [
            "string",
            "null"
          ]
        },
        "languages": {
          "type": "array",
          "items": {
            "type": "string"
          }
        }
      }
    },
    "course": {
      "type": "object",
      "required": [
        "holes",
        "par",
        "par_basis",
        "course_type",
        "designer",
        "year_opened",
        "length_m",
        "length_tee",
        "course_rating",
        "slope_rating"
      ],
      "properties": {
        "holes": {
          "type": [
            "integer",
            "null"
          ]
        },
        "par": {
          "type": [
            "integer",
            "null"
          ]
        },
        "par_basis": {
          "type": [
            "string",
            "null"
          ],
          "enum": [
            "9_holes",
            "18_holes",
            null
          ]
        },
        "course_type": {
          "type": [
            "string",
            "null"
          ]
        },
        "designer": {
          "type": [
            "string",
            "null"
          ]
        },
        "year_opened": {
          "type": [
            "integer",
            "null"
          ]
        },
        "length_m": {
          "type": [
            "integer",
            "null"
          ]
        },
        "length_tee": {
          "type": [
            "string",
            "null"
          ]
        },
        "course_rating": {
          "type": [
            "number",
            "null"
          ]
        },
        "slope_rating": {
          "type": [
            "integer",
            "null"
          ]
        }
      }
    },
    "play": {
      "type": "object",
      "required": [
        "visitors",
        "handicap_max",
        "dress_code",
        "green_fees",
        "buggy"
      ],
      "properties": {
        "visitors": {
          "type": [
            "string",
            "null"
          ],
          "enum": [
            "welcome",
            "handicap_required",
            "members_only",
            null
          ]
        },
        "handicap_max": {
          "type": [
            "number",
            "null"
          ]
        },
        "dress_code": {
          "type": [
            "string",
            "null"
          ]
        },
        "green_fees": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string"
              },
              "label": {
                "type": "string"
              },
              "from": {
                "type": [
                  "number",
                  "null"
                ]
              },
              "to": {
                "type": [
                  "number",
                  "null"
                ]
              },
              "currency": {
                "type": "string"
              },
              "year": {
                "type": [
                  "integer",
                  "null"
                ]
              },
              "basis": {
                "type": "object",
                "properties": {
                  "holes": {
                    "type": [
                      "integer",
                      "null"
                    ]
                  },
                  "player": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "season": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "twilight": {
                    "type": [
                      "boolean",
                      "null"
                    ]
                  },
                  "weekday": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "includes_buggy": {
                    "type": [
                      "boolean",
                      "null"
                    ]
                  }
                },
                "required": [
                  "holes",
                  "player",
                  "season",
                  "twilight",
                  "weekday",
                  "includes_buggy"
                ]
              }
            },
            "required": [
              "id",
              "label",
              "from",
              "to",
              "currency",
              "year",
              "basis"
            ]
          }
        },
        "buggy": {
          "type": "object",
          "required": [
            "available",
            "price"
          ],
          "properties": {
            "available": {
              "type": [
                "string",
                "null"
              ],
              "enum": [
                "included",
                "optional",
                "no",
                null
              ]
            },
            "price": {
              "type": [
                "object",
                "null"
              ],
              "properties": {
                "amount": {
                  "type": [
                    "number",
                    "null"
                  ]
                },
                "currency": {
                  "type": "string"
                },
                "per": {
                  "type": "string",
                  "enum": [
                    "buggy",
                    "seat"
                  ]
                },
                "holes": {
                  "type": [
                    "integer",
                    "null"
                  ]
                }
              }
            }
          }
        }
      }
    },
    "booking": {
      "type": "object",
      "required": [
        "mode",
        "channels",
        "provider",
        "lead_time",
        "cancellation",
        "expected_response",
        "requests_enabled"
      ],
      "properties": {
        "mode": {
          "type": "string",
          "enum": [
            "online",
            "email",
            "whatsapp",
            "phone",
            "none"
          ]
        },
        "channels": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "type": {
                "type": "string",
                "enum": [
                  "deep_link",
                  "phone",
                  "email",
                  "whatsapp"
                ]
              }
            },
            "required": [
              "type"
            ]
          }
        },
        "provider": {
          "type": [
            "object",
            "null"
          ],
          "properties": {
            "id": {
              "type": "string"
            },
            "provider_club_id": {
              "type": [
                "string",
                "null"
              ]
            }
          },
          "required": [
            "id",
            "provider_club_id"
          ]
        },
        "lead_time": {
          "type": "object",
          "properties": {
            "min_hours": {
              "type": [
                "integer",
                "null"
              ]
            },
            "max_days": {
              "type": [
                "integer",
                "null"
              ]
            }
          },
          "required": [
            "min_hours",
            "max_days"
          ]
        },
        "cancellation": {
          "type": "object",
          "properties": {
            "free_until_hours": {
              "type": [
                "integer",
                "null"
              ]
            },
            "text": {
              "type": [
                "string",
                "null"
              ]
            },
            "url": {
              "type": [
                "string",
                "null"
              ]
            }
          },
          "required": [
            "free_until_hours",
            "text",
            "url"
          ]
        },
        "expected_response": {
          "type": "object",
          "properties": {
            "email_hours": {
              "type": [
                "integer",
                "null"
              ]
            },
            "whatsapp_hours": {
              "type": [
                "integer",
                "null"
              ]
            }
          },
          "required": [
            "email_hours",
            "whatsapp_hours"
          ]
        },
        "requests_enabled": {
          "type": "boolean"
        },
        "request": {
          "type": [
            "object",
            "null"
          ],
          "properties": {
            "mcp_tool": {
              "type": "string"
            },
            "url": {
              "type": "string"
            }
          },
          "required": [
            "mcp_tool",
            "url"
          ]
        }
      }
    },
    "hours": {
      "type": "object",
      "required": [
        "text",
        "structured"
      ],
      "properties": {
        "text": {
          "type": [
            "string",
            "null"
          ]
        },
        "structured": {
          "type": [
            "array",
            "null"
          ],
          "items": {
            "type": "object",
            "properties": {
              "days": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "opens": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "closes": {
                "type": [
                  "string",
                  "null"
                ]
              }
            },
            "required": [
              "days",
              "opens",
              "closes"
            ]
          }
        }
      }
    },
    "facilities": {
      "type": "array",
      "items": {
        "type": "string"
      }
    },
    "status": {
      "type": "object",
      "required": [
        "claimed",
        "claimed_at",
        "claim_method",
        "verified_by_club",
        "club_verified_at",
        "club_verified_fields",
        "last_verified",
        "updated_at",
        "version"
      ],
      "properties": {
        "claimed": {
          "type": "boolean"
        },
        "claimed_at": {
          "type": [
            "string",
            "null"
          ]
        },
        "claim_method": {
          "type": [
            "string",
            "null"
          ]
        },
        "verified_by_club": {
          "type": "boolean"
        },
        "club_verified_at": {
          "type": [
            "string",
            "null"
          ]
        },
        "club_verified_fields": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "last_verified": {
          "type": [
            "string",
            "null"
          ]
        },
        "updated_at": {
          "type": [
            "string",
            "null"
          ]
        },
        "version": {
          "type": [
            "integer",
            "null"
          ]
        }
      }
    },
    "provenance": {
      "type": "object",
      "required": [
        "fields",
        "sources",
        "sources_total",
        "sources_truncated"
      ],
      "properties": {
        "fields": {
          "type": "object",
          "additionalProperties": {
            "type": "object",
            "properties": {
              "value": {},
              "sources": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "last_verified": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "verified_by": {
                "type": "string",
                "enum": [
                  "directory",
                  "club",
                  "agency"
                ]
              },
              "origin": {
                "type": "string",
                "enum": [
                  "source_extraction",
                  "club_statement",
                  "agency_recheck",
                  "derived_country_default",
                  "derived_from_booking_url",
                  "derived_from_facilities",
                  "normalised"
                ]
              }
            },
            "required": [
              "value",
              "sources",
              "last_verified",
              "verified_by",
              "origin"
            ]
          }
        },
        "sources": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string"
              },
              "field": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "value": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "url": {
                "type": "string"
              },
              "publisher": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "trust_level": {
                "type": [
                  "integer",
                  "null"
                ]
              },
              "retrieved_at": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "licence": {
                "type": "string"
              }
            },
            "required": [
              "id",
              "field",
              "value",
              "url",
              "publisher",
              "trust_level",
              "retrieved_at",
              "licence"
            ]
          }
        },
        "sources_total": {
          "type": "integer"
        },
        "sources_truncated": {
          "type": "boolean"
        }
      }
    },
    "licence": {
      "type": "object",
      "required": [
        "card",
        "components"
      ],
      "properties": {
        "card": {
          "type": "object",
          "properties": {
            "id": {
              "type": "string"
            },
            "url": {
              "type": "string"
            },
            "attribution": {
              "type": "string"
            }
          },
          "required": [
            "id",
            "url",
            "attribution"
          ]
        },
        "components": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string"
              },
              "url": {
                "type": "string"
              },
              "attribution": {
                "type": "string"
              },
              "fields": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              }
            },
            "required": [
              "id",
              "url",
              "attribution",
              "fields"
            ]
          }
        }
      }
    },
    "links": {
      "type": "object",
      "required": [
        "page",
        "feed",
        "mcp",
        "llms",
        "schema"
      ],
      "properties": {
        "page": {
          "type": "string"
        },
        "feed": {
          "type": "string"
        },
        "mcp": {
          "type": "string"
        },
        "llms": {
          "type": "string"
        },
        "schema": {
          "type": "string"
        }
      }
    }
  }
}
