package tibiotapi

import (
	"git.rosy.net.cn/baseapi"
	"git.rosy.net.cn/baseapi/utils"
	"go.uber.org/zap"
	"testing"
)

var (
	api         *API
	sugarLogger *zap.SugaredLogger
)

func init() {
	logger, _ := zap.NewDevelopment()
	sugarLogger = logger.Sugar()
	baseapi.Init(sugarLogger)

	api = New("ruoxikeji", "Ruoxi@369")
}

func TestGetCardInfo(t *testing.T) {
	result, err := api.GetCardInfo("89860426102180138547")
	if err != nil {
		t.Fatalf("PrintMsg return error:%v", err)
	}
	t.Log(utils.Format4Output(result, false))
}

func TestBatchQueryCardInfo(t *testing.T) {
	result, err := api.BatchQueryCardInfo(nil)
	if err != nil {
		t.Fatalf("PrintMsg return error:%v", err)
	}
	t.Log(utils.Format4Output(result, false))
}

func TestIotData(t *testing.T) {
	result, err := api.IotData("89860490102070456598", "2021-07-19")
	if err != nil {
		t.Fatalf("PrintMsg return error:%v", err)
	}
	t.Log(utils.Format4Output(result, false))
}

func TestIotData2(t *testing.T) {
	result, err := api.IotDataMonth("89860490102070456598")
	if err != nil {
		t.Fatalf("PrintMsg return error:%v", err)
	}
	t.Log(utils.Format4Output(result, false))
}

func TestCardActivation(t *testing.T) {
	result, err := api.CardActivation("1")
	if err != nil {
		t.Fatalf("PrintMsg return error:%v", err)
	}
	t.Log(utils.Format4Output(result, false))
}

func TestSubmit(t *testing.T) {
	result, err := api.Submit("1", 0)
	if err != nil {
		t.Fatalf("PrintMsg return error:%v", err)
	}
	t.Log(utils.Format4Output(result, false))
}
