feat:top sdk
This commit is contained in:
commit
a8a51379ef
|
@ -0,0 +1,8 @@
|
|||
# 默认忽略的文件
|
||||
/shelf/
|
||||
/workspace.xml
|
||||
# 基于编辑器的 HTTP 客户端请求
|
||||
/httpRequests/
|
||||
# Datasource local storage ignored files
|
||||
/dataSources/
|
||||
/dataSources.local.xml
|
|
@ -0,0 +1,8 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/.idea/topsdk.iml" filepath="$PROJECT_DIR$/.idea/topsdk.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
</project>
|
|
@ -0,0 +1,9 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="WEB_MODULE" version="4">
|
||||
<component name="Go" enabled="true" />
|
||||
<component name="NewModuleRootManager">
|
||||
<content url="file://$MODULE_DIR$" />
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
</component>
|
||||
</module>
|
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="" vcs="Git" />
|
||||
</component>
|
||||
</project>
|
|
@ -0,0 +1,198 @@
|
|||
package ability132
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"log"
|
||||
"topsdk"
|
||||
"topsdk/ability132/request"
|
||||
"topsdk/ability132/response"
|
||||
"topsdk/util"
|
||||
)
|
||||
|
||||
type Ability132 struct {
|
||||
Client *topsdk.TopClient
|
||||
}
|
||||
|
||||
func NewAbility132(client *topsdk.TopClient) *Ability132 {
|
||||
return &Ability132{client}
|
||||
}
|
||||
|
||||
/*
|
||||
批量发送消息
|
||||
*/
|
||||
func (ability *Ability132) TaobaoTmcMessagesProduce(req *request.TaobaoTmcMessagesProduceRequest) (*response.TaobaoTmcMessagesProduceResponse, error) {
|
||||
if ability.Client == nil {
|
||||
return nil, errors.New("Ability132 topClient is nil")
|
||||
}
|
||||
var jsonStr, err = ability.Client.Execute("taobao.tmc.messages.produce", req.ToMap(), req.ToFileMap())
|
||||
var respStruct = response.TaobaoTmcMessagesProduceResponse{}
|
||||
if err != nil {
|
||||
log.Println("taobaoTmcMessagesProduce error", err)
|
||||
return &respStruct, err
|
||||
}
|
||||
err = util.HandleJsonResponse(jsonStr, &respStruct)
|
||||
if respStruct.Body == "" || len(respStruct.Body) == 0 {
|
||||
respStruct.Body = jsonStr
|
||||
}
|
||||
return &respStruct, err
|
||||
}
|
||||
|
||||
/*
|
||||
获取自定义用户分组列表
|
||||
*/
|
||||
func (ability *Ability132) TaobaoTmcGroupsGet(req *request.TaobaoTmcGroupsGetRequest) (*response.TaobaoTmcGroupsGetResponse, error) {
|
||||
if ability.Client == nil {
|
||||
return nil, errors.New("Ability132 topClient is nil")
|
||||
}
|
||||
var jsonStr, err = ability.Client.Execute("taobao.tmc.groups.get", req.ToMap(), req.ToFileMap())
|
||||
var respStruct = response.TaobaoTmcGroupsGetResponse{}
|
||||
if err != nil {
|
||||
log.Println("taobaoTmcGroupsGet error", err)
|
||||
return &respStruct, err
|
||||
}
|
||||
err = util.HandleJsonResponse(jsonStr, &respStruct)
|
||||
if respStruct.Body == "" || len(respStruct.Body) == 0 {
|
||||
respStruct.Body = jsonStr
|
||||
}
|
||||
return &respStruct, err
|
||||
}
|
||||
|
||||
/*
|
||||
删除指定的分组或分组下的用户
|
||||
*/
|
||||
func (ability *Ability132) TaobaoTmcGroupDelete(req *request.TaobaoTmcGroupDeleteRequest) (*response.TaobaoTmcGroupDeleteResponse, error) {
|
||||
if ability.Client == nil {
|
||||
return nil, errors.New("Ability132 topClient is nil")
|
||||
}
|
||||
var jsonStr, err = ability.Client.Execute("taobao.tmc.group.delete", req.ToMap(), req.ToFileMap())
|
||||
var respStruct = response.TaobaoTmcGroupDeleteResponse{}
|
||||
if err != nil {
|
||||
log.Println("taobaoTmcGroupDelete error", err)
|
||||
return &respStruct, err
|
||||
}
|
||||
err = util.HandleJsonResponse(jsonStr, &respStruct)
|
||||
if respStruct.Body == "" || len(respStruct.Body) == 0 {
|
||||
respStruct.Body = jsonStr
|
||||
}
|
||||
return &respStruct, err
|
||||
}
|
||||
|
||||
/*
|
||||
为已开通用户添加用户分组
|
||||
*/
|
||||
func (ability *Ability132) TaobaoTmcGroupAdd(req *request.TaobaoTmcGroupAddRequest) (*response.TaobaoTmcGroupAddResponse, error) {
|
||||
if ability.Client == nil {
|
||||
return nil, errors.New("Ability132 topClient is nil")
|
||||
}
|
||||
var jsonStr, err = ability.Client.Execute("taobao.tmc.group.add", req.ToMap(), req.ToFileMap())
|
||||
var respStruct = response.TaobaoTmcGroupAddResponse{}
|
||||
if err != nil {
|
||||
log.Println("taobaoTmcGroupAdd error", err)
|
||||
return &respStruct, err
|
||||
}
|
||||
err = util.HandleJsonResponse(jsonStr, &respStruct)
|
||||
if respStruct.Body == "" || len(respStruct.Body) == 0 {
|
||||
respStruct.Body = jsonStr
|
||||
}
|
||||
return &respStruct, err
|
||||
}
|
||||
|
||||
/*
|
||||
删除消息topic分组路由
|
||||
*/
|
||||
func (ability *Ability132) TaobaoTmcTopicGroupDelete(req *request.TaobaoTmcTopicGroupDeleteRequest) (*response.TaobaoTmcTopicGroupDeleteResponse, error) {
|
||||
if ability.Client == nil {
|
||||
return nil, errors.New("Ability132 topClient is nil")
|
||||
}
|
||||
var jsonStr, err = ability.Client.Execute("taobao.tmc.topic.group.delete", req.ToMap(), req.ToFileMap())
|
||||
var respStruct = response.TaobaoTmcTopicGroupDeleteResponse{}
|
||||
if err != nil {
|
||||
log.Println("taobaoTmcTopicGroupDelete error", err)
|
||||
return &respStruct, err
|
||||
}
|
||||
err = util.HandleJsonResponse(jsonStr, &respStruct)
|
||||
if respStruct.Body == "" || len(respStruct.Body) == 0 {
|
||||
respStruct.Body = jsonStr
|
||||
}
|
||||
return &respStruct, err
|
||||
}
|
||||
|
||||
/*
|
||||
点对点消息topic分组路由
|
||||
*/
|
||||
func (ability *Ability132) TaobaoTmcTopicGroupAdd(req *request.TaobaoTmcTopicGroupAddRequest) (*response.TaobaoTmcTopicGroupAddResponse, error) {
|
||||
if ability.Client == nil {
|
||||
return nil, errors.New("Ability132 topClient is nil")
|
||||
}
|
||||
var jsonStr, err = ability.Client.Execute("taobao.tmc.topic.group.add", req.ToMap(), req.ToFileMap())
|
||||
var respStruct = response.TaobaoTmcTopicGroupAddResponse{}
|
||||
if err != nil {
|
||||
log.Println("taobaoTmcTopicGroupAdd error", err)
|
||||
return &respStruct, err
|
||||
}
|
||||
err = util.HandleJsonResponse(jsonStr, &respStruct)
|
||||
if respStruct.Body == "" || len(respStruct.Body) == 0 {
|
||||
respStruct.Body = jsonStr
|
||||
}
|
||||
return &respStruct, err
|
||||
}
|
||||
|
||||
/*
|
||||
确认消费消息的状态
|
||||
*/
|
||||
func (ability *Ability132) TaobaoTmcMessagesConfirm(req *request.TaobaoTmcMessagesConfirmRequest) (*response.TaobaoTmcMessagesConfirmResponse, error) {
|
||||
if ability.Client == nil {
|
||||
return nil, errors.New("Ability132 topClient is nil")
|
||||
}
|
||||
var jsonStr, err = ability.Client.Execute("taobao.tmc.messages.confirm", req.ToMap(), req.ToFileMap())
|
||||
var respStruct = response.TaobaoTmcMessagesConfirmResponse{}
|
||||
if err != nil {
|
||||
log.Println("taobaoTmcMessagesConfirm error", err)
|
||||
return &respStruct, err
|
||||
}
|
||||
err = util.HandleJsonResponse(jsonStr, &respStruct)
|
||||
if respStruct.Body == "" || len(respStruct.Body) == 0 {
|
||||
respStruct.Body = jsonStr
|
||||
}
|
||||
return &respStruct, err
|
||||
}
|
||||
|
||||
/*
|
||||
消费多条消息
|
||||
*/
|
||||
func (ability *Ability132) TaobaoTmcMessagesConsume(req *request.TaobaoTmcMessagesConsumeRequest) (*response.TaobaoTmcMessagesConsumeResponse, error) {
|
||||
if ability.Client == nil {
|
||||
return nil, errors.New("Ability132 topClient is nil")
|
||||
}
|
||||
var jsonStr, err = ability.Client.Execute("taobao.tmc.messages.consume", req.ToMap(), req.ToFileMap())
|
||||
var respStruct = response.TaobaoTmcMessagesConsumeResponse{}
|
||||
if err != nil {
|
||||
log.Println("taobaoTmcMessagesConsume error", err)
|
||||
return &respStruct, err
|
||||
}
|
||||
err = util.HandleJsonResponse(jsonStr, &respStruct)
|
||||
if respStruct.Body == "" || len(respStruct.Body) == 0 {
|
||||
respStruct.Body = jsonStr
|
||||
}
|
||||
return &respStruct, err
|
||||
}
|
||||
|
||||
/*
|
||||
TMC授权token
|
||||
*/
|
||||
func (ability *Ability132) TaobaoTmcAuthGet(req *request.TaobaoTmcAuthGetRequest) (*response.TaobaoTmcAuthGetResponse, error) {
|
||||
if ability.Client == nil {
|
||||
return nil, errors.New("Ability132 topClient is nil")
|
||||
}
|
||||
var jsonStr, err = ability.Client.Execute("taobao.tmc.auth.get", req.ToMap(), req.ToFileMap())
|
||||
var respStruct = response.TaobaoTmcAuthGetResponse{}
|
||||
if err != nil {
|
||||
log.Println("taobaoTmcAuthGet error", err)
|
||||
return &respStruct, err
|
||||
}
|
||||
err = util.HandleJsonResponse(jsonStr, &respStruct)
|
||||
if respStruct.Body == "" || len(respStruct.Body) == 0 {
|
||||
respStruct.Body = jsonStr
|
||||
}
|
||||
return &respStruct, err
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
package domain
|
||||
|
||||
type TaobaoTmcGroupsGetTmcGroup struct {
|
||||
/*
|
||||
分组名称 */
|
||||
Name *string `json:"name,omitempty" `
|
||||
}
|
||||
|
||||
func (s *TaobaoTmcGroupsGetTmcGroup) SetName(v string) *TaobaoTmcGroupsGetTmcGroup {
|
||||
s.Name = &v
|
||||
return s
|
||||
}
|
|
@ -0,0 +1,64 @@
|
|||
package domain
|
||||
|
||||
import (
|
||||
"topsdk/util"
|
||||
)
|
||||
|
||||
type TaobaoTmcMessagesConsumeTmcMessage struct {
|
||||
/*
|
||||
消息所属的用户编号 */
|
||||
UserId *int64 `json:"user_id,omitempty" `
|
||||
|
||||
/*
|
||||
用户的昵称 */
|
||||
UserNick *string `json:"user_nick,omitempty" `
|
||||
|
||||
/*
|
||||
消息详细内容,格式为JSON/XML */
|
||||
Content *string `json:"content,omitempty" `
|
||||
|
||||
/*
|
||||
消息ID */
|
||||
Id *int64 `json:"id,omitempty" `
|
||||
|
||||
/*
|
||||
消息发布时间 */
|
||||
PubTime *util.LocalTime `json:"pub_time,omitempty" `
|
||||
|
||||
/*
|
||||
消息发布者的AppKey */
|
||||
PubAppKey *string `json:"pub_app_key,omitempty" `
|
||||
|
||||
/*
|
||||
消息所属主题 */
|
||||
Topic *string `json:"topic,omitempty" `
|
||||
}
|
||||
|
||||
func (s *TaobaoTmcMessagesConsumeTmcMessage) SetUserId(v int64) *TaobaoTmcMessagesConsumeTmcMessage {
|
||||
s.UserId = &v
|
||||
return s
|
||||
}
|
||||
func (s *TaobaoTmcMessagesConsumeTmcMessage) SetUserNick(v string) *TaobaoTmcMessagesConsumeTmcMessage {
|
||||
s.UserNick = &v
|
||||
return s
|
||||
}
|
||||
func (s *TaobaoTmcMessagesConsumeTmcMessage) SetContent(v string) *TaobaoTmcMessagesConsumeTmcMessage {
|
||||
s.Content = &v
|
||||
return s
|
||||
}
|
||||
func (s *TaobaoTmcMessagesConsumeTmcMessage) SetId(v int64) *TaobaoTmcMessagesConsumeTmcMessage {
|
||||
s.Id = &v
|
||||
return s
|
||||
}
|
||||
func (s *TaobaoTmcMessagesConsumeTmcMessage) SetPubTime(v util.LocalTime) *TaobaoTmcMessagesConsumeTmcMessage {
|
||||
s.PubTime = &v
|
||||
return s
|
||||
}
|
||||
func (s *TaobaoTmcMessagesConsumeTmcMessage) SetPubAppKey(v string) *TaobaoTmcMessagesConsumeTmcMessage {
|
||||
s.PubAppKey = &v
|
||||
return s
|
||||
}
|
||||
func (s *TaobaoTmcMessagesConsumeTmcMessage) SetTopic(v string) *TaobaoTmcMessagesConsumeTmcMessage {
|
||||
s.Topic = &v
|
||||
return s
|
||||
}
|
|
@ -0,0 +1,28 @@
|
|||
package domain
|
||||
|
||||
type TaobaoTmcMessagesProduceTmcProduceResult struct {
|
||||
/*
|
||||
错误码 */
|
||||
ErrorCode *string `json:"error_code,omitempty" `
|
||||
|
||||
/*
|
||||
错误信息 */
|
||||
ErrorMessage *string `json:"error_message,omitempty" `
|
||||
|
||||
/*
|
||||
是否成功 */
|
||||
IsSuccess *bool `json:"is_success,omitempty" `
|
||||
}
|
||||
|
||||
func (s *TaobaoTmcMessagesProduceTmcProduceResult) SetErrorCode(v string) *TaobaoTmcMessagesProduceTmcProduceResult {
|
||||
s.ErrorCode = &v
|
||||
return s
|
||||
}
|
||||
func (s *TaobaoTmcMessagesProduceTmcProduceResult) SetErrorMessage(v string) *TaobaoTmcMessagesProduceTmcProduceResult {
|
||||
s.ErrorMessage = &v
|
||||
return s
|
||||
}
|
||||
func (s *TaobaoTmcMessagesProduceTmcProduceResult) SetIsSuccess(v bool) *TaobaoTmcMessagesProduceTmcProduceResult {
|
||||
s.IsSuccess = &v
|
||||
return s
|
||||
}
|
|
@ -0,0 +1,44 @@
|
|||
package domain
|
||||
|
||||
type TaobaoTmcMessagesProduceTmcPublishMessage struct {
|
||||
/*
|
||||
消息内容的JSON表述,必须按照topic的定义来填充 */
|
||||
Content *string `json:"content,omitempty" `
|
||||
|
||||
/*
|
||||
消息的扩增属性,用json格式表示 */
|
||||
JsonExContent *string `json:"json_ex_content,omitempty" `
|
||||
|
||||
/*
|
||||
直发消息需要传入目标appkey */
|
||||
TargetAppKey *string `json:"target_app_key,omitempty" `
|
||||
|
||||
/*
|
||||
目标分组 */
|
||||
TargetGroup *string `json:"target_group,omitempty" `
|
||||
|
||||
/*
|
||||
消息类型 */
|
||||
Topic *string `json:"topic,omitempty" `
|
||||
}
|
||||
|
||||
func (s *TaobaoTmcMessagesProduceTmcPublishMessage) SetContent(v string) *TaobaoTmcMessagesProduceTmcPublishMessage {
|
||||
s.Content = &v
|
||||
return s
|
||||
}
|
||||
func (s *TaobaoTmcMessagesProduceTmcPublishMessage) SetJsonExContent(v string) *TaobaoTmcMessagesProduceTmcPublishMessage {
|
||||
s.JsonExContent = &v
|
||||
return s
|
||||
}
|
||||
func (s *TaobaoTmcMessagesProduceTmcPublishMessage) SetTargetAppKey(v string) *TaobaoTmcMessagesProduceTmcPublishMessage {
|
||||
s.TargetAppKey = &v
|
||||
return s
|
||||
}
|
||||
func (s *TaobaoTmcMessagesProduceTmcPublishMessage) SetTargetGroup(v string) *TaobaoTmcMessagesProduceTmcPublishMessage {
|
||||
s.TargetGroup = &v
|
||||
return s
|
||||
}
|
||||
func (s *TaobaoTmcMessagesProduceTmcPublishMessage) SetTopic(v string) *TaobaoTmcMessagesProduceTmcPublishMessage {
|
||||
s.Topic = &v
|
||||
return s
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
package request
|
||||
|
||||
type TaobaoTmcAuthGetRequest struct {
|
||||
/*
|
||||
tmc组名 */
|
||||
Group *string `json:"group,omitempty" required:"false" `
|
||||
}
|
||||
|
||||
func (s *TaobaoTmcAuthGetRequest) SetGroup(v string) *TaobaoTmcAuthGetRequest {
|
||||
s.Group = &v
|
||||
return s
|
||||
}
|
||||
|
||||
func (req *TaobaoTmcAuthGetRequest) ToMap() map[string]interface{} {
|
||||
paramMap := make(map[string]interface{})
|
||||
if req.Group != nil {
|
||||
paramMap["group"] = *req.Group
|
||||
}
|
||||
return paramMap
|
||||
}
|
||||
|
||||
func (req *TaobaoTmcAuthGetRequest) ToFileMap() map[string]interface{} {
|
||||
fileMap := make(map[string]interface{})
|
||||
return fileMap
|
||||
}
|
|
@ -0,0 +1,49 @@
|
|||
package request
|
||||
|
||||
import (
|
||||
"topsdk/util"
|
||||
)
|
||||
|
||||
type TaobaoTmcGroupAddRequest struct {
|
||||
/*
|
||||
分组名称,同一个应用下需要保证唯一性,最长32个字符。添加分组后,消息通道会为用户的消息分配独立分组,但之前的消息还是存储于默认分组中。不能以default开头,default开头为系统默认组。 */
|
||||
GroupName *string `json:"group_name" required:"true" `
|
||||
/*
|
||||
用户昵称列表,以半角逗号分隔,支持子账号,支持增量添加用户 */
|
||||
Nicks *[]string `json:"nicks" required:"true" `
|
||||
/*
|
||||
用户所属于的平台类型,tbUIC:淘宝用户; icbu: icbu用户;ae:ae用户 defalutValue<EFBFBD><EFBFBD>tbUIC */
|
||||
UserPlatform *string `json:"user_platform,omitempty" required:"false" `
|
||||
}
|
||||
|
||||
func (s *TaobaoTmcGroupAddRequest) SetGroupName(v string) *TaobaoTmcGroupAddRequest {
|
||||
s.GroupName = &v
|
||||
return s
|
||||
}
|
||||
func (s *TaobaoTmcGroupAddRequest) SetNicks(v []string) *TaobaoTmcGroupAddRequest {
|
||||
s.Nicks = &v
|
||||
return s
|
||||
}
|
||||
func (s *TaobaoTmcGroupAddRequest) SetUserPlatform(v string) *TaobaoTmcGroupAddRequest {
|
||||
s.UserPlatform = &v
|
||||
return s
|
||||
}
|
||||
|
||||
func (req *TaobaoTmcGroupAddRequest) ToMap() map[string]interface{} {
|
||||
paramMap := make(map[string]interface{})
|
||||
if req.GroupName != nil {
|
||||
paramMap["group_name"] = *req.GroupName
|
||||
}
|
||||
if req.Nicks != nil {
|
||||
paramMap["nicks"] = util.ConvertBasicList(*req.Nicks)
|
||||
}
|
||||
if req.UserPlatform != nil {
|
||||
paramMap["user_platform"] = *req.UserPlatform
|
||||
}
|
||||
return paramMap
|
||||
}
|
||||
|
||||
func (req *TaobaoTmcGroupAddRequest) ToFileMap() map[string]interface{} {
|
||||
fileMap := make(map[string]interface{})
|
||||
return fileMap
|
||||
}
|
|
@ -0,0 +1,49 @@
|
|||
package request
|
||||
|
||||
import (
|
||||
"topsdk/util"
|
||||
)
|
||||
|
||||
type TaobaoTmcGroupDeleteRequest struct {
|
||||
/*
|
||||
分组名称,分组删除后,用户的消息将会存储于默认分组中。警告:由于分组已经删除,用户之前未消费的消息将无法再获取。不能以default开头,default开头为系统默认组。 */
|
||||
GroupName *string `json:"group_name" required:"true" `
|
||||
/*
|
||||
用户列表,不传表示删除整个分组,如果用户全部删除后,也会自动删除整个分组 */
|
||||
Nicks *[]string `json:"nicks,omitempty" required:"false" `
|
||||
/*
|
||||
用户所属于的平台类型,tbUIC:淘宝用户; icbu: icbu用户;ae:ae用户 defalutValue<EFBFBD><EFBFBD>tbUIC */
|
||||
UserPlatform *string `json:"user_platform,omitempty" required:"false" `
|
||||
}
|
||||
|
||||
func (s *TaobaoTmcGroupDeleteRequest) SetGroupName(v string) *TaobaoTmcGroupDeleteRequest {
|
||||
s.GroupName = &v
|
||||
return s
|
||||
}
|
||||
func (s *TaobaoTmcGroupDeleteRequest) SetNicks(v []string) *TaobaoTmcGroupDeleteRequest {
|
||||
s.Nicks = &v
|
||||
return s
|
||||
}
|
||||
func (s *TaobaoTmcGroupDeleteRequest) SetUserPlatform(v string) *TaobaoTmcGroupDeleteRequest {
|
||||
s.UserPlatform = &v
|
||||
return s
|
||||
}
|
||||
|
||||
func (req *TaobaoTmcGroupDeleteRequest) ToMap() map[string]interface{} {
|
||||
paramMap := make(map[string]interface{})
|
||||
if req.GroupName != nil {
|
||||
paramMap["group_name"] = *req.GroupName
|
||||
}
|
||||
if req.Nicks != nil {
|
||||
paramMap["nicks"] = util.ConvertBasicList(*req.Nicks)
|
||||
}
|
||||
if req.UserPlatform != nil {
|
||||
paramMap["user_platform"] = *req.UserPlatform
|
||||
}
|
||||
return paramMap
|
||||
}
|
||||
|
||||
func (req *TaobaoTmcGroupDeleteRequest) ToFileMap() map[string]interface{} {
|
||||
fileMap := make(map[string]interface{})
|
||||
return fileMap
|
||||
}
|
|
@ -0,0 +1,49 @@
|
|||
package request
|
||||
|
||||
import (
|
||||
"topsdk/util"
|
||||
)
|
||||
|
||||
type TaobaoTmcGroupsGetRequest struct {
|
||||
/*
|
||||
要查询分组的名称,多个分组用半角逗号分隔,不传代表查询所有分组信息,但不会返回组下面的用户信息。如果应用没有设置分组则返回空。组名不能以default开头,default开头是系统默认的组。 */
|
||||
GroupNames *[]string `json:"group_names,omitempty" required:"false" `
|
||||
/*
|
||||
页码 defalutValue<EFBFBD><EFBFBD>1 */
|
||||
PageNo *int64 `json:"page_no,omitempty" required:"false" `
|
||||
/*
|
||||
每页返回多少个分组 defalutValue<EFBFBD><EFBFBD>40 */
|
||||
PageSize *int64 `json:"page_size,omitempty" required:"false" `
|
||||
}
|
||||
|
||||
func (s *TaobaoTmcGroupsGetRequest) SetGroupNames(v []string) *TaobaoTmcGroupsGetRequest {
|
||||
s.GroupNames = &v
|
||||
return s
|
||||
}
|
||||
func (s *TaobaoTmcGroupsGetRequest) SetPageNo(v int64) *TaobaoTmcGroupsGetRequest {
|
||||
s.PageNo = &v
|
||||
return s
|
||||
}
|
||||
func (s *TaobaoTmcGroupsGetRequest) SetPageSize(v int64) *TaobaoTmcGroupsGetRequest {
|
||||
s.PageSize = &v
|
||||
return s
|
||||
}
|
||||
|
||||
func (req *TaobaoTmcGroupsGetRequest) ToMap() map[string]interface{} {
|
||||
paramMap := make(map[string]interface{})
|
||||
if req.GroupNames != nil {
|
||||
paramMap["group_names"] = util.ConvertBasicList(*req.GroupNames)
|
||||
}
|
||||
if req.PageNo != nil {
|
||||
paramMap["page_no"] = *req.PageNo
|
||||
}
|
||||
if req.PageSize != nil {
|
||||
paramMap["page_size"] = *req.PageSize
|
||||
}
|
||||
return paramMap
|
||||
}
|
||||
|
||||
func (req *TaobaoTmcGroupsGetRequest) ToFileMap() map[string]interface{} {
|
||||
fileMap := make(map[string]interface{})
|
||||
return fileMap
|
||||
}
|
|
@ -0,0 +1,49 @@
|
|||
package request
|
||||
|
||||
import (
|
||||
"topsdk/util"
|
||||
)
|
||||
|
||||
type TaobaoTmcMessagesConfirmRequest struct {
|
||||
/*
|
||||
分组名称,不传代表默认分组 */
|
||||
GroupName *string `json:"group_name,omitempty" required:"false" `
|
||||
/*
|
||||
处理成功的消息ID列表 最大 200个ID */
|
||||
SMessageIds *[]int64 `json:"s_message_ids" required:"true" `
|
||||
/*
|
||||
处理失败的消息ID列表--已废弃,无需传此字段 */
|
||||
FMessageIds *[]int64 `json:"f_message_ids,omitempty" required:"false" `
|
||||
}
|
||||
|
||||
func (s *TaobaoTmcMessagesConfirmRequest) SetGroupName(v string) *TaobaoTmcMessagesConfirmRequest {
|
||||
s.GroupName = &v
|
||||
return s
|
||||
}
|
||||
func (s *TaobaoTmcMessagesConfirmRequest) SetSMessageIds(v []int64) *TaobaoTmcMessagesConfirmRequest {
|
||||
s.SMessageIds = &v
|
||||
return s
|
||||
}
|
||||
func (s *TaobaoTmcMessagesConfirmRequest) SetFMessageIds(v []int64) *TaobaoTmcMessagesConfirmRequest {
|
||||
s.FMessageIds = &v
|
||||
return s
|
||||
}
|
||||
|
||||
func (req *TaobaoTmcMessagesConfirmRequest) ToMap() map[string]interface{} {
|
||||
paramMap := make(map[string]interface{})
|
||||
if req.GroupName != nil {
|
||||
paramMap["group_name"] = *req.GroupName
|
||||
}
|
||||
if req.SMessageIds != nil {
|
||||
paramMap["s_message_ids"] = util.ConvertBasicList(*req.SMessageIds)
|
||||
}
|
||||
if req.FMessageIds != nil {
|
||||
paramMap["f_message_ids"] = util.ConvertBasicList(*req.FMessageIds)
|
||||
}
|
||||
return paramMap
|
||||
}
|
||||
|
||||
func (req *TaobaoTmcMessagesConfirmRequest) ToFileMap() map[string]interface{} {
|
||||
fileMap := make(map[string]interface{})
|
||||
return fileMap
|
||||
}
|
|
@ -0,0 +1,35 @@
|
|||
package request
|
||||
|
||||
type TaobaoTmcMessagesConsumeRequest struct {
|
||||
/*
|
||||
用户分组名称,不传表示消费默认分组,如果应用没有设置用户分组,传入分组名称将会返回错误 */
|
||||
GroupName *string `json:"group_name,omitempty" required:"false" `
|
||||
/*
|
||||
每次批量消费消息的条数,最小值:10;最大值:200 defalutValue<EFBFBD><EFBFBD>100 */
|
||||
Quantity *int64 `json:"quantity,omitempty" required:"false" `
|
||||
}
|
||||
|
||||
func (s *TaobaoTmcMessagesConsumeRequest) SetGroupName(v string) *TaobaoTmcMessagesConsumeRequest {
|
||||
s.GroupName = &v
|
||||
return s
|
||||
}
|
||||
func (s *TaobaoTmcMessagesConsumeRequest) SetQuantity(v int64) *TaobaoTmcMessagesConsumeRequest {
|
||||
s.Quantity = &v
|
||||
return s
|
||||
}
|
||||
|
||||
func (req *TaobaoTmcMessagesConsumeRequest) ToMap() map[string]interface{} {
|
||||
paramMap := make(map[string]interface{})
|
||||
if req.GroupName != nil {
|
||||
paramMap["group_name"] = *req.GroupName
|
||||
}
|
||||
if req.Quantity != nil {
|
||||
paramMap["quantity"] = *req.Quantity
|
||||
}
|
||||
return paramMap
|
||||
}
|
||||
|
||||
func (req *TaobaoTmcMessagesConsumeRequest) ToFileMap() map[string]interface{} {
|
||||
fileMap := make(map[string]interface{})
|
||||
return fileMap
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
package request
|
||||
|
||||
import (
|
||||
"topsdk/ability132/domain"
|
||||
"topsdk/util"
|
||||
)
|
||||
|
||||
type TaobaoTmcMessagesProduceRequest struct {
|
||||
/*
|
||||
tmc消息列表, 最多50条,元素结构与taobao.tmc.message.produce一致,用json表示的消息列表。例如:[{"content": "{\"tid\":1234554321,\"status\":\"X_LOGISTICS_PRINTED\",\"action_time\":\"2014-08-08 18:24:00\",\"seller_nick\": \"向阳aa\",\"operator\":\"小张\"}","topic": "taobao_jds_TradeTrace"},{"content": "{\"tid\":1234554321,\"status\":\"X_LOGISTICS_PRINTED\",\"action_time\":\"2014-08-08 18:24:00\",\"seller_nick\": \"向阳aa\",\"operator\":\"小张\"}","topic": "taobao_jds_TradeTrace"}] */
|
||||
Messages *[]domain.TaobaoTmcMessagesProduceTmcPublishMessage `json:"messages" required:"true" `
|
||||
}
|
||||
|
||||
func (s *TaobaoTmcMessagesProduceRequest) SetMessages(v []domain.TaobaoTmcMessagesProduceTmcPublishMessage) *TaobaoTmcMessagesProduceRequest {
|
||||
s.Messages = &v
|
||||
return s
|
||||
}
|
||||
|
||||
func (req *TaobaoTmcMessagesProduceRequest) ToMap() map[string]interface{} {
|
||||
paramMap := make(map[string]interface{})
|
||||
if req.Messages != nil {
|
||||
paramMap["messages"] = util.ConvertStructList(*req.Messages)
|
||||
}
|
||||
return paramMap
|
||||
}
|
||||
|
||||
func (req *TaobaoTmcMessagesProduceRequest) ToFileMap() map[string]interface{} {
|
||||
fileMap := make(map[string]interface{})
|
||||
return fileMap
|
||||
}
|
|
@ -0,0 +1,39 @@
|
|||
package request
|
||||
|
||||
import (
|
||||
"topsdk/util"
|
||||
)
|
||||
|
||||
type TaobaoTmcTopicGroupAddRequest struct {
|
||||
/*
|
||||
消息分组名,如果不存在,会自动创建 */
|
||||
GroupName *string `json:"group_name" required:"true" `
|
||||
/*
|
||||
消息topic名称,多个以逗号(,)分割 */
|
||||
Topics *[]string `json:"topics" required:"true" `
|
||||
}
|
||||
|
||||
func (s *TaobaoTmcTopicGroupAddRequest) SetGroupName(v string) *TaobaoTmcTopicGroupAddRequest {
|
||||
s.GroupName = &v
|
||||
return s
|
||||
}
|
||||
func (s *TaobaoTmcTopicGroupAddRequest) SetTopics(v []string) *TaobaoTmcTopicGroupAddRequest {
|
||||
s.Topics = &v
|
||||
return s
|
||||
}
|
||||
|
||||
func (req *TaobaoTmcTopicGroupAddRequest) ToMap() map[string]interface{} {
|
||||
paramMap := make(map[string]interface{})
|
||||
if req.GroupName != nil {
|
||||
paramMap["group_name"] = *req.GroupName
|
||||
}
|
||||
if req.Topics != nil {
|
||||
paramMap["topics"] = util.ConvertBasicList(*req.Topics)
|
||||
}
|
||||
return paramMap
|
||||
}
|
||||
|
||||
func (req *TaobaoTmcTopicGroupAddRequest) ToFileMap() map[string]interface{} {
|
||||
fileMap := make(map[string]interface{})
|
||||
return fileMap
|
||||
}
|
|
@ -0,0 +1,49 @@
|
|||
package request
|
||||
|
||||
import (
|
||||
"topsdk/util"
|
||||
)
|
||||
|
||||
type TaobaoTmcTopicGroupDeleteRequest struct {
|
||||
/*
|
||||
消息分组名 */
|
||||
GroupName *string `json:"group_name" required:"true" `
|
||||
/*
|
||||
消息分组Id,一般不用填写,如果分组已经被删除,则根据问题排查工具返回的ID删除路由关系 */
|
||||
GroupId *int64 `json:"group_id,omitempty" required:"false" `
|
||||
/*
|
||||
消息topic名称,多个以逗号(,)分割 */
|
||||
Topics *[]string `json:"topics" required:"true" `
|
||||
}
|
||||
|
||||
func (s *TaobaoTmcTopicGroupDeleteRequest) SetGroupName(v string) *TaobaoTmcTopicGroupDeleteRequest {
|
||||
s.GroupName = &v
|
||||
return s
|
||||
}
|
||||
func (s *TaobaoTmcTopicGroupDeleteRequest) SetGroupId(v int64) *TaobaoTmcTopicGroupDeleteRequest {
|
||||
s.GroupId = &v
|
||||
return s
|
||||
}
|
||||
func (s *TaobaoTmcTopicGroupDeleteRequest) SetTopics(v []string) *TaobaoTmcTopicGroupDeleteRequest {
|
||||
s.Topics = &v
|
||||
return s
|
||||
}
|
||||
|
||||
func (req *TaobaoTmcTopicGroupDeleteRequest) ToMap() map[string]interface{} {
|
||||
paramMap := make(map[string]interface{})
|
||||
if req.GroupName != nil {
|
||||
paramMap["group_name"] = *req.GroupName
|
||||
}
|
||||
if req.GroupId != nil {
|
||||
paramMap["group_id"] = *req.GroupId
|
||||
}
|
||||
if req.Topics != nil {
|
||||
paramMap["topics"] = util.ConvertBasicList(*req.Topics)
|
||||
}
|
||||
return paramMap
|
||||
}
|
||||
|
||||
func (req *TaobaoTmcTopicGroupDeleteRequest) ToFileMap() map[string]interface{} {
|
||||
fileMap := make(map[string]interface{})
|
||||
return fileMap
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
package response
|
||||
|
||||
import ()
|
||||
|
||||
type TaobaoTmcAuthGetResponse struct {
|
||||
|
||||
/*
|
||||
System request id
|
||||
*/
|
||||
RequestId string `json:"request_id,omitempty" `
|
||||
|
||||
/*
|
||||
System body
|
||||
*/
|
||||
Body string
|
||||
|
||||
/*
|
||||
result
|
||||
*/
|
||||
Result string `json:"result,omitempty" `
|
||||
}
|
|
@ -0,0 +1,27 @@
|
|||
package response
|
||||
|
||||
import (
|
||||
"topsdk/util"
|
||||
)
|
||||
|
||||
type TaobaoTmcGroupAddResponse struct {
|
||||
|
||||
/*
|
||||
System request id
|
||||
*/
|
||||
RequestId string `json:"request_id,omitempty" `
|
||||
|
||||
/*
|
||||
System body
|
||||
*/
|
||||
Body string
|
||||
|
||||
/*
|
||||
创建时间
|
||||
*/
|
||||
Created util.LocalTime `json:"created,omitempty" `
|
||||
/*
|
||||
分组名称
|
||||
*/
|
||||
GroupName string `json:"group_name,omitempty" `
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
package response
|
||||
|
||||
import ()
|
||||
|
||||
type TaobaoTmcGroupDeleteResponse struct {
|
||||
|
||||
/*
|
||||
System request id
|
||||
*/
|
||||
RequestId string `json:"request_id,omitempty" `
|
||||
|
||||
/*
|
||||
System body
|
||||
*/
|
||||
Body string
|
||||
|
||||
/*
|
||||
是否成功
|
||||
*/
|
||||
IsSuccess bool `json:"is_success,omitempty" `
|
||||
}
|
|
@ -0,0 +1,27 @@
|
|||
package response
|
||||
|
||||
import (
|
||||
"topsdk/ability132/domain"
|
||||
)
|
||||
|
||||
type TaobaoTmcGroupsGetResponse struct {
|
||||
|
||||
/*
|
||||
System request id
|
||||
*/
|
||||
RequestId string `json:"request_id,omitempty" `
|
||||
|
||||
/*
|
||||
System body
|
||||
*/
|
||||
Body string
|
||||
|
||||
/*
|
||||
dasdasd
|
||||
*/
|
||||
Groups []domain.TaobaoTmcGroupsGetTmcGroup `json:"groups,omitempty" `
|
||||
/*
|
||||
分组总数
|
||||
*/
|
||||
TotalResults int64 `json:"total_results,omitempty" `
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
package response
|
||||
|
||||
import ()
|
||||
|
||||
type TaobaoTmcMessagesConfirmResponse struct {
|
||||
|
||||
/*
|
||||
System request id
|
||||
*/
|
||||
RequestId string `json:"request_id,omitempty" `
|
||||
|
||||
/*
|
||||
System body
|
||||
*/
|
||||
Body string
|
||||
|
||||
/*
|
||||
是否成功
|
||||
*/
|
||||
IsSuccess bool `json:"is_success,omitempty" `
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
package response
|
||||
|
||||
import (
|
||||
"topsdk/ability132/domain"
|
||||
)
|
||||
|
||||
type TaobaoTmcMessagesConsumeResponse struct {
|
||||
|
||||
/*
|
||||
System request id
|
||||
*/
|
||||
RequestId string `json:"request_id,omitempty" `
|
||||
|
||||
/*
|
||||
System body
|
||||
*/
|
||||
Body string
|
||||
|
||||
/*
|
||||
消息列表
|
||||
*/
|
||||
Messages []domain.TaobaoTmcMessagesConsumeTmcMessage `json:"messages,omitempty" `
|
||||
}
|
|
@ -0,0 +1,27 @@
|
|||
package response
|
||||
|
||||
import (
|
||||
"topsdk/ability132/domain"
|
||||
)
|
||||
|
||||
type TaobaoTmcMessagesProduceResponse struct {
|
||||
|
||||
/*
|
||||
System request id
|
||||
*/
|
||||
RequestId string `json:"request_id,omitempty" `
|
||||
|
||||
/*
|
||||
System body
|
||||
*/
|
||||
Body string
|
||||
|
||||
/*
|
||||
是否全部成功
|
||||
*/
|
||||
IsAllSuccess bool `json:"is_all_success,omitempty" `
|
||||
/*
|
||||
发送结果,与发送时的参数顺序一致。如果is_all_success为true时,不用校验result是否成功
|
||||
*/
|
||||
Results []domain.TaobaoTmcMessagesProduceTmcProduceResult `json:"results,omitempty" `
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
package response
|
||||
|
||||
import ()
|
||||
|
||||
type TaobaoTmcTopicGroupAddResponse struct {
|
||||
|
||||
/*
|
||||
System request id
|
||||
*/
|
||||
RequestId string `json:"request_id,omitempty" `
|
||||
|
||||
/*
|
||||
System body
|
||||
*/
|
||||
Body string
|
||||
|
||||
/*
|
||||
true
|
||||
*/
|
||||
Result bool `json:"result,omitempty" `
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
package response
|
||||
|
||||
import ()
|
||||
|
||||
type TaobaoTmcTopicGroupDeleteResponse struct {
|
||||
|
||||
/*
|
||||
System request id
|
||||
*/
|
||||
RequestId string `json:"request_id,omitempty" `
|
||||
|
||||
/*
|
||||
System body
|
||||
*/
|
||||
Body string
|
||||
|
||||
/*
|
||||
true
|
||||
*/
|
||||
Result bool `json:"result,omitempty" `
|
||||
}
|
|
@ -0,0 +1,218 @@
|
|||
package ability304
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"log"
|
||||
"topsdk"
|
||||
"topsdk/ability304/request"
|
||||
"topsdk/ability304/response"
|
||||
"topsdk/util"
|
||||
)
|
||||
|
||||
type Ability304 struct {
|
||||
Client *topsdk.TopClient
|
||||
}
|
||||
|
||||
func NewAbility304(client *topsdk.TopClient) *Ability304 {
|
||||
return &Ability304{client}
|
||||
}
|
||||
|
||||
/*
|
||||
获取授权账号对应的OpenUid
|
||||
*/
|
||||
func (ability *Ability304) TaobaoOpenuidGet(req *request.TaobaoOpenuidGetRequest, session string) (*response.TaobaoOpenuidGetResponse, error) {
|
||||
if ability.Client == nil {
|
||||
return nil, errors.New("Ability304 topClient is nil")
|
||||
}
|
||||
var jsonStr, err = ability.Client.ExecuteWithSession("taobao.openuid.get", req.ToMap(), req.ToFileMap(), session)
|
||||
var respStruct = response.TaobaoOpenuidGetResponse{}
|
||||
if err != nil {
|
||||
log.Println("taobaoOpenuidGet error", err)
|
||||
return &respStruct, err
|
||||
}
|
||||
err = util.HandleJsonResponse(jsonStr, &respStruct)
|
||||
if respStruct.Body == "" || len(respStruct.Body) == 0 {
|
||||
respStruct.Body = jsonStr
|
||||
}
|
||||
return &respStruct, err
|
||||
}
|
||||
|
||||
/*
|
||||
通过订单获取对应买家的openUID
|
||||
*/
|
||||
func (ability *Ability304) TaobaoOpenuidGetBytrade(req *request.TaobaoOpenuidGetBytradeRequest, session string) (*response.TaobaoOpenuidGetBytradeResponse, error) {
|
||||
if ability.Client == nil {
|
||||
return nil, errors.New("Ability304 topClient is nil")
|
||||
}
|
||||
var jsonStr, err = ability.Client.ExecuteWithSession("taobao.openuid.get.bytrade", req.ToMap(), req.ToFileMap(), session)
|
||||
var respStruct = response.TaobaoOpenuidGetBytradeResponse{}
|
||||
if err != nil {
|
||||
log.Println("taobaoOpenuidGetBytrade error", err)
|
||||
return &respStruct, err
|
||||
}
|
||||
err = util.HandleJsonResponse(jsonStr, &respStruct)
|
||||
if respStruct.Body == "" || len(respStruct.Body) == 0 {
|
||||
respStruct.Body = jsonStr
|
||||
}
|
||||
return &respStruct, err
|
||||
}
|
||||
|
||||
/*
|
||||
TOPDNS配置
|
||||
*/
|
||||
func (ability *Ability304) TaobaoHttpdnsGet(req *request.TaobaoHttpdnsGetRequest) (*response.TaobaoHttpdnsGetResponse, error) {
|
||||
if ability.Client == nil {
|
||||
return nil, errors.New("Ability304 topClient is nil")
|
||||
}
|
||||
var jsonStr, err = ability.Client.Execute("taobao.httpdns.get", req.ToMap(), req.ToFileMap())
|
||||
var respStruct = response.TaobaoHttpdnsGetResponse{}
|
||||
if err != nil {
|
||||
log.Println("taobaoHttpdnsGet error", err)
|
||||
return &respStruct, err
|
||||
}
|
||||
err = util.HandleJsonResponse(jsonStr, &respStruct)
|
||||
if respStruct.Body == "" || len(respStruct.Body) == 0 {
|
||||
respStruct.Body = jsonStr
|
||||
}
|
||||
return &respStruct, err
|
||||
}
|
||||
|
||||
/*
|
||||
获取TOP通道解密秘钥
|
||||
*/
|
||||
func (ability *Ability304) TaobaoTopSecretGet(req *request.TaobaoTopSecretGetRequest) (*response.TaobaoTopSecretGetResponse, error) {
|
||||
if ability.Client == nil {
|
||||
return nil, errors.New("Ability304 topClient is nil")
|
||||
}
|
||||
var jsonStr, err = ability.Client.Execute("taobao.top.secret.get", req.ToMap(), req.ToFileMap())
|
||||
var respStruct = response.TaobaoTopSecretGetResponse{}
|
||||
if err != nil {
|
||||
log.Println("taobaoTopSecretGet error", err)
|
||||
return &respStruct, err
|
||||
}
|
||||
err = util.HandleJsonResponse(jsonStr, &respStruct)
|
||||
if respStruct.Body == "" || len(respStruct.Body) == 0 {
|
||||
respStruct.Body = jsonStr
|
||||
}
|
||||
return &respStruct, err
|
||||
}
|
||||
|
||||
/*
|
||||
通过mixnick转换openuid
|
||||
*/
|
||||
func (ability *Ability304) TaobaoOpenuidGetBymixnick(req *request.TaobaoOpenuidGetBymixnickRequest) (*response.TaobaoOpenuidGetBymixnickResponse, error) {
|
||||
if ability.Client == nil {
|
||||
return nil, errors.New("Ability304 topClient is nil")
|
||||
}
|
||||
var jsonStr, err = ability.Client.Execute("taobao.openuid.get.bymixnick", req.ToMap(), req.ToFileMap())
|
||||
var respStruct = response.TaobaoOpenuidGetBymixnickResponse{}
|
||||
if err != nil {
|
||||
log.Println("taobaoOpenuidGetBymixnick error", err)
|
||||
return &respStruct, err
|
||||
}
|
||||
err = util.HandleJsonResponse(jsonStr, &respStruct)
|
||||
if respStruct.Body == "" || len(respStruct.Body) == 0 {
|
||||
respStruct.Body = jsonStr
|
||||
}
|
||||
return &respStruct, err
|
||||
}
|
||||
|
||||
/*
|
||||
获取ISV发起请求服务器IP
|
||||
*/
|
||||
func (ability *Ability304) TaobaoAppipGet(req *request.TaobaoAppipGetRequest) (*response.TaobaoAppipGetResponse, error) {
|
||||
if ability.Client == nil {
|
||||
return nil, errors.New("Ability304 topClient is nil")
|
||||
}
|
||||
var jsonStr, err = ability.Client.Execute("taobao.appip.get", req.ToMap(), req.ToFileMap())
|
||||
var respStruct = response.TaobaoAppipGetResponse{}
|
||||
if err != nil {
|
||||
log.Println("taobaoAppipGet error", err)
|
||||
return &respStruct, err
|
||||
}
|
||||
err = util.HandleJsonResponse(jsonStr, &respStruct)
|
||||
if respStruct.Body == "" || len(respStruct.Body) == 0 {
|
||||
respStruct.Body = jsonStr
|
||||
}
|
||||
return &respStruct, err
|
||||
}
|
||||
|
||||
/*
|
||||
业务文件获取
|
||||
*/
|
||||
func (ability *Ability304) TaobaoFilesGet(req *request.TaobaoFilesGetRequest) (*response.TaobaoFilesGetResponse, error) {
|
||||
if ability.Client == nil {
|
||||
return nil, errors.New("Ability304 topClient is nil")
|
||||
}
|
||||
var jsonStr, err = ability.Client.Execute("taobao.files.get", req.ToMap(), req.ToFileMap())
|
||||
var respStruct = response.TaobaoFilesGetResponse{}
|
||||
if err != nil {
|
||||
log.Println("taobaoFilesGet error", err)
|
||||
return &respStruct, err
|
||||
}
|
||||
err = util.HandleJsonResponse(jsonStr, &respStruct)
|
||||
if respStruct.Body == "" || len(respStruct.Body) == 0 {
|
||||
respStruct.Body = jsonStr
|
||||
}
|
||||
return &respStruct, err
|
||||
}
|
||||
|
||||
/*
|
||||
刷新Access Token
|
||||
*/
|
||||
func (ability *Ability304) TaobaoTopAuthTokenRefresh(req *request.TaobaoTopAuthTokenRefreshRequest) (*response.TaobaoTopAuthTokenRefreshResponse, error) {
|
||||
if ability.Client == nil {
|
||||
return nil, errors.New("Ability304 topClient is nil")
|
||||
}
|
||||
var jsonStr, err = ability.Client.Execute("taobao.top.auth.token.refresh", req.ToMap(), req.ToFileMap())
|
||||
var respStruct = response.TaobaoTopAuthTokenRefreshResponse{}
|
||||
if err != nil {
|
||||
log.Println("taobaoTopAuthTokenRefresh error", err)
|
||||
return &respStruct, err
|
||||
}
|
||||
err = util.HandleJsonResponse(jsonStr, &respStruct)
|
||||
if respStruct.Body == "" || len(respStruct.Body) == 0 {
|
||||
respStruct.Body = jsonStr
|
||||
}
|
||||
return &respStruct, err
|
||||
}
|
||||
|
||||
/*
|
||||
获取Access Token
|
||||
*/
|
||||
func (ability *Ability304) TaobaoTopAuthTokenCreate(req *request.TaobaoTopAuthTokenCreateRequest) (*response.TaobaoTopAuthTokenCreateResponse, error) {
|
||||
if ability.Client == nil {
|
||||
return nil, errors.New("Ability304 topClient is nil")
|
||||
}
|
||||
var jsonStr, err = ability.Client.Execute("taobao.top.auth.token.create", req.ToMap(), req.ToFileMap())
|
||||
var respStruct = response.TaobaoTopAuthTokenCreateResponse{}
|
||||
if err != nil {
|
||||
log.Println("taobaoTopAuthTokenCreate error", err)
|
||||
return &respStruct, err
|
||||
}
|
||||
err = util.HandleJsonResponse(jsonStr, &respStruct)
|
||||
if respStruct.Body == "" || len(respStruct.Body) == 0 {
|
||||
respStruct.Body = jsonStr
|
||||
}
|
||||
return &respStruct, err
|
||||
}
|
||||
|
||||
/*
|
||||
sdk信息回调
|
||||
*/
|
||||
func (ability *Ability304) TaobaoTopSdkFeedbackUpload(req *request.TaobaoTopSdkFeedbackUploadRequest) (*response.TaobaoTopSdkFeedbackUploadResponse, error) {
|
||||
if ability.Client == nil {
|
||||
return nil, errors.New("Ability304 topClient is nil")
|
||||
}
|
||||
var jsonStr, err = ability.Client.Execute("taobao.top.sdk.feedback.upload", req.ToMap(), req.ToFileMap())
|
||||
var respStruct = response.TaobaoTopSdkFeedbackUploadResponse{}
|
||||
if err != nil {
|
||||
log.Println("taobaoTopSdkFeedbackUpload error", err)
|
||||
return &respStruct, err
|
||||
}
|
||||
err = util.HandleJsonResponse(jsonStr, &respStruct)
|
||||
if respStruct.Body == "" || len(respStruct.Body) == 0 {
|
||||
respStruct.Body = jsonStr
|
||||
}
|
||||
return &respStruct, err
|
||||
}
|
|
@ -0,0 +1,32 @@
|
|||
package domain
|
||||
|
||||
import (
|
||||
"topsdk/util"
|
||||
)
|
||||
|
||||
type TaobaoFilesGetTopDownloadRecordDo struct {
|
||||
/*
|
||||
下载链接 */
|
||||
Url *string `json:"url,omitempty" `
|
||||
|
||||
/*
|
||||
文件创建时间 */
|
||||
Created *util.LocalTime `json:"created,omitempty" `
|
||||
|
||||
/*
|
||||
下载链接状态。1:未下载。2:已下载 */
|
||||
Status *int64 `json:"status,omitempty" `
|
||||
}
|
||||
|
||||
func (s *TaobaoFilesGetTopDownloadRecordDo) SetUrl(v string) *TaobaoFilesGetTopDownloadRecordDo {
|
||||
s.Url = &v
|
||||
return s
|
||||
}
|
||||
func (s *TaobaoFilesGetTopDownloadRecordDo) SetCreated(v util.LocalTime) *TaobaoFilesGetTopDownloadRecordDo {
|
||||
s.Created = &v
|
||||
return s
|
||||
}
|
||||
func (s *TaobaoFilesGetTopDownloadRecordDo) SetStatus(v int64) *TaobaoFilesGetTopDownloadRecordDo {
|
||||
s.Status = &v
|
||||
return s
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
package request
|
||||
|
||||
type TaobaoAppipGetRequest struct {
|
||||
}
|
||||
|
||||
func (req *TaobaoAppipGetRequest) ToMap() map[string]interface{} {
|
||||
paramMap := make(map[string]interface{})
|
||||
return paramMap
|
||||
}
|
||||
|
||||
func (req *TaobaoAppipGetRequest) ToFileMap() map[string]interface{} {
|
||||
fileMap := make(map[string]interface{})
|
||||
return fileMap
|
||||
}
|
|
@ -0,0 +1,49 @@
|
|||
package request
|
||||
|
||||
import (
|
||||
"topsdk/util"
|
||||
)
|
||||
|
||||
type TaobaoFilesGetRequest struct {
|
||||
/*
|
||||
下载链接状态。1:未下载。2:已下载 */
|
||||
Status *int64 `json:"status,omitempty" required:"false" `
|
||||
/*
|
||||
搜索开始时间 */
|
||||
StartDate *util.LocalTime `json:"start_date" required:"true" `
|
||||
/*
|
||||
搜索结束时间 */
|
||||
EndDate *util.LocalTime `json:"end_date" required:"true" `
|
||||
}
|
||||
|
||||
func (s *TaobaoFilesGetRequest) SetStatus(v int64) *TaobaoFilesGetRequest {
|
||||
s.Status = &v
|
||||
return s
|
||||
}
|
||||
func (s *TaobaoFilesGetRequest) SetStartDate(v util.LocalTime) *TaobaoFilesGetRequest {
|
||||
s.StartDate = &v
|
||||
return s
|
||||
}
|
||||
func (s *TaobaoFilesGetRequest) SetEndDate(v util.LocalTime) *TaobaoFilesGetRequest {
|
||||
s.EndDate = &v
|
||||
return s
|
||||
}
|
||||
|
||||
func (req *TaobaoFilesGetRequest) ToMap() map[string]interface{} {
|
||||
paramMap := make(map[string]interface{})
|
||||
if req.Status != nil {
|
||||
paramMap["status"] = *req.Status
|
||||
}
|
||||
if req.StartDate != nil {
|
||||
paramMap["start_date"] = *req.StartDate
|
||||
}
|
||||
if req.EndDate != nil {
|
||||
paramMap["end_date"] = *req.EndDate
|
||||
}
|
||||
return paramMap
|
||||
}
|
||||
|
||||
func (req *TaobaoFilesGetRequest) ToFileMap() map[string]interface{} {
|
||||
fileMap := make(map[string]interface{})
|
||||
return fileMap
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
package request
|
||||
|
||||
type TaobaoHttpdnsGetRequest struct {
|
||||
}
|
||||
|
||||
func (req *TaobaoHttpdnsGetRequest) ToMap() map[string]interface{} {
|
||||
paramMap := make(map[string]interface{})
|
||||
return paramMap
|
||||
}
|
||||
|
||||
func (req *TaobaoHttpdnsGetRequest) ToFileMap() map[string]interface{} {
|
||||
fileMap := make(map[string]interface{})
|
||||
return fileMap
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
package request
|
||||
|
||||
type TaobaoOpenuidGetBymixnickRequest struct {
|
||||
/*
|
||||
无线类应用获取到的混淆的nick */
|
||||
MixNick *string `json:"mix_nick" required:"true" `
|
||||
}
|
||||
|
||||
func (s *TaobaoOpenuidGetBymixnickRequest) SetMixNick(v string) *TaobaoOpenuidGetBymixnickRequest {
|
||||
s.MixNick = &v
|
||||
return s
|
||||
}
|
||||
|
||||
func (req *TaobaoOpenuidGetBymixnickRequest) ToMap() map[string]interface{} {
|
||||
paramMap := make(map[string]interface{})
|
||||
if req.MixNick != nil {
|
||||
paramMap["mix_nick"] = *req.MixNick
|
||||
}
|
||||
return paramMap
|
||||
}
|
||||
|
||||
func (req *TaobaoOpenuidGetBymixnickRequest) ToFileMap() map[string]interface{} {
|
||||
fileMap := make(map[string]interface{})
|
||||
return fileMap
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
package request
|
||||
|
||||
type TaobaoOpenuidGetBytradeRequest struct {
|
||||
/*
|
||||
订单ID */
|
||||
Tid *int64 `json:"tid" required:"true" `
|
||||
}
|
||||
|
||||
func (s *TaobaoOpenuidGetBytradeRequest) SetTid(v int64) *TaobaoOpenuidGetBytradeRequest {
|
||||
s.Tid = &v
|
||||
return s
|
||||
}
|
||||
|
||||
func (req *TaobaoOpenuidGetBytradeRequest) ToMap() map[string]interface{} {
|
||||
paramMap := make(map[string]interface{})
|
||||
if req.Tid != nil {
|
||||
paramMap["tid"] = *req.Tid
|
||||
}
|
||||
return paramMap
|
||||
}
|
||||
|
||||
func (req *TaobaoOpenuidGetBytradeRequest) ToFileMap() map[string]interface{} {
|
||||
fileMap := make(map[string]interface{})
|
||||
return fileMap
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
package request
|
||||
|
||||
type TaobaoOpenuidGetRequest struct {
|
||||
}
|
||||
|
||||
func (req *TaobaoOpenuidGetRequest) ToMap() map[string]interface{} {
|
||||
paramMap := make(map[string]interface{})
|
||||
return paramMap
|
||||
}
|
||||
|
||||
func (req *TaobaoOpenuidGetRequest) ToFileMap() map[string]interface{} {
|
||||
fileMap := make(map[string]interface{})
|
||||
return fileMap
|
||||
}
|
|
@ -0,0 +1,35 @@
|
|||
package request
|
||||
|
||||
type TaobaoTopAuthTokenCreateRequest struct {
|
||||
/*
|
||||
授权code,grantType==authorization_code 时需要 */
|
||||
Code *string `json:"code" required:"true" `
|
||||
/*
|
||||
非必填,与生成code的uuid配对,使用方式参考文档 */
|
||||
Uuid *string `json:"uuid,omitempty" required:"false" `
|
||||
}
|
||||
|
||||
func (s *TaobaoTopAuthTokenCreateRequest) SetCode(v string) *TaobaoTopAuthTokenCreateRequest {
|
||||
s.Code = &v
|
||||
return s
|
||||
}
|
||||
func (s *TaobaoTopAuthTokenCreateRequest) SetUuid(v string) *TaobaoTopAuthTokenCreateRequest {
|
||||
s.Uuid = &v
|
||||
return s
|
||||
}
|
||||
|
||||
func (req *TaobaoTopAuthTokenCreateRequest) ToMap() map[string]interface{} {
|
||||
paramMap := make(map[string]interface{})
|
||||
if req.Code != nil {
|
||||
paramMap["code"] = *req.Code
|
||||
}
|
||||
if req.Uuid != nil {
|
||||
paramMap["uuid"] = *req.Uuid
|
||||
}
|
||||
return paramMap
|
||||
}
|
||||
|
||||
func (req *TaobaoTopAuthTokenCreateRequest) ToFileMap() map[string]interface{} {
|
||||
fileMap := make(map[string]interface{})
|
||||
return fileMap
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
package request
|
||||
|
||||
type TaobaoTopAuthTokenRefreshRequest struct {
|
||||
/*
|
||||
grantType==refresh_token 时需要 */
|
||||
RefreshToken *string `json:"refresh_token" required:"true" `
|
||||
}
|
||||
|
||||
func (s *TaobaoTopAuthTokenRefreshRequest) SetRefreshToken(v string) *TaobaoTopAuthTokenRefreshRequest {
|
||||
s.RefreshToken = &v
|
||||
return s
|
||||
}
|
||||
|
||||
func (req *TaobaoTopAuthTokenRefreshRequest) ToMap() map[string]interface{} {
|
||||
paramMap := make(map[string]interface{})
|
||||
if req.RefreshToken != nil {
|
||||
paramMap["refresh_token"] = *req.RefreshToken
|
||||
}
|
||||
return paramMap
|
||||
}
|
||||
|
||||
func (req *TaobaoTopAuthTokenRefreshRequest) ToFileMap() map[string]interface{} {
|
||||
fileMap := make(map[string]interface{})
|
||||
return fileMap
|
||||
}
|
|
@ -0,0 +1,35 @@
|
|||
package request
|
||||
|
||||
type TaobaoTopSdkFeedbackUploadRequest struct {
|
||||
/*
|
||||
1、回传加密信息 */
|
||||
Type *string `json:"type" required:"true" `
|
||||
/*
|
||||
具体内容,json形式 */
|
||||
Content *string `json:"content,omitempty" required:"false" `
|
||||
}
|
||||
|
||||
func (s *TaobaoTopSdkFeedbackUploadRequest) SetType(v string) *TaobaoTopSdkFeedbackUploadRequest {
|
||||
s.Type = &v
|
||||
return s
|
||||
}
|
||||
func (s *TaobaoTopSdkFeedbackUploadRequest) SetContent(v string) *TaobaoTopSdkFeedbackUploadRequest {
|
||||
s.Content = &v
|
||||
return s
|
||||
}
|
||||
|
||||
func (req *TaobaoTopSdkFeedbackUploadRequest) ToMap() map[string]interface{} {
|
||||
paramMap := make(map[string]interface{})
|
||||
if req.Type != nil {
|
||||
paramMap["type"] = *req.Type
|
||||
}
|
||||
if req.Content != nil {
|
||||
paramMap["content"] = *req.Content
|
||||
}
|
||||
return paramMap
|
||||
}
|
||||
|
||||
func (req *TaobaoTopSdkFeedbackUploadRequest) ToFileMap() map[string]interface{} {
|
||||
fileMap := make(map[string]interface{})
|
||||
return fileMap
|
||||
}
|
|
@ -0,0 +1,45 @@
|
|||
package request
|
||||
|
||||
type TaobaoTopSecretGetRequest struct {
|
||||
/*
|
||||
秘钥版本号 */
|
||||
SecretVersion *int64 `json:"secret_version,omitempty" required:"false" `
|
||||
/*
|
||||
伪随机数 */
|
||||
RandomNum *string `json:"random_num" required:"true" `
|
||||
/*
|
||||
自定义用户id */
|
||||
CustomerUserId *int64 `json:"customer_user_id,omitempty" required:"false" `
|
||||
}
|
||||
|
||||
func (s *TaobaoTopSecretGetRequest) SetSecretVersion(v int64) *TaobaoTopSecretGetRequest {
|
||||
s.SecretVersion = &v
|
||||
return s
|
||||
}
|
||||
func (s *TaobaoTopSecretGetRequest) SetRandomNum(v string) *TaobaoTopSecretGetRequest {
|
||||
s.RandomNum = &v
|
||||
return s
|
||||
}
|
||||
func (s *TaobaoTopSecretGetRequest) SetCustomerUserId(v int64) *TaobaoTopSecretGetRequest {
|
||||
s.CustomerUserId = &v
|
||||
return s
|
||||
}
|
||||
|
||||
func (req *TaobaoTopSecretGetRequest) ToMap() map[string]interface{} {
|
||||
paramMap := make(map[string]interface{})
|
||||
if req.SecretVersion != nil {
|
||||
paramMap["secret_version"] = *req.SecretVersion
|
||||
}
|
||||
if req.RandomNum != nil {
|
||||
paramMap["random_num"] = *req.RandomNum
|
||||
}
|
||||
if req.CustomerUserId != nil {
|
||||
paramMap["customer_user_id"] = *req.CustomerUserId
|
||||
}
|
||||
return paramMap
|
||||
}
|
||||
|
||||
func (req *TaobaoTopSecretGetRequest) ToFileMap() map[string]interface{} {
|
||||
fileMap := make(map[string]interface{})
|
||||
return fileMap
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
package response
|
||||
|
||||
import ()
|
||||
|
||||
type TaobaoAppipGetResponse struct {
|
||||
|
||||
/*
|
||||
System request id
|
||||
*/
|
||||
RequestId string `json:"request_id,omitempty" `
|
||||
|
||||
/*
|
||||
System body
|
||||
*/
|
||||
Body string
|
||||
|
||||
/*
|
||||
ISV发起请求服务器IP
|
||||
*/
|
||||
Ip string `json:"ip,omitempty" `
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
package response
|
||||
|
||||
import (
|
||||
"topsdk/ability304/domain"
|
||||
)
|
||||
|
||||
type TaobaoFilesGetResponse struct {
|
||||
|
||||
/*
|
||||
System request id
|
||||
*/
|
||||
RequestId string `json:"request_id,omitempty" `
|
||||
|
||||
/*
|
||||
System body
|
||||
*/
|
||||
Body string
|
||||
|
||||
/*
|
||||
results
|
||||
*/
|
||||
Results []domain.TaobaoFilesGetTopDownloadRecordDo `json:"results,omitempty" `
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
package response
|
||||
|
||||
import ()
|
||||
|
||||
type TaobaoHttpdnsGetResponse struct {
|
||||
|
||||
/*
|
||||
System request id
|
||||
*/
|
||||
RequestId string `json:"request_id,omitempty" `
|
||||
|
||||
/*
|
||||
System body
|
||||
*/
|
||||
Body string
|
||||
|
||||
/*
|
||||
HTTP DNS配置信息
|
||||
*/
|
||||
Result string `json:"result,omitempty" `
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
package response
|
||||
|
||||
import ()
|
||||
|
||||
type TaobaoOpenuidGetBymixnickResponse struct {
|
||||
|
||||
/*
|
||||
System request id
|
||||
*/
|
||||
RequestId string `json:"request_id,omitempty" `
|
||||
|
||||
/*
|
||||
System body
|
||||
*/
|
||||
Body string
|
||||
|
||||
/*
|
||||
OpenUID
|
||||
*/
|
||||
OpenUid string `json:"open_uid,omitempty" `
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
package response
|
||||
|
||||
import ()
|
||||
|
||||
type TaobaoOpenuidGetBytradeResponse struct {
|
||||
|
||||
/*
|
||||
System request id
|
||||
*/
|
||||
RequestId string `json:"request_id,omitempty" `
|
||||
|
||||
/*
|
||||
System body
|
||||
*/
|
||||
Body string
|
||||
|
||||
/*
|
||||
当前交易tid对应买家的openuid
|
||||
*/
|
||||
OpenUid string `json:"open_uid,omitempty" `
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
package response
|
||||
|
||||
import ()
|
||||
|
||||
type TaobaoOpenuidGetResponse struct {
|
||||
|
||||
/*
|
||||
System request id
|
||||
*/
|
||||
RequestId string `json:"request_id,omitempty" `
|
||||
|
||||
/*
|
||||
System body
|
||||
*/
|
||||
Body string
|
||||
|
||||
/*
|
||||
OpenUID
|
||||
*/
|
||||
OpenUid string `json:"open_uid,omitempty" `
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
package response
|
||||
|
||||
import ()
|
||||
|
||||
type TaobaoTopAuthTokenCreateResponse struct {
|
||||
|
||||
/*
|
||||
System request id
|
||||
*/
|
||||
RequestId string `json:"request_id,omitempty" `
|
||||
|
||||
/*
|
||||
System body
|
||||
*/
|
||||
Body string
|
||||
|
||||
/*
|
||||
返回的是json信息,和之前调用https://oauth.taobao.com/tac/token https://oauth.alibaba.com/token 换token返回的字段信息一致
|
||||
*/
|
||||
TokenResult string `json:"token_result,omitempty" `
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
package response
|
||||
|
||||
import ()
|
||||
|
||||
type TaobaoTopAuthTokenRefreshResponse struct {
|
||||
|
||||
/*
|
||||
System request id
|
||||
*/
|
||||
RequestId string `json:"request_id,omitempty" `
|
||||
|
||||
/*
|
||||
System body
|
||||
*/
|
||||
Body string
|
||||
|
||||
/*
|
||||
返回的是json信息
|
||||
*/
|
||||
TokenResult string `json:"token_result,omitempty" `
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
package response
|
||||
|
||||
import ()
|
||||
|
||||
type TaobaoTopSdkFeedbackUploadResponse struct {
|
||||
|
||||
/*
|
||||
System request id
|
||||
*/
|
||||
RequestId string `json:"request_id,omitempty" `
|
||||
|
||||
/*
|
||||
System body
|
||||
*/
|
||||
Body string
|
||||
|
||||
/*
|
||||
控制回传间隔(单位:秒)
|
||||
*/
|
||||
UploadInterval int64 `json:"upload_interval,omitempty" `
|
||||
}
|
|
@ -0,0 +1,37 @@
|
|||
package response
|
||||
|
||||
import ()
|
||||
|
||||
type TaobaoTopSecretGetResponse struct {
|
||||
|
||||
/*
|
||||
System request id
|
||||
*/
|
||||
RequestId string `json:"request_id,omitempty" `
|
||||
|
||||
/*
|
||||
System body
|
||||
*/
|
||||
Body string
|
||||
|
||||
/*
|
||||
下次更新秘钥间隔,单位(秒)
|
||||
*/
|
||||
Interval int64 `json:"interval,omitempty" `
|
||||
/*
|
||||
最长有效期,容灾使用,单位(秒)
|
||||
*/
|
||||
MaxInterval int64 `json:"max_interval,omitempty" `
|
||||
/*
|
||||
秘钥值
|
||||
*/
|
||||
Secret string `json:"secret,omitempty" `
|
||||
/*
|
||||
秘钥版本号
|
||||
*/
|
||||
SecretVersion int64 `json:"secret_version,omitempty" `
|
||||
/*
|
||||
app配置信息
|
||||
*/
|
||||
AppConfig string `json:"app_config,omitempty" `
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
package topsdk
|
||||
|
||||
/*
|
||||
*
|
||||
|
||||
sdk使用常量,请勿修改
|
||||
*/
|
||||
const (
|
||||
// SdkVersion 版本号
|
||||
SdkVersion = "new_go_sdk_20240801"
|
||||
|
||||
// ApiFormat api格式
|
||||
ApiFormat = "json"
|
||||
|
||||
// SignMethod 签名算法
|
||||
SignMethod = "hmac-sha256"
|
||||
|
||||
// Version 网关版本号
|
||||
TopVersion = "2.0"
|
||||
|
||||
// DateFormat 日期格式
|
||||
DateFormat = "2006-01-02 15:04:05"
|
||||
)
|
|
@ -0,0 +1,118 @@
|
|||
package defaultability
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"log"
|
||||
"topsdk"
|
||||
"topsdk/defaultability/request"
|
||||
"topsdk/defaultability/response"
|
||||
"topsdk/util"
|
||||
)
|
||||
|
||||
type Defaultability struct {
|
||||
Client *topsdk.TopClient
|
||||
}
|
||||
|
||||
func NewDefaultability(client *topsdk.TopClient) *Defaultability {
|
||||
return &Defaultability{client}
|
||||
}
|
||||
|
||||
/*
|
||||
关键词过滤匹配
|
||||
*/
|
||||
func (ability *Defaultability) TaobaoKfcKeywordSearch(req *request.TaobaoKfcKeywordSearchRequest, session string) (*response.TaobaoKfcKeywordSearchResponse, error) {
|
||||
if ability.Client == nil {
|
||||
return nil, errors.New("Defaultability topClient is nil")
|
||||
}
|
||||
var jsonStr, err = ability.Client.ExecuteWithSession("taobao.kfc.keyword.search", req.ToMap(), req.ToFileMap(), session)
|
||||
var respStruct = response.TaobaoKfcKeywordSearchResponse{}
|
||||
if err != nil {
|
||||
log.Println("taobaoKfcKeywordSearch error", err)
|
||||
return &respStruct, err
|
||||
}
|
||||
err = util.HandleJsonResponse(jsonStr, &respStruct)
|
||||
if respStruct.Body == "" || len(respStruct.Body) == 0 {
|
||||
respStruct.Body = jsonStr
|
||||
}
|
||||
return &respStruct, err
|
||||
}
|
||||
|
||||
/*
|
||||
获取商家所在分组及其已授权(广播)消息topics
|
||||
*/
|
||||
func (ability *Defaultability) TaobaoTmcUserGet(req *request.TaobaoTmcUserGetRequest) (*response.TaobaoTmcUserGetResponse, error) {
|
||||
if ability.Client == nil {
|
||||
return nil, errors.New("Defaultability topClient is nil")
|
||||
}
|
||||
var jsonStr, err = ability.Client.Execute("taobao.tmc.user.get", req.ToMap(), req.ToFileMap())
|
||||
var respStruct = response.TaobaoTmcUserGetResponse{}
|
||||
if err != nil {
|
||||
log.Println("taobaoTmcUserGet error", err)
|
||||
return &respStruct, err
|
||||
}
|
||||
err = util.HandleJsonResponse(jsonStr, &respStruct)
|
||||
if respStruct.Body == "" || len(respStruct.Body) == 0 {
|
||||
respStruct.Body = jsonStr
|
||||
}
|
||||
return &respStruct, err
|
||||
}
|
||||
|
||||
/*
|
||||
发布单条消息
|
||||
*/
|
||||
func (ability *Defaultability) TaobaoTmcMessageProduce(req *request.TaobaoTmcMessageProduceRequest) (*response.TaobaoTmcMessageProduceResponse, error) {
|
||||
if ability.Client == nil {
|
||||
return nil, errors.New("Defaultability topClient is nil")
|
||||
}
|
||||
var jsonStr, err = ability.Client.Execute("taobao.tmc.message.produce", req.ToMap(), req.ToFileMap())
|
||||
var respStruct = response.TaobaoTmcMessageProduceResponse{}
|
||||
if err != nil {
|
||||
log.Println("taobaoTmcMessageProduce error", err)
|
||||
return &respStruct, err
|
||||
}
|
||||
err = util.HandleJsonResponse(jsonStr, &respStruct)
|
||||
if respStruct.Body == "" || len(respStruct.Body) == 0 {
|
||||
respStruct.Body = jsonStr
|
||||
}
|
||||
return &respStruct, err
|
||||
}
|
||||
|
||||
/*
|
||||
取消用户的消息服务
|
||||
*/
|
||||
func (ability *Defaultability) TaobaoTmcUserCancel(req *request.TaobaoTmcUserCancelRequest) (*response.TaobaoTmcUserCancelResponse, error) {
|
||||
if ability.Client == nil {
|
||||
return nil, errors.New("Defaultability topClient is nil")
|
||||
}
|
||||
var jsonStr, err = ability.Client.Execute("taobao.tmc.user.cancel", req.ToMap(), req.ToFileMap())
|
||||
var respStruct = response.TaobaoTmcUserCancelResponse{}
|
||||
if err != nil {
|
||||
log.Println("taobaoTmcUserCancel error", err)
|
||||
return &respStruct, err
|
||||
}
|
||||
err = util.HandleJsonResponse(jsonStr, &respStruct)
|
||||
if respStruct.Body == "" || len(respStruct.Body) == 0 {
|
||||
respStruct.Body = jsonStr
|
||||
}
|
||||
return &respStruct, err
|
||||
}
|
||||
|
||||
/*
|
||||
为已授权的用户开通消息服务
|
||||
*/
|
||||
func (ability *Defaultability) TaobaoTmcUserPermit(req *request.TaobaoTmcUserPermitRequest, session string) (*response.TaobaoTmcUserPermitResponse, error) {
|
||||
if ability.Client == nil {
|
||||
return nil, errors.New("Defaultability topClient is nil")
|
||||
}
|
||||
var jsonStr, err = ability.Client.ExecuteWithSession("taobao.tmc.user.permit", req.ToMap(), req.ToFileMap(), session)
|
||||
var respStruct = response.TaobaoTmcUserPermitResponse{}
|
||||
if err != nil {
|
||||
log.Println("taobaoTmcUserPermit error", err)
|
||||
return &respStruct, err
|
||||
}
|
||||
err = util.HandleJsonResponse(jsonStr, &respStruct)
|
||||
if respStruct.Body == "" || len(respStruct.Body) == 0 {
|
||||
respStruct.Body = jsonStr
|
||||
}
|
||||
return &respStruct, err
|
||||
}
|
|
@ -0,0 +1,32 @@
|
|||
package domain
|
||||
|
||||
type TaobaoKfcKeywordSearchKfcSearchResult struct {
|
||||
/*
|
||||
是否匹配到关键词,匹配到则为true. */
|
||||
Matched *bool `json:"matched,omitempty" `
|
||||
|
||||
/*
|
||||
匹配到的关键词的等级,值为null,或为A、B、C、D。
|
||||
当匹配不到关键词时,值为null,否则值为A、B、C、D中的一个。
|
||||
A、B、C、D等级按严重程度从高至低排列。 */
|
||||
Level *string `json:"level,omitempty" `
|
||||
|
||||
/*
|
||||
过滤后的文本:
|
||||
当匹配到B等级的词时,文本中的关键词被替换为*号,content即为关键词替换后的文本;
|
||||
其他情况,content始终为null */
|
||||
Content *string `json:"content,omitempty" `
|
||||
}
|
||||
|
||||
func (s *TaobaoKfcKeywordSearchKfcSearchResult) SetMatched(v bool) *TaobaoKfcKeywordSearchKfcSearchResult {
|
||||
s.Matched = &v
|
||||
return s
|
||||
}
|
||||
func (s *TaobaoKfcKeywordSearchKfcSearchResult) SetLevel(v string) *TaobaoKfcKeywordSearchKfcSearchResult {
|
||||
s.Level = &v
|
||||
return s
|
||||
}
|
||||
func (s *TaobaoKfcKeywordSearchKfcSearchResult) SetContent(v string) *TaobaoKfcKeywordSearchKfcSearchResult {
|
||||
s.Content = &v
|
||||
return s
|
||||
}
|
|
@ -0,0 +1,72 @@
|
|||
package domain
|
||||
|
||||
import (
|
||||
"topsdk/util"
|
||||
)
|
||||
|
||||
type TaobaoTmcUserGetTmcUser struct {
|
||||
/*
|
||||
用户首次开通时间 */
|
||||
Created *util.LocalTime `json:"created,omitempty" `
|
||||
|
||||
/*
|
||||
接收用户消息的组名 */
|
||||
GroupName *string `json:"group_name,omitempty" `
|
||||
|
||||
/*
|
||||
用户授权是否有效,true表示授权有效,false表示授权过期 */
|
||||
IsValid *bool `json:"is_valid,omitempty" `
|
||||
|
||||
/*
|
||||
用户最后开通时间 */
|
||||
Modified *util.LocalTime `json:"modified,omitempty" `
|
||||
|
||||
/*
|
||||
用户开通的消息类型列表。如果为空表示应用开通的所有类型 */
|
||||
Topics *[]string `json:"topics,omitempty" `
|
||||
|
||||
/*
|
||||
用户ID */
|
||||
UserId *int64 `json:"user_id,omitempty" `
|
||||
|
||||
/*
|
||||
用户昵称 */
|
||||
UserNick *string `json:"user_nick,omitempty" `
|
||||
|
||||
/*
|
||||
用户所属的平台类型,tbUIC:淘宝用户; icbu: icbu用户 */
|
||||
UserPlatform *string `json:"user_platform,omitempty" `
|
||||
}
|
||||
|
||||
func (s *TaobaoTmcUserGetTmcUser) SetCreated(v util.LocalTime) *TaobaoTmcUserGetTmcUser {
|
||||
s.Created = &v
|
||||
return s
|
||||
}
|
||||
func (s *TaobaoTmcUserGetTmcUser) SetGroupName(v string) *TaobaoTmcUserGetTmcUser {
|
||||
s.GroupName = &v
|
||||
return s
|
||||
}
|
||||
func (s *TaobaoTmcUserGetTmcUser) SetIsValid(v bool) *TaobaoTmcUserGetTmcUser {
|
||||
s.IsValid = &v
|
||||
return s
|
||||
}
|
||||
func (s *TaobaoTmcUserGetTmcUser) SetModified(v util.LocalTime) *TaobaoTmcUserGetTmcUser {
|
||||
s.Modified = &v
|
||||
return s
|
||||
}
|
||||
func (s *TaobaoTmcUserGetTmcUser) SetTopics(v []string) *TaobaoTmcUserGetTmcUser {
|
||||
s.Topics = &v
|
||||
return s
|
||||
}
|
||||
func (s *TaobaoTmcUserGetTmcUser) SetUserId(v int64) *TaobaoTmcUserGetTmcUser {
|
||||
s.UserId = &v
|
||||
return s
|
||||
}
|
||||
func (s *TaobaoTmcUserGetTmcUser) SetUserNick(v string) *TaobaoTmcUserGetTmcUser {
|
||||
s.UserNick = &v
|
||||
return s
|
||||
}
|
||||
func (s *TaobaoTmcUserGetTmcUser) SetUserPlatform(v string) *TaobaoTmcUserGetTmcUser {
|
||||
s.UserPlatform = &v
|
||||
return s
|
||||
}
|
|
@ -0,0 +1,50 @@
|
|||
package request
|
||||
|
||||
type TaobaoKfcKeywordSearchRequest struct {
|
||||
/*
|
||||
发布信息的淘宝会员名,可以不传 */
|
||||
Nick *string `json:"nick,omitempty" required:"false" `
|
||||
/*
|
||||
应用点,分为一级应用点、二级应用点。其中一级应用点通常是指某一个系统或产品,比如淘宝的商品应用(taobao_auction);二级应用点,是指一级应用点下的具体的分类,比如商品标题(title)、商品描述(content)。不同的二级应用可以设置不同关键词。
|
||||
|
||||
这里的apply参数是由一级应用点与二级应用点合起来的字符(一级应用点+"."+二级应用点),如taobao_auction.title。
|
||||
|
||||
|
||||
通常apply参数是不需要传递的。如有特殊需求(比如特殊的过滤需求,需要自己维护一套自己词库),需传递此参数。 */
|
||||
Apply *string `json:"apply,omitempty" required:"false" `
|
||||
/*
|
||||
需要过滤的文本信息 */
|
||||
Content *string `json:"content" required:"true" `
|
||||
}
|
||||
|
||||
func (s *TaobaoKfcKeywordSearchRequest) SetNick(v string) *TaobaoKfcKeywordSearchRequest {
|
||||
s.Nick = &v
|
||||
return s
|
||||
}
|
||||
func (s *TaobaoKfcKeywordSearchRequest) SetApply(v string) *TaobaoKfcKeywordSearchRequest {
|
||||
s.Apply = &v
|
||||
return s
|
||||
}
|
||||
func (s *TaobaoKfcKeywordSearchRequest) SetContent(v string) *TaobaoKfcKeywordSearchRequest {
|
||||
s.Content = &v
|
||||
return s
|
||||
}
|
||||
|
||||
func (req *TaobaoKfcKeywordSearchRequest) ToMap() map[string]interface{} {
|
||||
paramMap := make(map[string]interface{})
|
||||
if req.Nick != nil {
|
||||
paramMap["nick"] = *req.Nick
|
||||
}
|
||||
if req.Apply != nil {
|
||||
paramMap["apply"] = *req.Apply
|
||||
}
|
||||
if req.Content != nil {
|
||||
paramMap["content"] = *req.Content
|
||||
}
|
||||
return paramMap
|
||||
}
|
||||
|
||||
func (req *TaobaoKfcKeywordSearchRequest) ToFileMap() map[string]interface{} {
|
||||
fileMap := make(map[string]interface{})
|
||||
return fileMap
|
||||
}
|
|
@ -0,0 +1,139 @@
|
|||
package request
|
||||
|
||||
import (
|
||||
"topsdk/util"
|
||||
)
|
||||
|
||||
type TaobaoTmcMessageProduceRequest struct {
|
||||
/*
|
||||
消息内容的JSON表述,必须按照topic的定义来填充 */
|
||||
Content *string `json:"content" required:"true" `
|
||||
/*
|
||||
消息的扩增属性,用json格式表示 */
|
||||
ExContent *string `json:"ex_content,omitempty" required:"false" `
|
||||
/*
|
||||
直发消息需要传入目标appkey */
|
||||
TargetAppkey *string `json:"target_appkey,omitempty" required:"false" `
|
||||
/*
|
||||
目标分组,一般为default defalutValue<EFBFBD><EFBFBD>default */
|
||||
TargetGroup *string `json:"target_group,omitempty" required:"false" `
|
||||
/*
|
||||
消息类型 */
|
||||
Topic *string `json:"topic" required:"true" `
|
||||
/*
|
||||
回传的文件内容,目前仅支持jpg,png,bmp,gif,pdf类型的文件,文件最大1M。只有消息中有byte[]类型的数据时,才需要传此字段; 否则不需要传此字段。 */
|
||||
MediaContent *[]byte `json:"media_content,omitempty" required:"false" `
|
||||
/*
|
||||
回传的文件内容,目前仅支持jpg,png,bmp,gif,pdf类型的文件,文件最大1M。只有消息中有byte[]类型的数据时,才需要传此字段; 否则不需要传此字段。具体对应到沙体中的什么值,请参考消息字段说明。 */
|
||||
MediaContent2 *[]byte `json:"media_content2,omitempty" required:"false" `
|
||||
/*
|
||||
回传的文件内容,目前仅支持jpg,png,bmp,gif,pdf类型的文件,文件最大1M。只有消息中有byte[]类型的数据时,才需要传此字段; 否则不需要传此字段。具体对应到沙体中的什么值,请参考消息字段说明。 */
|
||||
MediaContent3 *[]byte `json:"media_content3,omitempty" required:"false" `
|
||||
/*
|
||||
回传的文件内容,目前仅支持jpg,png,bmp,gif,pdf类型的文件,文件最大1M。只有消息中有byte[]类型的数据时,才需要传此字段; 否则不需要传此字段。具体对应到沙体中的什么值,请参考消息字段说明。 */
|
||||
MediaContent5 *[]byte `json:"media_content5,omitempty" required:"false" `
|
||||
/*
|
||||
回传的文件内容,目前仅支持jpg,png,bmp,gif,pdf类型的文件,文件最大1M。只有消息中有byte[]类型的数据时,才需要传此字段; 否则不需要传此字段。具体对应到沙体中的什么值,请参考消息字段说明。 */
|
||||
MediaContent4 *[]byte `json:"media_content4,omitempty" required:"false" `
|
||||
/*
|
||||
延时参数 时间戳 预期发送时间 defalutValue<EFBFBD><EFBFBD>0 */
|
||||
DelayMillis *int64 `json:"delay_millis,omitempty" required:"false" `
|
||||
/*
|
||||
提前过期 相对时间差 毫秒 defalutValue<EFBFBD><EFBFBD>0 */
|
||||
ExpiresMillis *int64 `json:"expires_millis,omitempty" required:"false" `
|
||||
}
|
||||
|
||||
func (s *TaobaoTmcMessageProduceRequest) SetContent(v string) *TaobaoTmcMessageProduceRequest {
|
||||
s.Content = &v
|
||||
return s
|
||||
}
|
||||
func (s *TaobaoTmcMessageProduceRequest) SetExContent(v string) *TaobaoTmcMessageProduceRequest {
|
||||
s.ExContent = &v
|
||||
return s
|
||||
}
|
||||
func (s *TaobaoTmcMessageProduceRequest) SetTargetAppkey(v string) *TaobaoTmcMessageProduceRequest {
|
||||
s.TargetAppkey = &v
|
||||
return s
|
||||
}
|
||||
func (s *TaobaoTmcMessageProduceRequest) SetTargetGroup(v string) *TaobaoTmcMessageProduceRequest {
|
||||
s.TargetGroup = &v
|
||||
return s
|
||||
}
|
||||
func (s *TaobaoTmcMessageProduceRequest) SetTopic(v string) *TaobaoTmcMessageProduceRequest {
|
||||
s.Topic = &v
|
||||
return s
|
||||
}
|
||||
func (s *TaobaoTmcMessageProduceRequest) SetMediaContent(v []byte) *TaobaoTmcMessageProduceRequest {
|
||||
s.MediaContent = &v
|
||||
return s
|
||||
}
|
||||
func (s *TaobaoTmcMessageProduceRequest) SetMediaContent2(v []byte) *TaobaoTmcMessageProduceRequest {
|
||||
s.MediaContent2 = &v
|
||||
return s
|
||||
}
|
||||
func (s *TaobaoTmcMessageProduceRequest) SetMediaContent3(v []byte) *TaobaoTmcMessageProduceRequest {
|
||||
s.MediaContent3 = &v
|
||||
return s
|
||||
}
|
||||
func (s *TaobaoTmcMessageProduceRequest) SetMediaContent5(v []byte) *TaobaoTmcMessageProduceRequest {
|
||||
s.MediaContent5 = &v
|
||||
return s
|
||||
}
|
||||
func (s *TaobaoTmcMessageProduceRequest) SetMediaContent4(v []byte) *TaobaoTmcMessageProduceRequest {
|
||||
s.MediaContent4 = &v
|
||||
return s
|
||||
}
|
||||
func (s *TaobaoTmcMessageProduceRequest) SetDelayMillis(v int64) *TaobaoTmcMessageProduceRequest {
|
||||
s.DelayMillis = &v
|
||||
return s
|
||||
}
|
||||
func (s *TaobaoTmcMessageProduceRequest) SetExpiresMillis(v int64) *TaobaoTmcMessageProduceRequest {
|
||||
s.ExpiresMillis = &v
|
||||
return s
|
||||
}
|
||||
|
||||
func (req *TaobaoTmcMessageProduceRequest) ToMap() map[string]interface{} {
|
||||
paramMap := make(map[string]interface{})
|
||||
if req.Content != nil {
|
||||
paramMap["content"] = *req.Content
|
||||
}
|
||||
if req.ExContent != nil {
|
||||
paramMap["ex_content"] = *req.ExContent
|
||||
}
|
||||
if req.TargetAppkey != nil {
|
||||
paramMap["target_appkey"] = *req.TargetAppkey
|
||||
}
|
||||
if req.TargetGroup != nil {
|
||||
paramMap["target_group"] = *req.TargetGroup
|
||||
}
|
||||
if req.Topic != nil {
|
||||
paramMap["topic"] = *req.Topic
|
||||
}
|
||||
if req.DelayMillis != nil {
|
||||
paramMap["delay_millis"] = *req.DelayMillis
|
||||
}
|
||||
if req.ExpiresMillis != nil {
|
||||
paramMap["expires_millis"] = *req.ExpiresMillis
|
||||
}
|
||||
return paramMap
|
||||
}
|
||||
|
||||
func (req *TaobaoTmcMessageProduceRequest) ToFileMap() map[string]interface{} {
|
||||
fileMap := make(map[string]interface{})
|
||||
if req.MediaContent != nil {
|
||||
fileMap["media_content"] = *req.MediaContent
|
||||
}
|
||||
if req.MediaContent2 != nil {
|
||||
fileMap["media_content2"] = *req.MediaContent2
|
||||
}
|
||||
if req.MediaContent3 != nil {
|
||||
fileMap["media_content3"] = *req.MediaContent3
|
||||
}
|
||||
if req.MediaContent5 != nil {
|
||||
fileMap["media_content5"] = *req.MediaContent5
|
||||
}
|
||||
if req.MediaContent4 != nil {
|
||||
fileMap["media_content4"] = *req.MediaContent4
|
||||
}
|
||||
return fileMap
|
||||
}
|
|
@ -0,0 +1,35 @@
|
|||
package request
|
||||
|
||||
type TaobaoTmcUserCancelRequest struct {
|
||||
/*
|
||||
用户昵称 */
|
||||
Nick *string `json:"nick" required:"true" `
|
||||
/*
|
||||
用户所属的平台类型,tbUIC:淘宝用户; icbu: icbu用户;ae:ae用户 defalutValue<EFBFBD><EFBFBD>tbUIC */
|
||||
UserPlatform *string `json:"user_platform,omitempty" required:"false" `
|
||||
}
|
||||
|
||||
func (s *TaobaoTmcUserCancelRequest) SetNick(v string) *TaobaoTmcUserCancelRequest {
|
||||
s.Nick = &v
|
||||
return s
|
||||
}
|
||||
func (s *TaobaoTmcUserCancelRequest) SetUserPlatform(v string) *TaobaoTmcUserCancelRequest {
|
||||
s.UserPlatform = &v
|
||||
return s
|
||||
}
|
||||
|
||||
func (req *TaobaoTmcUserCancelRequest) ToMap() map[string]interface{} {
|
||||
paramMap := make(map[string]interface{})
|
||||
if req.Nick != nil {
|
||||
paramMap["nick"] = *req.Nick
|
||||
}
|
||||
if req.UserPlatform != nil {
|
||||
paramMap["user_platform"] = *req.UserPlatform
|
||||
}
|
||||
return paramMap
|
||||
}
|
||||
|
||||
func (req *TaobaoTmcUserCancelRequest) ToFileMap() map[string]interface{} {
|
||||
fileMap := make(map[string]interface{})
|
||||
return fileMap
|
||||
}
|
|
@ -0,0 +1,49 @@
|
|||
package request
|
||||
|
||||
import (
|
||||
"topsdk/util"
|
||||
)
|
||||
|
||||
type TaobaoTmcUserGetRequest struct {
|
||||
/*
|
||||
需返回的字段列表,多个字段以半角逗号分隔。可选值:TmcUser结构体中的所有字段,一定要返回topic。 */
|
||||
Fields *[]string `json:"fields" required:"true" `
|
||||
/*
|
||||
用户昵称 */
|
||||
Nick *string `json:"nick" required:"true" `
|
||||
/*
|
||||
用户所属的平台类型,tbUIC:淘宝用户; icbu: icbu用户;ae:ae用户 defalutValue<EFBFBD><EFBFBD>tbUIC */
|
||||
UserPlatform *string `json:"user_platform,omitempty" required:"false" `
|
||||
}
|
||||
|
||||
func (s *TaobaoTmcUserGetRequest) SetFields(v []string) *TaobaoTmcUserGetRequest {
|
||||
s.Fields = &v
|
||||
return s
|
||||
}
|
||||
func (s *TaobaoTmcUserGetRequest) SetNick(v string) *TaobaoTmcUserGetRequest {
|
||||
s.Nick = &v
|
||||
return s
|
||||
}
|
||||
func (s *TaobaoTmcUserGetRequest) SetUserPlatform(v string) *TaobaoTmcUserGetRequest {
|
||||
s.UserPlatform = &v
|
||||
return s
|
||||
}
|
||||
|
||||
func (req *TaobaoTmcUserGetRequest) ToMap() map[string]interface{} {
|
||||
paramMap := make(map[string]interface{})
|
||||
if req.Fields != nil {
|
||||
paramMap["fields"] = util.ConvertBasicList(*req.Fields)
|
||||
}
|
||||
if req.Nick != nil {
|
||||
paramMap["nick"] = *req.Nick
|
||||
}
|
||||
if req.UserPlatform != nil {
|
||||
paramMap["user_platform"] = *req.UserPlatform
|
||||
}
|
||||
return paramMap
|
||||
}
|
||||
|
||||
func (req *TaobaoTmcUserGetRequest) ToFileMap() map[string]interface{} {
|
||||
fileMap := make(map[string]interface{})
|
||||
return fileMap
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
package request
|
||||
|
||||
import (
|
||||
"topsdk/util"
|
||||
)
|
||||
|
||||
type TaobaoTmcUserPermitRequest struct {
|
||||
/*
|
||||
消息主题列表,用半角逗号分隔。当用户订阅的topic是应用订阅的子集时才需要设置,不设置表示继承应用所订阅的所有topic,一般情况建议不要设置。 */
|
||||
Topics *[]string `json:"topics,omitempty" required:"false" `
|
||||
}
|
||||
|
||||
func (s *TaobaoTmcUserPermitRequest) SetTopics(v []string) *TaobaoTmcUserPermitRequest {
|
||||
s.Topics = &v
|
||||
return s
|
||||
}
|
||||
|
||||
func (req *TaobaoTmcUserPermitRequest) ToMap() map[string]interface{} {
|
||||
paramMap := make(map[string]interface{})
|
||||
if req.Topics != nil {
|
||||
paramMap["topics"] = util.ConvertBasicList(*req.Topics)
|
||||
}
|
||||
return paramMap
|
||||
}
|
||||
|
||||
func (req *TaobaoTmcUserPermitRequest) ToFileMap() map[string]interface{} {
|
||||
fileMap := make(map[string]interface{})
|
||||
return fileMap
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
package response
|
||||
|
||||
import (
|
||||
"topsdk/defaultability/domain"
|
||||
)
|
||||
|
||||
type TaobaoKfcKeywordSearchResponse struct {
|
||||
|
||||
/*
|
||||
System request id
|
||||
*/
|
||||
RequestId string `json:"request_id,omitempty" `
|
||||
|
||||
/*
|
||||
System body
|
||||
*/
|
||||
Body string
|
||||
|
||||
/*
|
||||
KFC 关键词过滤匹配结果
|
||||
*/
|
||||
KfcSearchResult domain.TaobaoKfcKeywordSearchKfcSearchResult `json:"kfc_search_result,omitempty" `
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
package response
|
||||
|
||||
import ()
|
||||
|
||||
type TaobaoTmcMessageProduceResponse struct {
|
||||
|
||||
/*
|
||||
System request id
|
||||
*/
|
||||
RequestId string `json:"request_id,omitempty" `
|
||||
|
||||
/*
|
||||
System body
|
||||
*/
|
||||
Body string
|
||||
|
||||
/*
|
||||
是否成功
|
||||
*/
|
||||
IsSuccess bool `json:"is_success,omitempty" `
|
||||
/*
|
||||
投递目标数
|
||||
*/
|
||||
Total int64 `json:"total,omitempty" `
|
||||
/*
|
||||
消息ID
|
||||
*/
|
||||
MsgIds []string `json:"msg_ids,omitempty" `
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
package response
|
||||
|
||||
import ()
|
||||
|
||||
type TaobaoTmcUserCancelResponse struct {
|
||||
|
||||
/*
|
||||
System request id
|
||||
*/
|
||||
RequestId string `json:"request_id,omitempty" `
|
||||
|
||||
/*
|
||||
System body
|
||||
*/
|
||||
Body string
|
||||
|
||||
/*
|
||||
是否成功,如果为false并且没有错误码,表示删除的用户不存在。
|
||||
*/
|
||||
IsSuccess bool `json:"is_success,omitempty" `
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
package response
|
||||
|
||||
import (
|
||||
"topsdk/defaultability/domain"
|
||||
)
|
||||
|
||||
type TaobaoTmcUserGetResponse struct {
|
||||
|
||||
/*
|
||||
System request id
|
||||
*/
|
||||
RequestId string `json:"request_id,omitempty" `
|
||||
|
||||
/*
|
||||
System body
|
||||
*/
|
||||
Body string
|
||||
|
||||
/*
|
||||
开通的用户数据
|
||||
*/
|
||||
TmcUser domain.TaobaoTmcUserGetTmcUser `json:"tmc_user,omitempty" `
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
package response
|
||||
|
||||
import ()
|
||||
|
||||
type TaobaoTmcUserPermitResponse struct {
|
||||
|
||||
/*
|
||||
System request id
|
||||
*/
|
||||
RequestId string `json:"request_id,omitempty" `
|
||||
|
||||
/*
|
||||
System body
|
||||
*/
|
||||
Body string
|
||||
|
||||
/*
|
||||
是否成功
|
||||
*/
|
||||
IsSuccess bool `json:"is_success,omitempty" `
|
||||
}
|
|
@ -0,0 +1,190 @@
|
|||
package topsdk
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"mime/multipart"
|
||||
"net"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"strings"
|
||||
"time"
|
||||
"topsdk/util"
|
||||
)
|
||||
|
||||
type TopClient struct {
|
||||
AppKey string
|
||||
AppSecret string
|
||||
ServerUrl string
|
||||
Format string
|
||||
SignMethod string
|
||||
ConnectTimeout int64
|
||||
ReadTimeout int64
|
||||
Version string
|
||||
Simplify bool
|
||||
httpClient *http.Client
|
||||
}
|
||||
type HttpTransportConfig struct {
|
||||
DialTimeout int64
|
||||
KeepAlive int64
|
||||
MaxIdleConns int
|
||||
MaxIdleConnsPerHost int
|
||||
IdleConnTimeout int64
|
||||
MaxConnsPerHost int
|
||||
}
|
||||
|
||||
func NewDefaultTopClient(AppKey string, AppSecret string, ServerUrl string, connectTimeount int64, readTimeout int64) TopClient {
|
||||
var httpTransportConfig = &HttpTransportConfig{
|
||||
DialTimeout: 30000,
|
||||
KeepAlive: 30000,
|
||||
MaxIdleConns: 100,
|
||||
MaxIdleConnsPerHost: 50,
|
||||
IdleConnTimeout: 30000,
|
||||
}
|
||||
return NewTopClientWithConfig(AppKey, AppSecret, ServerUrl, connectTimeount, readTimeout, httpTransportConfig)
|
||||
|
||||
}
|
||||
|
||||
func NewTopClientWithConfig(AppKey string, AppSecret string, ServerUrl string, connectTimeount int64, readTimeout int64, httpTransportConfig *HttpTransportConfig) TopClient {
|
||||
httpClient := http.Client{
|
||||
Timeout: time.Duration(connectTimeount) * time.Millisecond,
|
||||
Transport: &http.Transport{
|
||||
DialContext: (&net.Dialer{
|
||||
Timeout: time.Duration(httpTransportConfig.DialTimeout) * time.Millisecond,
|
||||
KeepAlive: time.Duration(httpTransportConfig.KeepAlive) * time.Millisecond,
|
||||
}).DialContext,
|
||||
ForceAttemptHTTP2: true,
|
||||
MaxIdleConns: httpTransportConfig.MaxIdleConns,
|
||||
MaxIdleConnsPerHost: httpTransportConfig.MaxIdleConnsPerHost,
|
||||
IdleConnTimeout: time.Duration(httpTransportConfig.IdleConnTimeout) * time.Millisecond,
|
||||
TLSHandshakeTimeout: 10 * time.Second,
|
||||
ExpectContinueTimeout: 1 * time.Second,
|
||||
},
|
||||
}
|
||||
return TopClient{
|
||||
AppKey: AppKey,
|
||||
AppSecret: AppSecret,
|
||||
ServerUrl: ServerUrl,
|
||||
Format: ApiFormat,
|
||||
SignMethod: SignMethod,
|
||||
ConnectTimeout: connectTimeount,
|
||||
ReadTimeout: readTimeout,
|
||||
Version: TopVersion,
|
||||
Simplify: true,
|
||||
httpClient: &httpClient,
|
||||
}
|
||||
}
|
||||
|
||||
func (client *TopClient) ExecuteWithSession(method string, data map[string]interface{}, fileData map[string]interface{}, session string) (string, error) {
|
||||
var publicParam = make(map[string]interface{})
|
||||
publicParam["method"] = method
|
||||
publicParam["app_key"] = client.AppKey
|
||||
publicParam["timestamp"] = time.Now().Format(DateFormat)
|
||||
publicParam["v"] = client.Version
|
||||
publicParam["sign_method"] = client.SignMethod
|
||||
publicParam["format"] = client.Format
|
||||
publicParam["simplify"] = client.Simplify
|
||||
publicParam["partner_id"] = SdkVersion
|
||||
if session != "" {
|
||||
publicParam["session"] = session
|
||||
}
|
||||
sign := util.GetSign(publicParam, data, client.AppSecret)
|
||||
// 构建url
|
||||
serverUrl, _ := url.Parse(client.ServerUrl)
|
||||
urlValues := url.Values{}
|
||||
urlValues.Add("sign", sign)
|
||||
for k, v := range publicParam {
|
||||
urlValues.Add(k, fmt.Sprint(v))
|
||||
}
|
||||
serverUrl.RawQuery = urlValues.Encode()
|
||||
urlPath := serverUrl.String()
|
||||
// 构建body
|
||||
if fileData != nil && len(fileData) > 0 {
|
||||
return doPostWithFile(urlPath, data, fileData, client.httpClient)
|
||||
} else {
|
||||
return doPost(urlPath, data, client.httpClient)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func doPost(urlPath string, data map[string]interface{}, httpClient *http.Client) (string, error) {
|
||||
bodyParam := url.Values{}
|
||||
for k, v := range data {
|
||||
bodyParam.Add(k, fmt.Sprint(v))
|
||||
}
|
||||
resp, err := httpClient.Post(urlPath, "application/x-www-form-urlencoded", strings.NewReader(bodyParam.Encode()))
|
||||
if resp != nil {
|
||||
defer resp.Body.Close()
|
||||
}
|
||||
if err != nil {
|
||||
log.Println("http.PostForm error", err)
|
||||
return "", err
|
||||
}
|
||||
body, err := ioutil.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
log.Println("ioutil.ReadAll", err)
|
||||
return "", err
|
||||
}
|
||||
return string(body), nil
|
||||
}
|
||||
|
||||
func doPostWithFile(urlPath string, data map[string]interface{}, fileData map[string]interface{}, httpClient *http.Client) (string, error) {
|
||||
bodyBuf := &bytes.Buffer{}
|
||||
writer := multipart.NewWriter(bodyBuf)
|
||||
for k, v := range data {
|
||||
err := writer.WriteField(k, fmt.Sprint(v))
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
}
|
||||
for k, v := range fileData {
|
||||
value, ok := v.([]byte)
|
||||
if ok {
|
||||
fileWriter, err := writer.CreateFormFile(k, "file")
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
_, err = io.Copy(fileWriter, bytes.NewReader(value))
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
} else {
|
||||
value, ok := v.(*util.FileItem)
|
||||
if ok {
|
||||
fileWriter, err := writer.CreateFormFile(k, value.FileName)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
_, err = io.Copy(fileWriter, bytes.NewReader(value.Content))
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
err := writer.Close()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
resp, err := httpClient.Post(urlPath, writer.FormDataContentType(), bodyBuf)
|
||||
if err != nil {
|
||||
log.Println("http.PostForm error", err)
|
||||
return "", err
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
body, err := ioutil.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
log.Println("ioutil.ReadAll", err)
|
||||
return "", err
|
||||
}
|
||||
return string(body), nil
|
||||
}
|
||||
|
||||
func (client *TopClient) Execute(method string, data map[string]interface{}, fileData map[string]interface{}) (string, error) {
|
||||
return client.ExecuteWithSession(method, data, fileData, "")
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
package util
|
||||
|
||||
type FileItem struct {
|
||||
FileName string
|
||||
|
||||
Content []byte
|
||||
}
|
||||
|
||||
func (s *FileItem) SetFileName(v string) *FileItem {
|
||||
s.FileName = v
|
||||
return s
|
||||
}
|
||||
func (s *FileItem) SetContent(v []byte) *FileItem {
|
||||
s.Content = v
|
||||
return s
|
||||
}
|
||||
|
||||
func NewFileItem(fileName string, content []byte) *FileItem {
|
||||
return &FileItem{FileName: fileName, Content: content}
|
||||
}
|
|
@ -0,0 +1,34 @@
|
|||
package util
|
||||
|
||||
import "fmt"
|
||||
|
||||
type TopApiRequestError struct {
|
||||
/*
|
||||
System code
|
||||
*/
|
||||
TopCode int `json:"code,omitempty" `
|
||||
|
||||
/*
|
||||
System error message
|
||||
*/
|
||||
Msg string `json:"msg,omitempty" `
|
||||
|
||||
/*
|
||||
System sub code
|
||||
*/
|
||||
SubCode string `json:"sub_code,omitempty" `
|
||||
|
||||
/*
|
||||
System sub message
|
||||
*/
|
||||
SubMsg string `json:"sub_msg,omitempty" `
|
||||
|
||||
/*
|
||||
System request id
|
||||
*/
|
||||
RequestId string `json:"request_id,omitempty" `
|
||||
}
|
||||
|
||||
func (e *TopApiRequestError) Error() string {
|
||||
return fmt.Sprintf("code: %d, msg: %s, sub_code: %s, sub_msg: %s ,request_id: %s", e.TopCode, e.Msg, e.SubCode, e.SubMsg, e.RequestId)
|
||||
}
|
|
@ -0,0 +1,114 @@
|
|||
package util
|
||||
|
||||
import (
|
||||
"crypto/hmac"
|
||||
"crypto/sha256"
|
||||
"encoding/hex"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"sort"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
type LocalTime time.Time
|
||||
|
||||
const (
|
||||
TimeFormat = "2006-01-02 15:04:05"
|
||||
)
|
||||
|
||||
func (t *LocalTime) UnmarshalJSON(data []byte) (err error) {
|
||||
// 空值不进行解析
|
||||
if len(data) == 2 {
|
||||
*t = LocalTime(time.Time{})
|
||||
return
|
||||
}
|
||||
now, err := time.ParseInLocation(`"`+TimeFormat+`"`, string(data), time.Local)
|
||||
*t = LocalTime(now)
|
||||
return
|
||||
}
|
||||
|
||||
func (t LocalTime) MarshalJSON() ([]byte, error) {
|
||||
b := make([]byte, 0, len(TimeFormat)+2)
|
||||
b = append(b, '"')
|
||||
b = time.Time(t).AppendFormat(b, TimeFormat)
|
||||
b = append(b, '"')
|
||||
return b, nil
|
||||
}
|
||||
|
||||
func (t LocalTime) String() string {
|
||||
return time.Time(t).Format(TimeFormat)
|
||||
}
|
||||
|
||||
func UnmarshalJSON(data []byte, v interface{}) (err error) {
|
||||
return json.Unmarshal(data, v)
|
||||
}
|
||||
|
||||
func ConvertStructList(data interface{}) string {
|
||||
if data == nil {
|
||||
return "[]"
|
||||
}
|
||||
jsonStr, _ := json.Marshal(data)
|
||||
return string(jsonStr)
|
||||
}
|
||||
|
||||
func ConvertStruct(data interface{}) string {
|
||||
if data == nil {
|
||||
return "{}"
|
||||
}
|
||||
jsonStr, _ := json.Marshal(data)
|
||||
return string(jsonStr)
|
||||
}
|
||||
|
||||
func ConvertBasicList(data interface{}) string {
|
||||
if data == nil {
|
||||
return "[]"
|
||||
}
|
||||
return strings.Replace(strings.Trim(fmt.Sprint(data), "[]"), " ", ",", -1)
|
||||
}
|
||||
|
||||
func HandleJsonResponse(jsonStr string, v interface{}) (err error) {
|
||||
|
||||
if strings.Contains(jsonStr[0:20], "error_response") {
|
||||
err := &TopApiRequestError{}
|
||||
jsonStr = jsonStr[18 : len(jsonStr)-1]
|
||||
err2 := json.Unmarshal([]byte(jsonStr), err)
|
||||
if err2 != nil {
|
||||
return err2
|
||||
}
|
||||
return err
|
||||
}
|
||||
return json.Unmarshal([]byte(jsonStr), v)
|
||||
}
|
||||
|
||||
func GetSign(publicParam map[string]interface{}, data map[string]interface{}, secret string) string {
|
||||
var allParamMap = make(map[string]interface{})
|
||||
for k, v := range data {
|
||||
allParamMap[k] = v
|
||||
}
|
||||
for k, v := range publicParam {
|
||||
allParamMap[k] = v
|
||||
}
|
||||
var keyList []string
|
||||
for k := range allParamMap {
|
||||
keyList = append(keyList, k)
|
||||
}
|
||||
sort.Strings(keyList)
|
||||
var signStr = ""
|
||||
for _, key := range keyList {
|
||||
value := allParamMap[key]
|
||||
signStr = signStr + fmt.Sprintf("%v%v", key, value)
|
||||
//if(value != ""){
|
||||
// signStr = signStr + fmt.Sprintf("%v%v", key, value)
|
||||
//}
|
||||
}
|
||||
fmt.Println(signStr)
|
||||
sign := strings.ToUpper(HmacSha256(signStr, secret))
|
||||
return sign
|
||||
}
|
||||
|
||||
func HmacSha256(data string, secret string) string {
|
||||
h := hmac.New(sha256.New, []byte(secret))
|
||||
h.Write([]byte(data))
|
||||
return hex.EncodeToString(h.Sum(nil))
|
||||
}
|
Loading…
Reference in New Issue