taskId
This commit is contained in:
parent
7fcd58e7f6
commit
e90c68f339
|
@ -42,6 +42,11 @@ type GetuiMessage struct {
|
||||||
Intent string
|
Intent string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type GetuiPushRsp struct {
|
||||||
|
TaskId string
|
||||||
|
Status string
|
||||||
|
}
|
||||||
|
|
||||||
type Getui struct {
|
type Getui struct {
|
||||||
config *GetuiConfig
|
config *GetuiConfig
|
||||||
token string
|
token string
|
||||||
|
@ -103,7 +108,7 @@ func (g *Getui) Token() string {
|
||||||
return g.token
|
return g.token
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *Getui) Push(req *GetuiMessage) error {
|
func (g *Getui) Push(req *GetuiMessage) (*GetuiPushRsp, error) {
|
||||||
reqUrl := fmt.Sprintf("https://restapi.getui.com/v2/%s/push/single/cid", g.config.AppId)
|
reqUrl := fmt.Sprintf("https://restapi.getui.com/v2/%s/push/single/cid", g.config.AppId)
|
||||||
|
|
||||||
params := make(map[string]interface{})
|
params := make(map[string]interface{})
|
||||||
|
@ -138,13 +143,26 @@ func (g *Getui) Push(req *GetuiMessage) error {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
reqBody, _ := json.Marshal(params)
|
reqBody, _ := json.Marshal(params)
|
||||||
_, err := util.HttpPostJson(reqUrl, map[string]string{"token": g.Token()}, reqBody)
|
rspBody, err := util.HttpPostJson(reqUrl, map[string]string{"token": g.Token()}, reqBody)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Errorf("goutil http post error :%s", err.Error())
|
log.Errorf("goutil http post error :%s", err.Error())
|
||||||
return err
|
return nil, err
|
||||||
|
}
|
||||||
|
data, err := g.getResult(rspBody)
|
||||||
|
if err != nil {
|
||||||
|
log.Errorf("get result[%s] error :%s", rspBody, err.Error())
|
||||||
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
rsp := new(GetuiPushRsp)
|
||||||
|
for taskId, task := range data {
|
||||||
|
rsp.TaskId = taskId
|
||||||
|
cidStatus := cast.ToStringMap(task)
|
||||||
|
for _, v := range cidStatus {
|
||||||
|
rsp.Status = cast.ToString(v)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return rsp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *Getui) GetUserStatus(cid string) (*GetuiStatus, error) {
|
func (g *Getui) GetUserStatus(cid string) (*GetuiStatus, error) {
|
||||||
|
|
Loading…
Reference in New Issue