lib/twitter/api/users.rb in twitter-4.3.0 vs lib/twitter/api/users.rb in twitter-4.4.0

- old
+ new

@@ -237,19 +237,26 @@ # @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid. # @return [Array<Twitter::User>] The requested users. # @overload users(*users) # @param users [Array<Integer, String, Twitter::User>, Set<Integer, String, Twitter::User>] An array of Twitter user IDs, screen names, or objects. # @example Return extended information for @sferik and @pengwynn - # Twitter.users('sferik', 'pengwynn') - # Twitter.users(7505382, 14100886) # Same as above + # Twitter.users('sferik', 'pengwynn') # Retrieve users with a POST request using screen_names + # Twitter.users(7505382, 14100886) # Same as above using twitter_ids # @overload users(*users, options) # @param users [Array<Integer, String, Twitter::User>, Set<Integer, String, Twitter::User>] An array of Twitter user IDs, screen names, or objects. # @param options [Hash] A customizable set of options. + # @option options [Symbol, String] :method Requests users via a GET request instead of the standard POST request if set to ':get'. + # @option options [Boolean] :include_entities The tweet entities node will be disincluded when set to false. + # @example Return extended information for @sferik and @pengwynn + # Twitter.users('sferik', 'pengwynn', :method => :get) # Retrieve users with a GET request + # Twitter.users(7505382, 14100886, {:method => :get}) # Same as above + # Twitter.users(7505382, 14100886, {:method => :get, :include_entities => false}) # See Twitter API documentation def users(*args) - options = args.extract_options! + options = extract_options!(args) + method = options.delete(:method) || :post args.flatten.each_slice(MAX_USERS_PER_REQUEST).threaded_map do |users| - collection_from_response(Twitter::User, :post, "/1.1/users/lookup.json", options.merge_users(users)) + collection_from_response(Twitter::User, method, "/1.1/users/lookup.json", merge_users(options, users)) end.flatten end # @see https://dev.twitter.com/docs/api/1.1/get/users/show # @rate_limited Yes @@ -270,13 +277,13 @@ # @param options [Hash] A customizable set of options. # @example Return extended information for @sferik # Twitter.user('sferik') # Twitter.user(7505382) # Same as above def user(*args) - options = args.extract_options! + options = extract_options!(args) if user = args.pop - options.merge_user!(user) + merge_user!(options, user) object_from_response(Twitter::User, :get, "/1.1/users/show.json", options) else verify_credentials(options) end end @@ -290,11 +297,11 @@ # @param user [Integer, String, Twitter::User] A Twitter user ID, screen name, or object. # @example Return true if @sferik exists # Twitter.user?('sferik') # Twitter.user?(7505382) # Same as above def user?(user, options={}) - options.merge_user!(user) + merge_user!(options, user) get("/1.1/users/show.json", options) true rescue Twitter::Error::NotFound false end @@ -414,14 +421,13 @@ # @param user [Integer, String, Twitter::User] A Twitter user ID, screen name, or object. # @example Return the specified user's profile banner # Twitter.profile_banner('sferik') # Twitter.profile_banner(7505382) # Same as above def profile_banner(*args) - options = args.extract_options! - options.merge_user!(args.pop || screen_name) + options = extract_options!(args) + merge_user!(options, args.pop || screen_name) object_from_response(Twitter::ProfileBanner, :get, "/1.1/users/profile_banner.json", options) end - end end end