Add stylesheet methods and more to subreddit service

Signed-off-by: Vartan Benohanian <vartanbeno@gmail.com>
This commit is contained in:
Vartan Benohanian
2020-09-13 21:43:59 -04:00
parent 9c85166c66
commit 7bb73ddc6e
4 changed files with 308 additions and 0 deletions
+8
View File
@@ -23,6 +23,7 @@ const (
kindWikiPage = "wikipage"
kindWikiPageListing = "wikipagelisting"
kindWikiPageSettings = "wikipagesettings"
kindStyleSheet = "stylesheet"
)
type anchor interface {
@@ -106,6 +107,8 @@ func (t *thing) UnmarshalJSON(b []byte) error {
v = new([]string)
case kindWikiPageSettings:
v = new(WikiPageSettings)
case kindStyleSheet:
v = new(SubredditStyleSheet)
default:
return fmt.Errorf("unrecognized kind: %q", t.Kind)
}
@@ -206,6 +209,11 @@ func (t *thing) WikiPageSettings() (v *WikiPageSettings, ok bool) {
return
}
func (t *thing) StyleSheet() (v *SubredditStyleSheet, ok bool) {
v, ok = t.Data.(*SubredditStyleSheet)
return
}
// listing is a list of things coming from the Reddit API.
// It also contains the after/before anchors useful for subsequent requests.
type listing struct {