-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathseries.go
97 lines (89 loc) · 3.65 KB
/
series.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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
package tapas
import (
"encoding/json"
"fmt"
"net/url"
"time"
"github.com/pkg/errors"
)
// Series of a comic.
type Series struct {
AgeRating AgeRating `json:"age_rating"`
AvailableImpression bool `json:"available_impression"`
BackgroundURL string `json:"background_url"`
Blurb string `json:"blurb"`
BookCoverURL string `json:"book_cover_url"`
Bookmarked bool `json:"bookmarked"`
Claimed bool `json:"claimed"`
Colophon string `json:"colophon"`
CommentCount int `json:"comment_cnt"`
Completed bool `json:"completed"`
Creators []Creator `json:"creators"`
DescOrder bool `json:"desc_order"`
Description string `json:"description"`
DiscountRate int `json:"discount_rate"`
DisplayAd bool `json:"display_ad"`
EarlyAccessEpCount int `json:"early_access_ep_cnt"`
EpisodeCount int `json:"episode_cnt"`
Genre Genre `json:"genre"`
HasNewEpisode bool `json:"has_new_episode"`
HumanURL string `json:"human_url"`
ID int `json:"id"`
LastEpisodeScheduledDate time.Time `json:"last_episode_scheduled_date"`
LastEpisodeUpdatedDate time.Time `json:"last_episode_updated_date"`
LikeCount int `json:"like_cnt"`
MasterKeyBanner bool `json:"master_key_banner"`
MustPayCount int `json:"must_pay_cnt"`
NewEpisodeCount int `json:"new_episode_cnt"`
NotificationOn bool `json:"notification_on"`
OnSale bool `json:"on_sale"`
Original bool `json:"original"`
PrivateReading bool `json:"private_reading"`
PublishDays []string `json:"publish_days"`
RectBannerURL string `json:"rect_banner_url"`
Restricted bool `json:"restricted"`
// ReviewRating Rating `json:"review_rating"`
RgbHex string `json:"rgb_hex"`
SaleEndDate time.Time `json:"sale_end_date"`
SaleStartDate time.Time `json:"sale_start_date"`
SaleType string `json:"sale_type"`
SpLikeCount int `json:"sp_like_cnt"`
SubTitle string `json:"sub_title"`
SubscribeCount int `json:"subscribe_cnt"`
SupportingAd Image `json:"supporting_ad"`
SupportingAdLink string `json:"supporting_ad_link"`
Tags []string `json:"tags"`
Thumbnail Image `json:"thumb"`
Title string `json:"title"`
Type string `json:"type"`
UnusedKeyCount int `json:"unused_key_cnt"`
Up bool `json:"up"`
UpdatedDate time.Time `json:"updated_date"`
ViewCount int `json:"view_cnt"`
WopInterval int `json:"wop_interval"`
}
func (s Series) String() string { return s.Title }
// AgeRating of a comic.
type AgeRating struct {
IconPath string `json:"icon_path"`
Name string `json:"name"`
}
func (a AgeRating) String() string { return a.Name }
// Rating of a comic.
type Rating struct {
ID int `json:"id"`
Count int `json:"cnt"`
Rating float64 `json:"rating"`
}
// Series fetches a series.
func (c *Client) Series(series int) (Series, error) {
raw, err := c.get(fmt.Sprintf("/series/%d", series), url.Values{})
if err != nil {
return Series{}, err
}
var res Series
if err := json.Unmarshal(raw, &res); err != nil {
return Series{}, errors.Wrap(err, "could not unmarshal series")
}
return res, nil
}