package com.example.samplejavaapp.wrappers.message

import pl.novelpay.client.sdk.interceptor.ClientInterceptor
import pl.novelpay.retailer.message.request.RetailerRequest
import pl.novelpay.transport.shared.message.DomainMessage

open class JMessageHandler : ClientInterceptor {
    override fun intercept(message: DomainMessage): Result<DomainMessage> =
        when (message) {
            is RetailerRequest -> Result.success(message)
            else -> onMessage(message)?.let {
                Result.success(it)
            } ?: Result.failure(NullPointerException())
        }


    open fun onMessage(message: DomainMessage): DomainMessage? = null
}