Chage NewRequest methods, add multi description kind to thing
Since Reddit's API accepts form data as the body for most of its endpoints, it made sense to me to make the default NewRequest method set the request body as form data (if provided of course). The NewJSONRequest method can accept a JSON body. Signed-off-by: Vartan Benohanian <vartanbeno@gmail.com>
This commit is contained in:
@@ -19,6 +19,7 @@ const (
|
||||
kindMore = "more"
|
||||
kindModAction = "modaction"
|
||||
kindMulti = "LabeledMulti"
|
||||
kindMultiDescription = "LabeledMultiDescription"
|
||||
kindWikiPage = "wikipage"
|
||||
kindWikiPageListing = "wikipagelisting"
|
||||
kindWikiPageSettings = "wikipagesettings"
|
||||
@@ -91,6 +92,8 @@ func (t *thing) UnmarshalJSON(b []byte) error {
|
||||
v = new(ModAction)
|
||||
case kindMulti:
|
||||
v = new(Multi)
|
||||
case kindMultiDescription:
|
||||
v = new(rootMultiDescription)
|
||||
case kindTrophy:
|
||||
v = new(Trophy)
|
||||
case kindTrophyList:
|
||||
@@ -156,6 +159,14 @@ func (t *thing) Multi() (v *Multi, ok bool) {
|
||||
return
|
||||
}
|
||||
|
||||
func (t *thing) MultiDescription() (s string, ok bool) {
|
||||
v, ok := t.Data.(*rootMultiDescription)
|
||||
if ok {
|
||||
s = v.Body
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func (t *thing) Trophy() (v *Trophy, ok bool) {
|
||||
v, ok = t.Data.(*Trophy)
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user