-
Notifications
You must be signed in to change notification settings - Fork 0
/
owners.go
46 lines (40 loc) · 1.02 KB
/
owners.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 openaq
import (
"context"
"fmt"
"net/url"
)
type OwnersArgs struct {
BaseArgs BaseArgs
}
func (ownersArgs *OwnersArgs) Values(q url.Values) (url.Values, error) {
return q, nil
}
// QueryParams translates OwnerArgs struct into url.Values
func (args OwnersArgs) QueryParams() (url.Values, error) {
q := make(url.Values)
return q, nil
}
// GetOwners fetches all owners filtered by any params passed.
func (c *Client) GetOwners(ctx context.Context, args OwnersArgs) (*OwnersResponse, error) {
resp := &OwnersResponse{}
queryParams, err := args.QueryParams()
if err != nil {
return nil, err
}
err = c.request(ctx, "GET", "/owners", queryParams, resp)
if err != nil {
return nil, err
}
return resp, nil
}
// GetOwner fetches a single owner by ID.
func (c *Client) GetOwner(ctx context.Context, OwnersID int64) (*OwnersResponse, error) {
path := fmt.Sprintf("/owners/%d", OwnersID)
resp := &OwnersResponse{}
err := c.request(ctx, "GET", path, nil, resp)
if err != nil {
return nil, err
}
return resp, nil
}