package tiktok_api

import (
	"git.rosy.net.cn/jx-callback/globals"
	"strings"
	"testing"
)

func TestN2ame(t *testing.T) {
	a.GetProductUpdateRule(32241)
}

func TestGetRecommendCategory(t *testing.T) {
	a.GetRecommendCategory([]string{"https://p3-aio.ecombdimg.com/obj/ecom-shop-material/jpeg_m_b145e9c8e91e58960e75efe189af74f5_sx_347106_www800-800", "https://p3-aio.ecombdimg.com/obj/ecom-shop-material/jpeg_m_1e15828b61eb2bc83588bd0d88bee288_sx_458861_www800-800"})
	//data, err := a.GetRecommendCategoryByName(name)
	//fmt.Println(data)
	//fmt.Println(err)
}

// GetTiktokImgList 获取抖音图片链接
func GetTiktokImgListTest(api *API, storeId, appOrgCode string, detailImg string, img ...string) (string, string, error) {
	imgs := make([]Imgs, 0, 0)
	for _, v := range img {
		if v != "" {
			imgs = append(imgs, Imgs{
				Name: storeId + "_" + v[21:54],
				Url:  v,
			})
		}
	}
	if detailImg != "" {
		imgs = append(imgs, Imgs{
			Name: "detail_" + storeId + "_" + detailImg[21:54],
			Url:  detailImg,
		})
	}
	tiktokImgList, err := api.BatchUploadImages(imgs)
	if err != nil {
		return "", "", err
	}

	detailTiktok := ""
	var tiktokImg []string
	for k, v := range tiktokImgList {
		if strings.Contains(k, "detail_") {
			detailTiktok = v.ByteUrl
			continue
		}
		tiktokImg = append(tiktokImg, v.ByteUrl)
	}
	if detailTiktok == "" {
		detailTiktok = tiktokImg[0]
	}

	return strings.Join(tiktokImg, "|"), detailTiktok, nil
}

func TestGetSkuBrand(t *testing.T) {
	data, err := a.GetSkuBrand(23156, "娃哈哈")
	globals.SugarLogger.Debugf("data ========= %v", data)
	globals.SugarLogger.Debugf("data ========= %s", err)
}

func TestQualityList(t *testing.T) {
	a.QualityList(33079)
}
