-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathclient_sites.go
34 lines (29 loc) · 941 Bytes
/
client_sites.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
package monta
import (
"context"
"fmt"
"net/url"
)
// ListSitesRequest is the request input to the [Client.ListSites] method.
type ListSitesRequest struct {
PageFilters
}
// ListSitesResponse is the response output from the [Client.ListSites] method.
type ListSitesResponse struct {
// Sites in the current page.
Sites []*Site `json:"data"`
// PageMeta with metadata about the current page.
PageMeta PageMeta `json:"meta"`
}
// ListSites to retrieve your (charge) sites.
func (c *clientImpl) ListSites(ctx context.Context, request *ListSitesRequest) (*ListSitesResponse, error) {
path := "/v1/sites"
query := url.Values{}
request.PageFilters.Apply(query)
return doGet[ListSitesResponse](ctx, c, path, query)
}
// GetSite to retrieve a single (charge) site.
func (c *clientImpl) GetSite(ctx context.Context, siteID int64) (*Site, error) {
path := fmt.Sprintf("/v1/sites/%d", siteID)
return doGet[Site](ctx, c, path, nil)
}