{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "https://api.reputation.com/v3/schemas/location",
  "title": "Location",
  "description": "A business location managed on the Reputation platform.",
  "type": "object",
  "properties": {
    "locationID": {
      "type": "string",
      "description": "Unique identifier for the location"
    },
    "name": {
      "type": "string",
      "description": "Business name"
    },
    "address": {
      "type": "object",
      "description": "Normalized business address",
      "properties": {
        "street": {"type": "string"},
        "city": {"type": "string"},
        "state": {"type": "string"},
        "zip": {"type": "string"},
        "country": {"type": "string"}
      }
    },
    "originalAddress": {
      "type": "object",
      "description": "Original address as entered",
      "properties": {
        "street": {"type": "string"},
        "city": {"type": "string"},
        "state": {"type": "string"},
        "zip": {"type": "string"},
        "country": {"type": "string"}
      }
    },
    "phones": {
      "type": "array",
      "description": "List of phone numbers",
      "items": {
        "type": "object",
        "properties": {
          "number": {"type": "string"},
          "type": {"type": "string", "enum": ["main", "fax", "mobile", "other"]}
        }
      }
    },
    "emails": {
      "type": "array",
      "items": {"type": "string", "format": "email"}
    },
    "websites": {
      "type": "array",
      "items": {"type": "string", "format": "uri"}
    },
    "businessHours": {
      "type": "object",
      "description": "Regular business hours by day of week",
      "properties": {
        "monday": {"$ref": "#/definitions/HoursEntry"},
        "tuesday": {"$ref": "#/definitions/HoursEntry"},
        "wednesday": {"$ref": "#/definitions/HoursEntry"},
        "thursday": {"$ref": "#/definitions/HoursEntry"},
        "friday": {"$ref": "#/definitions/HoursEntry"},
        "saturday": {"$ref": "#/definitions/HoursEntry"},
        "sunday": {"$ref": "#/definitions/HoursEntry"}
      }
    },
    "specialHours": {
      "type": "array",
      "description": "Holiday or special hours overrides",
      "items": {
        "type": "object",
        "properties": {
          "date": {"type": "string", "format": "date"},
          "open": {"type": "string"},
          "close": {"type": "string"},
          "closed": {"type": "boolean"}
        }
      }
    },
    "categories": {
      "type": "array",
      "items": {"type": "string"},
      "description": "Business category identifiers"
    },
    "attributes": {
      "type": "object",
      "description": "Extended business attributes",
      "additionalProperties": true
    },
    "socialProfiles": {
      "type": "object",
      "description": "Social media profile URLs",
      "properties": {
        "facebook": {"type": "string", "format": "uri"},
        "twitter": {"type": "string", "format": "uri"},
        "instagram": {"type": "string", "format": "uri"},
        "linkedin": {"type": "string", "format": "uri"}
      }
    },
    "media": {
      "type": "array",
      "description": "Media assets associated with the location",
      "items": {
        "type": "object",
        "properties": {
          "url": {"type": "string", "format": "uri"},
          "type": {"type": "string", "enum": ["photo", "logo", "cover"]},
          "caption": {"type": "string"}
        }
      }
    },
    "medical": {
      "type": "object",
      "description": "Medical-specific attributes (healthcare locations)",
      "properties": {
        "npi": {"type": "string"},
        "licenses": {"type": "array", "items": {"type": "string"}},
        "insurance": {"type": "array", "items": {"type": "string"}}
      }
    },
    "customVariables": {
      "type": "object",
      "description": "Custom variables configured for the tenant",
      "additionalProperties": true
    },
    "locationCode": {
      "type": "string",
      "description": "External reference code for the location"
    },
    "tenantID": {
      "type": "string",
      "description": "ID of the tenant this location belongs to"
    },
    "status": {
      "type": "string",
      "description": "Location status",
      "enum": ["active", "inactive", "paused"]
    }
  },
  "definitions": {
    "HoursEntry": {
      "type": "object",
      "properties": {
        "open": {"type": "string", "pattern": "^[0-9]{2}:[0-9]{2}$"},
        "close": {"type": "string", "pattern": "^[0-9]{2}:[0-9]{2}$"},
        "closed": {"type": "boolean"}
      }
    }
  }
}
