-
Notifications
You must be signed in to change notification settings - Fork 1
/
fluidsize.go
74 lines (65 loc) · 1.58 KB
/
fluidsize.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
package brewerydb
import (
"fmt"
"net/http"
)
// FluidsizeService provides access to the BreweryDB Fluidsize API.
// Use Client.Fluidsize.
//
// See: http://www.brewerydb.com/developers/docs-endpoint/fluidsize_index
type FluidsizeService struct {
c *Client
}
// Volume represents a fluidsize volume.
type Volume string
// Pre-defined fluidsize Volumes.
const (
VolumeBarrel Volume = "barrel"
VolumePack = "pack"
VolumeOunce = "oz"
VolumeLiter = "liter"
)
// Fluidsize represents a Fluidsize assigned to a UPC code.
type Fluidsize struct {
ID int
Volume string
VolumeDisplay string
Quantity string
CreateDate string
}
// List returns a list of Fluidsizes.
//
// See: http://www.brewerydb.com/developers/docs-endpoint/fluidsize_index#1
func (fs *FluidsizeService) List() (fl []Fluidsize, err error) {
// GET: /fluidsizes
var req *http.Request
req, err = fs.c.NewRequest("GET", "/fluidsizes", nil)
if err != nil {
return
}
resp := struct {
Status string
Data []Fluidsize
Message string
}{}
err = fs.c.Do(req, &resp)
return resp.Data, err
}
// Get returns the Fluidsize with the given Fluidsize ID.
//
// See: http://www.brewerydb.com/developers/docs-endpoint/fluidsize_index#2
func (fs *FluidsizeService) Get(id int) (f Fluidsize, err error) {
// GET: /fluidsize/:fluidsizeId
var req *http.Request
req, err = fs.c.NewRequest("GET", fmt.Sprintf("/fluidsize/%d", id), nil)
if err != nil {
return
}
resp := struct {
Status string
Data Fluidsize
Message string
}{}
err = fs.c.Do(req, &resp)
return resp.Data, err
}