Skip to content

Commit

Permalink
Add users/contributees
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnFord committed Aug 22, 2011
1 parent 53501ab commit 2b88f81
Show file tree
Hide file tree
Showing 4 changed files with 435 additions and 0 deletions.
38 changes: 38 additions & 0 deletions lib/twitter/client/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,44 @@ def recommendations(options={})
response = get('users/recommendations', options)
format.to_s.downcase == 'xml' ? response['userrecommendations'] : response
end

# Returns users the specified user can contribute to.
#
# @see http://dev.twitter.com/docs/api/1/get/users/contributees
# @rate_limited Yes
# @requires_authentication No unless requesting it from a protected user
#
# If getting this data of a protected user, you must authenticate (and be allowed to see that user).
# @response_format `json`
# @response_format `xml`
# @overload contributees(options={})
# @param options [Hash] A customizable set of options.
# @option options [Boolean, String, Integer] :include_entities Include {http://dev.twitter.com/pages/tweet_entities Tweet Entities} when set to true, 't' or 1.
# @option options [Boolean, String, Integer] :skip_status Do not include contributee's statuses when set to true, 't' or 1.
# @return [Array]
# @example Return the authenticated user's contributees
# Twitter.contributees
## @overload contributees(user, options={})
# @param user [Integer, String] A Twitter user ID or screen name.
# @param options [Hash] A customizable set of options.
# @option options [Boolean, String, Integer] :include_entities Include {http://dev.twitter.com/pages/tweet_entities Tweet Entities} when set to true, 't' or 1.
# @option options [Boolean, String, Integer] :skip_status Do not include contributee's statuses when set to true, 't' or 1.
# @return [Array]
# @example Return users @sferik can contribute to
# Twitter.contributees("sferik")
# Twitter.contributees(7505382) # Same as above
def contributees(*args)
options = {}
options.merge!(args.last.is_a?(Hash) ? args.pop : {})
user = args.pop || get_screen_name
if user
merge_user_into_options!(user, options)
response = get('users/contributees', options)
else
response = get('users/contributees', options)
end
format.to_s.downcase == 'xml' ? response['users'] : response
end
end
end
end
1 change: 1 addition & 0 deletions spec/fixtures/contributees.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[{"time_zone":"Pacific Time (US & Canada)","protected":false,"profile_use_background_image":true,"name":"Twitter API","contributors_enabled":true,"created_at":"Wed May 23 06:01:13 +0000 2007","profile_background_color":"e8f2f7","expanded_url":null,"listed_count":9032,"profile_background_image_url":"http:\/\/a2.twimg.com\/profile_background_images\/229557229\/twitterapi-bg.png","utc_offset":-28800,"description":"The Real Twitter API. I tweet about API changes, service issues and happily answer questions about Twitter and our API. Don't get an answer? It's on my website.","display_url":null,"verified":true,"profile_image_url":"http:\/\/a2.twimg.com\/profile_images\/1438634086\/avatar_normal.png","id_str":"6253282","entities":{"user_mentions":[],"urls":[],"hashtags":[]},"lang":"en","profile_background_image_url_https":"https:\/\/si0.twimg.com\/profile_background_images\/229557229\/twitterapi-bg.png","favourites_count":22,"profile_text_color":"437792","status":{"truncated":false,"created_at":"Sun Aug 21 15:47:24 +0000 2011","geo":null,"in_reply_to_user_id":null,"in_reply_to_status_id":null,"favorited":false,"in_reply_to_status_id_str":null,"coordinates":null,"id_str":"105305005493452801","in_reply_to_screen_name":null,"in_reply_to_user_id_str":null,"place":null,"contributors":[819797],"retweeted":false,"retweet_count":27,"source":"web","id":105305005493452801,"text":"dev.twitter.com is still inaccessible from some locations. We're working to restore availability to everyone again. ^TS"},"default_profile":false,"friends_count":30,"profile_sidebar_fill_color":"a9d9f1","profile_image_url_https":"https:\/\/si0.twimg.com\/profile_images\/1438634086\/avatar_normal.png","screen_name":"twitterapi","default_profile_image":false,"show_all_inline_media":false,"geo_enabled":true,"profile_background_tile":false,"location":"San Francisco, CA","notifications":null,"is_translator":false,"profile_link_color":"0094C2","url":"http:\/\/dev.twitter.com","id":6253282,"follow_request_sent":null,"statuses_count":3044,"following":null,"profile_sidebar_border_color":"0094C2","followers_count":633992},{"time_zone":"Pacific Time (US & Canada)","protected":true,"is_translator":false,"profile_use_background_image":true,"name":"teamteam","follow_request_sent":false,"statuses_count":490,"created_at":"Thu Jun 04 20:20:20 +0000 2009","profile_background_color":"C0DEED","expanded_url":null,"profile_background_image_url":"http:\/\/a0.twimg.com\/images\/themes\/theme1\/bg.png","utc_offset":-28800,"description":"Do more with less. ","display_url":null,"verified":false,"profile_image_url":"http:\/\/a2.twimg.com\/profile_images\/323680542\/Bluebird_of_Happiness_normal.jpg","id_str":"44709792","entities":{"user_mentions":[],"urls":[],"hashtags":[]},"contributors_enabled":true,"lang":"en","favourites_count":18,"profile_text_color":"333333","listed_count":161,"profile_sidebar_fill_color":"DDEEF6","screen_name":"teamteam","default_profile":true,"profile_background_tile":false,"location":"Twitter","notifications":false,"profile_background_image_url_https":"https:\/\/si0.twimg.com\/images\/themes\/theme1\/bg.png","friends_count":633,"profile_link_color":"0084B4","url":"http:\/\/www.flickr.com\/photos\/twitteroffice","profile_image_url_https":"https:\/\/si0.twimg.com\/profile_images\/323680542\/Bluebird_of_Happiness_normal.jpg","id":44709792,"default_profile_image":false,"show_all_inline_media":false,"following":false,"geo_enabled":false,"profile_sidebar_border_color":"C0DEED","followers_count":433},{"time_zone":"Pacific Time (US & Canada)","protected":true,"profile_use_background_image":true,"name":"Shoutout","contributors_enabled":true,"created_at":"Sun Dec 27 19:22:01 +0000 2009","profile_background_color":"022330","expanded_url":null,"listed_count":61,"profile_background_image_url":"http:\/\/a0.twimg.com\/images\/themes\/theme15\/bg.png","utc_offset":-28800,"description":"Contribute your shoutouts to peeps.","display_url":null,"verified":false,"profile_image_url":"http:\/\/a2.twimg.com\/profile_images\/597683385\/shout_normal.png","id_str":"99765600","entities":{"user_mentions":[],"urls":[],"hashtags":[]},"lang":"en","profile_background_image_url_https":"https:\/\/si0.twimg.com\/images\/themes\/theme15\/bg.png","favourites_count":8,"profile_text_color":"333333","friends_count":3,"profile_sidebar_fill_color":"C0DFEC","profile_image_url_https":"https:\/\/si0.twimg.com\/profile_images\/597683385\/shout_normal.png","screen_name":"twittershoutout","default_profile_image":false,"default_profile":false,"show_all_inline_media":false,"geo_enabled":true,"profile_background_tile":false,"location":"","notifications":false,"is_translator":false,"profile_link_color":"0084B4","url":"http:\/\/twitter.com","id":99765600,"follow_request_sent":false,"statuses_count":693,"following":false,"profile_sidebar_border_color":"a8c7f7","followers_count":336},{"time_zone":"Pacific Time (US & Canada)","protected":false,"is_translator":false,"profile_use_background_image":true,"name":"Anywhere","follow_request_sent":null,"statuses_count":31,"created_at":"Sun Oct 21 09:05:41 +0000 2007","profile_background_color":"022330","expanded_url":null,"profile_background_image_url":"http:\/\/a0.twimg.com\/images\/themes\/theme15\/bg.png","utc_offset":-28800,"description":"Here. There. Anywhere.","display_url":null,"verified":false,"profile_image_url":"http:\/\/a1.twimg.com\/profile_images\/754566723\/_anywhere_normal.png","id_str":"9576402","entities":{"user_mentions":[],"urls":[],"hashtags":[]},"contributors_enabled":true,"lang":"en","favourites_count":11,"profile_text_color":"333333","status":{"truncated":false,"created_at":"Tue Feb 01 05:28:46 +0000 2011","geo":null,"in_reply_to_user_id":null,"in_reply_to_status_id":null,"favorited":false,"possibly_sensitive":false,"in_reply_to_status_id_str":null,"coordinates":null,"id_str":"32309362097651712","in_reply_to_screen_name":null,"in_reply_to_user_id_str":null,"place":{"country_code":"US","name":"Ashbury Heights","attributes":{},"full_name":"Ashbury Heights, San Francisco","place_type":"neighborhood","country":"United States","bounding_box":{"type":"Polygon","coordinates":[[[-122.45778216,37.75932999],[-122.44248216,37.75932999],[-122.44248216,37.76752899],[-122.45778216,37.76752899]]]},"id":"866269c983527d5a","url":"http:\/\/api.twitter.com\/1\/geo\/id\/866269c983527d5a.json"},"contributors":[777925],"retweeted":false,"retweet_count":75,"source":"web","id":32309362097651712,"text":"Version 1.2 was released today. If you version locked to anything other than '1' you need to update now. Read more: http:\/\/t.co\/ACcUovI"},"listed_count":2246,"profile_sidebar_fill_color":"C0DFEC","screen_name":"anywhere","profile_background_tile":false,"location":"Twitter, HQ","notifications":null,"profile_background_image_url_https":"https:\/\/si0.twimg.com\/images\/themes\/theme15\/bg.png","default_profile":false,"friends_count":16,"profile_link_color":"0084B4","url":null,"profile_image_url_https":"https:\/\/si0.twimg.com\/profile_images\/754566723\/_anywhere_normal.png","id":9576402,"default_profile_image":false,"show_all_inline_media":false,"following":null,"geo_enabled":true,"profile_sidebar_border_color":"a8c7f7","followers_count":47444},{"is_translator":false,"time_zone":"Alaska","protected":false,"follow_request_sent":false,"statuses_count":0,"profile_use_background_image":true,"name":"Geo Team","created_at":"Thu Jan 07 20:30:42 +0000 2010","profile_background_color":"C0DEED","expanded_url":null,"profile_background_image_url":"http:\/\/a0.twimg.com\/images\/themes\/theme1\/bg.png","utc_offset":-32400,"description":"All your lats and longs are belong to us","display_url":null,"contributors_enabled":true,"verified":false,"profile_image_url":"http:\/\/a2.twimg.com\/profile_images\/622831073\/Geo-profile-icon_normal.png","id_str":"102782288","entities":{"user_mentions":[],"urls":[],"hashtags":[]},"listed_count":202,"lang":"en","favourites_count":0,"profile_text_color":"333333","profile_sidebar_fill_color":"DDEEF6","screen_name":"geo","profile_background_tile":false,"profile_background_image_url_https":"https:\/\/si0.twimg.com\/images\/themes\/theme1\/bg.png","location":"San Francisco, CA","notifications":false,"friends_count":0,"profile_image_url_https":"https:\/\/si0.twimg.com\/profile_images\/622831073\/Geo-profile-icon_normal.png","default_profile_image":false,"default_profile":true,"show_all_inline_media":false,"geo_enabled":true,"profile_link_color":"0084B4","url":null,"id":102782288,"following":false,"profile_sidebar_border_color":"C0DEED","followers_count":3596},{"time_zone":null,"protected":false,"default_profile":true,"listed_count":98,"profile_use_background_image":true,"name":"Site Streams Beta","created_at":"Fri Aug 27 18:04:38 +0000 2010","profile_background_color":"C0DEED","expanded_url":null,"profile_background_image_url_https":"https:\/\/si0.twimg.com\/images\/themes\/theme1\/bg.png","profile_background_image_url":"http:\/\/a0.twimg.com\/images\/themes\/theme1\/bg.png","utc_offset":null,"description":"Twitter Site Streams Beta Announcements. When reporting an issue, include account & UTC. You may DM critical outages.","display_url":null,"contributors_enabled":true,"verified":true,"friends_count":1,"profile_image_url":"http:\/\/a1.twimg.com\/profile_images\/1112022529\/api_normal.png","id_str":"183709371","entities":{"user_mentions":[],"urls":[],"hashtags":[]},"default_profile_image":false,"lang":"en","favourites_count":0,"profile_text_color":"333333","status":{"truncated":false,"created_at":"Thu Aug 18 19:39:20 +0000 2011","geo":null,"in_reply_to_user_id":null,"in_reply_to_status_id":null,"favorited":false,"in_reply_to_status_id_str":null,"coordinates":null,"id_str":"104276210699341825","in_reply_to_screen_name":null,"in_reply_to_user_id_str":null,"place":null,"contributors":[777925],"retweeted":false,"retweet_count":0,"source":"web","id":104276210699341825,"text":"For the moment we've stopped the rollout of the new SSL certificate for sitestreams. We'll tweet again when we resume."},"show_all_inline_media":false,"geo_enabled":false,"profile_sidebar_fill_color":"DDEEF6","profile_image_url_https":"https:\/\/si0.twimg.com\/profile_images\/1112022529\/api_normal.png","screen_name":"sitestreams","is_translator":false,"profile_background_tile":false,"location":"San Francisco, CA","follow_request_sent":false,"notifications":false,"statuses_count":139,"profile_link_color":"0084B4","url":"http:\/\/twitter.com","id":183709371,"following":false,"profile_sidebar_border_color":"C0DEED","followers_count":2199}]
Loading

0 comments on commit 2b88f81

Please sign in to comment.