package com.gh.gamecenter

import android.app.Application
import com.gism.sdk.GismConfig
import com.gism.sdk.GismEventBuilder
import com.gism.sdk.GismSDK

object SMHelper {
    private val mAppId by lazy { BuildConfig.SDK_APP_ID.ifEmpty { "105312" } }
    private val mAppName by lazy { BuildConfig.SDK_APP_NAME.ifEmpty { "guanghuanzhushou" } }

    @JvmStatic
    fun init(application: Application, channel: String) {
        GismSDK.init(
            GismConfig.newBuilder(application)
                .appID(mAppId)
                .appName(mAppName)
                .appChannel(channel)
                .build()
        )
    }

    @JvmStatic
    fun onEvent(type: String) {
        when (type) {
            "EVENT_ACTIVE" -> {
                GismSDK.onLaunchApp()
                GismSDK.onEvent(
                    GismEventBuilder
                        .onRegisterEvent()
                        .isRegisterSuccess(true)
                        .registerType("mobile")
                        .build()
                )
                GismSDK.onEvent(
                    GismEventBuilder
                        .onPayEvent()
                        .isPaySuccess(true)
                        .payAmount(1.0F)
                        .build()
                )
            }
            "active_register" -> GismSDK.onEvent(
                GismEventBuilder
                    .onRegisterEvent()
                    .isRegisterSuccess(true)
                    .registerType("mobile")
                    .build()
            )

            "EVENT_NEXTDAY_STAY" -> {
                GismSDK.onEvent(
                    GismEventBuilder
                        .onCustomEvent()
                        .action("next_day_stay")
                        .build()
                )
            }
        }
    }
}