{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "title": "Putarko ciljni program — podatkovni ugovor v1",
  "description": "Specifikacija za produkcijski WordPress. Demo frontend koristi jednostavniji model iz demo-catalog.json. Aplikacijski provjeriti datume, potpunost za objavu, prava, referencijalni integritet i istu osnovu cijene. JSON Schema sama ne uspoređuje dva datuma.",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "id",
    "slug",
    "organizer_id",
    "title",
    "destination_ids",
    "transport",
    "days",
    "nights",
    "included",
    "extras",
    "itinerary",
    "photos",
    "status",
    "last_verified_at",
    "conditions_url",
    "contact_organizer_id",
    "departures",
    "demo",
    "source_permission_reference"
  ],
  "properties": {
    "id": {
      "type": "string",
      "minLength": 1,
      "maxLength": 100
    },
    "slug": {
      "type": "string",
      "pattern": "^[a-z0-9]+(?:-[a-z0-9]+)*$"
    },
    "organizer_id": {
      "type": "string",
      "minLength": 1,
      "maxLength": 100
    },
    "title": {
      "type": "string",
      "minLength": 3,
      "maxLength": 200
    },
    "summary": {
      "type": "string"
    },
    "destination_ids": {
      "type": "array",
      "minItems": 1,
      "uniqueItems": true,
      "items": {
        "type": "string",
        "minLength": 1,
        "maxLength": 100
      }
    },
    "occasion_ids": {
      "type": "array",
      "items": {
        "type": "string",
        "minLength": 1,
        "maxLength": 100
      }
    },
    "theme_ids": {
      "type": "array",
      "items": {
        "type": "string",
        "minLength": 1,
        "maxLength": 100
      }
    },
    "type_ids": {
      "type": "array",
      "items": {
        "type": "string",
        "minLength": 1,
        "maxLength": 100
      }
    },
    "shrine_ids": {
      "type": "array",
      "items": {
        "type": "string",
        "minLength": 1,
        "maxLength": 100
      }
    },
    "transport": {
      "type": "string",
      "enum": [
        "bus",
        "air",
        "ship",
        "train",
        "own",
        "mixed"
      ]
    },
    "days": {
      "type": "integer",
      "minimum": 1,
      "maximum": 365
    },
    "nights": {
      "type": "integer",
      "minimum": 0,
      "maximum": 365
    },
    "included": {
      "type": "array",
      "items": {
        "type": "string"
      }
    },
    "extras": {
      "type": "array",
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "name",
          "mandatory",
          "amount_known",
          "basis"
        ],
        "properties": {
          "name": {
            "type": "string",
            "minLength": 1
          },
          "mandatory": {
            "type": "boolean"
          },
          "amount_known": {
            "type": "boolean"
          },
          "amount_minor": {
            "type": [
              "integer",
              "null"
            ],
            "minimum": 0
          },
          "currency": {
            "type": "string",
            "pattern": "^[A-Z]{3}$"
          },
          "basis": {
            "type": "string",
            "enum": [
              "person",
              "room",
              "booking",
              "night",
              "other"
            ]
          },
          "description": {
            "type": "string"
          }
        }
      }
    },
    "itinerary": {
      "type": "array",
      "minItems": 1,
      "items": {
        "type": "object",
        "required": [
          "day",
          "text"
        ],
        "properties": {
          "day": {
            "type": "integer",
            "minimum": 1
          },
          "text": {
            "type": "string",
            "minLength": 1
          }
        }
      }
    },
    "photos": {
      "type": "array",
      "items": {
        "type": "object",
        "required": [
          "url",
          "author",
          "source_url",
          "license",
          "permission_reference",
          "alt"
        ],
        "properties": {
          "url": {
            "type": "string",
            "format": "uri"
          },
          "author": {
            "type": "string"
          },
          "source_url": {
            "type": "string",
            "format": "uri"
          },
          "license": {
            "type": "string"
          },
          "permission_reference": {
            "type": "string"
          },
          "alt": {
            "type": "string"
          },
          "illustrative": {
            "type": "boolean"
          }
        }
      }
    },
    "status": {
      "type": "string",
      "enum": [
        "draft",
        "pending_review",
        "changes_requested",
        "published",
        "suspended",
        "archived"
      ]
    },
    "last_verified_at": {
      "type": [
        "string",
        "null"
      ],
      "format": "date-time"
    },
    "conditions_url": {
      "type": [
        "string",
        "null"
      ],
      "format": "uri"
    },
    "booking_url": {
      "type": [
        "string",
        "null"
      ],
      "format": "uri"
    },
    "contact_organizer_id": {
      "type": "string",
      "minLength": 1,
      "maxLength": 100
    },
    "departures": {
      "type": "array",
      "minItems": 1,
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "id",
          "start_date",
          "end_date",
          "price_minor",
          "currency",
          "price_basis",
          "status",
          "origins",
          "verified_at",
          "spiritual_support"
        ],
        "properties": {
          "id": {
            "type": "string",
            "minLength": 1,
            "maxLength": 100
          },
          "external_id": {
            "type": "string",
            "minLength": 1,
            "maxLength": 100
          },
          "start_date": {
            "type": "string",
            "format": "date"
          },
          "end_date": {
            "type": "string",
            "format": "date"
          },
          "price_minor": {
            "type": "integer",
            "minimum": 0,
            "description": "Cijeli broj najmanjih novčanih jedinica, npr. centi; nije float."
          },
          "currency": {
            "type": "string",
            "pattern": "^[A-Z]{3}$"
          },
          "price_basis": {
            "type": "string",
            "enum": [
              "person_double_room",
              "person_cabin",
              "person",
              "room",
              "other"
            ]
          },
          "status": {
            "type": "string",
            "enum": [
              "pending",
              "active",
              "on_request",
              "sold_out",
              "cancelled",
              "expired"
            ]
          },
          "origins": {
            "type": "array",
            "minItems": 1,
            "items": {
              "type": "object",
              "additionalProperties": false,
              "required": [
                "id",
                "name",
                "country_code"
              ],
              "properties": {
                "id": {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 100
                },
                "name": {
                  "type": "string",
                  "minLength": 1
                },
                "country_code": {
                  "type": "string",
                  "pattern": "^[A-Z]{2}$"
                },
                "meeting_point": {
                  "type": "string"
                },
                "time": {
                  "type": "string"
                },
                "surcharge_minor": {
                  "type": "integer",
                  "minimum": 0,
                  "description": "Cijeli broj najmanjih novčanih jedinica, npr. centi; nije float."
                }
              }
            }
          },
          "booking_url": {
            "type": [
              "string",
              "null"
            ],
            "format": "uri"
          },
          "verified_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "spiritual_support": {
            "type": "object",
            "required": [
              "confirmed"
            ],
            "properties": {
              "confirmed": {
                "type": "boolean"
              },
              "description": {
                "type": "string"
              }
            }
          },
          "extras": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": false,
              "required": [
                "name",
                "mandatory",
                "amount_known",
                "basis"
              ],
              "properties": {
                "name": {
                  "type": "string",
                  "minLength": 1
                },
                "mandatory": {
                  "type": "boolean"
                },
                "amount_known": {
                  "type": "boolean"
                },
                "amount_minor": {
                  "type": [
                    "integer",
                    "null"
                  ],
                  "minimum": 0
                },
                "currency": {
                  "type": "string",
                  "pattern": "^[A-Z]{3}$"
                },
                "basis": {
                  "type": "string",
                  "enum": [
                    "person",
                    "room",
                    "booking",
                    "night",
                    "other"
                  ]
                },
                "description": {
                  "type": "string"
                }
              }
            }
          }
        }
      }
    },
    "demo": {
      "type": "boolean"
    },
    "source_permission_reference": {
      "type": "string"
    },
    "editorial_notes": {
      "type": "string",
      "description": "Privatno, ne izlagati javnim API odgovorom."
    }
  },
  "allOf": [
    {
      "if": {
        "properties": {
          "status": {
            "const": "published"
          },
          "demo": {
            "const": false
          }
        },
        "required": [
          "status",
          "demo"
        ]
      },
      "then": {
        "properties": {
          "last_verified_at": {
            "type": "string",
            "format": "date-time"
          },
          "conditions_url": {
            "type": "string",
            "format": "uri"
          },
          "source_permission_reference": {
            "type": "string",
            "minLength": 1
          },
          "photos": {
            "type": "array",
            "minItems": 1,
            "items": {
              "type": "object",
              "required": [
                "url",
                "author",
                "source_url",
                "license",
                "permission_reference",
                "alt"
              ],
              "properties": {
                "url": {
                  "type": "string",
                  "format": "uri"
                },
                "author": {
                  "type": "string"
                },
                "source_url": {
                  "type": "string",
                  "format": "uri"
                },
                "license": {
                  "type": "string"
                },
                "permission_reference": {
                  "type": "string"
                },
                "alt": {
                  "type": "string"
                },
                "illustrative": {
                  "type": "boolean"
                }
              }
            }
          }
        }
      }
    }
  ]
}