{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "title": "Fehlgeschlagen",
  "description": "The `data` of `de.mako.sperr.fehlgeschlagen`.",
  "type": "object",
  "properties": {
    "order_id": {
      "type": "string",
      "format": "uuid"
    },
    "external_ref": {
      "description": "The executing system's own reference, where the order carries one.",
      "type": [
        "string",
        "null"
      ]
    },
    "status": {
      "$ref": "#/$defs/OrderStatus"
    },
    "iftsta_code": {
      "description": "`SG15 STS DE4405` — `Z13` gescheitert.",
      "type": [
        "string",
        "null"
      ]
    },
    "iftsta_queued": {
      "description": "Whether the IFTSTA 21039 committed with the outcome; `false` for an\norder an operator created by hand, which owes none.",
      "type": "boolean"
    },
    "detail": {
      "$ref": "#/$defs/FehlschlagDetail"
    }
  },
  "required": [
    "order_id",
    "status",
    "iftsta_queued",
    "detail"
  ],
  "$defs": {
    "OrderStatus": {
      "description": "Where the order stands in this service.",
      "oneOf": [
        {
          "description": "Waiting for the field team.",
          "type": "string",
          "const": "pending"
        },
        {
          "description": "Carried out — IFTSTA `DE4405 = Z14 erfolgreich`.",
          "type": "string",
          "const": "executed"
        },
        {
          "description": "Attempted and not carried out — IFTSTA `DE4405 = Z13 gescheitert`.",
          "type": "string",
          "const": "failed"
        },
        {
          "description": "Withdrawn before execution. No IFTSTA: nothing happened to report.",
          "type": "string",
          "const": "cancelled"
        }
      ]
    },
    "FehlschlagDetail": {
      "description": "What the field team reported on an order that was not carried out.",
      "type": "object",
      "properties": {
        "reason": {
          "type": "string"
        },
        "pruefschritt_code": {
          "description": "`SG15 STS DE9013` — the EBD Prüfschritt code.",
          "type": [
            "string",
            "null"
          ]
        },
        "responsible": {
          "description": "Whom the last visit is put down to, where the report said.",
          "anyOf": [
            {
              "$ref": "#/$defs/Responsible"
            },
            {
              "type": "null"
            }
          ]
        }
      },
      "required": [
        "reason"
      ]
    },
    "Responsible": {
      "description": "Whom an unsuccessful visit is put down to.\n\nThe Lieferant asks why a Sperrung did not happen, and „niemand angetroffen\"\nand „der Monteur kam nicht\" are different answers with different costs.",
      "oneOf": [
        {
          "description": "The Anschlussnutzer: refused access, or prevented the work.",
          "type": "string",
          "const": "customer"
        },
        {
          "description": "The firm or team sent to do the work: did not come, came unequipped.",
          "type": "string",
          "const": "contractor"
        },
        {
          "description": "The Netzbetreiber itself: a wrong address, a withdrawn or faulty order.",
          "type": "string",
          "const": "operator"
        },
        {
          "description": "Nobody: nobody was there, the device could not be reached.",
          "type": "string",
          "const": "nobody"
        }
      ]
    }
  },
  "$id": "https://hupe1980.github.io/mako/schemas/events/de.mako.sperr.fehlgeschlagen.json"
}
