{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://veritaset.com/feeds/operator-feed-1.0.schema.json",
  "title": "Veritaset operator feed 1.0",
  "description": "Consumer mobile plans as published by the operator. One file per operator and country. Omit a field you do not publish; never guess.",
  "type": "object",
  "additionalProperties": false,
  "required": ["format", "version", "operator", "country", "currency", "prices_include_vat", "generated_at", "plans"],
  "properties": {
    "format": {"const": "veritaset-operator-feed"},
    "version": {"const": "1.0"},
    "operator": {
      "type": "object", "additionalProperties": false, "required": ["name", "website", "contact_email"],
      "properties": {
        "name": {"type": "string", "minLength": 1, "description": "Brand name as shown to customers."},
        "website": {"type": "string", "format": "uri", "pattern": "^https://", "description": "Home page. Every plan url must be on this domain."},
        "contact_email": {"type": "string", "format": "email", "description": "Who we contact about this feed."}
      }
    },
    "country": {"type": "string", "pattern": "^[A-Z]{2}$", "description": "ISO 3166-1 alpha-2, e.g. LT."},
    "currency": {"type": "string", "pattern": "^[A-Z]{3}$", "description": "ISO 4217, e.g. EUR."},
    "prices_include_vat": {"type": "boolean", "description": "Consumer prices: true."},
    "generated_at": {"type": "string", "format": "date-time", "description": "When this file was produced (ISO 8601 with time zone)."},
    "plans": {"type": "array", "minItems": 1, "items": {"$ref": "#/$defs/plan"}}
  },
  "$defs": {
    "money": {"type": "number", "minimum": 0},
    "allowance": {
      "type": "object", "additionalProperties": false, "required": ["unlimited"],
      "properties": {
        "unlimited": {"type": "boolean"},
        "amount": {"type": "number", "minimum": 0, "description": "Minutes or messages when not unlimited."},
        "scope": {"enum": ["domestic", "domestic_and_eu", "domestic_and_eea"], "description": "Where the allowance applies."},
        "conditions": {"type": "string"}
      }
    },
    "plan": {
      "type": "object", "additionalProperties": false,
      "required": ["plan_id", "name", "url", "payment", "price", "data", "calls", "sms"],
      "properties": {
        "plan_id": {"type": "string", "pattern": "^[A-Za-z0-9._-]{1,64}$", "description": "Your stable id for the plan. Keep it the same when the price changes."},
        "name": {"type": "string", "minLength": 1, "description": "Plan name as shown on your website."},
        "url": {"type": "string", "format": "uri", "pattern": "^https://", "description": "Public page where a customer sees this plan and its price."},
        "status": {"enum": ["available", "new_customers_only", "existing_customers_only", "closed"], "default": "available"},
        "payment": {"enum": ["postpaid", "prepaid"]},
        "price": {
          "type": "object", "additionalProperties": false, "required": ["amount", "period"],
          "description": "Regular price, without temporary discounts.",
          "properties": {
            "amount": {"$ref": "#/$defs/money"},
            "period": {"enum": ["month", "days"]},
            "period_days": {"type": "integer", "minimum": 1, "description": "Required when period is days, e.g. 28 or 30."}
          },
          "if": {"properties": {"period": {"const": "days"}}}, "then": {"required": ["period_days"]}
        },
        "promo": {
          "type": "object", "additionalProperties": false, "required": ["amount"],
          "description": "A temporary or conditional price, if any.",
          "properties": {
            "amount": {"$ref": "#/$defs/money"},
            "months": {"type": "integer", "minimum": 1, "description": "How long the promo price lasts."},
            "ends_on": {"type": "string", "format": "date", "description": "Last day to sign up at this price."},
            "new_customers_only": {"type": "boolean"},
            "conditions": {"type": "string", "description": "e.g. discount code, bundle, 12-month contract."}
          }
        },
        "contract": {
          "type": "object", "additionalProperties": false,
          "properties": {
            "min_months": {"type": "integer", "minimum": 0, "description": "0 = cancel any time."},
            "early_exit_fee": {"type": "string", "description": "How the exit fee is calculated, if any."}
          }
        },
        "one_off_fees": {
          "type": "array",
          "items": {"type": "object", "additionalProperties": false, "required": ["name", "amount"],
                    "properties": {"name": {"type": "string"}, "amount": {"$ref": "#/$defs/money"}}}
        },
        "data": {
          "type": "object", "additionalProperties": false, "required": ["unlimited"],
          "properties": {
            "unlimited": {"type": "boolean"},
            "gb": {"type": "number", "minimum": 0, "description": "Domestic data per period when not unlimited."},
            "extra_gb_price": {"$ref": "#/$defs/money", "description": "Price per extra GB after the allowance, if offered."},
            "after_allowance": {"enum": ["blocked", "slowed", "charged_per_gb", "buy_extra_pack"]},
            "slowed_to_mbps": {"type": "number", "minimum": 0, "description": "Speed after the allowance or fair-use limit."},
            "fair_use_gb": {"type": "number", "minimum": 0, "description": "For unlimited plans: the volume after which speed is reduced."},
            "conditions": {"type": "string"}
          }
        },
        "eu_roaming": {
          "type": "object", "additionalProperties": false,
          "properties": {
            "data_gb": {"type": "number", "minimum": 0, "description": "Data usable in the EU/EEA per period, as you state it."},
            "extra_gb_price": {"$ref": "#/$defs/money"},
            "calls_sms_like_home": {"type": "boolean"},
            "conditions": {"type": "string"}
          }
        },
        "calls": {"$ref": "#/$defs/allowance"},
        "sms": {"$ref": "#/$defs/allowance"},
        "network": {
          "type": "object", "additionalProperties": false,
          "properties": {
            "technology": {"type": "array", "items": {"enum": ["3G", "4G", "5G"]}, "uniqueItems": true},
            "host_network": {"type": "string", "description": "Network the plan runs on, if you are an MVNO."}
          }
        },
        "esim": {"type": "boolean"},
        "lines": {"type": "integer", "minimum": 1, "default": 1, "description": "Number of SIMs included in the price."},
        "conditions": {"type": "string", "description": "Anything else a customer must know, in any language."},
        "valid_from": {"type": "string", "format": "date", "description": "Date this price applies from, if not today."}
      }
    }
  }
}
