package dingdingapi

import (
	"testing"

	"git.rosy.net.cn/baseapi"

	"go.uber.org/zap"
)

var (
	api         *API
	sugarLogger *zap.SugaredLogger
)

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

	api = NewWithAgentID(241047291, "ding7ab5687f3784a8db", "dingpx4hcf55zb4ubewg", "1zooB4bmEXPesdwb1ElWASVQ1vinOSZM-1XCUFrrSjHsNAId1UuVCT5tmHSmg5_V")
	api.RetrieveToken()
}

func TestRetrieveToken(t *testing.T) {
	result, err := api.RetrieveToken()
	if err != nil {
		t.Fatal(err.Error())
	}
	sugarLogger.Debug(result)
}

func TestGetJSAPITicket(t *testing.T) {
	expiresIn, ticket, err := api.GetJSAPITicket("")
	if err != nil {
		t.Fatal(err.Error())
	}
	sugarLogger.Debug(expiresIn, ticket)
}
