-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathinvoiced_usage.go
63 lines (51 loc) · 1.53 KB
/
invoiced_usage.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 InvoicedUsageRequest struct {
client *Client
}
type InvoicedUsageListInput struct {
AmountCurrency string `json:"currency,omitempty"`
Months int `json:"months,omitempty,string"`
}
type InvoicedUsageResult struct {
InvoicedUsage *InvoicedUsage `json:"invoiced_usage,omitempty"`
InvoicedUsages []InvoicedUsage `json:"invoiced_usages,omitempty"`
}
type InvoicedUsage struct {
Month string `json:"month,omitempty"`
Code string `json:"code,omitempty"`
AmountCents int `json:"amount_cents,omitempty"`
AmountCurrency Currency `json:"currency,omitempty"`
}
func (c *Client) InvoicedUsage() *InvoicedUsageRequest {
return &InvoicedUsageRequest{
client: c,
}
}
func (adr *InvoicedUsageRequest) GetList(ctx context.Context, InvoicedUsageListInput *InvoicedUsageListInput) (*InvoicedUsageResult, *Error) {
jsonQueryparams, err := json.Marshal(InvoicedUsageListInput)
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/invoiced_usage",
QueryParams: queryParams,
Result: &InvoicedUsageResult{},
}
result, clientErr := adr.client.Get(ctx, clientRequest)
if clientErr != nil {
return nil, clientErr
}
InvoicedUsageResult, ok := result.(*InvoicedUsageResult)
if !ok {
return nil, &ErrorTypeAssert
}
return InvoicedUsageResult, nil
}