| Total Lines | 31 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | package neero |
||
| 2 | |||
| 3 | import ( |
||
| 4 | "context" |
||
| 5 | "encoding/json" |
||
| 6 | "net/http" |
||
| 7 | ) |
||
| 8 | |||
| 9 | // balanceService is the API client for the `/payment-gateway/api/v1/balances/` endpoint |
||
| 10 | type balanceService service |
||
| 11 | |||
| 12 | // Get balance By Payment Method Id |
||
| 13 | // |
||
| 14 | // API Docs: https://app.theneo.io/neero/neero-payment-gateway/balances/get-balance-by-payment-method-id |
||
| 15 | func (service *balanceService) Get(ctx context.Context, paymentMethodID string) (*BalanceResponse, *Response, error) { |
||
| 16 | request, err := service.client.newRequest(ctx, http.MethodGet, "/payment-gateway/api/v1/balances/payment-method/"+paymentMethodID, nil) |
||
| 17 | if err != nil { |
||
| 18 | return nil, nil, err |
||
| 19 | } |
||
| 20 | |||
| 21 | response, err := service.client.do(request) |
||
| 22 | if err != nil { |
||
| 23 | return nil, response, err |
||
| 24 | } |
||
| 25 | |||
| 26 | balance := new(BalanceResponse) |
||
| 27 | if err = json.Unmarshal(*response.Body, balance); err != nil { |
||
| 28 | return nil, response, err |
||
| 29 | } |
||
| 30 | |||
| 31 | return balance, response, nil |
||
| 32 | } |
||
| 33 |