All Downloads are FREE. Search and download functionalities are using the official Maven repository.

co.saltpay.epos.models.response.PrintReceiptResponse.kt Maven / Gradle / Ivy

There is a newer version: 1.3.2
Show newest version
package co.saltpay.epos.models.response

import co.saltpay.epos.models.response.PrintReceiptResponse.Failure.Reason
import kotlinx.serialization.ExperimentalSerializationApi
import kotlinx.serialization.Serializable
import kotlinx.serialization.json.JsonNames

/**
 * Subtype of [ResponseModel] which contains possible responses
 * for the [co.saltpay.epos.models.request.PrintReceipt] request.
 */
@Serializable
sealed interface PrintReceiptResponse : ResponseModel {

    /**
     * Subtype of [PrintReceiptResponse] sent when the print receipt
     * request is successfully completed by payment application.
     *
     * @property requestId see [ResponseModel.requestId]
     */
    @Serializable
    data class Success(
        override val requestId: String
    ) : PrintReceiptResponse

    /**
     * Subtype of [PrintReceiptResponse] sent when the print receipt
     * request fails to be completed by payment application.
     *
     * @property requestId see [ResponseModel.requestId]
     * @property reason reason for the failure [Reason]
     */
    @Serializable
    data class Failure(
        override val requestId: String,
        val reason: Reason
    ) : PrintReceiptResponse {

        @OptIn(ExperimentalSerializationApi::class)
        enum class Reason {

            /**
             * There was a connection error while fetching the payment details for
             * preparing the receipt information.
             */
            SERVER_CONNECTION_ERROR,

            /**
             * The terminal ran out of paper during this printing action.
             */
            OUT_OF_PAPER,

            /**
             * Printer is busy
             */
            @JsonNames("BUSY", "MALFUNCTION" /*V2 error - can be deleted when v2 is not used anymore*/)
            BUSY,

            /**
             * The printer overheated
             */
            OVERHEAT,

            /**
             * Printing cover is open
             */
            @JsonNames("COVER_OPEN", "VOLTAGE_TOO_LOW" /*V2 error - can be deleted when v2 is not used anymore*/)
            COVER_OPEN,

            /**
             * Some other unknown issue happened.
             */
            UNKNOWN
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy