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:
Vartan Benohanian
2020-09-09 23:02:06 -04:00
parent 34c2559707
commit def7e3bdb7
17 changed files with 157 additions and 164 deletions
+3 -3
View File
@@ -28,7 +28,7 @@ func (s *CommentService) Submit(ctx context.Context, parentID string, text strin
form.Set("parent", parentID)
form.Set("text", text)
req, err := s.client.NewRequestWithForm(http.MethodPost, path, form)
req, err := s.client.NewRequest(http.MethodPost, path, form)
if err != nil {
return nil, nil, err
}
@@ -52,7 +52,7 @@ func (s *CommentService) Edit(ctx context.Context, id string, text string) (*Com
form.Set("thing_id", id)
form.Set("text", text)
req, err := s.client.NewRequestWithForm(http.MethodPost, path, form)
req, err := s.client.NewRequest(http.MethodPost, path, form)
if err != nil {
return nil, nil, err
}
@@ -88,7 +88,7 @@ func (s *CommentService) LoadMoreReplies(ctx context.Context, comment *Comment)
// This was originally a GET, but with POST you can send a bigger payload
// since it's in the body and not the URI.
req, err := s.client.NewRequestWithForm(http.MethodPost, path, form)
req, err := s.client.NewRequest(http.MethodPost, path, form)
if err != nil {
return nil, err
}