Merge branch 'master' of e.coding.net:rosydev/baseapi
This commit is contained in:
@@ -7,11 +7,14 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
IMStoreStatusOnLine = "ONLINE" // 门店im在线状态
|
IMStoreStatusOnLine = "ONLINE" // 门店im在线状态
|
||||||
IMStoreStatusBusy = "BUSY" // 忙碌状态
|
IMStoreStatusBusy = "BUSY" // 忙碌状态
|
||||||
IMType = "IM" // 业务类型,消息默认IM
|
IMType = "IM" // 业务类型,消息默认IM
|
||||||
SubTypeDef = "SEND_MESSAGE" // 子业务类型,发送消息。默认值:SEND_MESSAGE
|
IMTypeSendMsg = "SEND_MESSAGE" //
|
||||||
ReadIMType = "READ_MESSAGE"
|
IMTypeReadMsg = "READ_MESSAGE" //
|
||||||
|
IMTypeGetMedia = "GET_MEDIA_URL" //
|
||||||
|
|
||||||
|
DefaultUrlExpireTime = 86400 //s
|
||||||
|
|
||||||
//消息类型
|
//消息类型
|
||||||
ContentTypeNormal = 1 //普通文本信息
|
ContentTypeNormal = 1 //普通文本信息
|
||||||
@@ -53,6 +56,26 @@ func (a *API) BusinessSendMsg(param *BusinessSendMsgReq) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetMediaUrl 获取多媒体文件url
|
||||||
|
func (a *API) GetMediaUrl(platformShopId, mediaID string) (url string, err error) {
|
||||||
|
result, err := a.AccessAPI("im.get.media.url", map[string]interface{}{
|
||||||
|
"platformShopId": platformShopId,
|
||||||
|
"bizType": IMType,
|
||||||
|
"subBizType": IMTypeGetMedia,
|
||||||
|
"payload": map[string]interface{}{
|
||||||
|
"mediaId": mediaID,
|
||||||
|
"urlExpireTime": DefaultUrlExpireTime,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
if result.ErrNo != 0 {
|
||||||
|
return "", errors.New(result.Error)
|
||||||
|
}
|
||||||
|
return result.Data.(map[string]interface{})["url"].(string), nil
|
||||||
|
}
|
||||||
|
|
||||||
// GetStoreIMStatus 获取门店的im状态 1:开启,-1:关闭
|
// GetStoreIMStatus 获取门店的im状态 1:开启,-1:关闭
|
||||||
func (a *API) GetStoreIMStatus(platformShopId string) (string, error) {
|
func (a *API) GetStoreIMStatus(platformShopId string) (string, error) {
|
||||||
result, err := a.AccessAPI("im.getIMStatus", map[string]interface{}{"platformShopId": platformShopId})
|
result, err := a.AccessAPI("im.getIMStatus", map[string]interface{}{"platformShopId": platformShopId})
|
||||||
|
|||||||
@@ -5,6 +5,12 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func TestGetMediaUrl(t *testing.T) {
|
||||||
|
data, err := api.GetMediaUrl("1157916361", "$igHNA-kCpGpwZWcDAQTNBDgFzQlUBtoAI4QBpCErI2gCqszMIMLSLDBJb6QDzwAAAYuJvuhDBM4B-Y3tB88AAAACXUH2dAgACgQLzgAC08U")
|
||||||
|
fmt.Println(err)
|
||||||
|
fmt.Println(data)
|
||||||
|
}
|
||||||
|
|
||||||
func TestGetStoreImStatus(t *testing.T) {
|
func TestGetStoreImStatus(t *testing.T) {
|
||||||
data, err := api.GetStoreIMStatus("1157916361")
|
data, err := api.GetStoreIMStatus("1157916361")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -22,7 +28,7 @@ func TestSendMsg(t *testing.T) {
|
|||||||
err := api.BusinessSendMsg(&BusinessSendMsgReq{
|
err := api.BusinessSendMsg(&BusinessSendMsgReq{
|
||||||
PlatformShopId: "1157916361",
|
PlatformShopId: "1157916361",
|
||||||
BizType: IMType,
|
BizType: IMType,
|
||||||
SubBizType: SubTypeDef,
|
SubBizType: IMTypeSendMsg,
|
||||||
Payload: BusinessMsgPayload{
|
Payload: BusinessMsgPayload{
|
||||||
GroupId: "$2$13205337818$PNM",
|
GroupId: "$2$13205337818$PNM",
|
||||||
ReceiverIds: []string{"301157916361", "10154538612", "321921188187760"},
|
ReceiverIds: []string{"301157916361", "10154538612", "321921188187760"},
|
||||||
|
|||||||
Reference in New Issue
Block a user