Complete CollectionService
Signed-off-by: Vartan Benohanian <vartanbeno@gmail.com>
This commit is contained in:
+82
-1
@@ -109,7 +109,6 @@ func (s *CollectionService) Create(ctx context.Context, createRequest *Collectio
|
||||
|
||||
path := "api/v1/collections/create_collection"
|
||||
|
||||
// todo: do this for multireddit stuff too
|
||||
form, err := query.Values(createRequest)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
@@ -191,3 +190,85 @@ func (s *CollectionService) ReorderPosts(ctx context.Context, collectionID strin
|
||||
|
||||
return s.client.Do(ctx, req, nil)
|
||||
}
|
||||
|
||||
// UpdateTitle updates a collection's title.
|
||||
func (s *CollectionService) UpdateTitle(ctx context.Context, id string, title string) (*Response, error) {
|
||||
path := "api/v1/collections/update_collection_title"
|
||||
|
||||
form := url.Values{}
|
||||
form.Set("collection_id", id)
|
||||
form.Set("title", title)
|
||||
|
||||
req, err := s.client.NewRequestWithForm(http.MethodPost, path, form)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return s.client.Do(ctx, req, nil)
|
||||
}
|
||||
|
||||
// UpdateDescription updates a collection's description.
|
||||
func (s *CollectionService) UpdateDescription(ctx context.Context, id string, description string) (*Response, error) {
|
||||
path := "api/v1/collections/update_collection_description"
|
||||
|
||||
form := url.Values{}
|
||||
form.Set("collection_id", id)
|
||||
form.Set("description", description)
|
||||
|
||||
req, err := s.client.NewRequestWithForm(http.MethodPost, path, form)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return s.client.Do(ctx, req, nil)
|
||||
}
|
||||
|
||||
// UpdateLayout updates a collection's layout.
|
||||
// layout is one of: TIMELINE, GALLERY.
|
||||
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"
|
||||
|
||||
form := url.Values{}
|
||||
form.Set("collection_id", id)
|
||||
form.Set("display_layout", layout)
|
||||
|
||||
req, err := s.client.NewRequestWithForm(http.MethodPost, path, form)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return s.client.Do(ctx, req, nil)
|
||||
}
|
||||
|
||||
// Follow follows a collection.
|
||||
func (s *CollectionService) Follow(ctx context.Context, id string) (*Response, error) {
|
||||
path := "api/v1/collections/follow_collection"
|
||||
|
||||
form := url.Values{}
|
||||
form.Set("collection_id", id)
|
||||
form.Set("follow", "true")
|
||||
|
||||
req, err := s.client.NewRequestWithForm(http.MethodPost, path, form)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return s.client.Do(ctx, req, nil)
|
||||
}
|
||||
|
||||
// Unfollow unfollows a collection.
|
||||
func (s *CollectionService) Unfollow(ctx context.Context, id string) (*Response, error) {
|
||||
path := "api/v1/collections/follow_collection"
|
||||
|
||||
form := url.Values{}
|
||||
form.Set("collection_id", id)
|
||||
form.Set("follow", "false")
|
||||
|
||||
req, err := s.client.NewRequestWithForm(http.MethodPost, path, form)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return s.client.Do(ctx, req, nil)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user