-
Notifications
You must be signed in to change notification settings - Fork 0
/
event_archive.go
40 lines (32 loc) · 1.11 KB
/
event_archive.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
package groovecoaster
import "fmt"
// PlayerEventDetail is the structure that represents player's awards and scores
type PlayerEventDetail struct {
Awards *Awards `json:"award_data"`
EventPoint int `json:"event_point,string"`
HighScore int `json:"high_score"`
Rank int
}
// EventDetail is the structure that represents the event result by event id
type EventDetail struct {
Player *PlayerEventDetail `json:"user_event_data"`
OpenDate string `json:"open_date"`
CloseDate string `json:"close_date"`
Title string `json:"title_name"`
}
// EventArchive fetches a event archive detail by event id
func (c *APIClient) EventArchive(eventID int) (*EventDetail, error) {
const uri = "mypage.groovecoaster.jp/sp/json/event_data.php?event_id=%d&old_flag=true"
data, err := c.get(fmt.Sprintf(uri, eventID))
if err != nil {
return nil, err
}
var ed struct {
EventDetail *EventDetail `json:"event_data"`
}
c.unmarshal(data, &ed)
if ed.EventDetail == nil {
return nil, fmt.Errorf("invalid JSON structure: EventArchive()")
}
return ed.EventDetail, nil
}