-
Notifications
You must be signed in to change notification settings - Fork 0
/
shop_messages.go
58 lines (49 loc) · 1.24 KB
/
shop_messages.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
package groovecoaster
import "fmt"
// Messages is the structure that represents shop sales info about messages
type Messages struct {
GC int `json:",string"`
ID int
Name string
New StringToBool
ProductID string `json:"product_id"`
}
// ShopMessages is the structure that is a set of each categories
type ShopMessages struct {
Communication []*Messages
AA []*Messages
Item []*Messages
Music []*Messages
Character []*Messages
}
// ShopMessages fetches all musics in shop
func (c *APIClient) ShopMessages() (*ShopMessages, error) {
type shopMessages struct {
ShopMessages []*Messages `json:"product_list"`
}
const uri = "mypage.groovecoaster.jp/sp/#/sp_me/%d"
const (
Communication = iota
AA
Item
Music
Character
)
var sm ShopMessages
var messages = make([][]*Messages, 5)
for i := Communication; i <= Character; i++ {
var message *shopMessages
data, err := c.get(fmt.Sprintf(uri, i+1))
if err != nil {
return nil, err
}
c.unmarshal(data, &message)
messages[i] = message.ShopMessages
}
sm.Communication = messages[Communication]
sm.AA = messages[AA]
sm.Character = messages[Character]
sm.Item = messages[Item]
sm.Music = messages[Music]
return &sm, nil
}