{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "title": "SupplyCreated",
  "description": "A supply contract on its creation date.",
  "type": "object",
  "properties": {
    "client_reference": {
      "type": [
        "string",
        "null"
      ]
    },
    "profile": {
      "type": "string",
      "const": "product-lifecycle@1"
    },
    "state": {
      "type": "string",
      "const": "created"
    },
    "product": {
      "$ref": "#/$defs/SupplyProduct"
    },
    "effective": {
      "$ref": "#/$defs/EffectiveDate"
    },
    "sector": {
      "$ref": "#/$defs/SupplySector"
    },
    "extensions": {
      "$ref": "#/$defs/ProductExtensions"
    }
  },
  "additionalProperties": false,
  "required": [
    "profile",
    "state",
    "product",
    "effective",
    "sector",
    "extensions"
  ],
  "$defs": {
    "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/CreationDetail"
        },
        "energy": {
          "anyOf": [
            {
              "$ref": "#/$defs/EnergyLocation"
            },
            {
              "type": "null"
            }
          ]
        }
      },
      "required": [
        "de.mako"
      ]
    },
    "CreationDetail": {
      "type": "object",
      "properties": {
        "type": {
          "type": "string",
          "const": "de.mako.vertrag.erstellt"
        },
        "vertrag_id": {
          "type": "string",
          "format": "uuid"
        },
        "created_at": {
          "type": "string",
          "format": "date-time"
        }
      },
      "required": [
        "type",
        "vertrag_id",
        "created_at"
      ]
    },
    "EnergyLocation": {
      "type": "object",
      "properties": {
        "marktlokation": {
          "type": "string"
        }
      },
      "required": [
        "marktlokation"
      ]
    }
  },
  "$id": "https://hupe1980.github.io/mako/schemas/events/de.mako.vertrag.erstellt.json",
  "x-dataschema": "urn:open-utility-stack:product-lifecycle:1"
}
