-
Notifications
You must be signed in to change notification settings - Fork 1
/
glass.go
63 lines (56 loc) · 1.27 KB
/
glass.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
package brewerydb
import (
"fmt"
"net/http"
)
// GlassService provides access to the BreweryDB Glassware API.
// Use Client.Glass.
//
// See: http://www.brewerydb.com/developers/docs-endpoint/glass_index
type GlassService struct {
c *Client
}
// Glass represents a Glass assigned to a UPC code.
type Glass struct {
ID int
Name string
Description string
CreateDate string
UpdateDate string
}
// List returns a list of Glasses.
//
// See: http://www.brewerydb.com/developers/docs-endpoint/glass_index#1
func (gs *GlassService) List() (gl []Glass, err error) {
// GET: /glassware
var req *http.Request
req, err = gs.c.NewRequest("GET", "/glassware", nil)
if err != nil {
return
}
resp := struct {
Status string
Data []Glass
Message string
}{}
err = gs.c.Do(req, &resp)
return resp.Data, err
}
// Get returns the Glass with the given Glass ID.
//
// See: http://www.brewerydb.com/developers/docs-endpoint/glass_index#2
func (gs *GlassService) Get(id int) (g Glass, err error) {
// GET: /glass/:glassId
var req *http.Request
req, err = gs.c.NewRequest("GET", fmt.Sprintf("/glass/%d", id), nil)
if err != nil {
return
}
resp := struct {
Status string
Data Glass
Message string
}{}
err = gs.c.Do(req, &resp)
return resp.Data, err
}