package kr.co.vividnext.sodalive.mypage.can

import kr.co.vividnext.sodalive.mypage.can.charge.iap.GoogleChargeRequest
import kr.co.vividnext.sodalive.mypage.can.charge.pg.ChargeRequest
import kr.co.vividnext.sodalive.mypage.can.charge.pg.VerifyRequest
import kr.co.vividnext.sodalive.mypage.can.coupon.UseCanCouponRequest
import java.util.TimeZone

class CanRepository(private val api: CanApi) {
    fun googleChargeCan(
        request: GoogleChargeRequest,
        token: String
    ) = api.googleChargeCan(request, authHeader = token)

    fun chargeCan(
        chargeRequest: ChargeRequest,
        token: String
    ) = api.chargeCan(chargeRequest, authHeader = token)

    fun verify(
        request: VerifyRequest,
        token: String
    ) = api.verifyCharge(request, authHeader = token)

    fun verifyHecto(
        request: VerifyRequest,
        token: String
    ) = api.verifyChargeHecto(request, authHeader = token)

    fun getCans(token: String) = api.getCans(authHeader = token)

    fun getCanStatus(token: String) = api.getCanStatus(authHeader = token)

    fun getCanUseStatus(
        page: Int,
        pageSize: Int,
        token: String
    ) = api.getCanUseStatus(
        timezone = TimeZone.getDefault().id,
        page = page - 1,
        size = pageSize,
        authHeader = token
    )

    fun getCanChargeStatus(
        page: Int,
        pageSize: Int,
        token: String
    ) = api.getCanChargeStatus(
        timezone = TimeZone.getDefault().id,
        page = page - 1,
        size = pageSize,
        authHeader = token
    )

    fun useCanCoupon(couponNumber: String, token: String) = api.useCanCoupon(
        request = UseCanCouponRequest(couponNumber),
        authHeader = token
    )
}
