Skip to content

Commit 1cc3684

Browse files
Jusabe Guedesdojusa
authored andcommitted
feat: add missing filters when listing charges
1 parent 6ec2827 commit 1cc3684

File tree

1 file changed

+39
-5
lines changed

1 file changed

+39
-5
lines changed

client_charges_list.go

Lines changed: 39 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,34 @@ import (
44
"context"
55
"net/url"
66
"strconv"
7+
"time"
78
)
89

910
// ListChargesRequest is the request input to the [Client.ListCharges] method.
1011
type ListChargesRequest struct {
1112
PageFilters
12-
// TeamID allows to filter list of charges points by a team ID.
13-
TeamID *int64
14-
// ChargePointID allows to filter list of charges points by a charge point ID.
13+
14+
// Filter to retrieve charges with specified chargePointId.
1515
ChargePointID *int64
16+
17+
// Filter to retrieve charges with specified teamId.
18+
TeamID *int64
19+
20+
// Filter to retrieve charges with specified siteId.
21+
SiteID *int64
22+
23+
// Filter to retrieve charges by state.
24+
State *ChargeState
25+
26+
// Filter to retrieve charges by the charge authentication type, must be combined with chargeAuthId.
27+
ChargeAuthType *ChargeAuthType
28+
29+
// Filter to retrieve charges by the charge authentication ID, must be combined with chargeAuthType
30+
// Note: for type vehicleId, chargeAuthId must not include the VID: prefix.
31+
ChargeAuthID *string
32+
33+
// Filter to retrieve charges where createdAt >= fromDate.
34+
FromDate *time.Time
1635
}
1736

1837
// ListChargesResponse is the response output from the [Client.ListCharges] method.
@@ -28,11 +47,26 @@ func (c *Client) ListCharges(ctx context.Context, request *ListChargesRequest) (
2847
path := "/v1/charges"
2948
query := url.Values{}
3049
request.PageFilters.Apply(query)
50+
if request.ChargePointID != nil {
51+
query.Set("chargePointId", strconv.Itoa(int(*request.ChargePointID)))
52+
}
3153
if request.TeamID != nil {
3254
query.Set("teamId", strconv.Itoa(int(*request.TeamID)))
3355
}
34-
if request.ChargePointID != nil {
35-
query.Set("chargePointId", strconv.Itoa(int(*request.ChargePointID)))
56+
if request.SiteID != nil {
57+
query.Set("siteId", strconv.Itoa(int(*request.SiteID)))
58+
}
59+
if request.State != nil {
60+
query.Set("state", string(*request.State))
61+
}
62+
if request.ChargeAuthType != nil {
63+
query.Set("chargeAuthType", string(*request.ChargeAuthType))
64+
}
65+
if request.ChargeAuthID != nil {
66+
query.Set("chargeAuthId", *request.ChargeAuthID)
67+
}
68+
if request.FromDate != nil {
69+
query.Set("fromDate", request.FromDate.UTC().Format(time.RFC3339))
3670
}
3771
return doGet[ListChargesResponse](ctx, c, path, query)
3872
}

0 commit comments

Comments
 (0)