stbz

package module
v0.0.0-...-9642d78 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 15, 2023 License: MIT Imports: 16 Imported by: 0

README

京世胜天 SDK GoLang

使用说明

准备工作
  1. go mod 文件增加如下配置
require github.com/dadahuzi/jsst-golang-sdk v1.0.0

go get github.com/dadahuzi/jsst-golang-sdk
  1. 在需要使用sdk的地方import
import jsst "github.com/dadahuzi/jsst-golang-sdk"
  1. 配置密钥
config := jsst.NewConfig("AccessKey", "SecretKey")
SetConfig(config)
  1. 调用API
result, err := jsst.API(Method, api, queryMap, bodyMap)
使用示例
GET请求,query传参(form-data格式)
config := jsst.NewConfig("1AD0700D6D7D92E52ED00EDF2937BD90", "6081AE2E69B1E01DF75DA7FB77FB685E")
jsst.SetConfig(config)
result, err := jsst.API(Method.GET, "/v2/Goods/Lists", map[string]string{"page": "1", "limit": "10", "source": "0", "search_words": "牙线"}, map[string]interface{}{})

fmt.Println(result, err)

GET请求,body传参(json格式)
config := jsst.NewConfig("1AD0700D6D7D92E52ED00EDF2937BD90", "6081AE2E69B1E01DF75DA7FB77FB685E")
jsst.SetConfig(config)
result, err = jsst.API(Method.GET, "/v2/order", map[string]string{}, g.Map{"page": 1, "limit": 10, "search": g.Map{"goodsName": "蒙牛"}})
fmt.Println(result, err)

POST请求,body传参(json格式)
config := jsst.NewConfig("1AD0700D6D7D92E52ED00EDF2937BD90", "6081AE2E69B1E01DF75DA7FB77FB685E")
jsst.SetConfig(config)
result, err = jsst.API(
    Method.GET,
    "/v2/order/availableCheck",
    map[string]string{},
    g.Map{
        "spu": g.Array{
            g.Map{"sku": 43870, "number": 1},
            g.Map{"sku": 429618, "number": 1},
        },
        "address": g.Map{
            "consignee":   "赵宏源",
            "phone":       "18914999333",
            "province":    "北京市",
            "city":        "北京市",
            "area":        "丰台区",
            "street":      "卢沟桥街道",
            "description": "马官营家园1号楼1单元",
        },
    },
)
fmt.Println(result, err)

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Method = new(UtilMethod)

Method Method

Functions

func SetConfig

func SetConfig(config *Config)

SetConfig SetConfig

func Sign

func Sign(params signV2, queryMaps map[string]string, bodyMaps map[string]interface{}, secretKey string) string

Sign 签名

Types

type APIResult

type APIResult struct {
	ID   string      `json:"id"`
	Code int         `json:"code"`
	Msg  string      `json:"msg"`
	Data interface{} `json:"data"`
}

APIResult APIResult

func API

func API(method method, api string, queryMap map[string]string, bodyMap map[string]interface{}) (result *APIResult, err error)

API API

type Config

type Config struct {
	AccessKey string
	SecretKey string
	Host      string
}

Config Config

func NewConfig

func NewConfig(accessKey string, secretKey string) *Config

NewConfig NewConfig

type UtilMethod

type UtilMethod struct {
	GET  method
	POST method
}

UtilMethod UtilMethod

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL