Total Lines | 35 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | package client |
||
2 | |||
3 | import ( |
||
4 | "context" |
||
5 | "encoding/json" |
||
6 | "net/http" |
||
7 | ) |
||
8 | |||
9 | // accountService is the API client for the `/api/account/` endpoint |
||
10 | type accountService service |
||
11 | |||
12 | // Balance is used for the partner to get the Balance of his account |
||
13 | // |
||
14 | // API Docs: https://developer.afrikpay.com/documentation/account/agent/balance/v2/ |
||
15 | func (service *accountService) Balance(ctx context.Context) (map[string]interface{}, *Response, error) { |
||
16 | request, err := service.client.newRequest(ctx, http.MethodPost, "/api/account/agent/balance/v2/", map[string]string{ |
||
17 | "agentid": service.client.agentID, |
||
18 | "agentplatform": service.client.agentPlatform, |
||
19 | "hash": service.client.hash(service.client.agentID, service.client.apiKey), |
||
20 | }) |
||
21 | if err != nil { |
||
22 | return nil, nil, err |
||
23 | } |
||
24 | |||
25 | response, err := service.client.do(request) |
||
26 | if err != nil { |
||
27 | return nil, response, err |
||
28 | } |
||
29 | |||
30 | status := map[string]interface{}{} |
||
31 | if err = json.Unmarshal(*response.Body, &status); err != nil { |
||
32 | return nil, response, err |
||
33 | } |
||
34 | |||
35 | return status, response, nil |
||
36 | } |
||
37 |