-
Notifications
You must be signed in to change notification settings - Fork 3
/
getCustomerPoints.go
executable file
·47 lines (38 loc) · 1.38 KB
/
getCustomerPoints.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
46
47
package crm
import (
"github.com/XiBao/jos/api"
"github.com/XiBao/jos/sdk"
"github.com/XiBao/jos/sdk/request/crm"
)
type GetCustomerPointsRequest struct {
api.BaseRequest
CustomerPin string `json:"customer_pin,omitempty" codec:"customer_pin,omitempty"` //
}
type GetCustomerPointsResponse struct {
ErrorResp *api.ErrorResponnse `json:"error_response,omitempty" codec:"error_response,omitempty"`
Data *GetCustomerPointsData `json:"jingdong_pop_crm_getCustomerPoints_responce,omitempty" codec:"jingdong_pop_crm_getCustomerPoints_responce,omitempty"`
}
func (r GetCustomerPointsResponse) IsError() bool {
return r.ErrorResp != nil || r.Data == nil
}
func (r GetCustomerPointsResponse) Error() string {
if r.ErrorResp != nil {
return r.ErrorResp.Error()
}
return "no result data"
}
type GetCustomerPointsData struct {
Code string `json:"code,omitempty" codec:"code,omitempty"`
Result int64 `json:"getcustomerpoints_result,omitempty" codec:"getcustomerpoints_result,omitempty"`
}
func GetCustomerPoints(req *GetCustomerPointsRequest) (int64, error) {
client := sdk.NewClient(req.AnApiKey.Key, req.AnApiKey.Secret)
client.Debug = req.Debug
r := crm.NewGetCustomerPointsRequest()
r.SetCustomerPin(req.CustomerPin)
var response GetCustomerPointsResponse
if err := client.Execute(r.Request, req.Session, &response); err != nil {
return 0, err
}
return response.Data.Result, nil
}