package com.example.tis_app.viewmodel

import android.content.Intent
import androidx.activity.result.ActivityResult
import androidx.lifecycle.ViewModel
import com.example.core.domain.AppConfig
import com.example.core.domain.PaymentResult
import com.example.core.domain.Printer
import com.example.core.domain.PspService
import com.example.core.model.PaymentResultEntity
import com.example.core.model.PrintEntity
import com.example.tis_app.R
import dagger.hilt.android.lifecycle.HiltViewModel
import javax.inject.Inject

@HiltViewModel
class WebViewModel @Inject constructor(
    private val pspService: PspService,
    private val paymentResult: PaymentResult,
    private val printer: Printer,
    private val appConfig: AppConfig
) : ViewModel() {


    fun postPaymentResult(paymentResultEntity: PaymentResultEntity?): String {
        return paymentResult.post(paymentResultEntity)
    }

    fun pay(amount: Long): Intent = pspService.pay(amount)

    fun paymentResult(
        id: String?,
        activityResult: ActivityResult
    ): PaymentResultEntity? {
        return pspService.decodePosResponse(
            id = id,
            activityResult = activityResult
        )
    }
    fun print(printEntities : List<PrintEntity>) {
        printer.print(
            printEntities = printEntities,
            icon = R.drawable.tis_icon
        )
    }

    fun sendAndroidId(id : String) {
        appConfig.androidId(id)
    }
}
