-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathquery.go
29 lines (24 loc) · 803 Bytes
/
query.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
package surflinef
import (
"github.com/google/go-querystring/query"
)
// Query is used to build Forecast query params.
// False, nil or empty values are ignored.
type Query struct {
Resources []string `url:"resources,comma,omitempty"`
Days int `url:"days,omitempty"`
GetAllSpots bool `url:"getAllSpots,omitempty"`
Aggregate bool `url:"aggregate,omitempty"`
Units string `url:"units,omitempty"`
FullAnalysis bool `url:"fullAnalysis,omitempty"`
ShowOptimal bool `url:"showOptimal,omitempty"`
Interpolate bool `url:"interpolate,omitempty"`
}
// QueryString builds a query string from a Query.
func (q *Query) QueryString() (string, error) {
values, err := query.Values(q)
if err != nil {
return "", err
}
return values.Encode(), nil
}