7 Star 19 Fork 4

白菜林 / tbsdk

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
param.go 1.12 KB
一键复制 编辑 原始数据 按行查看 历史
白菜林 提交于 2017-09-23 11:32 . taobao to tbsdk
package tbsdk
import (
"encoding/json"
)
////////////////////////////////////////////////////////////////////////////////
type ITaoBaoParam interface{
// 用于提供访问的 method
APIName() string
// 返回参数列表
Params() map[string]string
// 返回扩展 JSON 参数的字段名称
ExtJSONParamName() string
// 返回扩展 JSON 参数的字段值
ExtJSONParamValue() string
}
////////////////////////////////////////////////////////////////////////////////
// 示例,别无它用
type TaoBaoParam map[string]interface{}
func (this TaoBaoParam) APIName() string {
return "taobao.open.sms.sendmsg"
}
func (this TaoBaoParam) Params() map[string]string {
return nil
}
func (this TaoBaoParam) ExtJSONParamName() string {
return "send_message_request"
}
func (this TaoBaoParam) ExtJSONParamValue() string {
var bytes, err = json.Marshal(this)
if err != nil {
return ""
}
return string(bytes)
}
func (this TaoBaoParam) AddParam(key string, value interface{}) {
this[key] = value
}
func marshal(obj interface{}) string {
var bytes, err = json.Marshal(obj)
if err != nil {
return ""
}
return string(bytes)
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/lyhuilin/tbsdk.git
git@gitee.com:lyhuilin/tbsdk.git
lyhuilin
tbsdk
tbsdk
master

搜索帮助

344bd9b3 5694891 D2dac590 5694891