package kuaishou

import (
	zhios_third_party_utils "code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/utils"
	"fmt"
	"strings"
)

/*
app_id  开发者appKey

grant_type 授权的类型,"code"

code 2.2中获取到的code

app_secret 开发者的appSecret
*/
func GetKuaishouToken(args map[string]string) (string, error) {
	url := "https://openapi.kwaixiaodian.com/oauth2/access_token"
	for k, v := range args {
		if strings.Contains(url, "?") == false {
			url += "?" + k + "=" + v
		} else {
			url += "&" + k + "=" + v
		}
	}
	get, err := zhios_third_party_utils.CurlGet(url, nil)
	fmt.Println(url)
	fmt.Println(string(get))
	fmt.Println(err)
	return string(get), err
}

/*

 */
func GetKuaishouRefreshToken(args map[string]string) (string, error) {
	url := "https://openapi.kwaixiaodian.com/oauth2/refresh_token"
	get, err := zhios_third_party_utils.CurlPost(url, args, nil)
	fmt.Println(url)
	fmt.Println(string(get))
	fmt.Println(err)
	return string(get), err
}

//https://open.kwaixiaodian.com/zone/docs/api?name=open.distribution.investment.activity.open.list&version=1
func GetKuishouActivity(signSecret string, param map[string]string) (string, error) {

	return SendGet("open.distribution.investment.activity.open.list", signSecret, param)
}

//https://open.kwaixiaodian.com/zone/new/docs/api?name=open.distribution.investment.activity.item.detail&version=1
func GetKuishouGoodsDetail(signSecret string, param map[string]string) (string, error) {

	return SendGet("open.distribution.investment.activity.item.detail", signSecret, param)
}

//https://open.kwaixiaodian.com/zone/docs/api?name=open.distribution.investment.activity.open.list&version=1
func GetKuishouGoods(signSecret string, param map[string]string) (string, error) {

	return SendGet("open.distribution.investment.activity.open.item.list", signSecret, param)
}

////https://open.kwaixiaodian.com/zone/docs/api?name=open.distribution.second.apply.investment.activity.list&version=1
func GetKuishouMyActivity(signSecret string, param map[string]string) (string, error) {

	return SendGet("open.distribution.second.apply.investment.activity.list", signSecret, param)
}

//
////https://open.kwaixiaodian.com/zone/docs/api?name=open.distribution.second.apply.investment.activity.item.list&version=1
func GetKuishouMyGoods(signSecret string, param map[string]string) (string, error) {
	return SendGet("open.distribution.second.apply.investment.activity.item.list", signSecret, param)
}

//https://open.kwaixiaodian.com/zone/docs/api?name=open.distribution.cps.leader.order.cursor.list&version=1
func GetKuishouOrder(signSecret string, param map[string]string) (string, error) {
	return SendGet("open.distribution.cps.leader.order.cursor.list", signSecret, param)
}

//https://open.kwaixiaodian.com/zone/docs/api?name=open.distribution.cps.leader.order.detail&version=1

//https://open.kwaixiaodian.com/zone/docs/api?name=open.distribution.selection.pick&version=1  橱窗
func GetKuishouSelectionPick(signSecret string, param map[string]string) (string, error) {
	return SendPost("open.distribution.selection.pick", signSecret, param)
}

//https://open.kwaixiaodian.com/zone/docs/api?name=open.user.info.get&version=1 用户信息
func GetKuishouUser(signSecret string, param map[string]string) (string, error) {
	return SendGet("open.user.info.get", signSecret, param)
}
func GetKuishouOrderDetail(signSecret string, param map[string]string) (string, error) {
	return SendGet("open.distribution.cps.leader.order.detail", signSecret, param)
}

//https://open.kwaixiaodian.com/zone/docs/api?name=open.distribution.cps.kwaimoney.selection.item.list&version=1
func GetKuishouCpsGoods(signSecret string, param map[string]string) (string, error) {
	return SendGet("open.distribution.cps.kwaimoney.selection.item.list", signSecret, param)
}

func GetKuishouCpsGoodsDetail(signSecret string, param map[string]string) (string, error) {
	return SendGet("open.distribution.cps.kwaimoney.selection.item.detail", signSecret, param)
}
func GetKuishouCpsKlGoods(signSecret string, param map[string]string) (string, error) {
	return SendPost("open.distribution.cps.kwaimoney.link.parse", signSecret, param)
}
func GetKuishouCpsUrl(signSecret string, param map[string]string) (string, error) {
	return SendPost("open.distribution.cps.kwaimoney.link.create", signSecret, param)
}
func GetKuishouCpsPid(signSecret string, param map[string]string) (string, error) {
	return SendPost("open.distribution.cps.kwaimoney.pid.create", signSecret, param)
}
func GetKuishouCpsOrder(signSecret string, param map[string]string) (string, error) {
	return SendPost("open.distribution.cps.kwaimoney.order.list", signSecret, param)
}
func GetKuishouCpsChannel(signSecret string, param map[string]string) (string, error) {
	return SendGet("open.distribution.cps.kwaimoney.selection.channel.list", signSecret, param)
}