package macao_logistics

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

var Url = "https://jyb-admin-backend.aoyunltd.com/api/v1"

func GetSign(appSecret string, param map[string]string) string {
	str := ""
	keys := comm.KsortToStr(param)

	for _, k := range keys {
		str += strings.ReplaceAll(param[k], "\\n", "")
	}
	return ""
}
func Send(method string, params map[string]interface{}, acctoken string) (string, error) {
	url := Url + method
	header := make(map[string]string, 0)
	if acctoken != "" {
		header["Authorization"] = "Bearer " + acctoken
	}
	data, err := zhios_third_party_utils.CurlPost(url, params, header)
	fmt.Println(string(data))
	fmt.Println(err)
	return string(data), err
}
func SendGet(method string, params map[string]interface{}, acctoken string) (string, error) {
	url := Url + method
	header := make(map[string]string, 0)
	if acctoken != "" {
		header["Authorization"] = "Bearer " + acctoken
	}
	for k, v := range params {
		if strings.Contains(url, "?") == false {
			url += "?" + k + "=" + zhios_third_party_utils.AnyToString(v)
		} else {
			url += "&" + k + "=" + zhios_third_party_utils.AnyToString(v)
		}
	}
	data, err := zhios_third_party_utils.CurlGet(url, header)
	fmt.Println(string(data))
	fmt.Println(err)
	return string(data), err
}