<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema
    xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    targetNamespace="http://www.vibbek.com/device"
    xmlns="http://www.vibbek.com/device"
    elementFormDefault="unqualified"
    attributeFormDefault="unqualified">

    <xsd:include schemaLocation="base_types.xsd" />

    <!-- Request to interact with an attendant  -->
    <xsd:element name="confirmationRequest" type="ConfirmationRequest" />
    <xsd:element name="confirmationResponse" type="ConfirmationResponse" />

    <!-- Request to display information for an attendant (a response is not expected) -->
    <xsd:element name="displayNotification" type="DisplayNotification" />

    <!-- Request to generate a printout (a response is not expected) -->
    <xsd:element name="printerNotification" type="PrinterNotification" />

    <!-- Request to abort a transaction process from the PoS system (initiated by attendant). There is no response to this message. -->
    <xsd:element name="abortCardEntryNotification" type="AbortCardEntryNotification" />

    <!-- Sent to PoS system when the card has been inserted -->
    <xsd:element name="cardEntryNotification" type="CardEntryNotification" />

    <!-- Sent to PoS system when the QR code has been scanned (e.g. a Twint payment was initiated) -->
    <xsd:element name="qrCodeScanNotification" type="QrCodeScanNotification" />

    <!-- Sent to PoS system when the card has been removed -->
    <xsd:element name="cardRemovalNotification" type="CardRemovalNotification" />

    <!-- Sent to PoS system when the transaction has been started -->
    <xsd:element name="trxStartNotification" type="TrxStartNotification" />

    <!-- Sent to PoS system when the transaction has been completed -->
    <xsd:element name="trxEndNotification" type="TrxEndNotification" />

    <!-- Sent to PoS system when the transaction has been aborted without correct completion -->
    <xsd:element name="trxAbortNotification" type="TrxAbortNotification" />

    <xsd:simpleType name="DisplayType">
        <xsd:restriction base="xsd:token">
            <xsd:enumeration value="CARDHOLDER" />
            <xsd:enumeration value="ATTENDANT" />
        </xsd:restriction>
    </xsd:simpleType>

    <xsd:complexType name="Display">
        <xsd:sequence minOccurs="0" maxOccurs="unbounded">
            <xsd:element name="line" type="xsd:string" />
        </xsd:sequence>
    </xsd:complexType>

    <xsd:complexType name="MerchantReceipt">
        <xsd:simpleContent>
            <xsd:extension base="xsd:string">
                <xsd:attribute name="admin" type="xsd:boolean" use="required" />
            </xsd:extension>
        </xsd:simpleContent>
    </xsd:complexType>

    <xsd:complexType name="ConfirmationRequest">
        <xsd:all>
            <xsd:element name="display" type="Display" minOccurs="1" maxOccurs="1" />
            <xsd:element name="timeout" type="xsd:integer" minOccurs="1" maxOccurs="1" />
            <xsd:element name="timeoutReminder" type="xsd:integer" minOccurs="0" maxOccurs="1" />
        </xsd:all>
        <xsd:attribute name="displayType" type="DisplayType" use="required" />
    </xsd:complexType>

    <xsd:complexType name="ConfirmationResponse">
        <xsd:all>
            <xsd:element name="result" type="xsd:unsignedByte" minOccurs="1" maxOccurs="1" />
        </xsd:all>
    </xsd:complexType>

    <xsd:complexType name="CardEntryNotification">
        <xsd:all>
            <xsd:element name="cardEntryMode" type="xsd:unsignedInt" minOccurs="0" maxOccurs="1" />
        </xsd:all>
    </xsd:complexType>

    <xsd:complexType name="QrCodeScanNotification">
    </xsd:complexType>

    <xsd:complexType name="CardRemovalNotification">
    </xsd:complexType>

    <xsd:complexType name="TrxStartNotification">
    </xsd:complexType>

    <xsd:complexType name="TrxEndNotification">
    </xsd:complexType>

    <xsd:complexType name="TrxAbortNotification">
    </xsd:complexType>

    <xsd:complexType name="DisplayNotification">
        <xsd:all>
            <xsd:element name="display" type="Display" minOccurs="1" maxOccurs="1" />
        </xsd:all>
        <xsd:attribute name="displayType" type="DisplayType" use="required" />
    </xsd:complexType>

    <xsd:complexType name="PrinterNotification">
        <xsd:all>
            <xsd:element name="merchantReceipt" type="MerchantReceipt" minOccurs="0" maxOccurs="1" />
            <xsd:element name="cardholderReceipt" type="xsd:string" minOccurs="0" maxOccurs="1" />
            <xsd:element name="admin" type="xsd:boolean" minOccurs="0" maxOccurs="1" />
        </xsd:all>
    </xsd:complexType>

    <xsd:complexType name="AbortCardEntryNotification">
        <xsd:all>
            <xsd:element name="silentAbort" type="xsd:boolean" minOccurs="0" maxOccurs="1" />
        </xsd:all>
    </xsd:complexType>

</xsd:schema>
