twitter 5.0.0 → 5.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.yardopts +4 -0
- data/CHANGELOG.md +47 -0
- data/CONTRIBUTING.md +5 -5
- data/README.md +57 -56
- data/Rakefile +26 -5
- data/lib/twitter/arguments.rb +1 -2
- data/lib/twitter/base.rb +15 -18
- data/lib/twitter/basic_user.rb +3 -3
- data/lib/twitter/client.rb +9 -10
- data/lib/twitter/configuration.rb +5 -5
- data/lib/twitter/creatable.rb +0 -1
- data/lib/twitter/cursor.rb +9 -36
- data/lib/twitter/direct_message.rb +1 -1
- data/lib/twitter/entity/uri.rb +2 -2
- data/lib/twitter/enumerable.rb +10 -1
- data/lib/twitter/error/already_favorited.rb +1 -1
- data/lib/twitter/error/already_posted.rb +1 -1
- data/lib/twitter/error/already_retweeted.rb +1 -1
- data/lib/twitter/error/too_many_requests.rb +2 -2
- data/lib/twitter/error.rb +6 -6
- data/lib/twitter/factory.rb +2 -6
- data/lib/twitter/geo/point.rb +3 -5
- data/lib/twitter/geo.rb +1 -1
- data/lib/twitter/geo_factory.rb +1 -5
- data/lib/twitter/geo_results.rb +5 -8
- data/lib/twitter/identity.rb +1 -2
- data/lib/twitter/list.rb +10 -11
- data/lib/twitter/media/photo.rb +1 -2
- data/lib/twitter/media_factory.rb +1 -5
- data/lib/twitter/null_object.rb +4 -6
- data/lib/twitter/oembed.rb +1 -1
- data/lib/twitter/place.rb +17 -6
- data/lib/twitter/profile_banner.rb +1 -3
- data/lib/twitter/rate_limit.rb +1 -3
- data/lib/twitter/relationship.rb +1 -2
- data/lib/twitter/rest/api/direct_messages.rb +15 -15
- data/lib/twitter/rest/api/favorites.rb +15 -15
- data/lib/twitter/rest/api/friends_and_followers.rb +37 -42
- data/lib/twitter/rest/api/help.rb +8 -9
- data/lib/twitter/rest/api/lists.rb +69 -69
- data/lib/twitter/rest/api/oauth.rb +3 -4
- data/lib/twitter/rest/api/places_and_geo.rb +9 -10
- data/lib/twitter/rest/api/saved_searches.rb +8 -8
- data/lib/twitter/rest/api/search.rb +10 -2
- data/lib/twitter/rest/api/spam_reporting.rb +1 -2
- data/lib/twitter/rest/api/suggested_users.rb +4 -5
- data/lib/twitter/rest/api/timelines.rb +17 -18
- data/lib/twitter/rest/api/trends.rb +10 -11
- data/lib/twitter/rest/api/tweets.rb +31 -20
- data/lib/twitter/rest/api/undocumented.rb +6 -7
- data/lib/twitter/rest/api/users.rb +53 -54
- data/lib/twitter/rest/api/utils.rb +28 -34
- data/lib/twitter/rest/client.rb +8 -9
- data/lib/twitter/rest/request/multipart_with_file.rb +7 -5
- data/lib/twitter/rest/response/parse_error_json.rb +0 -2
- data/lib/twitter/rest/response/parse_json.rb +2 -2
- data/lib/twitter/rest/response/raise_error.rb +1 -3
- data/lib/twitter/search_results.rb +38 -56
- data/lib/twitter/settings.rb +2 -2
- data/lib/twitter/size.rb +2 -2
- data/lib/twitter/source_user.rb +1 -1
- data/lib/twitter/streaming/client.rb +69 -18
- data/lib/twitter/streaming/connection.rb +1 -3
- data/lib/twitter/streaming/deleted_tweet.rb +8 -0
- data/lib/twitter/streaming/event.rb +8 -8
- data/lib/twitter/streaming/friend_list.rb +2 -9
- data/lib/twitter/streaming/message_parser.rb +13 -3
- data/lib/twitter/streaming/response.rb +0 -2
- data/lib/twitter/streaming/stall_warning.rb +7 -0
- data/lib/twitter/suggestion.rb +0 -1
- data/lib/twitter/token.rb +2 -3
- data/lib/twitter/trend_results.rb +5 -8
- data/lib/twitter/tweet.rb +17 -18
- data/lib/twitter/user.rb +33 -35
- data/lib/twitter/utils.rb +14 -0
- data/lib/twitter/version.rb +2 -5
- data/lib/twitter.rb +1 -1
- data/spec/fixtures/forbidden.json +1 -0
- data/spec/fixtures/search.json +1 -1
- data/spec/fixtures/search2.json +1 -0
- data/spec/fixtures/track_streaming_user.json +2 -1
- data/spec/helper.rb +6 -2
- data/spec/twitter/base_spec.rb +9 -9
- data/spec/twitter/basic_user_spec.rb +6 -6
- data/spec/twitter/configuration_spec.rb +4 -4
- data/spec/twitter/cursor_spec.rb +13 -51
- data/spec/twitter/direct_message_spec.rb +36 -36
- data/spec/twitter/entity/uri_spec.rb +29 -29
- data/spec/twitter/error_spec.rb +21 -21
- data/spec/twitter/geo/point_spec.rb +9 -9
- data/spec/twitter/geo/polygon_spec.rb +5 -5
- data/spec/twitter/geo_factory_spec.rb +7 -7
- data/spec/twitter/geo_results_spec.rb +11 -11
- data/spec/twitter/geo_spec.rb +5 -5
- data/spec/twitter/identifiable_spec.rb +9 -9
- data/spec/twitter/list_spec.rb +38 -38
- data/spec/twitter/media/photo_spec.rb +58 -58
- data/spec/twitter/media_factory_spec.rb +5 -5
- data/spec/twitter/null_object_spec.rb +6 -6
- data/spec/twitter/oembed_spec.rb +68 -68
- data/spec/twitter/place_spec.rb +91 -62
- data/spec/twitter/profile_banner_spec.rb +3 -3
- data/spec/twitter/rate_limit_spec.rb +18 -18
- data/spec/twitter/relationship_spec.rb +16 -16
- data/spec/twitter/rest/api/direct_messages_spec.rb +61 -61
- data/spec/twitter/rest/api/favorites_spec.rb +93 -93
- data/spec/twitter/rest/api/friends_and_followers_spec.rb +357 -349
- data/spec/twitter/rest/api/geo_spec.rb +33 -33
- data/spec/twitter/rest/api/help_spec.rb +24 -24
- data/spec/twitter/rest/api/lists_spec.rb +487 -487
- data/spec/twitter/rest/api/oauth_spec.rb +30 -30
- data/spec/twitter/rest/api/saved_searches_spec.rb +50 -40
- data/spec/twitter/rest/api/search_spec.rb +27 -26
- data/spec/twitter/rest/api/spam_reporting_spec.rb +9 -9
- data/spec/twitter/rest/api/suggested_users_spec.rb +23 -23
- data/spec/twitter/rest/api/timelines_spec.rb +58 -58
- data/spec/twitter/rest/api/trends_spec.rb +26 -26
- data/spec/twitter/rest/api/tweets_spec.rb +304 -266
- data/spec/twitter/rest/api/undocumented_spec.rb +51 -51
- data/spec/twitter/rest/api/users_spec.rb +360 -360
- data/spec/twitter/rest/client_spec.rb +99 -103
- data/spec/twitter/saved_search_spec.rb +16 -16
- data/spec/twitter/search_results_spec.rb +14 -110
- data/spec/twitter/settings_spec.rb +8 -8
- data/spec/twitter/size_spec.rb +5 -5
- data/spec/twitter/source_user_spec.rb +6 -6
- data/spec/twitter/streaming/client_spec.rb +85 -54
- data/spec/twitter/streaming/deleted_tweet_spec.rb +23 -0
- data/spec/twitter/streaming/event_spec.rb +20 -22
- data/spec/twitter/streaming/friend_list_spec.rb +11 -0
- data/spec/twitter/streaming/message_parser_spec.rb +54 -0
- data/spec/twitter/suggestion_spec.rb +11 -11
- data/spec/twitter/target_user_spec.rb +6 -6
- data/spec/twitter/token_spec.rb +4 -4
- data/spec/twitter/trend_results_spec.rb +30 -30
- data/spec/twitter/trend_spec.rb +21 -21
- data/spec/twitter/tweet_spec.rb +178 -164
- data/spec/twitter/user_spec.rb +190 -190
- data/twitter.gemspec +6 -6
- data.tar.gz.sig +0 -0
- metadata +44 -16
- metadata.gz.sig +0 -0
- data/lib/twitter/core_ext/enumerable.rb +0 -10
- data/lib/twitter/core_ext/kernel.rb +0 -10
- data/spec/twitter_spec.rb +0 -0
|
@@ -13,12 +13,12 @@ module Twitter
|
|
|
13
13
|
# @rate_limited Yes
|
|
14
14
|
# @authentication Requires user context
|
|
15
15
|
# @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
|
|
16
|
-
# @overload suggestions(options={})
|
|
16
|
+
# @overload suggestions(options = {})
|
|
17
17
|
# Returns the list of suggested user categories
|
|
18
18
|
#
|
|
19
19
|
# @see https://dev.twitter.com/docs/api/1.1/get/users/suggestions
|
|
20
20
|
# @param options [Hash] A customizable set of options.
|
|
21
|
-
# @overload suggestions(slug, options={})
|
|
21
|
+
# @overload suggestions(slug, options = {})
|
|
22
22
|
# Returns the users in a given category
|
|
23
23
|
#
|
|
24
24
|
# @see https://dev.twitter.com/docs/api/1.1/get/users/suggestions/:slug
|
|
@@ -29,7 +29,7 @@ module Twitter
|
|
|
29
29
|
if arguments.last
|
|
30
30
|
object_from_response(Twitter::Suggestion, :get, "/1.1/users/suggestions/#{arguments.pop}.json", arguments.options)
|
|
31
31
|
else
|
|
32
|
-
objects_from_response(Twitter::Suggestion, :get,
|
|
32
|
+
objects_from_response(Twitter::Suggestion, :get, '/1.1/users/suggestions.json', arguments.options)
|
|
33
33
|
end
|
|
34
34
|
end
|
|
35
35
|
|
|
@@ -41,10 +41,9 @@ module Twitter
|
|
|
41
41
|
# @param slug [String] The short name of list or a category.
|
|
42
42
|
# @param options [Hash] A customizable set of options.
|
|
43
43
|
# @return [Array<Twitter::User>]
|
|
44
|
-
def suggest_users(slug, options={})
|
|
44
|
+
def suggest_users(slug, options = {})
|
|
45
45
|
objects_from_response(Twitter::User, :get, "/1.1/users/suggestions/#{slug}/members.json", options)
|
|
46
46
|
end
|
|
47
|
-
|
|
48
47
|
end
|
|
49
48
|
end
|
|
50
49
|
end
|
|
@@ -23,10 +23,10 @@ module Twitter
|
|
|
23
23
|
# @option options [Integer] :max_id Returns results with an ID less than (that is, older than) or equal to the specified ID.
|
|
24
24
|
# @option options [Integer] :count Specifies the number of records to retrieve. Must be less than or equal to 200.
|
|
25
25
|
# @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.
|
|
26
|
-
def mentions_timeline(options={})
|
|
27
|
-
objects_from_response(Twitter::Tweet, :get,
|
|
26
|
+
def mentions_timeline(options = {})
|
|
27
|
+
objects_from_response(Twitter::Tweet, :get, '/1.1/statuses/mentions_timeline.json', options)
|
|
28
28
|
end
|
|
29
|
-
|
|
29
|
+
alias_method :mentions, :mentions_timeline
|
|
30
30
|
|
|
31
31
|
# Returns the 20 most recent Tweets posted by the specified user
|
|
32
32
|
#
|
|
@@ -36,7 +36,7 @@ module Twitter
|
|
|
36
36
|
# @authentication Requires user context
|
|
37
37
|
# @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
|
|
38
38
|
# @return [Array<Twitter::Tweet>]
|
|
39
|
-
# @overload user_timeline(user, options={})
|
|
39
|
+
# @overload user_timeline(user, options = {})
|
|
40
40
|
# @param user [Integer, String, Twitter::User] A Twitter user ID, screen name, URI, or object.
|
|
41
41
|
# @param options [Hash] A customizable set of options.
|
|
42
42
|
# @option options [Integer] :since_id Returns results with an ID greater than (that is, more recent than) the specified ID.
|
|
@@ -47,7 +47,7 @@ module Twitter
|
|
|
47
47
|
# @option options [Boolean, String, Integer] :contributor_details Specifies that the contributors element should be enhanced to include the screen_name of the contributor.
|
|
48
48
|
# @option options [Boolean, String, Integer] :include_rts Specifies that the timeline should include native retweets in addition to regular tweets. Note: If you're using the trim_user parameter in conjunction with include_rts, the retweets will no longer contain a full user object.
|
|
49
49
|
def user_timeline(*args)
|
|
50
|
-
objects_from_response_with_user(Twitter::Tweet, :get,
|
|
50
|
+
objects_from_response_with_user(Twitter::Tweet, :get, '/1.1/statuses/user_timeline.json', args)
|
|
51
51
|
end
|
|
52
52
|
|
|
53
53
|
# Returns the 20 most recent retweets posted by the specified user
|
|
@@ -66,12 +66,12 @@ module Twitter
|
|
|
66
66
|
# @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.
|
|
67
67
|
# @option options [Boolean, String, Integer] :exclude_replies This parameter will prevent replies from appearing in the returned timeline. Using exclude_replies with the count parameter will mean you will receive up-to count tweets - this is because the count parameter retrieves that many tweets before filtering out retweets and replies.
|
|
68
68
|
# @option options [Boolean, String, Integer] :contributor_details Specifies that the contributors element should be enhanced to include the screen_name of the contributor.
|
|
69
|
-
def retweeted_by_user(user, options={})
|
|
69
|
+
def retweeted_by_user(user, options = {})
|
|
70
70
|
retweets_from_timeline(options) do |opts|
|
|
71
71
|
user_timeline(user, opts)
|
|
72
72
|
end
|
|
73
73
|
end
|
|
74
|
-
|
|
74
|
+
alias_method :retweeted_by, :retweeted_by_user
|
|
75
75
|
|
|
76
76
|
# Returns the 20 most recent retweets posted by the authenticating user
|
|
77
77
|
#
|
|
@@ -88,7 +88,7 @@ module Twitter
|
|
|
88
88
|
# @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.
|
|
89
89
|
# @option options [Boolean, String, Integer] :exclude_replies This parameter will prevent replies from appearing in the returned timeline. Using exclude_replies with the count parameter will mean you will receive up-to count tweets - this is because the count parameter retrieves that many tweets before filtering out retweets and replies.
|
|
90
90
|
# @option options [Boolean, String, Integer] :contributor_details Specifies that the contributors element should be enhanced to include the screen_name of the contributor.
|
|
91
|
-
def retweeted_by_me(options={})
|
|
91
|
+
def retweeted_by_me(options = {})
|
|
92
92
|
retweets_from_timeline(options) do |opts|
|
|
93
93
|
user_timeline(opts)
|
|
94
94
|
end
|
|
@@ -111,8 +111,8 @@ module Twitter
|
|
|
111
111
|
# @option options [Boolean, String, Integer] :include_rts Specifies that the timeline should include native retweets in addition to regular tweets. Note: If you're using the trim_user parameter in conjunction with include_rts, the retweets will no longer contain a full user object.
|
|
112
112
|
# @option options [Boolean, String, Integer] :contributor_details Specifies that the contributors element should be enhanced to include the screen_name of the contributor.
|
|
113
113
|
# @option options [Boolean, String, Integer] :include_entities The tweet entities node will be disincluded when set to false.
|
|
114
|
-
def home_timeline(options={})
|
|
115
|
-
objects_from_response(Twitter::Tweet, :get,
|
|
114
|
+
def home_timeline(options = {})
|
|
115
|
+
objects_from_response(Twitter::Tweet, :get, '/1.1/statuses/home_timeline.json', options)
|
|
116
116
|
end
|
|
117
117
|
|
|
118
118
|
# Returns the 20 most recent retweets posted by users the authenticating user follow.
|
|
@@ -131,7 +131,7 @@ module Twitter
|
|
|
131
131
|
# @option options [Boolean, String, Integer] :exclude_replies This parameter will prevent replies from appearing in the returned timeline. Using exclude_replies with the count parameter will mean you will receive up-to count tweets - this is because the count parameter retrieves that many tweets before filtering out retweets and replies.
|
|
132
132
|
# @option options [Boolean, String, Integer] :contributor_details Specifies that the contributors element should be enhanced to include the screen_name of the contributor.
|
|
133
133
|
# @option options [Boolean, String, Integer] :include_entities The tweet entities node will be disincluded when set to false.
|
|
134
|
-
def retweeted_to_me(options={})
|
|
134
|
+
def retweeted_to_me(options = {})
|
|
135
135
|
retweets_from_timeline(options) do |opts|
|
|
136
136
|
home_timeline(opts)
|
|
137
137
|
end
|
|
@@ -151,8 +151,8 @@ module Twitter
|
|
|
151
151
|
# @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.
|
|
152
152
|
# @option options [Boolean, String, Integer] :include_entities The tweet entities node will be disincluded when set to false.
|
|
153
153
|
# @option options [Boolean, String, Integer] :include_user_entities The user entities node will be disincluded when set to false.
|
|
154
|
-
def retweets_of_me(options={})
|
|
155
|
-
objects_from_response(Twitter::Tweet, :get,
|
|
154
|
+
def retweets_of_me(options = {})
|
|
155
|
+
objects_from_response(Twitter::Tweet, :get, '/1.1/statuses/retweets_of_me.json', options)
|
|
156
156
|
end
|
|
157
157
|
|
|
158
158
|
private
|
|
@@ -166,13 +166,13 @@ module Twitter
|
|
|
166
166
|
end
|
|
167
167
|
|
|
168
168
|
# @param tweets [Array]
|
|
169
|
-
# @return [Array]
|
|
169
|
+
# @return [Array<Twitter::Tweet>]
|
|
170
170
|
def select_retweets(tweets)
|
|
171
171
|
tweets.select(&:retweet?)
|
|
172
172
|
end
|
|
173
173
|
|
|
174
174
|
# @param count [Integer]
|
|
175
|
-
# @return [Array]
|
|
175
|
+
# @return [Array<Twitter::Tweet>]
|
|
176
176
|
def collect_with_count(count, &block)
|
|
177
177
|
options = {}
|
|
178
178
|
options[:count] = MAX_TWEETS_PER_REQUEST
|
|
@@ -188,14 +188,13 @@ module Twitter
|
|
|
188
188
|
|
|
189
189
|
# @param collection [Array]
|
|
190
190
|
# @param max_id [Integer, NilClass]
|
|
191
|
-
# @return [Array]
|
|
192
|
-
def collect_with_max_id(collection=[], max_id=nil, &block)
|
|
191
|
+
# @return [Array<Twitter::Tweet>]
|
|
192
|
+
def collect_with_max_id(collection = [], max_id = nil, &block)
|
|
193
193
|
tweets = yield(max_id)
|
|
194
194
|
return collection if tweets.nil?
|
|
195
195
|
collection += tweets
|
|
196
196
|
tweets.empty? ? collection.flatten : collect_with_max_id(collection, tweets.last.id - 1, &block)
|
|
197
197
|
end
|
|
198
|
-
|
|
199
198
|
end
|
|
200
199
|
end
|
|
201
200
|
end
|
|
@@ -14,16 +14,16 @@ module Twitter
|
|
|
14
14
|
# @rate_limited Yes
|
|
15
15
|
# @authentication Requires user context
|
|
16
16
|
# @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
|
|
17
|
-
# @param id [Integer] The {https://developer.yahoo.com/geo/geoplanet Yahoo! Where On Earth ID} of the location to return trending information for. WOEIDs can be retrieved by calling {Twitter::REST::API::Trends#
|
|
17
|
+
# @param id [Integer] The {https://developer.yahoo.com/geo/geoplanet Yahoo! Where On Earth ID} of the location to return trending information for. WOEIDs can be retrieved by calling {Twitter::REST::API::Trends#trends_available}. Global information is available by using 1 as the WOEID.
|
|
18
18
|
# @param options [Hash] A customizable set of options.
|
|
19
19
|
# @option options [String] :exclude Setting this equal to 'hashtags' will remove all hashtags from the trends list.
|
|
20
20
|
# @return [Array<Twitter::Trend>]
|
|
21
|
-
def trends(id=1, options={})
|
|
21
|
+
def trends(id = 1, options = {})
|
|
22
22
|
options[:id] = id
|
|
23
|
-
object_from_response(Twitter::TrendResults, :get,
|
|
23
|
+
object_from_response(Twitter::TrendResults, :get, '/1.1/trends/place.json', options)
|
|
24
24
|
end
|
|
25
|
-
|
|
26
|
-
|
|
25
|
+
alias_method :local_trends, :trends
|
|
26
|
+
alias_method :trends_place, :trends
|
|
27
27
|
|
|
28
28
|
# Returns the locations that Twitter has trending topic information for
|
|
29
29
|
#
|
|
@@ -33,10 +33,10 @@ module Twitter
|
|
|
33
33
|
# @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
|
|
34
34
|
# @param options [Hash] A customizable set of options.
|
|
35
35
|
# @return [Array<Twitter::Place>]
|
|
36
|
-
def trends_available(options={})
|
|
37
|
-
objects_from_response(Twitter::Place, :get,
|
|
36
|
+
def trends_available(options = {})
|
|
37
|
+
objects_from_response(Twitter::Place, :get, '/1.1/trends/available.json', options)
|
|
38
38
|
end
|
|
39
|
-
|
|
39
|
+
alias_method :trend_locations, :trends_available
|
|
40
40
|
|
|
41
41
|
# Returns the locations that Twitter has trending topic information for, closest to a specified location.
|
|
42
42
|
#
|
|
@@ -48,10 +48,9 @@ module Twitter
|
|
|
48
48
|
# @option options [Float] :lat If provided with a :long option the available trend locations will be sorted by distance, nearest to furthest, to the co-ordinate pair. The valid ranges for latitude are -90.0 to +90.0 (North is positive) inclusive.
|
|
49
49
|
# @option options [Float] :long If provided with a :lat option the available trend locations will be sorted by distance, nearest to furthest, to the co-ordinate pair. The valid ranges for longitude are -180.0 to +180.0 (East is positive) inclusive.
|
|
50
50
|
# @return [Array<Twitter::Place>]
|
|
51
|
-
def trends_closest(options={})
|
|
52
|
-
objects_from_response(Twitter::Place, :get,
|
|
51
|
+
def trends_closest(options = {})
|
|
52
|
+
objects_from_response(Twitter::Place, :get, '/1.1/trends/closest.json', options)
|
|
53
53
|
end
|
|
54
|
-
|
|
55
54
|
end
|
|
56
55
|
end
|
|
57
56
|
end
|
|
@@ -5,6 +5,7 @@ require 'twitter/error/forbidden'
|
|
|
5
5
|
require 'twitter/oembed'
|
|
6
6
|
require 'twitter/rest/api/utils'
|
|
7
7
|
require 'twitter/tweet'
|
|
8
|
+
require 'twitter/utils'
|
|
8
9
|
|
|
9
10
|
module Twitter
|
|
10
11
|
module REST
|
|
@@ -23,7 +24,7 @@ module Twitter
|
|
|
23
24
|
# @param options [Hash] A customizable set of options.
|
|
24
25
|
# @option options [Integer] :count Specifies the number of records to retrieve. Must be less than or equal to 100.
|
|
25
26
|
# @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.
|
|
26
|
-
def retweets(tweet, options={})
|
|
27
|
+
def retweets(tweet, options = {})
|
|
27
28
|
id = extract_id(tweet)
|
|
28
29
|
objects_from_response(Twitter::Tweet, :get, "/1.1/statuses/retweets/#{id}.json", options)
|
|
29
30
|
end
|
|
@@ -40,7 +41,7 @@ module Twitter
|
|
|
40
41
|
# @option options [Integer] :count Specifies the number of records to retrieve. Must be less than or equal to 100.
|
|
41
42
|
# @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.
|
|
42
43
|
# @option options [Boolean] :ids_only ('false') Only return user ids instead of full user objects.
|
|
43
|
-
def retweeters_of(tweet, options={})
|
|
44
|
+
def retweeters_of(tweet, options = {})
|
|
44
45
|
ids_only = !!options.delete(:ids_only)
|
|
45
46
|
retweeters = retweets(tweet, options).map(&:user)
|
|
46
47
|
ids_only ? retweeters.map(&:id) : retweeters
|
|
@@ -57,7 +58,7 @@ module Twitter
|
|
|
57
58
|
# @param tweet [Integer, String, URI, Twitter::Tweet] A Tweet ID, URI, or object.
|
|
58
59
|
# @param options [Hash] A customizable set of options.
|
|
59
60
|
# @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.
|
|
60
|
-
def status(tweet, options={})
|
|
61
|
+
def status(tweet, options = {})
|
|
61
62
|
id = extract_id(tweet)
|
|
62
63
|
object_from_response(Twitter::Tweet, :get, "/1.1/statuses/show/#{id}.json", options)
|
|
63
64
|
end
|
|
@@ -76,7 +77,7 @@ module Twitter
|
|
|
76
77
|
# @param options [Hash] A customizable set of options.
|
|
77
78
|
# @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.
|
|
78
79
|
def statuses(*args)
|
|
79
|
-
threaded_tweets_from_response(:get,
|
|
80
|
+
threaded_tweets_from_response(:get, '/1.1/statuses/show', args)
|
|
80
81
|
end
|
|
81
82
|
|
|
82
83
|
# Destroys the specified Tweets
|
|
@@ -94,9 +95,9 @@ module Twitter
|
|
|
94
95
|
# @param options [Hash] A customizable set of options.
|
|
95
96
|
# @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.
|
|
96
97
|
def destroy_status(*args)
|
|
97
|
-
threaded_tweets_from_response(:post,
|
|
98
|
+
threaded_tweets_from_response(:post, '/1.1/statuses/destroy', args)
|
|
98
99
|
end
|
|
99
|
-
|
|
100
|
+
alias_method :destroy_tweet, :destroy_status
|
|
100
101
|
deprecate_alias :status_destroy, :destroy_status
|
|
101
102
|
deprecate_alias :tweet_destroy, :destroy_status
|
|
102
103
|
|
|
@@ -110,14 +111,19 @@ module Twitter
|
|
|
110
111
|
# @return [Twitter::Tweet] The created Tweet.
|
|
111
112
|
# @param status [String] The text of your status update, up to 140 characters.
|
|
112
113
|
# @param options [Hash] A customizable set of options.
|
|
114
|
+
# @option options [Twitter::Tweet] :in_reply_to_status An existing status that the update is in reply to.
|
|
113
115
|
# @option options [Integer] :in_reply_to_status_id The ID of an existing status that the update is in reply to.
|
|
114
116
|
# @option options [Float] :lat The latitude of the location this tweet refers to. This option will be ignored unless it is inside the range -90.0 to +90.0 (North is positive) inclusive. It will also be ignored if there isn't a corresponding :long option.
|
|
115
117
|
# @option options [Float] :long The longitude of the location this tweet refers to. The valid ranges for longitude is -180.0 to +180.0 (East is positive) inclusive. This option will be ignored if outside that range, if it is not a number, if geo_enabled is disabled, or if there not a corresponding :lat option.
|
|
118
|
+
# @option options [Twitter::Place] :place A place in the world. These can be retrieved from {Twitter::REST::API::PlacesAndGeo#reverse_geocode}.
|
|
116
119
|
# @option options [String] :place_id A place in the world. These IDs can be retrieved from {Twitter::REST::API::PlacesAndGeo#reverse_geocode}.
|
|
117
120
|
# @option options [String] :display_coordinates Whether or not to put a pin on the exact coordinates a tweet has been sent from.
|
|
118
121
|
# @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.
|
|
119
|
-
def update(status, options={})
|
|
120
|
-
|
|
122
|
+
def update(status, options = {})
|
|
123
|
+
hash = options.dup
|
|
124
|
+
hash[:in_reply_to_status_id] = hash.delete(:in_reply_to_status).id unless hash[:in_reply_to_status].nil?
|
|
125
|
+
hash[:place_id] = hash.delete(:place).woeid unless hash[:place].nil?
|
|
126
|
+
object_from_response(Twitter::Tweet, :post, '/1.1/statuses/update.json', hash.merge(:status => status))
|
|
121
127
|
rescue Twitter::Error::Forbidden => error
|
|
122
128
|
handle_forbidden_error(Twitter::Error::AlreadyPosted, error)
|
|
123
129
|
end
|
|
@@ -137,7 +143,7 @@ module Twitter
|
|
|
137
143
|
# @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.
|
|
138
144
|
def retweet(*args)
|
|
139
145
|
arguments = Twitter::Arguments.new(args)
|
|
140
|
-
arguments
|
|
146
|
+
Twitter::Utils.parallel_map(arguments) do |tweet|
|
|
141
147
|
id = extract_id(tweet)
|
|
142
148
|
begin
|
|
143
149
|
post_retweet(id, arguments.options)
|
|
@@ -163,7 +169,7 @@ module Twitter
|
|
|
163
169
|
# @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.
|
|
164
170
|
def retweet!(*args)
|
|
165
171
|
arguments = Twitter::Arguments.new(args)
|
|
166
|
-
arguments
|
|
172
|
+
Twitter::Utils.parallel_map(arguments) do |tweet|
|
|
167
173
|
id = extract_id(tweet)
|
|
168
174
|
begin
|
|
169
175
|
post_retweet(id, arguments.options)
|
|
@@ -184,14 +190,20 @@ module Twitter
|
|
|
184
190
|
# @param status [String] The text of your status update, up to 140 characters.
|
|
185
191
|
# @param media [File, Hash] A File object with your picture (PNG, JPEG or GIF)
|
|
186
192
|
# @param options [Hash] A customizable set of options.
|
|
193
|
+
# @option options [Boolean, String, Integer] :possibly_sensitive Set to true for content which may not be suitable for every audience.
|
|
194
|
+
# @option options [Twitter::Tweet] :in_reply_to_status An existing status that the update is in reply to.
|
|
187
195
|
# @option options [Integer] :in_reply_to_status_id The ID of an existing Tweet that the update is in reply to.
|
|
188
196
|
# @option options [Float] :lat The latitude of the location this tweet refers to. This option will be ignored unless it is inside the range -90.0 to +90.0 (North is positive) inclusive. It will also be ignored if there isn't a corresponding :long option.
|
|
189
197
|
# @option options [Float] :long The longitude of the location this tweet refers to. The valid ranges for longitude is -180.0 to +180.0 (East is positive) inclusive. This option will be ignored if outside that range, if it is not a number, if geo_enabled is disabled, or if there not a corresponding :lat option.
|
|
198
|
+
# @option options [Twitter::Place] :place A place in the world. These can be retrieved from {Twitter::REST::API::PlacesAndGeo#reverse_geocode}.
|
|
190
199
|
# @option options [String] :place_id A place in the world. These IDs can be retrieved from {Twitter::REST::API::PlacesAndGeo#reverse_geocode}.
|
|
191
200
|
# @option options [String] :display_coordinates Whether or not to put a pin on the exact coordinates a tweet has been sent from.
|
|
192
201
|
# @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.
|
|
193
|
-
def update_with_media(status, media, options={})
|
|
194
|
-
|
|
202
|
+
def update_with_media(status, media, options = {})
|
|
203
|
+
hash = options.dup
|
|
204
|
+
hash[:in_reply_to_status_id] = hash.delete(:in_reply_to_status).id unless hash[:in_reply_to_status].nil?
|
|
205
|
+
hash[:place_id] = hash.delete(:place).woeid unless hash[:place].nil?
|
|
206
|
+
object_from_response(Twitter::Tweet, :post, '/1.1/statuses/update_with_media.json', hash.merge('media[]' => media, 'status' => status))
|
|
195
207
|
rescue Twitter::Error::Forbidden => error
|
|
196
208
|
handle_forbidden_error(Twitter::Error::AlreadyPosted, error)
|
|
197
209
|
end
|
|
@@ -212,9 +224,9 @@ module Twitter
|
|
|
212
224
|
# @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.
|
|
213
225
|
# @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.
|
|
214
226
|
# @option options [String] :lang Language code for the rendered embed. This will affect the text and localization of the rendered HTML.
|
|
215
|
-
def oembed(tweet, options={})
|
|
227
|
+
def oembed(tweet, options = {})
|
|
216
228
|
options[:id] = extract_id(tweet)
|
|
217
|
-
object_from_response(Twitter::OEmbed, :get,
|
|
229
|
+
object_from_response(Twitter::OEmbed, :get, '/1.1/statuses/oembed.json', options)
|
|
218
230
|
end
|
|
219
231
|
|
|
220
232
|
# Returns oEmbeds for Tweets
|
|
@@ -238,7 +250,7 @@ module Twitter
|
|
|
238
250
|
# @option options [String] :lang Language code for the rendered embed. This will affect the text and localization of the rendered HTML.
|
|
239
251
|
def oembeds(*args)
|
|
240
252
|
arguments = Twitter::Arguments.new(args)
|
|
241
|
-
arguments
|
|
253
|
+
Twitter::Utils.parallel_map(arguments) do |tweet|
|
|
242
254
|
id = extract_id(tweet)
|
|
243
255
|
oembed(id, arguments.options)
|
|
244
256
|
end
|
|
@@ -250,16 +262,16 @@ module Twitter
|
|
|
250
262
|
# @rate_limited Yes
|
|
251
263
|
# @authentication Required
|
|
252
264
|
# @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
|
|
253
|
-
# @return [
|
|
265
|
+
# @return [Twitter::Cursor]
|
|
254
266
|
# @overload retweeters_ids(options)
|
|
255
267
|
# @param options [Hash] A customizable set of options.
|
|
256
|
-
# @overload retweeters_ids(id, options={})
|
|
268
|
+
# @overload retweeters_ids(id, options = {})
|
|
257
269
|
# @param tweet [Integer, String, URI, Twitter::Tweet] A Tweet ID, URI, or object.
|
|
258
270
|
# @param options [Hash] A customizable set of options.
|
|
259
271
|
def retweeters_ids(*args)
|
|
260
272
|
arguments = Twitter::Arguments.new(args)
|
|
261
273
|
arguments.options[:id] ||= extract_id(arguments.first)
|
|
262
|
-
cursor_from_response(:ids, nil, :get,
|
|
274
|
+
cursor_from_response(:ids, nil, :get, '/1.1/statuses/retweeters/ids.json', arguments.options)
|
|
263
275
|
end
|
|
264
276
|
|
|
265
277
|
private
|
|
@@ -270,7 +282,7 @@ module Twitter
|
|
|
270
282
|
# @return [Array<Twitter::Tweet>]
|
|
271
283
|
def threaded_tweets_from_response(request_method, path, args)
|
|
272
284
|
arguments = Twitter::Arguments.new(args)
|
|
273
|
-
arguments
|
|
285
|
+
Twitter::Utils.parallel_map(arguments) do |tweet|
|
|
274
286
|
id = extract_id(tweet)
|
|
275
287
|
object_from_response(Twitter::Tweet, request_method, path + "/#{id}.json", arguments.options)
|
|
276
288
|
end
|
|
@@ -284,7 +296,6 @@ module Twitter
|
|
|
284
296
|
retweeted_status[:body][:retweeted_status] = response[:body]
|
|
285
297
|
Twitter::Tweet.from_response(retweeted_status)
|
|
286
298
|
end
|
|
287
|
-
|
|
288
299
|
end
|
|
289
300
|
end
|
|
290
301
|
end
|
|
@@ -15,14 +15,14 @@ module Twitter
|
|
|
15
15
|
# @authentication Requires user context
|
|
16
16
|
# @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
|
|
17
17
|
#
|
|
18
|
-
# @overload following_followers_of(options={})
|
|
18
|
+
# @overload following_followers_of(options = {})
|
|
19
19
|
# Returns users following followers of the specified user
|
|
20
20
|
#
|
|
21
21
|
# @param options [Hash] A customizable set of options.
|
|
22
22
|
# @option options [Integer] :cursor (-1) Breaks the results into pages. Provide values as returned in the response objects's next_cursor and previous_cursor attributes to page back and forth in the list.
|
|
23
23
|
# @return [Twitter::Cursor]
|
|
24
24
|
#
|
|
25
|
-
# @overload following_followers_of(user, options={})
|
|
25
|
+
# @overload following_followers_of(user, options = {})
|
|
26
26
|
# Returns users following followers of the authenticated user
|
|
27
27
|
#
|
|
28
28
|
# @param user [Integer, String, Twitter::User] A Twitter user ID, screen name, URI, or object.
|
|
@@ -30,7 +30,7 @@ module Twitter
|
|
|
30
30
|
# @option options [Integer] :cursor (-1) Breaks the results into pages. Provide values as returned in the response objects's next_cursor and previous_cursor attributes to page back and forth in the list.
|
|
31
31
|
# @return [Twitter::Cursor]
|
|
32
32
|
def following_followers_of(*args)
|
|
33
|
-
cursor_from_response_with_user(:users, Twitter::User, :get,
|
|
33
|
+
cursor_from_response_with_user(:users, Twitter::User, :get, '/users/following_followers_of.json', args)
|
|
34
34
|
end
|
|
35
35
|
|
|
36
36
|
# Returns Tweets count for a URI
|
|
@@ -41,11 +41,10 @@ module Twitter
|
|
|
41
41
|
# @return [Integer]
|
|
42
42
|
# @param uri [String, URI] A URI.
|
|
43
43
|
# @param options [Hash] A customizable set of options.
|
|
44
|
-
def tweet_count(uri, options={})
|
|
45
|
-
connection = Faraday.new(
|
|
46
|
-
connection.get(
|
|
44
|
+
def tweet_count(uri, options = {})
|
|
45
|
+
connection = Faraday.new('https://cdn.api.twitter.com', connection_options.merge(:builder => middleware))
|
|
46
|
+
connection.get('/1/urls/count.json', options.merge(:url => uri.to_s)).body[:count]
|
|
47
47
|
end
|
|
48
|
-
|
|
49
48
|
end
|
|
50
49
|
end
|
|
51
50
|
end
|