neero.*balanceService.Get   A
last analyzed

Complexity

Conditions 4

Size

Total Lines 17
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 4
eloc 11
nop 2
dl 0
loc 17
rs 9.85
c 0
b 0
f 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