Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Added /media/{id}/likers endpoint

  • Loading branch information...
commit 598050a07f8a1154e48f18030af7e2ed01bcb06f 1 parent 8cc3d62
Shayne Sweeney authored
View
21 lib/instagram/client/media.rb
@@ -4,7 +4,7 @@ class Client
module Media
# Returns extended information of a given media item
#
- # @overload media_item(id=nil, options={})
+ # @overload media_item(id)
# @param user [Integer] An Instagram media item ID
# @return [Hashie::Mash] The requested media item.
# @example Return extended information for media item 1234
@@ -21,6 +21,25 @@ def media_item(*args)
response['data']
end
+ # Returns a list of users who liked the given media object
+ #
+ # @overload media_item_likers(id)
+ # @param user [Integer] An Instagram media item ID
+ # @return [Hashie::Mash] The requested media item.
+ # @example Return a list of all the likers for media item ID 1234
+ # Instagram.media_item_likers(1324)
+ # @format :json
+ # @authenticated false unless requesting media from a protected user
+ #
+ # If getting this data of a protected user, you must authenticate (and be allowed to see that user).
+ # @rate_limited true
+ # @see TODO:docs url
+ def media_item_likers(*args)
+ id = args.first || 'self'
+ response = get("media/#{id}/likers")
+ response['data']
+ end
+
# Returns a list of the overall most popular media
#
# @overload media_popular(options={})
View
1  spec/fixtures/media_likers.json
@@ -0,0 +1 @@
+{"meta": {"code": 200}, "data": [{"username": "chris", "profile_picture": "http://distillery.s3.amazonaws.com/profiles/profile_19_75sq_1286500536.jpg", "id": "19"}, {"username": "kevin", "profile_picture": "http://distillery.s3.amazonaws.com/profiles/profile_3_75sq_1286592842.jpg", "id": "3"}, {"username": "mikeyk", "profile_picture": "http://distillery.s3.amazonaws.com/profiles/profile_4_75sq_1286335374.jpg", "id": "4"}, {"username": "nicole", "profile_picture": "http://distillery.s3.amazonaws.com/profiles/profile_6_75sq_1285365377.jpg", "id": "6"}]}
View
23 spec/instagram/client/media_spec.rb
@@ -7,7 +7,7 @@
@client = Instagram::Client.new(:format => format, :client_id => 'CID', :access_token => 'AT')
end
- describe ".media" do
+ describe ".media_item" do
before do
stub_get("media/18600493.#{format}").
@@ -28,6 +28,27 @@
end
end
+ describe ".media_item_likers" do
+
+ before do
+ stub_get("media/18600493/likers.#{format}").
+ with(:query => {:access_token => @client.access_token}).
+ to_return(:body => fixture("media_likers.#{format}"), :headers => {:content_type => "application/#{format}; charset=utf-8"})
+ end
+
+ it "should get the correct resource" do
+ @client.media_item_likers(18600493)
+ a_get("media/18600493/likers.#{format}").
+ with(:query => {:access_token => @client.access_token}).
+ should have_been_made
+ end
+
+ it "should return extended information of a given media item" do
+ likers = @client.media_item_likers(18600493)
+ likers.first.username.should == "chris"
+ end
+ end
+
describe ".media_popular" do
before do

0 comments on commit 598050a

Please sign in to comment.
Something went wrong with that request. Please try again.