-
Notifications
You must be signed in to change notification settings - Fork 17
/
overdue_balance.go
63 lines (51 loc) · 1.58 KB
/
overdue_balance.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
package lago
import (
"context"
"encoding/json"
)
type OverdueBalanceRequest struct {
client *Client
}
type OverdueBalanceListInput struct {
AmountCurrency string `json:"currency,omitempty"`
ExternalCustomerId string `json:"external_customer_id,omitempty"`
Months int `json:"months,omitempty,string"`
}
type OverdueBalanceResult struct {
OverdueBalance *OverdueBalance `json:"overdue_balance,omitempty"`
OverdueBalances []OverdueBalance `json:"overdue_balances,omitempty"`
}
type OverdueBalance struct {
Month string `json:"month,omitempty"`
AmountCents int `json:"amount_cents,omitempty"`
AmountCurrency Currency `json:"currency,omitempty"`
}
func (c *Client) OverdueBalance() *OverdueBalanceRequest {
return &OverdueBalanceRequest{
client: c,
}
}
func (adr *OverdueBalanceRequest) GetList(ctx context.Context, OverdueBalanceListInput *OverdueBalanceListInput) (*OverdueBalanceResult, *Error) {
jsonQueryparams, err := json.Marshal(OverdueBalanceListInput)
if err != nil {
return nil, &Error{Err: err}
}
queryParams := make(map[string]string)
if err = json.Unmarshal(jsonQueryparams, &queryParams); err != nil {
return nil, &Error{Err: err}
}
clientRequest := &ClientRequest{
Path: "analytics/overdue_balance",
QueryParams: queryParams,
Result: &OverdueBalanceResult{},
}
result, clientErr := adr.client.Get(ctx, clientRequest)
if clientErr != nil {
return nil, clientErr
}
OverdueBalanceResult, ok := result.(*OverdueBalanceResult)
if !ok {
return nil, &ErrorTypeAssert
}
return OverdueBalanceResult, nil
}