package ebaiapi

import (
	"fmt"
	"testing"
)

func TestGetMediaUrl(t *testing.T) {
	data, err := api.GetMediaUrl("1157916361", "$igHNA-kCpGpwZWcDAQTNBDgFzQlUBtoAI4QBpCErI2gCqszMIMLSLDBJb6QDzwAAAYuJvuhDBM4B-Y3tB88AAAACXUH2dAgACgQLzgAC08U")
	fmt.Println(err)
	fmt.Println(data)
}

func TestGetStoreImStatus(t *testing.T) {
	data, err := api.GetStoreIMStatus("1157916361")
	if err != nil {
		t.Errorf("%v", err)
	}
	t.Log(data)
}

func TestAPI_UpdateIMStatus(t *testing.T) {
	err := api.UpdateIMStatus("1157916361", ImStatusOpen)
	fmt.Printf("err=%v", err)
}

func TestSendMsg(t *testing.T) {
	err := api.BusinessSendMsg(&BusinessSendMsgReq{
		PlatformShopId: "1157916361",
		BizType:        IMType,
		SubBizType:     IMTypeSendMsg,
		PayLoad: BusinessMsgPayload{
			GroupId:     "$2$13205337818$PNM",
			ReceiverIds: []string{"301157916361", "10154538612", "321921188187760"},
			Content:     "{\"text\": \"现在是20231027 10:04:44\"}",
			ContentType: "1",
		},
	})
	fmt.Println(err)
}

func TestInvoice(t *testing.T) {
	_, err := api.QueryInvoiceSetting([]string{"1310370176"})
	fmt.Println(err)
}

func TestQueryUnansweredInvoice(t *testing.T) {
	api.QueryUnansweredInvoice("32267184083")
}

func TestBathUpdateInvoiceSetting(t *testing.T) {
	api.BathUpdateInvoiceSetting("32267545379", &StoreInvoiceSetting{
		InvoiceMaterial: "ELECTRONIC",
		InvoiceClass:    "VAT_COMMON",
		InvoiceContact: struct {
			Person string `json:"person"`
			Phone  string `json:"phone"`
		}{Person: "老板", Phone: "13551100183"},
		InvoiceMode: "SYS_MANUAL",
	})
}
