Skip to content
This repository has been archived by the owner on May 4, 2019. It is now read-only.

Commit

Permalink
Cover 'flickr.photosets.addPhoto'
Browse files Browse the repository at this point in the history
  • Loading branch information
janko committed Jul 20, 2012
1 parent 7050794 commit 7863725
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 0 deletions.
13 changes: 13 additions & 0 deletions lib/flickrie/api_methods.rb
Original file line number Diff line number Diff line change
Expand Up @@ -779,6 +779,19 @@ def check_upload_tickets(tickets, params = {})
map { |info| Ticket.new(info) }
end

# Adds existing photo/video to a set with the given ID.
#
# @param set_id [Fixnum, String]
# @return [nil]
# @api_method [flickr.photosets.addPhoto](http://www.flickr.com/services/api/flickr.photosets.addPhoto.html)
#
# @note This method requires authentication with "write" permissions.
def add_media_to_set(set_id, media_id, params = {})
client.add_media_to_set(set_id, media_id, params)
end
alias add_photo_to_set add_media_to_set
alias add_video_to_set add_media_to_set

# Fetches information about the set with the given ID.
#
# @param set_id [String, Fixnum]
Expand Down
5 changes: 5 additions & 0 deletions lib/flickrie/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,11 @@ def rotate_media(media_id, degrees, params = {})
end

# photosets
def add_media_to_set(set_id, media_id, params = {})
post 'flickr.photosets.addPhoto',
{:photoset_id => set_id, :photo_id => media_id}.merge(params)
end

def get_set_info(set_id, params = {})
get 'flickr.photosets.getInfo',
{:photoset_id => set_id}.merge(params)
Expand Down
5 changes: 5 additions & 0 deletions spec/flickrie/api_methods_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,11 @@
end

context "photosets", :vcr do
context "photosets" do
it "adds media" do
expect { Flickrie.add_media_to_set(72157630665363720, PHOTO_ID) }.to_not raise_error
end

it "gets media" do
media = Flickrie.media_from_set(SET_ID)
media.each { |object| object.should be_a(Flickrie::Media) }
Expand Down
38 changes: 38 additions & 0 deletions spec/vcr_cassettes/ApiMethods/photosets/adds_media.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 7863725

Please sign in to comment.