-
Notifications
You must be signed in to change notification settings - Fork 0
/
sensors.go
40 lines (34 loc) · 932 Bytes
/
sensors.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
package openaq
import (
"context"
"fmt"
"net/url"
)
type SensorArgs struct {
BaseArgs BaseArgs
}
// QueryParams translates SensorArgs struct into url.Values
func (args SensorArgs) QueryParams() (url.Values, error) {
q := make(url.Values)
return q, nil
}
// GetSensors fetches all sensors of a given location
func (c *Client) GetLocationSensors(ctx context.Context, locationsID int64) (*SensorsResponse, error) {
path := fmt.Sprintf("locations/%d/sensors", locationsID)
resp := &SensorsResponse{}
err := c.request(ctx, "GET", path, nil, resp)
if err != nil {
return nil, err
}
return resp, nil
}
// GetSensor fetches a single Sensor by ID.
func (c *Client) GetSensor(ctx context.Context, SensorsID int64) (*SensorsResponse, error) {
path := fmt.Sprintf("/sensors/%d", SensorsID)
resp := &SensorsResponse{}
err := c.request(ctx, "GET", path, nil, resp)
if err != nil {
return nil, err
}
return resp, nil
}