package com.yidian.bcommon.sdk

import com.yidian.bcommon.app.YdBaseApplication
import com.yidian.bcommon.constant.AppConfig

/**
 * author: yinjiacheng
 * date: 7/27/21 2:01 PM
 * description: BCommon Manager
 */
object BCommonManager {

  const val TAG_HTTP = "merchant-b-http"

  /**
   * 加密接口实现
   */
  private lateinit var encryptIml: IEncryptService

  /**
   * C端 uid
   */
  // TODO: 7/27/21 Test
//  private var uid: String? = "510227073302"
  private var uid: String? = null

  /**
   * C端同步uid
   */
  fun syncUid(uid: String) {
    this.uid = uid
  }

  /**
   * 获取AppId
   */
  fun getAppId(): String {
    return when (JudgeClientUtils.judgeClient(YdBaseApplication.context.packageName)) {
      ClientType.MERCHANT_B -> AppConfig.appIdMerchantB
      ClientType.MERCHANT_C -> AppConfig.appIdMerchantC
    }
  }

  /**
   * 获取TowerPro通用配置模块KeyTag
   */
  fun getTowerProKeyTag(): String {
    return when (JudgeClientUtils.judgeClient(YdBaseApplication.context.packageName)) {
      ClientType.MERCHANT_B -> AppConfig.TowerApiKeyTagMerchantB
      ClientType.MERCHANT_C -> AppConfig.TowerApiKeyTagMerchantC
    }
  }

  /**
   * 获取C端uid
   */
  fun getUid(): String? {
    return uid
  }

  /**
   * 获取加密接口实现
   */
  fun getEncryptIml(): IEncryptService {
    return encryptIml
  }

  /**
   * 添加加密接口实现
   */
  fun setEncryptIml(service: IEncryptService) {
    encryptIml = service
  }
}
