-
Notifications
You must be signed in to change notification settings - Fork 0
/
overdue_balance.go
46 lines (36 loc) · 1.13 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
package lago
import (
"context"
"net/url"
"strconv"
)
type OverdueBalanceListInput struct {
AmountCurrency string `json:"currency,omitempty"`
ExternalCustomerId string `json:"external_customer_id,omitempty"`
Months int `json:"months,omitempty,string"`
}
func (i *OverdueBalanceListInput) query() url.Values {
q := make(url.Values)
if i.AmountCurrency != "" {
q.Add("currency", i.AmountCurrency)
}
if i.ExternalCustomerId != "" {
q.Add("external_customer_id", i.ExternalCustomerId)
}
if i.Months > 0 {
q.Add("months", strconv.Itoa(i.Months))
}
return q
}
type OverdueBalanceList struct {
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) ListOverdueBalances(ctx context.Context, OverdueBalanceListInput *OverdueBalanceListInput) (*OverdueBalanceList, error) {
u := c.url("analytics/overdue_balance", OverdueBalanceListInput.query())
return get[OverdueBalanceList](ctx, c, u)
}