package com.doverfuelingsolutions.issp.api

import com.doverfuelingsolutions.issp.utils.sp.SPKeys
import com.doverfuelingsolutions.issp.utils.sp.SPUtil

class WayneApiConfig {

    companion object {

        const val PATH_BASE_TOKEN = "token"
        const val PATH_BASE_DEVICE_SESSION = "api/DeviceManagement/GetCurrentSessionInfo"
        const val PATH_TRX_TRANS = "api/Transactions"
        const val PATH_TRX_PAY_PARAM = "api/mops/thirdParty"
        const val PATH_CONFIG_DESC = "api/Config/description"
        const val PATH_CONFIG_FILE = "api/Config/file"
        const val PATH_BARCODE = "api/products/barcode/{id}"
        const val PATH_PAY_BY_ID = "api/Transactions/{id}/payment"

        const val CONFIG_LOGO = "SiteLogo"

        // 默认值 - 云端
        const val DOMAIN_DEFAULT = "http://ipos.biz"
        const val PORT_BASE_DEFAULT = "8698"
        const val PORT_TRX_DEFAULT = "8699"
        const val PORT_CONFIG_DEFAULT = "8889"
        private const val HOST_BASE_DEFAULT = "$DOMAIN_DEFAULT:$PORT_BASE_DEFAULT"
        private const val HOST_TRX_DEFAULT = "$DOMAIN_DEFAULT:$PORT_TRX_DEFAULT"
        private const val HOST_CONFIG_DEFAULT = "$DOMAIN_DEFAULT:$PORT_CONFIG_DEFAULT"
        // 默认值 - 中控
        const val MIDDLE_IP_DEFAULT = "192.168.1.80"
        const val MIDDLE_PORT_DEFAULT = "4711"
        const val MIDDLE_WORKSTATION_ID = "8888"
        // 默认值 - 加油信息
        const val FUEL_IP_DEFAULT = "192.168.1.80"
        const val FUEL_PORT_DEFAULT = "8384"

        // 实时值
        val HOST_BASE: String get() {
            val domain = SPUtil.getString(SPKeys.SERVER_DOMAIN)
            val port = SPUtil.getString(SPKeys.SERVER_PORT_BASE)
            return if (domain.isEmpty() && port.isEmpty()) HOST_BASE_DEFAULT else "$domain:$port"
        }
        val HOST_TRX: String get() {
            val domain = SPUtil.getString(SPKeys.SERVER_DOMAIN)
            val port = SPUtil.getString(SPKeys.SERVER_PORT_TRX)
            return if (domain.isEmpty() && port.isEmpty()) HOST_TRX_DEFAULT else "$domain:$port"
        }
        val HOST_CONFIG: String get() {
            val domain = SPUtil.getString(SPKeys.SERVER_DOMAIN)
            val port = SPUtil.getString(SPKeys.SERVER_PORT_CONFIG)
            return if (domain.isEmpty() && port.isEmpty()) HOST_CONFIG_DEFAULT else "$domain:$port"
        }
    }
}