-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsocialsite.go
73 lines (65 loc) · 1.93 KB
/
socialsite.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
package brewerydb
import (
"fmt"
"net/http"
)
// SocialSiteService provides access to the BreweryDB Social Site API.
// Use Client.SocialSite.
//
// See: http://www.brewerydb.com/developers/docs-endpoint/socialsite_index
type SocialSiteService struct {
c *Client
}
// SocialSite represents a social media website.
type SocialSite struct {
ID int
Name string
Website string
CreateDate string
UpdateDate string
}
// SocialAccount represents a social media account/handle.
// TODO: it appears some SocialAccount responses include the SocialSite ("socialMedia") object as well.
// TODO: SocialAccount responses also return an object corresponding to the query (e.g. Beer, Event, Guild, etc.)
type SocialAccount struct {
ID int `url:"-"`
SocialMediaID int `url:"socialmediaId"`
SocialSite SocialSite `url:"-",json:"socialMedia"` // see TODO above
Handle string `url:"handle"`
}
// List returns a slice of all SocialSites in the BreweryDB.
//
// See: http://www.brewerydb.com/developers/docs-endpoint/socialsite_index#1
func (ss *SocialSiteService) List() (sl []SocialSite, err error) {
// GET: /socialsites
var req *http.Request
req, err = ss.c.NewRequest("GET", "/socialsites", nil)
if err != nil {
return
}
socialsitesResp := struct {
Status string
Data []SocialSite
Message string
}{}
err = ss.c.Do(req, &socialsitesResp)
return socialsitesResp.Data, err
}
// Get retrieves the SocialSite having the given ID.
//
// See: http://www.brewerydb.com/developers/docs-endpoint/socialsite_index#2
func (ss *SocialSiteService) Get(id int) (s SocialSite, err error) {
// GET: /socialsite/:socialsiteId
var req *http.Request
req, err = ss.c.NewRequest("GET", fmt.Sprintf("/socialsite/%d", id), nil)
if err != nil {
return
}
socialsiteResp := struct {
Status string
Data SocialSite
Message string
}{}
err = ss.c.Do(req, &socialsiteResp)
return socialsiteResp.Data, err
}