lib/twitter/rest/tweets.rb in twitter-5.12.0 vs lib/twitter/rest/tweets.rb in twitter-5.13.0
- old
+ new
@@ -1,9 +1,9 @@
require 'twitter/arguments'
require 'twitter/error'
require 'twitter/oembed'
-require 'twitter/request'
+require 'twitter/rest/request'
require 'twitter/rest/utils'
require 'twitter/tweet'
require 'twitter/utils'
module Twitter
@@ -23,11 +23,11 @@
# @param tweet [Integer, String, URI, Twitter::Tweet] A Tweet ID, URI, or object.
# @param options [Hash] A customizable set of options.
# @option options [Integer] :count Specifies the number of records to retrieve. Must be less than or equal to 100.
# @option options [Boolean, String, Integer] :trim_user Each tweet returned in a timeline will include a user object with only the author's numerical ID when set to true, 't' or 1.
def retweets(tweet, options = {})
- perform_with_objects(:get, "/1.1/statuses/retweets/#{extract_id(tweet)}.json", options, Twitter::Tweet)
+ perform_get_with_objects("/1.1/statuses/retweets/#{extract_id(tweet)}.json", options, Twitter::Tweet)
end
# Show up to 100 users who retweeted the Tweet
#
# @see https://dev.twitter.com/docs/api/1.1/get/statuses/retweets/:id
@@ -56,11 +56,11 @@
# @return [Twitter::Tweet] The requested Tweet.
# @param tweet [Integer, String, URI, Twitter::Tweet] A Tweet ID, URI, or object.
# @param options [Hash] A customizable set of options.
# @option options [Boolean, String, Integer] :trim_user Each tweet returned in a timeline will include a user object with only the author's numerical ID when set to true, 't' or 1.
def status(tweet, options = {})
- perform_with_object(:get, "/1.1/statuses/show/#{extract_id(tweet)}.json", options, Twitter::Tweet)
+ perform_get_with_object("/1.1/statuses/show/#{extract_id(tweet)}.json", options, Twitter::Tweet)
end
# Returns Tweets
#
# @see https://dev.twitter.com/docs/api/1.1/get/statuses/lookup
@@ -70,17 +70,15 @@
# @overload statuses(*tweets)
# @param tweets [Enumerable<Integer, String, URI, Twitter::Tweet>] A collection of Tweet IDs, URIs, or objects.
# @overload statuses(*tweets, options)
# @param tweets [Enumerable<Integer, String, URI, Twitter::Tweet>] A collection of Tweet IDs, URIs, 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, String, Integer] :trim_user Each tweet returned in a timeline will include a user object with only the author's numerical ID when set to true, 't' or 1.
def statuses(*args)
arguments = Twitter::Arguments.new(args)
- request_method = arguments.options.delete(:method) || :post
flat_pmap(arguments.each_slice(MAX_TWEETS_PER_REQUEST)) do |tweets|
- perform_with_objects(request_method, '/1.1/statuses/lookup.json', arguments.options.merge(:id => tweets.collect { |u| extract_id(u) }.join(',')), Twitter::Tweet)
+ perform_post_with_objects('/1.1/statuses/lookup.json', arguments.options.merge(:id => tweets.collect { |u| extract_id(u) }.join(',')), Twitter::Tweet)
end
end
# Destroys the specified Tweets
#
@@ -97,11 +95,11 @@
# @param options [Hash] A customizable set of options.
# @option options [Boolean, String, Integer] :trim_user Each tweet returned in a timeline will include a user object with only the author's numerical ID when set to true, 't' or 1.
def destroy_status(*args)
arguments = Twitter::Arguments.new(args)
pmap(arguments) do |tweet|
- perform_with_object(:post, "/1.1/statuses/destroy/#{extract_id(tweet)}.json", arguments.options, Twitter::Tweet)
+ perform_post_with_object("/1.1/statuses/destroy/#{extract_id(tweet)}.json", arguments.options, Twitter::Tweet)
end
end
alias_method :destroy_tweet, :destroy_status
deprecate_alias :status_destroy, :destroy_status
deprecate_alias :tweet_destroy, :destroy_status
@@ -155,11 +153,11 @@
# @option options [Boolean, String, Integer] :trim_user Each tweet returned in a timeline will include a user object with only the author's numerical ID when set to true, 't' or 1.
def update!(status, options = {})
hash = options.dup
hash[:in_reply_to_status_id] = hash.delete(:in_reply_to_status).id unless hash[:in_reply_to_status].nil?
hash[:place_id] = hash.delete(:place).woeid unless hash[:place].nil?
- perform_with_object(:post, '/1.1/statuses/update.json', hash.merge(:status => status), Twitter::Tweet)
+ perform_post_with_object('/1.1/statuses/update.json', hash.merge(:status => status), Twitter::Tweet)
end
# Retweets the specified Tweets as the authenticating user
#
# @see https://dev.twitter.com/docs/api/1.1/post/statuses/retweet/:id
@@ -230,11 +228,11 @@
def update_with_media(status, media, options = {})
fail(Twitter::Error::UnacceptableIO.new) unless media.respond_to?(:to_io)
hash = options.dup
hash[:in_reply_to_status_id] = hash.delete(:in_reply_to_status).id unless hash[:in_reply_to_status].nil?
hash[:place_id] = hash.delete(:place).woeid unless hash[:place].nil?
- perform_with_object(:post, '/1.1/statuses/update_with_media.json', hash.merge('media[]' => media, 'status' => status), Twitter::Tweet)
+ perform_post_with_object('/1.1/statuses/update_with_media.json', hash.merge('media[]' => media, 'status' => status), Twitter::Tweet)
end
# Returns oEmbed for a Tweet
#
# @see https://dev.twitter.com/docs/api/1.1/get/statuses/oembed
@@ -251,11 +249,11 @@
# @option options [String] :align Specifies whether the embedded Tweet should be left aligned, right aligned, or centered in the page. Valid values are left, right, center, and none. Defaults to none, meaning no alignment styles are specified for the Tweet.
# @option options [String] :related A value for the TWT related parameter, as described in {https://dev.twitter.com/docs/intents Web Intents}. This value will be forwarded to all Web Intents calls.
# @option options [String] :lang Language code for the rendered embed. This will affect the text and localization of the rendered HTML.
def oembed(tweet, options = {})
options[:id] = extract_id(tweet)
- perform_with_object(:get, '/1.1/statuses/oembed.json', options, Twitter::OEmbed)
+ perform_get_with_object('/1.1/statuses/oembed.json', options, Twitter::OEmbed)
end
# Returns oEmbeds for Tweets
#
# @see https://dev.twitter.com/docs/api/1.1/get/statuses/oembed
@@ -295,16 +293,16 @@
# @param tweet [Integer, String, URI, Twitter::Tweet] A Tweet ID, URI, or object.
# @param options [Hash] A customizable set of options.
def retweeters_ids(*args)
arguments = Twitter::Arguments.new(args)
arguments.options[:id] ||= extract_id(arguments.first)
- perform_with_cursor(:get, '/1.1/statuses/retweeters/ids.json', arguments.options, :ids)
+ perform_get_with_cursor('/1.1/statuses/retweeters/ids.json', arguments.options, :ids)
end
private
def post_retweet(tweet, options)
- response = post("/1.1/statuses/retweet/#{extract_id(tweet)}.json", options).body
+ response = perform_post("/1.1/statuses/retweet/#{extract_id(tweet)}.json", options)
Twitter::Tweet.new(response)
end
end
end
end