{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://feed-spec.nearcharger.sk/listing-template.schema.json",
  "title": "Nearcharger partner listing feed (JSON)",
  "description": "Inbound listing feed template for Nearcharger syndication partners. Validates structure and types; custom field names are mapped during onboarding. Spec: https://feed-spec.nearcharger.sk/",
  "type": "object",
  "required": ["vehicles"],
  "properties": {
    "feed_version": { "type": "string", "description": "Partner feed version identifier (free-form)." },
    "generated_at": { "type": "string", "format": "date-time", "description": "When the feed was generated." },
    "vehicles": {
      "type": "array",
      "minItems": 0,
      "items": { "$ref": "#/$defs/vehicle" }
    }
  },
  "additionalProperties": true,
  "$defs": {
    "vehicle": {
      "type": "object",
      "required": [
        "id",
        "brand",
        "model",
        "year_of_production",
        "price",
        "currency",
        "vat_deductible",
        "mileage_km",
        "status",
        "photos"
      ],
      "properties": {
        "id": {
          "type": "string",
          "pattern": "^[A-Za-z0-9_-]+$",
          "description": "Stable unique vehicle identifier in the partner system. Must never change during the listing lifetime."
        },
        "catalog_id": {
          "type": "integer",
          "minimum": 1,
          "description": "Optional but strongly recommended: Nearcharger catalog item id from /wp-json/nearcharger/v1/master-data/catalog. Makes matching unambiguous."
        },
        "brand": { "type": "string", "minLength": 1, "description": "Vehicle make, e.g. \"Škoda\"." },
        "model": { "type": "string", "minLength": 1, "description": "Vehicle model, ideally without the variant." },
        "variant": { "type": "string", "description": "Trim / version, e.g. \"Long Range AWD\". Omit if your system does not separate model and variant." },
        "year_of_production": { "type": "integer", "minimum": 2010, "maximum": 2100, "description": "Production year (YYYY)." },
        "price": { "type": "number", "exclusiveMinimum": 0, "description": "Price including VAT, digits only." },
        "currency": { "type": "string", "enum": ["EUR", "CZK"], "description": "ISO 4217 currency of the price." },
        "vat_deductible": {
          "description": "VAT deductible flag. Boolean or 0/1.",
          "oneOf": [ { "type": "boolean" }, { "type": "integer", "enum": [0, 1] } ]
        },
        "mileage_km": { "type": "integer", "minimum": 0, "description": "Odometer in km. 0 for new vehicles." },
        "status": { "type": "string", "enum": ["active", "available", "reserved", "sold"], "description": "Current listing status." },
        "photos": {
          "type": "array",
          "minItems": 1,
          "items": { "type": "string", "pattern": "^https://", "description": "Public HTTPS photo URL." },
          "description": "At least 1 photo. The first photo is treated as the main image."
        },

        "vin": { "type": "string", "minLength": 17, "maxLength": 17, "description": "17-character VIN." },
        "engine": { "type": "string", "description": "Factory powertrain designation, e.g. \"iV 60 (RWD)\"." },
        "battery_kwh": { "type": "number", "exclusiveMinimum": 0, "description": "Battery capacity in kWh." },
        "wltp_range_km": { "type": "integer", "minimum": 0, "description": "WLTP range in km." },
        "power_kw": { "type": "integer", "minimum": 0, "description": "Power in kW." },
        "body_type": { "type": "string", "description": "Body type, e.g. SUV, Hatchback, Sedan, Coupe, Liftback, Combi, MPV, Pickup." },
        "drive": { "type": "string", "description": "Drive type: FWD, RWD, AWD, 4WD." },
        "seats": { "type": "integer", "minimum": 1, "maximum": 9, "description": "Number of seats." },

        "registration_year": { "type": "integer", "minimum": 2010, "maximum": 2100, "description": "Year of first registration." },
        "registration_month": { "type": "integer", "minimum": 1, "maximum": 12, "description": "Month of first registration." },
        "battery_warranty": {
          "description": "Battery warranty still valid. Boolean or 0/1.",
          "oneOf": [ { "type": "boolean" }, { "type": "integer", "enum": [0, 1] } ]
        },
        "battery_warranty_km": { "type": "integer", "minimum": 0, "description": "Battery warranty km limit, if it differs from the manufacturer default." },

        "soh": { "type": "integer", "minimum": 0, "maximum": 100, "description": "Battery State of Health in %." },
        "soh_certificate_url": { "type": "string", "pattern": "^https://", "description": "Link to the SoH measurement certificate (PDF/image)." },
        "soh_measurement_date": { "type": "string", "format": "date", "description": "Date of the SoH measurement (YYYY-MM-DD)." },

        "color_exterior": { "type": "string", "description": "Exterior color. Ideally a canonical slug from /master-data/enums (e.g. black, pearl-white)." },
        "color_interior": { "type": "string", "description": "Interior color / material." },
        "metallic": {
          "description": "Metallic paint. Boolean or 0/1.",
          "oneOf": [ { "type": "boolean" }, { "type": "integer", "enum": [0, 1] } ]
        },

        "branch": { "type": "string", "description": "City / branch where the vehicle is located." },
        "location": { "type": "string", "description": "Alias of branch." },
        "address": { "type": "string", "description": "Full address." },
        "gps_lat": { "type": "number", "minimum": -90, "maximum": 90, "description": "GPS latitude. Strongly recommended - required for the location filter." },
        "gps_lng": { "type": "number", "minimum": -180, "maximum": 180, "description": "GPS longitude. Strongly recommended - required for the location filter." },

        "price_without_vat": { "type": "number", "exclusiveMinimum": 0, "description": "Price without VAT." },
        "original_price": { "type": "number", "exclusiveMinimum": 0, "description": "Original price before discount." },

        "doors": { "type": "integer", "minimum": 2, "maximum": 6, "description": "Number of doors." },
        "description": { "type": "string", "description": "Free-text vehicle description (may contain HTML break tags)." },
        "equipment": {
          "type": "array",
          "items": { "type": "string" },
          "description": "Equipment list, one item per entry. Ideally Nearcharger slugs from /master-data/equipment (e.g. heat-pump)."
        },
        "condition": { "type": "string", "enum": ["new", "used", "demo"], "description": "Vehicle condition." },
        "state": {
          "type": "array",
          "items": { "type": "string" },
          "description": "Vehicle state flags, multiple allowed. Ideally Nearcharger slugs from /master-data/enums (listing_state group), e.g. first-owner, service-book, imported-vehicle, crashed. Free text is mapped during onboarding."
        }
      },
      "additionalProperties": true
    }
  }
}
