im.go
1.3 KB
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
package im
import (
"encoding/json"
)
//func init() {
// InitImClient(constant.IM_SERVICE_ADDRESS, constant.IM_APP_KEY, constant.IM_APP_SECRET)
//}
type RequestParam interface {
Format() map[string]string
GetPath() string
Valid() error
}
//接口
func CallCreate(v UserCreate) (*UserTokenResult, error) {
var result UserTokenResult
btData, err := DefaultImClient.Call(v)
if err != nil {
return nil, err
}
err = json.Unmarshal(btData, &result)
if err != nil {
return nil, err
}
return &result, nil
}
func CallRefreshToken(v UserRefreshToken) (*UserTokenResult, error) {
var result UserTokenResult
btData, err := DefaultImClient.Call(v)
if err != nil {
return nil, err
}
err = json.Unmarshal(btData, &result)
if err != nil {
return nil, err
}
return &result, nil
}
func CallUpdate(v UserUpdate) (*BaseResp, error) {
var result BaseResp
btData, err := DefaultImClient.Call(v)
if err != nil {
return nil, err
}
err = json.Unmarshal(btData, &result)
if err != nil {
return nil, err
}
return &result, nil
}
/*CheckIm */
type CheckImRequest struct {
UserId int64
ImId string
Uname string
Icon string
CustomerImId string
IsCreated bool
}
type CheckImResponse struct {
ImToken string //net im token
CsAccount int64 //客服id
}