ApiConfig.kt 1.06 KB
Newer Older
1 2
package com.miya.fastcashier.net

3
import android.text.TextUtils
4
import com.miya.fastcashier.BuildConfig
5
import com.miya.fastcashier.beans.SelfCashierTerminalConfig
6 7 8

object ApiConfig {
    private const val BASE_URL = "https://hhms.miyapay.com/"
9
    private const val BASE_URL_4_TEST = "https://hhmspre.miyapay.com/"
10 11 12 13 14 15

    @JvmStatic
    val baseUrl: String
        get() = if (BuildConfig.ISTEST) {
            BASE_URL_4_TEST
        } else BASE_URL
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33

    fun getAuthorization(token: String): String {
        return "bearer $token"
    }

    fun getDataSourceIp(
        selfCashierTerminalConfig: SelfCashierTerminalConfig,
        equType: String
    ): String? {

        if (selfCashierTerminalConfig?.scoRuntimeConfig == null) {
            throw RuntimeException("DataSourceIpUtils SelfCashierTerminalConfig is null")
        }

        val path = "${ApiService.UPLOAD_LOG_FILE}?equType=$equType"
        return if (TextUtils.isEmpty(selfCashierTerminalConfig.scoRuntimeConfig.erpIp)) (baseUrl + path)
        else selfCashierTerminalConfig.scoRuntimeConfig.erpIp + path
    }
34
}