-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathapi_service.go
68 lines (55 loc) · 1.58 KB
/
api_service.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
package sdk
import "encoding/json"
// RequestServiceWebhook :
type RequestServiceWebhook struct {
Function string `json:"function"`
Header struct {
ClientID string `json:"clientId"`
NotificationURLs []string `json:"notificationUrls"`
} `json:"header"`
Data interface{} `json:"data"`
}
// ResponseServiceWebhook :
type ResponseServiceWebhook struct {
Code string `json:"code"`
}
// RequestService :
type RequestService struct {
Service string `json:"service"`
Version string `json:"version"`
Function string `json:"function"`
Request interface{} `json:"request"`
}
// ResponseService :
type ResponseService struct {
Code string `json:"code"`
Item json.RawMessage `json:"item"`
Items json.RawMessage `json:"items"`
Err *Error `json:"error"`
}
// ServiceWebhook :
func (c Client) ServiceWebhook(request RequestServiceWebhook) (*ResponseServiceWebhook, error) {
if c.err != nil {
return nil, c.err
}
method := pathAPIServiceWebhookURL.method
requestURL := c.prepareAPIURL(pathAPIServiceWebhookURL)
response := new(ResponseServiceWebhook)
if err := c.httpAPI(method, requestURL, request, response); err != nil {
return nil, err
}
return response, nil
}
// RequestService :
func (c Client) RequestService(request RequestService) (*ResponseService, error) {
if c.err != nil {
return nil, c.err
}
method := pathAPIService.method
requestURL := c.prepareAPIURL(pathAPIService)
response := new(ResponseService)
if err := c.httpAPI(method, requestURL, request, response); err != nil {
return nil, err
}
return response, nil
}