{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "title": "ProductTransition",
  "type": "object",
  "properties": {
    "profile": {
      "type": "string",
      "const": "product-lifecycle@1"
    },
    "state": {
      "type": "string",
      "const": "active"
    },
    "previous_state": {
      "$ref": "#/$defs/PreviousState"
    },
    "reason": {
      "anyOf": [
        {
          "$ref": "#/$defs/WithdrawalReason"
        },
        {
          "type": "null"
        }
      ]
    },
    "client_reference": {
      "type": [
        "string",
        "null"
      ]
    },
    "product": {
      "$ref": "#/$defs/SupplyProduct"
    },
    "effective": {
      "$ref": "#/$defs/EffectiveDate"
    },
    "sector": {
      "$ref": "#/$defs/SupplySector"
    },
    "extensions": {
      "$ref": "#/$defs/ProductExtensions"
    }
  },
  "additionalProperties": false,
  "required": [
    "profile",
    "state",
    "previous_state",
    "product",
    "effective",
    "sector",
    "extensions"
  ],
  "$defs": {
    "PreviousState": {
      "type": "string",
      "enum": [
        "created",
        "active",
        "pendingActive",
        "pendingTerminate"
      ]
    },
    "WithdrawalReason": {
      "type": "object",
      "properties": {
        "code": {
          "type": "string",
          "const": "withdrawn"
        }
      },
      "required": [
        "code"
      ]
    },
    "SupplyProduct": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string",
          "format": "uuid"
        },
        "number": {
          "type": "string",
          "maxLength": 64,
          "pattern": "\\S"
        }
      },
      "additionalProperties": false,
      "required": [
        "id",
        "number"
      ]
    },
    "EffectiveDate": {
      "type": "object",
      "properties": {
        "date": {
          "type": "string",
          "format": "date"
        },
        "zone": {
          "type": "string",
          "const": "Europe/Berlin"
        }
      },
      "additionalProperties": false,
      "required": [
        "date",
        "zone"
      ]
    },
    "SupplySector": {
      "type": "string",
      "enum": [
        "electricity",
        "gas",
        "heat",
        "water",
        "charging",
        "other"
      ]
    },
    "ProductExtensions": {
      "type": "object",
      "properties": {
        "de.mako": {
          "$ref": "#/$defs/NativeFact"
        },
        "energy": {
          "anyOf": [
            {
              "$ref": "#/$defs/EnergyLocation"
            },
            {
              "type": "null"
            }
          ]
        }
      },
      "required": [
        "de.mako"
      ]
    },
    "NativeFact": {
      "type": "object",
      "properties": {
        "type": {
          "type": "string"
        },
        "withdrawn_on": {
          "type": "string",
          "format": "date"
        },
        "vertrag_id": {
          "type": "string",
          "format": "uuid"
        }
      },
      "required": [
        "type",
        "withdrawn_on",
        "vertrag_id"
      ]
    },
    "EnergyLocation": {
      "type": "object",
      "properties": {
        "marktlokation": {
          "type": "string"
        }
      },
      "required": [
        "marktlokation"
      ]
    }
  },
  "$id": "https://hupe1980.github.io/mako/schemas/events/de.mako.vertrag.kuendigung-widerrufen.json",
  "x-dataschema": "urn:open-utility-stack:product-lifecycle:1"
}
