Finish some todos
Signed-off-by: Vartan Benohanian <vartanbeno@gmail.com>
This commit is contained in:
+19
-5
@@ -223,15 +223,29 @@ func (s *CollectionService) UpdateDescription(ctx context.Context, id string, de
|
|||||||
return s.client.Do(ctx, req, nil)
|
return s.client.Do(ctx, req, nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
// UpdateLayout updates a collection's layout.
|
// UpdateLayoutTimeline updates a collection's layout to the timeline format.
|
||||||
// layout is one of: TIMELINE, GALLERY.
|
func (s *CollectionService) UpdateLayoutTimeline(ctx context.Context, id string) (*Response, error) {
|
||||||
func (s *CollectionService) UpdateLayout(ctx context.Context, id string, layout string) (*Response, error) {
|
|
||||||
// todo: should we validate layout?
|
|
||||||
path := "api/v1/collections/update_collection_display_layout"
|
path := "api/v1/collections/update_collection_display_layout"
|
||||||
|
|
||||||
form := url.Values{}
|
form := url.Values{}
|
||||||
form.Set("collection_id", id)
|
form.Set("collection_id", id)
|
||||||
form.Set("display_layout", layout)
|
form.Set("display_layout", "TIMELINE")
|
||||||
|
|
||||||
|
req, err := s.client.NewRequestWithForm(http.MethodPost, path, form)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return s.client.Do(ctx, req, nil)
|
||||||
|
}
|
||||||
|
|
||||||
|
// UpdateLayoutGallery updates a collection's layout to the gallery format.
|
||||||
|
func (s *CollectionService) UpdateLayoutGallery(ctx context.Context, id string) (*Response, error) {
|
||||||
|
path := "api/v1/collections/update_collection_display_layout"
|
||||||
|
|
||||||
|
form := url.Values{}
|
||||||
|
form.Set("collection_id", id)
|
||||||
|
form.Set("display_layout", "GALLERY")
|
||||||
|
|
||||||
req, err := s.client.NewRequestWithForm(http.MethodPost, path, form)
|
req, err := s.client.NewRequestWithForm(http.MethodPost, path, form)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
+22
-2
@@ -274,7 +274,7 @@ func TestCollectionService_UpdateDescription(t *testing.T) {
|
|||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestCollectionService_UpdateLayout(t *testing.T) {
|
func TestCollectionService_UpdateLayoutTimeline(t *testing.T) {
|
||||||
setup()
|
setup()
|
||||||
defer teardown()
|
defer teardown()
|
||||||
|
|
||||||
@@ -290,7 +290,27 @@ func TestCollectionService_UpdateLayout(t *testing.T) {
|
|||||||
require.Equal(t, form, r.Form)
|
require.Equal(t, form, r.Form)
|
||||||
})
|
})
|
||||||
|
|
||||||
_, err := client.Collection.UpdateLayout(ctx, "37f1e52d-7ec9-466b-b4cc-59e86e071ed7", "TIMELINE")
|
_, err := client.Collection.UpdateLayoutTimeline(ctx, "37f1e52d-7ec9-466b-b4cc-59e86e071ed7")
|
||||||
|
require.NoError(t, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestCollectionService_UpdateLayoutGallery(t *testing.T) {
|
||||||
|
setup()
|
||||||
|
defer teardown()
|
||||||
|
|
||||||
|
mux.HandleFunc("/api/v1/collections/update_collection_display_layout", func(w http.ResponseWriter, r *http.Request) {
|
||||||
|
require.Equal(t, http.MethodPost, r.Method)
|
||||||
|
|
||||||
|
form := url.Values{}
|
||||||
|
form.Set("collection_id", "37f1e52d-7ec9-466b-b4cc-59e86e071ed7")
|
||||||
|
form.Set("display_layout", "GALLERY")
|
||||||
|
|
||||||
|
err := r.ParseForm()
|
||||||
|
require.NoError(t, err)
|
||||||
|
require.Equal(t, form, r.Form)
|
||||||
|
})
|
||||||
|
|
||||||
|
_, err := client.Collection.UpdateLayoutGallery(ctx, "37f1e52d-7ec9-466b-b4cc-59e86e071ed7")
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -22,7 +22,7 @@ var expectedCommentSubmitOrEdit = &Comment{
|
|||||||
AuthorFlairText: "Flair",
|
AuthorFlairText: "Flair",
|
||||||
AuthorFlairID: "024b2b66-05ca-11e1-96f4-12313d096aae",
|
AuthorFlairID: "024b2b66-05ca-11e1-96f4-12313d096aae",
|
||||||
|
|
||||||
Subreddit: "subreddit",
|
SubredditName: "subreddit",
|
||||||
SubredditNamePrefixed: "r/subreddit",
|
SubredditNamePrefixed: "r/subreddit",
|
||||||
SubredditID: "t5_test",
|
SubredditID: "t5_test",
|
||||||
|
|
||||||
|
|||||||
@@ -38,23 +38,19 @@ type JSONErrorResponse struct {
|
|||||||
// HTTP response that caused this error.
|
// HTTP response that caused this error.
|
||||||
Response *http.Response `json:"-"`
|
Response *http.Response `json:"-"`
|
||||||
|
|
||||||
JSON *struct {
|
JSON struct {
|
||||||
Errors []APIError `json:"errors,omitempty"`
|
Errors []APIError `json:"errors,omitempty"`
|
||||||
} `json:"json,omitempty"`
|
} `json:"json"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *JSONErrorResponse) Error() string {
|
func (r *JSONErrorResponse) Error() string {
|
||||||
var message string
|
var message string
|
||||||
if r.JSON != nil && len(r.JSON.Errors) > 0 {
|
if len(r.JSON.Errors) > 0 {
|
||||||
for i, err := range r.JSON.Errors {
|
message = r.JSON.Errors[0].Error()
|
||||||
message += err.Error()
|
|
||||||
if i < len(r.JSON.Errors)-1 {
|
|
||||||
message += ";"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return fmt.Sprintf(
|
return fmt.Sprintf(
|
||||||
"%v %v: %d %v",
|
"%s %s: %d %s",
|
||||||
r.Response.Request.Method, r.Response.Request.URL, r.Response.StatusCode, message,
|
r.Response.Request.Method, r.Response.Request.URL, r.Response.StatusCode, message,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -70,7 +66,7 @@ type ErrorResponse struct {
|
|||||||
|
|
||||||
func (r *ErrorResponse) Error() string {
|
func (r *ErrorResponse) Error() string {
|
||||||
return fmt.Sprintf(
|
return fmt.Sprintf(
|
||||||
"%v %v: %d %v",
|
"%s %s: %d %s",
|
||||||
r.Response.Request.Method, r.Response.Request.URL, r.Response.StatusCode, r.Message,
|
r.Response.Request.Method, r.Response.Request.URL, r.Response.StatusCode, r.Message,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
+10
-12
@@ -28,12 +28,12 @@ var expectedListingPosts = []*Post{
|
|||||||
UpvoteRatio: 1,
|
UpvoteRatio: 1,
|
||||||
NumberOfComments: 1,
|
NumberOfComments: 1,
|
||||||
|
|
||||||
SubredditID: "t5_2qh23",
|
|
||||||
SubredditName: "test",
|
SubredditName: "test",
|
||||||
SubredditNamePrefixed: "r/test",
|
SubredditNamePrefixed: "r/test",
|
||||||
|
SubredditID: "t5_2qh23",
|
||||||
|
|
||||||
AuthorID: "t2_164ab8",
|
Author: "v_95",
|
||||||
AuthorName: "v_95",
|
AuthorID: "t2_164ab8",
|
||||||
|
|
||||||
IsSelfPost: true,
|
IsSelfPost: true,
|
||||||
},
|
},
|
||||||
@@ -49,13 +49,11 @@ var expectedListingComments = []*Comment{
|
|||||||
ParentID: "t3_i2gvg4",
|
ParentID: "t3_i2gvg4",
|
||||||
Permalink: "https://www.reddit.com/r/test/comments/i2gvg4/this_is_a_title/g05v931/",
|
Permalink: "https://www.reddit.com/r/test/comments/i2gvg4/this_is_a_title/g05v931/",
|
||||||
|
|
||||||
// todo fix naming
|
|
||||||
Body: "Test comment",
|
Body: "Test comment",
|
||||||
Author: "v_95",
|
Author: "v_95",
|
||||||
AuthorID: "t2_164ab8",
|
AuthorID: "t2_164ab8",
|
||||||
|
|
||||||
// todo fix naming
|
SubredditName: "test",
|
||||||
Subreddit: "test",
|
|
||||||
SubredditNamePrefixed: "r/test",
|
SubredditNamePrefixed: "r/test",
|
||||||
SubredditID: "t5_2qh23",
|
SubredditID: "t5_2qh23",
|
||||||
|
|
||||||
@@ -104,12 +102,12 @@ var expectedListingPosts2 = []*Post{
|
|||||||
UpvoteRatio: 1,
|
UpvoteRatio: 1,
|
||||||
NumberOfComments: 1,
|
NumberOfComments: 1,
|
||||||
|
|
||||||
SubredditID: "t5_2qh23",
|
|
||||||
SubredditName: "test",
|
SubredditName: "test",
|
||||||
SubredditNamePrefixed: "r/test",
|
SubredditNamePrefixed: "r/test",
|
||||||
|
SubredditID: "t5_2qh23",
|
||||||
|
|
||||||
AuthorID: "t2_164ab8",
|
Author: "v_95",
|
||||||
AuthorName: "v_95",
|
AuthorID: "t2_164ab8",
|
||||||
|
|
||||||
IsSelfPost: true,
|
IsSelfPost: true,
|
||||||
},
|
},
|
||||||
@@ -129,12 +127,12 @@ var expectedListingPosts2 = []*Post{
|
|||||||
UpvoteRatio: 1,
|
UpvoteRatio: 1,
|
||||||
NumberOfComments: 0,
|
NumberOfComments: 0,
|
||||||
|
|
||||||
SubredditID: "t5_2qh23",
|
|
||||||
SubredditName: "test",
|
SubredditName: "test",
|
||||||
SubredditNamePrefixed: "r/test",
|
SubredditNamePrefixed: "r/test",
|
||||||
|
SubredditID: "t5_2qh23",
|
||||||
|
|
||||||
AuthorID: "t2_164ab8",
|
Author: "v_95",
|
||||||
AuthorName: "v_95",
|
AuthorID: "t2_164ab8",
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+17
-17
@@ -27,12 +27,12 @@ var expectedPostAndComments = &PostAndComments{
|
|||||||
UpvoteRatio: 1,
|
UpvoteRatio: 1,
|
||||||
NumberOfComments: 2,
|
NumberOfComments: 2,
|
||||||
|
|
||||||
SubredditID: "t5_2qh23",
|
|
||||||
SubredditName: "test",
|
SubredditName: "test",
|
||||||
SubredditNamePrefixed: "r/test",
|
SubredditNamePrefixed: "r/test",
|
||||||
|
SubredditID: "t5_2qh23",
|
||||||
|
|
||||||
AuthorID: "t2_testuser",
|
Author: "testuser",
|
||||||
AuthorName: "testuser",
|
AuthorID: "t2_testuser",
|
||||||
|
|
||||||
IsSelfPost: true,
|
IsSelfPost: true,
|
||||||
},
|
},
|
||||||
@@ -50,7 +50,7 @@ var expectedPostAndComments = &PostAndComments{
|
|||||||
Author: "testuser",
|
Author: "testuser",
|
||||||
AuthorID: "t2_testuser",
|
AuthorID: "t2_testuser",
|
||||||
|
|
||||||
Subreddit: "test",
|
SubredditName: "test",
|
||||||
SubredditNamePrefixed: "r/test",
|
SubredditNamePrefixed: "r/test",
|
||||||
SubredditID: "t5_2qh23",
|
SubredditID: "t5_2qh23",
|
||||||
|
|
||||||
@@ -77,7 +77,7 @@ var expectedPostAndComments = &PostAndComments{
|
|||||||
Author: "testuser",
|
Author: "testuser",
|
||||||
AuthorID: "t2_testuser",
|
AuthorID: "t2_testuser",
|
||||||
|
|
||||||
Subreddit: "test",
|
SubredditName: "test",
|
||||||
SubredditNamePrefixed: "r/test",
|
SubredditNamePrefixed: "r/test",
|
||||||
SubredditID: "t5_2qh23",
|
SubredditID: "t5_2qh23",
|
||||||
|
|
||||||
@@ -119,12 +119,12 @@ var expectedEditedPost = &Post{
|
|||||||
UpvoteRatio: 1,
|
UpvoteRatio: 1,
|
||||||
NumberOfComments: 0,
|
NumberOfComments: 0,
|
||||||
|
|
||||||
SubredditID: "t5_2qh23",
|
|
||||||
SubredditName: "test",
|
SubredditName: "test",
|
||||||
SubredditNamePrefixed: "r/test",
|
SubredditNamePrefixed: "r/test",
|
||||||
|
SubredditID: "t5_2qh23",
|
||||||
|
|
||||||
AuthorID: "t2_164ab8",
|
Author: "v_95",
|
||||||
AuthorName: "v_95",
|
AuthorID: "t2_164ab8",
|
||||||
|
|
||||||
Spoiler: true,
|
Spoiler: true,
|
||||||
IsSelfPost: true,
|
IsSelfPost: true,
|
||||||
@@ -147,12 +147,12 @@ var expectedPost2 = &Post{
|
|||||||
UpvoteRatio: 1,
|
UpvoteRatio: 1,
|
||||||
NumberOfComments: 0,
|
NumberOfComments: 0,
|
||||||
|
|
||||||
SubredditID: "t5_2qh23",
|
|
||||||
SubredditName: "test",
|
SubredditName: "test",
|
||||||
SubredditNamePrefixed: "r/test",
|
SubredditNamePrefixed: "r/test",
|
||||||
|
SubredditID: "t5_2qh23",
|
||||||
|
|
||||||
AuthorID: "t2_164ab8",
|
Author: "v_95",
|
||||||
AuthorName: "v_95",
|
AuthorID: "t2_164ab8",
|
||||||
}
|
}
|
||||||
|
|
||||||
var expectedPostDuplicates = &Posts{
|
var expectedPostDuplicates = &Posts{
|
||||||
@@ -174,12 +174,12 @@ var expectedPostDuplicates = &Posts{
|
|||||||
UpvoteRatio: 0.66,
|
UpvoteRatio: 0.66,
|
||||||
NumberOfComments: 1,
|
NumberOfComments: 1,
|
||||||
|
|
||||||
SubredditID: "t5_2qh23",
|
|
||||||
SubredditName: "test",
|
SubredditName: "test",
|
||||||
SubredditNamePrefixed: "r/test",
|
SubredditNamePrefixed: "r/test",
|
||||||
|
SubredditID: "t5_2qh23",
|
||||||
|
|
||||||
AuthorID: "t2_d2v1r90",
|
Author: "GarlicoinAccount",
|
||||||
AuthorName: "GarlicoinAccount",
|
AuthorID: "t2_d2v1r90",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
ID: "le1tc",
|
ID: "le1tc",
|
||||||
@@ -198,12 +198,12 @@ var expectedPostDuplicates = &Posts{
|
|||||||
UpvoteRatio: 1,
|
UpvoteRatio: 1,
|
||||||
NumberOfComments: 1,
|
NumberOfComments: 1,
|
||||||
|
|
||||||
SubredditID: "t5_2qh23",
|
|
||||||
SubredditName: "test",
|
SubredditName: "test",
|
||||||
SubredditNamePrefixed: "r/test",
|
SubredditNamePrefixed: "r/test",
|
||||||
|
SubredditID: "t5_2qh23",
|
||||||
|
|
||||||
AuthorID: "t2_8dyo",
|
Author: "prog101",
|
||||||
AuthorName: "prog101",
|
AuthorID: "t2_8dyo",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
After: "t3_le1tc",
|
After: "t3_le1tc",
|
||||||
|
|||||||
@@ -320,7 +320,7 @@ func CheckResponse(r *http.Response) error {
|
|||||||
data, err := ioutil.ReadAll(r.Body)
|
data, err := ioutil.ReadAll(r.Body)
|
||||||
if err == nil && len(data) > 0 {
|
if err == nil && len(data) > 0 {
|
||||||
json.Unmarshal(data, jsonErrorResponse)
|
json.Unmarshal(data, jsonErrorResponse)
|
||||||
if jsonErrorResponse.JSON != nil && len(jsonErrorResponse.JSON.Errors) > 0 {
|
if len(jsonErrorResponse.JSON.Errors) > 0 {
|
||||||
return jsonErrorResponse
|
return jsonErrorResponse
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+12
-12
@@ -28,12 +28,12 @@ var expectedPosts = &Posts{
|
|||||||
UpvoteRatio: 0.99,
|
UpvoteRatio: 0.99,
|
||||||
NumberOfComments: 1634,
|
NumberOfComments: 1634,
|
||||||
|
|
||||||
SubredditID: "t5_2qh23",
|
|
||||||
SubredditName: "test",
|
SubredditName: "test",
|
||||||
SubredditNamePrefixed: "r/test",
|
SubredditNamePrefixed: "r/test",
|
||||||
|
SubredditID: "t5_2qh23",
|
||||||
|
|
||||||
AuthorID: "t2_30a5ktgt",
|
Author: "kmiller0112",
|
||||||
AuthorName: "kmiller0112",
|
AuthorID: "t2_30a5ktgt",
|
||||||
|
|
||||||
IsSelfPost: true,
|
IsSelfPost: true,
|
||||||
Stickied: true,
|
Stickied: true,
|
||||||
@@ -53,12 +53,12 @@ var expectedPosts = &Posts{
|
|||||||
UpvoteRatio: 1,
|
UpvoteRatio: 1,
|
||||||
NumberOfComments: 0,
|
NumberOfComments: 0,
|
||||||
|
|
||||||
SubredditID: "t5_2qh23",
|
|
||||||
SubredditName: "test",
|
SubredditName: "test",
|
||||||
SubredditNamePrefixed: "r/test",
|
SubredditNamePrefixed: "r/test",
|
||||||
|
SubredditID: "t5_2qh23",
|
||||||
|
|
||||||
AuthorID: "t2_6fqntbwq",
|
Author: "MuckleMcDuckle",
|
||||||
AuthorName: "MuckleMcDuckle",
|
AuthorID: "t2_6fqntbwq",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
After: "t3_hyhquk",
|
After: "t3_hyhquk",
|
||||||
@@ -167,12 +167,12 @@ var expectedSearchPosts = &Posts{
|
|||||||
UpvoteRatio: 0.88,
|
UpvoteRatio: 0.88,
|
||||||
NumberOfComments: 3748,
|
NumberOfComments: 3748,
|
||||||
|
|
||||||
SubredditID: "t5_3h4zq",
|
|
||||||
SubredditName: "WatchPeopleDieInside",
|
SubredditName: "WatchPeopleDieInside",
|
||||||
SubredditNamePrefixed: "r/WatchPeopleDieInside",
|
SubredditNamePrefixed: "r/WatchPeopleDieInside",
|
||||||
|
SubredditID: "t5_3h4zq",
|
||||||
|
|
||||||
AuthorID: "t2_3p32m02",
|
Author: "chocolat_ice_cream",
|
||||||
AuthorName: "chocolat_ice_cream",
|
AuthorID: "t2_3p32m02",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
ID: "hmwhd7",
|
ID: "hmwhd7",
|
||||||
@@ -189,12 +189,12 @@ var expectedSearchPosts = &Posts{
|
|||||||
UpvoteRatio: 0.94,
|
UpvoteRatio: 0.94,
|
||||||
NumberOfComments: 7415,
|
NumberOfComments: 7415,
|
||||||
|
|
||||||
SubredditID: "t5_2qh13",
|
|
||||||
SubredditName: "worldnews",
|
SubredditName: "worldnews",
|
||||||
SubredditNamePrefixed: "r/worldnews",
|
SubredditNamePrefixed: "r/worldnews",
|
||||||
|
SubredditID: "t5_2qh13",
|
||||||
|
|
||||||
AuthorID: "t2_wgrkg",
|
Author: "Jeremy_Martin",
|
||||||
AuthorName: "Jeremy_Martin",
|
AuthorID: "t2_wgrkg",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
After: "t3_hmwhd7",
|
After: "t3_hmwhd7",
|
||||||
|
|||||||
@@ -62,7 +62,6 @@ type things struct {
|
|||||||
Posts []*Post
|
Posts []*Post
|
||||||
Subreddits []*Subreddit
|
Subreddits []*Subreddit
|
||||||
ModActions []*ModAction
|
ModActions []*ModAction
|
||||||
// todo: add the other kinds of things
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// init initializes or clears the listing.
|
// init initializes or clears the listing.
|
||||||
@@ -111,7 +110,6 @@ func (t *things) UnmarshalJSON(b []byte) error {
|
|||||||
if err := json.Unmarshal(thing.Data, v); err == nil {
|
if err := json.Unmarshal(thing.Data, v); err == nil {
|
||||||
t.Subreddits = append(t.Subreddits, v)
|
t.Subreddits = append(t.Subreddits, v)
|
||||||
}
|
}
|
||||||
case kindAward:
|
|
||||||
case kindModAction:
|
case kindModAction:
|
||||||
v := new(ModAction)
|
v := new(ModAction)
|
||||||
if err := json.Unmarshal(thing.Data, v); err == nil {
|
if err := json.Unmarshal(thing.Data, v); err == nil {
|
||||||
@@ -123,7 +121,7 @@ func (t *things) UnmarshalJSON(b []byte) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Comment is a comment posted by a user
|
// Comment is a comment posted by a user.
|
||||||
type Comment struct {
|
type Comment struct {
|
||||||
ID string `json:"id,omitempty"`
|
ID string `json:"id,omitempty"`
|
||||||
FullID string `json:"name,omitempty"`
|
FullID string `json:"name,omitempty"`
|
||||||
@@ -139,7 +137,7 @@ type Comment struct {
|
|||||||
AuthorFlairText string `json:"author_flair_text,omitempty"`
|
AuthorFlairText string `json:"author_flair_text,omitempty"`
|
||||||
AuthorFlairID string `json:"author_flair_template_id,omitempty"`
|
AuthorFlairID string `json:"author_flair_template_id,omitempty"`
|
||||||
|
|
||||||
Subreddit string `json:"subreddit,omitempty"`
|
SubredditName string `json:"subreddit,omitempty"`
|
||||||
SubredditNamePrefixed string `json:"subreddit_name_prefixed,omitempty"`
|
SubredditNamePrefixed string `json:"subreddit_name_prefixed,omitempty"`
|
||||||
SubredditID string `json:"subreddit_id,omitempty"`
|
SubredditID string `json:"subreddit_id,omitempty"`
|
||||||
|
|
||||||
@@ -150,16 +148,14 @@ type Comment struct {
|
|||||||
Score int `json:"score"`
|
Score int `json:"score"`
|
||||||
Controversiality int `json:"controversiality"`
|
Controversiality int `json:"controversiality"`
|
||||||
|
|
||||||
// todo: check the validity of these comments
|
|
||||||
PostID string `json:"link_id,omitempty"`
|
PostID string `json:"link_id,omitempty"`
|
||||||
// This doesn't appear when submitting a comment.
|
// This doesn't appear consistently.
|
||||||
PostTitle string `json:"link_title,omitempty"`
|
PostTitle string `json:"link_title,omitempty"`
|
||||||
// This doesn't appear when submitting a comment.
|
// This doesn't appear consistently.
|
||||||
PostPermalink string `json:"link_permalink,omitempty"`
|
PostPermalink string `json:"link_permalink,omitempty"`
|
||||||
// This doesn't appear when submitting a comment.
|
// This doesn't appear consistently.
|
||||||
PostAuthor string `json:"link_author,omitempty"`
|
PostAuthor string `json:"link_author,omitempty"`
|
||||||
// This doesn't appear when submitting a comment
|
// This doesn't appear consistently.
|
||||||
// or when getting a post with its comments.
|
|
||||||
PostNumComments *int `json:"num_comments,omitempty"`
|
PostNumComments *int `json:"num_comments,omitempty"`
|
||||||
|
|
||||||
IsSubmitter bool `json:"is_submitter"`
|
IsSubmitter bool `json:"is_submitter"`
|
||||||
@@ -238,9 +234,7 @@ func (r *Replies) MarshalJSON() ([]byte, error) {
|
|||||||
return json.Marshal(r.Comments)
|
return json.Marshal(r.Comments)
|
||||||
}
|
}
|
||||||
|
|
||||||
// todo: should we implement json.Marshaler?
|
// More holds information used to retrieve additional comments omitted from a base comment tree.
|
||||||
|
|
||||||
// More holds information
|
|
||||||
type More struct {
|
type More struct {
|
||||||
ID string `json:"id"`
|
ID string `json:"id"`
|
||||||
FullID string `json:"name"`
|
FullID string `json:"name"`
|
||||||
@@ -273,12 +267,12 @@ type Post struct {
|
|||||||
UpvoteRatio float32 `json:"upvote_ratio"`
|
UpvoteRatio float32 `json:"upvote_ratio"`
|
||||||
NumberOfComments int `json:"num_comments"`
|
NumberOfComments int `json:"num_comments"`
|
||||||
|
|
||||||
SubredditID string `json:"subreddit_id,omitempty"`
|
|
||||||
SubredditName string `json:"subreddit,omitempty"`
|
SubredditName string `json:"subreddit,omitempty"`
|
||||||
SubredditNamePrefixed string `json:"subreddit_name_prefixed,omitempty"`
|
SubredditNamePrefixed string `json:"subreddit_name_prefixed,omitempty"`
|
||||||
|
SubredditID string `json:"subreddit_id,omitempty"`
|
||||||
|
|
||||||
AuthorID string `json:"author_fullname,omitempty"`
|
Author string `json:"author,omitempty"`
|
||||||
AuthorName string `json:"author,omitempty"`
|
AuthorID string `json:"author_fullname,omitempty"`
|
||||||
|
|
||||||
Spoiler bool `json:"spoiler"`
|
Spoiler bool `json:"spoiler"`
|
||||||
Locked bool `json:"locked"`
|
Locked bool `json:"locked"`
|
||||||
|
|||||||
+4
-4
@@ -64,12 +64,12 @@ var expectedPost = &Post{
|
|||||||
UpvoteRatio: 0.86,
|
UpvoteRatio: 0.86,
|
||||||
NumberOfComments: 2,
|
NumberOfComments: 2,
|
||||||
|
|
||||||
SubredditID: "t5_2qizd",
|
|
||||||
SubredditName: "redditdev",
|
SubredditName: "redditdev",
|
||||||
SubredditNamePrefixed: "r/redditdev",
|
SubredditNamePrefixed: "r/redditdev",
|
||||||
|
SubredditID: "t5_2qizd",
|
||||||
|
|
||||||
AuthorID: "t2_164ab8",
|
Author: "v_95",
|
||||||
AuthorName: "v_95",
|
AuthorID: "t2_164ab8",
|
||||||
|
|
||||||
IsSelfPost: true,
|
IsSelfPost: true,
|
||||||
}
|
}
|
||||||
@@ -87,7 +87,7 @@ var expectedComment = &Comment{
|
|||||||
Author: "v_95",
|
Author: "v_95",
|
||||||
AuthorID: "t2_164ab8",
|
AuthorID: "t2_164ab8",
|
||||||
|
|
||||||
Subreddit: "apple",
|
SubredditName: "apple",
|
||||||
SubredditNamePrefixed: "r/apple",
|
SubredditNamePrefixed: "r/apple",
|
||||||
SubredditID: "t5_2qh1f",
|
SubredditID: "t5_2qh1f",
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user