Module: OauthTwitter::API::Users
- Included in:
- OauthTwitter
- Defined in:
- lib/oauth_twitter/api/users.rb
Constant Summary collapse
- PATH =
{ :users_lookup => '/1.1/users/lookup.json', :users_show => '/1.1/users/show.json', :users_search => '/1.1/users/search.json', :users_contributees => '/1.1/users/contributees.json', :users_contributors => '/1.1/users/contributors.json', :users_profile_banner => '/1.1/users/profile_banner.json' }
Instance Method Summary collapse
- #users_contributees(params, options = {}) ⇒ Object
- #users_contributors(params, options = {}) ⇒ Object
- #users_lookup(params, options = {}) ⇒ Object
- #users_profile_banner(params = {}, options = {}) ⇒ Object
- #users_search(params, options = {}) ⇒ Object
- #users_show(params, options = {}) ⇒ Object
Instance Method Details
#users_contributees(params, options = {}) ⇒ Object
52 53 54 |
# File 'lib/oauth_twitter/api/users.rb', line 52 def users_contributees(params, ={}) return send_request(:GET, PATH[:users_contributees], params, true, ) end |
#users_contributors(params, options = {}) ⇒ Object
56 57 58 |
# File 'lib/oauth_twitter/api/users.rb', line 56 def users_contributors(params, ={}) return send_request(:GET, PATH[:users_contributors], params, true, ) end |
#users_lookup(params, options = {}) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/oauth_twitter/api/users.rb', line 16 def users_lookup(params, ={}) query = params.clone users_array = query[:screen_name] || query[:user_id] users_array_type = (query[:screen_name]) ? :screen_name : :user_id # slice id_array for multiple request num_of_set = users_array.size / 100 num_of_set += 1 if users_array.size % 100 > 0 id_sets = num_of_set.times.map {|i| users_array.slice(i*100, (i+1)*100)} # send request full_response = [] response = nil id_sets.each do |set| query[users_array_type] = set.join(',') method = set.size <= 10 ? :GET : :POST response = send_request(method, PATH[:users_lookup], query, true) if response[:valid] full_response += response[:data] else break end end # return return assemble_multi_page_response(full_response, response, ) end |
#users_profile_banner(params = {}, options = {}) ⇒ Object
60 61 62 |
# File 'lib/oauth_twitter/api/users.rb', line 60 def (params={}, ={}) return send_request(:GET, PATH[:users_profile_banner], params, true, ) end |
#users_search(params, options = {}) ⇒ Object
48 49 50 |
# File 'lib/oauth_twitter/api/users.rb', line 48 def users_search(params, ={}) return send_request(:GET, PATH[:users_search], params, true, ) end |
#users_show(params, options = {}) ⇒ Object
44 45 46 |
# File 'lib/oauth_twitter/api/users.rb', line 44 def users_show(params, ={}) return send_request(:GET, PATH[:users_show], params, true, ) end |