/
types.go
82 lines (75 loc) · 2.48 KB
/
types.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
74
75
76
77
78
79
80
81
82
package igdbapi
import (
"strconv"
"time"
)
// https://api-docs.igdb.com/#website-enums
const (
WebsiteOfficial = 1
WebsiteWikia = 2
WebsiteWikipedia = 3
WebsiteFacebook = 4
WebsiteTwitter = 5
WebsiteTwitch = 6
WebsiteInstagram = 8
WebsiteYoutube = 9
WebsiteIphone = 10
WebsiteIpad = 11
WebsiteAndroid = 12
WebsiteSteam = 13
WebsiteReddit = 14
WebsiteItch = 15
WebsiteEpicgames = 16
WebsiteGog = 17
)
type Game struct {
ID int `json:"id"`
Name string `json:"name"`
Summary string `json:"summary"`
FirstReleaseDate *UnixTime `json:"first_release_date"`
Url string `json:"url"`
/* present, but not using / vetted these yet
AggregatedRating int `json:"aggregated_rating"`
AggregatedRatingCount int `json:"aggregated_rating_count"`
Category int `json:"category"`
Cover *uint64 `json:"cover"`
CreatedAt int `json:"created_at"`
ExternalGames []int `json:"external_games"`
GameModes []int `json:"game_modes"`
Genres []int `json:"genres"`
InvolvedCompanies []int `json:"involved_companies"`
Platforms []int `json:"platforms"`
Popularity int `json:"popularity"`
PulseCount int `json:"pulse_count"`
Rating int `json:"rating"`
RatingCount int `json:"rating_count"`
ReleaseDates []int `json:"release_dates"`
Screenshots []int `json:"screenshots"`
SimilarGames []int `json:"similar_games"`
Slug string `json:"slug"`
Tags []int `json:"tags"`
Themes []int `json:"themes"`
TotalRating int `json:"total_rating"`
TotalRatingCount int `json:"total_rating_count"`
UpdatedAt int `json:"updated_at"`
VersionParent int `json:"version_parent"`
VersionTitle string `json:"version_title"`
Websites []int `json:"websites"`
*/
}
type Website struct { // NOTE: more fields available
Category int `json:"category"`
Url string `json:"url"`
}
type UnixTime time.Time
func (t UnixTime) MarshalJSON() ([]byte, error) {
return []byte(strconv.FormatInt(time.Time(t).Unix(), 10)), nil
}
func (t *UnixTime) UnmarshalJSON(s []byte) (err error) {
q, err := strconv.ParseInt(string(s), 10, 64)
if err != nil {
return err
}
*(*time.Time)(t) = time.Unix(q, 0)
return nil
}