{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://docs.fispay.eu/schemas/diagnosis-response.json",
  "title": "Diagnosis response",
  "description": "Sent by the terminal to report the outcome of a diagnosis request. Placeholder until the real message catalog lands.",
  "x-placeholder": true,
  "type": "object",
  "required": [
    "SaleToPOIResponse"
  ],
  "examples": [
    {
      "SaleToPOIResponse": {
        "MessageHeader": {
          "ProtocolVersion": "3.1",
          "MessageClass": "Service",
          "MessageCategory": "Diagnosis",
          "MessageType": "Response",
          "ServiceID": "2041",
          "SaleID": "ECR-01",
          "POIID": "FISPAY-T-0001"
        },
        "DiagnosisResponse": {
          "Response": {
            "Result": "Success"
          }
        }
      }
    }
  ],
  "properties": {
    "SaleToPOIResponse": {
      "description": "Wrapper for every message the terminal sends back to the sale system.",
      "type": "object",
      "required": [
        "MessageHeader",
        "DiagnosisResponse"
      ],
      "examples": [
        {
          "MessageHeader": {
            "ProtocolVersion": "3.1",
            "MessageClass": "Service",
            "MessageCategory": "Diagnosis",
            "MessageType": "Response",
            "ServiceID": "2041",
            "SaleID": "ECR-01",
            "POIID": "FISPAY-T-0001"
          },
          "DiagnosisResponse": {
            "Response": {
              "Result": "Success"
            }
          }
        }
      ],
      "properties": {
        "MessageHeader": {
          "description": "Common envelope, narrowed to a diagnosis response.",
          "examples": [
            {
              "ProtocolVersion": "3.1",
              "MessageClass": "Service",
              "MessageCategory": "Diagnosis",
              "MessageType": "Response",
              "ServiceID": "2041",
              "SaleID": "ECR-01",
              "POIID": "FISPAY-T-0001"
            }
          ],
          "allOf": [
            {
              "$ref": "common/message-header.json"
            },
            {
              "properties": {
                "MessageClass": {
                  "description": "Fixed to Service for this message.",
                  "const": "Service",
                  "examples": [
                    "Service"
                  ]
                },
                "MessageCategory": {
                  "description": "Fixed to Diagnosis for this message.",
                  "const": "Diagnosis",
                  "examples": [
                    "Diagnosis"
                  ]
                },
                "MessageType": {
                  "description": "Fixed to Response for this message.",
                  "const": "Response",
                  "examples": [
                    "Response"
                  ]
                }
              }
            }
          ]
        },
        "DiagnosisResponse": {
          "description": "Body of the diagnosis response.",
          "type": "object",
          "required": [
            "Response"
          ],
          "examples": [
            {
              "Response": {
                "Result": "Success"
              }
            },
            {
              "Response": {
                "Result": "Failure"
              }
            }
          ],
          "properties": {
            "Response": {
              "description": "Outcome of the diagnosis.",
              "type": "object",
              "required": [
                "Result"
              ],
              "examples": [
                {
                  "Result": "Success"
                }
              ],
              "properties": {
                "Result": {
                  "description": "Overall verdict: Success when every check passed, Failure when the diagnosis could not be done or found a fault, Partial when only some checks passed.",
                  "type": "string",
                  "enum": [
                    "Success",
                    "Failure",
                    "Partial"
                  ],
                  "examples": [
                    "Success",
                    "Failure",
                    "Partial"
                  ]
                }
              }
            }
          }
        }
      }
    }
  }
}
