{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://docs.fispay.eu/schemas/diagnosis-request.json",
  "title": "Diagnosis request",
  "description": "Sent by the sale system to ask the terminal for a health check of itself and, on request, of its connection to the payment host. Placeholder until the real message catalog lands.",
  "x-placeholder": true,
  "type": "object",
  "required": [
    "SaleToPOIRequest"
  ],
  "examples": [
    {
      "SaleToPOIRequest": {
        "MessageHeader": {
          "ProtocolVersion": "3.1",
          "MessageClass": "Service",
          "MessageCategory": "Diagnosis",
          "MessageType": "Request",
          "ServiceID": "2041",
          "SaleID": "ECR-01",
          "POIID": "FISPAY-T-0001"
        },
        "DiagnosisRequest": {
          "HostDiagnosisFlag": true
        }
      }
    }
  ],
  "properties": {
    "SaleToPOIRequest": {
      "description": "Wrapper for every message the sale system sends to the terminal.",
      "type": "object",
      "required": [
        "MessageHeader",
        "DiagnosisRequest"
      ],
      "examples": [
        {
          "MessageHeader": {
            "ProtocolVersion": "3.1",
            "MessageClass": "Service",
            "MessageCategory": "Diagnosis",
            "MessageType": "Request",
            "ServiceID": "2041",
            "SaleID": "ECR-01",
            "POIID": "FISPAY-T-0001"
          },
          "DiagnosisRequest": {
            "HostDiagnosisFlag": true
          }
        }
      ],
      "properties": {
        "MessageHeader": {
          "description": "Common envelope, narrowed to a diagnosis request.",
          "examples": [
            {
              "ProtocolVersion": "3.1",
              "MessageClass": "Service",
              "MessageCategory": "Diagnosis",
              "MessageType": "Request",
              "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 Request for this message.",
                  "const": "Request",
                  "examples": [
                    "Request"
                  ]
                }
              }
            }
          ]
        },
        "DiagnosisRequest": {
          "description": "Body of the diagnosis request.",
          "type": "object",
          "examples": [
            {},
            {
              "HostDiagnosisFlag": true
            }
          ],
          "properties": {
            "HostDiagnosisFlag": {
              "description": "When true, the terminal also checks that it can reach the payment host. When absent or false, only the terminal itself is checked.",
              "type": "boolean",
              "examples": [
                true,
                false
              ]
            }
          }
        }
      }
    }
  }
}
