package jdunionapi

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("b6481f92b47918cd6e42e7ea4fae6084", "84d390777ddf691ff092e744ba26bfdd")
	api.SetCookieWithStr(`
		__jdu=16193999982702078345144; shshshfp=dee09226776379a93b45b81da4715c98; shshshfpa=972f47df-9252-dc1a-1d6d-40594ce0501b-1619400562; shshshfpb=msX4%2B2n384blCOGusOxGDvQ%3D%3D; __jdv=56585130|baidu|-|organic|not set|1619430075643; language=zh_CN; _base_=YKH2KDFHMOZBLCUV7NSRBWQUJPBI7JIMU5R3EFJ5UDHJ5LCU7R2NILKK5UJ6GLA2RGYT464UKXAI4Z6HPCTN4UQM3WHVQ4ENFP57OC2NCIWTST4KDNCWZES6EV2TD5XDTCNE6YVKRXISVWNQHZDBO6QEKYXMXGPYGVEOCQCSG4SOQWCP5WPWO6EFS7HEHMRWVKBRVHB33TFD4AUHV3TOJD7MGBX53BNNP2E6MSSOORYGL5H2GYFRURR5ACFJ54GH7PTHFL22YL3C6ODFYFTWGV5UAWCX5C6J372TDCL6LDNEERERTGC3KTG7LVQKL6T7DHP7K6V7RIDKHVQAQIWW3S2YBFMIMTF6SWAFAQ52UF5TATP7KZIQ; 3AB9D23F7A4B3C9B=CKENC5MAUU744ZQDKVRY2L7UIJ23PJRDYJ6HF3ZMQHC5FFD46FMUQXRINFCOC4SKHL5MU3PPNPP4C4AX5ZYBXJ7LZ4; TrackID=1-4fAVea4KplSma_hIJGsw5phupUEFkQdSsJg9ZFa-npEreLy9OChx9os40_wvxLSWCobRme6E77RFqq1TCAH58Y_FyHMCvepCTD76DkrWoU; pinId=j0UlOyGus3AVS-ADVdcgUg; pin=jingxicaishi; unick=jingxicaishi; ceshi3.com=000; _tp=kapINs%2BaezZAzjGD9fk%2FCQ%3D%3D; _pst=jingxicaishi; __jda=209449046.16193999982702078345144.1619399998.1620289515.1620375213.10; __jdc=209449046; __jdb=209449046.40.16193999982702078345144|10.1620375213; RT="z=1&dm=jd.com&si=a7jrd7a068o&ss=koe1kc1r&sl=11&tt=6ei&ld=7fz9&nu=9181cc8dff125f3f43c49c7b30f258ce&cl=7f1f"; thor=3E6120B5171447C2B8036184D5BAA67EC585CCFCAC8414C7AD68EC9ABD97AFAA229AAE4F2DAC096B6CE4C2630A264BEA68EAFB7EB88642B7733632ADCD9A4D80D73FC2A5E83E4DD05173EEA64EA5E3C34F10C695334CED27944FAB2E31EED2D9093DB30601C620F363A3F467018B4FDCB82B5DD76A21EBD7FD1F5C38582A58B3E11CD422682E1347EA3A24C32CB1902C
	`)
}

func TestListActivitys(t *testing.T) {
	result, err := api.ListActivitys()
	if err != nil {
		t.Fatal(err)
	}
	t.Log(utils.Format4Output(result, false))
}

func TestUnionPromotion(t *testing.T) {
	err := api.UnionPromotion("18160030913903")
	if err != nil {
		t.Fatal(err)
	}
	//t.Log(utils.Format4Output(result, false))
}
