-
Notifications
You must be signed in to change notification settings - Fork 0
/
shop.go
39 lines (31 loc) · 903 Bytes
/
shop.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
package groovecoaster
import "fmt"
// Sales is the structure that represents shop sales info
type Sales struct {
Avatar IntToBool `json:"avatar_sale"`
Item IntToBool `json:"item_sale"`
Message IntToBool `json:"message_sale"`
Music IntToBool `json:"music_sale"`
Skin IntToBool `json:"skin_sale"`
Sound IntToBool `json:"sound_sale"`
}
// Shop is the structure that contains sales info, whether is openning
type Shop struct {
Sales *Sales `json:"shop_data"`
IsOpen bool `json:"open_flg"`
Coin int `json:"current_coin"`
}
// ShopSummary fetches shop information
func (c *APIClient) ShopSummary() (*Shop, error) {
const uri = "mypage.groovecoaster.jp/sp/json/shop_sales_data.php"
data, err := c.get(uri)
if err != nil {
return nil, err
}
var s *Shop
c.unmarshal(data, &s)
if s.Sales == nil {
return nil, fmt.Errorf("Invalid JSON structure")
}
return s, nil
}