179 lines
6.2 KiB
Go
179 lines
6.2 KiB
Go
package defaultability
|
|
|
|
import (
|
|
"errors"
|
|
"log"
|
|
"repository.lenntc.com/lenntc/third-platform-sdk/sdk/fliggysdk"
|
|
"repository.lenntc.com/lenntc/third-platform-sdk/sdk/fliggysdk/defaultability/request"
|
|
"repository.lenntc.com/lenntc/third-platform-sdk/sdk/fliggysdk/defaultability/response"
|
|
"repository.lenntc.com/lenntc/third-platform-sdk/sdk/fliggysdk/util"
|
|
)
|
|
|
|
type Defaultability struct {
|
|
Client *fliggysdk.TopClient
|
|
}
|
|
|
|
func NewDefaultability(client *fliggysdk.TopClient) *Defaultability {
|
|
return &Defaultability{client}
|
|
}
|
|
|
|
/*
|
|
飞猪CPS通用卡券发放接口
|
|
*/
|
|
func (ability *Defaultability) AlibabaFliggyCpsCouponOffer(req *request.AlibabaFliggyCpsCouponOfferRequest) (*response.AlibabaFliggyCpsCouponOfferResponse, error) {
|
|
if ability.Client == nil {
|
|
return nil, errors.New("Defaultability topClient is nil")
|
|
}
|
|
var jsonStr, err = ability.Client.Execute("alibaba.fliggy.cps.coupon.offer", req.ToMap(), req.ToFileMap())
|
|
var respStruct = response.AlibabaFliggyCpsCouponOfferResponse{}
|
|
if err != nil {
|
|
log.Println("alibabaFliggyCpsCouponOffer 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) 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
|
|
}
|
|
|
|
/*
|
|
飞猪CPS通用三方卡券发放接口
|
|
*/
|
|
func (ability *Defaultability) AlibabaFliggyCpsCouponIssue(req *request.AlibabaFliggyCpsCouponIssueRequest) (*response.AlibabaFliggyCpsCouponIssueResponse, error) {
|
|
if ability.Client == nil {
|
|
return nil, errors.New("Defaultability topClient is nil")
|
|
}
|
|
var jsonStr, err = ability.Client.Execute("alibaba.fliggy.cps.coupon.issue", req.ToMap(), req.ToFileMap())
|
|
var respStruct = response.AlibabaFliggyCpsCouponIssueResponse{}
|
|
if err != nil {
|
|
log.Println("alibabaFliggyCpsCouponIssue 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) AlibabaFliggyPromoteOrdersList(req *request.AlibabaFliggyPromoteOrdersListRequest) (*response.AlibabaFliggyPromoteOrdersListResponse, error) {
|
|
if ability.Client == nil {
|
|
return nil, errors.New("Defaultability topClient is nil")
|
|
}
|
|
var jsonStr, err = ability.Client.Execute("alibaba.fliggy.promote.orders.list", req.ToMap(), req.ToFileMap())
|
|
var respStruct = response.AlibabaFliggyPromoteOrdersListResponse{}
|
|
if err != nil {
|
|
log.Println("alibabaFliggyPromoteOrdersList error", err)
|
|
return &respStruct, err
|
|
}
|
|
err = util.HandleJsonResponse(jsonStr, &respStruct)
|
|
if respStruct.Body == "" || len(respStruct.Body) == 0 {
|
|
respStruct.Body = jsonStr
|
|
}
|
|
return &respStruct, err
|
|
}
|