-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapi.go
45 lines (36 loc) · 822 Bytes
/
api.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package gomeng
import "fmt"
const (
baseURL = "https://msgapi.umeng.com"
apiPush = "api/send"
apiBroadcast = "api/send"
)
type requestType string
const (
unicastRequest requestType = "unicast"
listcastRequest requestType = "listcast"
broadcastRequest requestType = "broadcast"
)
type ReturnState string
const (
SuccessState ReturnState = "SUCCESS"
FailState ReturnState = "FAIL"
)
type (
Data struct {
MessageID string `json:"msg_id"`
TaskID string `json:"task_id"`
ErrMessage string `json:"error_msg"`
ErrCode string `json:"error_code"`
}
ResponseMessage struct {
Ret ReturnState `json:"ret"`
Data `json:"data"`
}
)
func (rm *ResponseMessage) Error() error {
if rm.Ret == SuccessState {
return nil
}
return fmt.Errorf("error %s: %s", rm.ErrCode, rm.ErrMessage)
}