1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
16
17
18
19 package swarm
20
21 type user struct {
22 Id string
23 FirstName string
24 LastName string
25 Photo photoItem
26 }
27
28 type userInfo struct {
29 Response struct {
30 User user
31 }
32 }
33
34 type checkinsList struct {
35 Response struct {
36 Checkins struct {
37 Items []*checkinItem
38 }
39 }
40 }
41
42 type checkinItem struct {
43 Id string
44 CreatedAt int64
45 TimeZoneOffset int
46 Shout string
47 Venue venueItem
48 With []*user
49 }
50
51 type venueItem struct {
52 Id string
53 Name string
54 Location *venueLocationItem
55 Categories []*venueCategory
56 }
57
58 type photosList struct {
59 Response struct {
60 Photos struct {
61 Items []*photoItem
62 }
63 }
64 }
65
66 type photoItem struct {
67 Id string
68 Prefix string
69 Suffix string
70 Width int
71 Height int
72 }
73
74 func (vi *venueItem) primaryCategory() *venueCategory {
75 for _, c := range vi.Categories {
76 if c.Primary {
77 return c
78 }
79 }
80 return nil
81 }
82
83 func (vi *venueItem) icon() string {
84 c := vi.primaryCategory()
85 if c == nil || c.Icon == nil || c.Icon.Prefix == "" {
86 return ""
87 }
88 return c.Icon.Prefix + "bg_88" + c.Icon.Suffix
89 }
90
91 func (user *user) icon() string {
92 if user.Photo.Prefix == "" || user.Photo.Suffix == "" {
93 return ""
94 }
95 return user.Photo.Prefix + "500x500" + user.Photo.Suffix
96 }
97
98 type venueLocationItem struct {
99 Address string
100 City string
101 PostalCode string
102 State string
103 Country string
104 Lat float64
105 Lng float64
106 }
107
108 type venueCategory struct {
109 Primary bool
110 Name string
111 Icon *categoryIcon
112 }
113
114 type categoryIcon struct {
115 Prefix string
116 Suffix string
117 }