lib/twitter/rest/tweets.rb in twitter-7.0.0 vs lib/twitter/rest/tweets.rb in twitter-8.0.0.rc.1

- old
+ new

@@ -1,13 +1,13 @@ -require 'twitter/arguments' -require 'twitter/error' -require 'twitter/oembed' -require 'twitter/rest/request' -require 'twitter/rest/upload_utils' -require 'twitter/rest/utils' -require 'twitter/tweet' -require 'twitter/utils' +require "twitter/arguments" +require "twitter/error" +require "twitter/oembed" +require "twitter/rest/request" +require "twitter/rest/upload_utils" +require "twitter/rest/utils" +require "twitter/tweet" +require "twitter/utils" module Twitter module REST module Tweets include Twitter::REST::UploadUtils @@ -77,11 +77,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 statuses(*args) arguments = Twitter::Arguments.new(args) flat_pmap(arguments.each_slice(MAX_TWEETS_PER_REQUEST)) do |tweets| - perform_post_with_objects('/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 # @@ -152,11 +152,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_post_with_object('/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/rest/reference/post/statuses/retweet/:id @@ -171,15 +171,13 @@ # @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 retweet(*args) arguments = Twitter::Arguments.new(args) pmap(arguments) do |tweet| - begin - post_retweet(extract_id(tweet), arguments.options) - rescue Twitter::Error::AlreadyRetweeted, Twitter::Error::NotFound - next - end + post_retweet(extract_id(tweet), arguments.options) + rescue Twitter::Error::AlreadyRetweeted, Twitter::Error::NotFound + next end.compact end # Retweets the specified Tweets as the authenticating user and raises an error if one has already been retweeted # @@ -226,11 +224,11 @@ def update_with_media(status, media, options = {}) options = options.dup media_ids = pmap(array_wrap(media)) do |medium| upload(medium)[:media_id] end - update!(status, options.merge(media_ids: media_ids.join(','))) + update!(status, options.merge(media_ids: media_ids.join(","))) end # Returns oEmbed for a Tweet # # @see https://dev.twitter.com/rest/reference/get/statuses/oembed @@ -250,11 +248,11 @@ # @option options [String] :widget_type Set to video to return a Twitter Video embed for the given Tweet. # @option options [Boolean, String] :hide_tweet Applies to video type only. Set to 1 or true to link directly to the Tweet URL instead of displaying a Tweet overlay when a viewer clicks on the Twitter bird logo. def oembed(tweet, options = {}) options = options.dup options[:id] = extract_id(tweet) - perform_get_with_object('/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/rest/reference/get/statuses/oembed @@ -294,11 +292,11 @@ # @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_get_with_cursor('/1.1/statuses/retweeters/ids.json', arguments.options, :ids) + perform_get_with_cursor("/1.1/statuses/retweeters/ids.json", arguments.options, :ids) end # Untweets a retweeted status as the authenticating user # # @see https://dev.twitter.com/rest/reference/post/statuses/unretweet/:id @@ -313,14 +311,12 @@ # @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 unretweet(*args) arguments = Twitter::Arguments.new(args) pmap(arguments) do |tweet| - begin - post_unretweet(extract_id(tweet), arguments.options) - rescue Twitter::Error::NotFound - next - end + post_unretweet(extract_id(tweet), arguments.options) + rescue Twitter::Error::NotFound + next end.compact end private