-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathstyle.go
78 lines (70 loc) · 1.62 KB
/
style.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
package brewerydb
import (
"fmt"
"net/http"
)
// StyleService provides access to the BreweryDB Style API. Use Client.Style.
//
// See: http://www.brewerydb.com/developers/docs-endpoint/style_index
type StyleService struct {
c *Client
}
// Style represents a style of Beer.
type Style struct {
ID int
Name string
ShortName string
Description string
CategoryID int
Category Category
IbuMin string
IbuMax string
SrmMin string
SrmMax string
OgMin string
OgMax string
FgMin string
FgMax string
AbvMin string
AbvMax string
CreateDate string
UpdateDate string
}
// StyleList represents a single "page" containing a slice of Styles.
type StyleList struct {
CurrentPage int
NumberOfPages int
TotalResults int
Styles []Style `json:"data"`
}
// List returns all Styles on the given page.
//
// See: http://www.brewerydb.com/developers/docs-endpoint/style_index#1
func (ss *StyleService) List(page int) (sl StyleList, err error) {
// GET: /styles
var req *http.Request
req, err = ss.c.NewRequest("GET", "/styles", &Page{page})
if err != nil {
return
}
err = ss.c.Do(req, &sl)
return
}
// Get obtains the Style with the given Style ID.
//
// See: http://www.brewerydb.com/developers/docs-endpoint/style_index#2
func (ss *StyleService) Get(id int) (s Style, err error) {
// GET: /style/:styleID
var req *http.Request
req, err = ss.c.NewRequest("GET", fmt.Sprintf("/style/%d", id), nil)
if err != nil {
return
}
resp := struct {
Status string
Data Style
Message string
}{}
err = ss.c.Do(req, &resp)
return resp.Data, err
}