twitter 5.12.0 → 5.13.0
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +10 -0
- data/lib/twitter/base.rb +6 -2
- data/lib/twitter/client.rb +4 -11
- data/lib/twitter/cursor.rb +5 -5
- data/lib/twitter/headers.rb +62 -0
- data/lib/twitter/null_object.rb +5 -0
- data/lib/twitter/rest/api.rb +2 -0
- data/lib/twitter/rest/client.rb +14 -69
- data/lib/twitter/rest/direct_messages.rb +4 -5
- data/lib/twitter/rest/favorites.rb +3 -4
- data/lib/twitter/rest/friends_and_followers.rb +12 -12
- data/lib/twitter/rest/help.rb +5 -5
- data/lib/twitter/rest/lists.rb +21 -21
- data/lib/twitter/rest/media.rb +4 -3
- data/lib/twitter/rest/oauth.rb +4 -4
- data/lib/twitter/rest/places_and_geo.rb +4 -5
- data/lib/twitter/rest/request.rb +44 -0
- data/lib/twitter/rest/request/multipart_with_file.rb +1 -1
- data/lib/twitter/rest/saved_searches.rb +4 -5
- data/lib/twitter/rest/search.rb +3 -4
- data/lib/twitter/rest/spam_reporting.rb +0 -1
- data/lib/twitter/rest/suggested_users.rb +3 -4
- data/lib/twitter/rest/timelines.rb +3 -4
- data/lib/twitter/rest/trends.rb +4 -4
- data/lib/twitter/rest/tweets.rb +10 -12
- data/lib/twitter/rest/undocumented.rb +2 -2
- data/lib/twitter/rest/users.rb +19 -21
- data/lib/twitter/rest/utils.rb +66 -17
- data/lib/twitter/search_results.rb +5 -5
- data/lib/twitter/streaming/client.rb +4 -2
- data/lib/twitter/user.rb +0 -1
- data/lib/twitter/version.rb +1 -1
- metadata +4 -3
- data/lib/twitter/request.rb +0 -47
data/lib/twitter/rest/trends.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
require 'twitter/place'
|
2
|
-
require 'twitter/request'
|
2
|
+
require 'twitter/rest/request'
|
3
3
|
require 'twitter/rest/utils'
|
4
4
|
require 'twitter/trend_results'
|
5
5
|
|
@@ -20,7 +20,7 @@ module Twitter
|
|
20
20
|
# @return [Array<Twitter::Trend>]
|
21
21
|
def trends(id = 1, options = {})
|
22
22
|
options[:id] = id
|
23
|
-
response =
|
23
|
+
response = perform_get('/1.1/trends/place.json', options).first
|
24
24
|
Twitter::TrendResults.new(response)
|
25
25
|
end
|
26
26
|
alias_method :local_trends, :trends
|
@@ -35,7 +35,7 @@ module Twitter
|
|
35
35
|
# @param options [Hash] A customizable set of options.
|
36
36
|
# @return [Array<Twitter::Place>]
|
37
37
|
def trends_available(options = {})
|
38
|
-
|
38
|
+
perform_get_with_objects('/1.1/trends/available.json', options, Twitter::Place)
|
39
39
|
end
|
40
40
|
alias_method :trend_locations, :trends_available
|
41
41
|
|
@@ -50,7 +50,7 @@ module Twitter
|
|
50
50
|
# @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.
|
51
51
|
# @return [Array<Twitter::Place>]
|
52
52
|
def trends_closest(options = {})
|
53
|
-
|
53
|
+
perform_get_with_objects('/1.1/trends/closest.json', options, Twitter::Place)
|
54
54
|
end
|
55
55
|
end
|
56
56
|
end
|
data/lib/twitter/rest/tweets.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'twitter/arguments'
|
2
2
|
require 'twitter/error'
|
3
3
|
require 'twitter/oembed'
|
4
|
-
require 'twitter/request'
|
4
|
+
require 'twitter/rest/request'
|
5
5
|
require 'twitter/rest/utils'
|
6
6
|
require 'twitter/tweet'
|
7
7
|
require 'twitter/utils'
|
@@ -25,7 +25,7 @@ module Twitter
|
|
25
25
|
# @option options [Integer] :count Specifies the number of records to retrieve. Must be less than or equal to 100.
|
26
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.
|
27
27
|
def retweets(tweet, options = {})
|
28
|
-
|
28
|
+
perform_get_with_objects("/1.1/statuses/retweets/#{extract_id(tweet)}.json", options, Twitter::Tweet)
|
29
29
|
end
|
30
30
|
|
31
31
|
# Show up to 100 users who retweeted the Tweet
|
@@ -58,7 +58,7 @@ module Twitter
|
|
58
58
|
# @param options [Hash] A customizable set of options.
|
59
59
|
# @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
60
|
def status(tweet, options = {})
|
61
|
-
|
61
|
+
perform_get_with_object("/1.1/statuses/show/#{extract_id(tweet)}.json", options, Twitter::Tweet)
|
62
62
|
end
|
63
63
|
|
64
64
|
# Returns Tweets
|
@@ -72,13 +72,11 @@ module Twitter
|
|
72
72
|
# @overload statuses(*tweets, options)
|
73
73
|
# @param tweets [Enumerable<Integer, String, URI, Twitter::Tweet>] A collection of Tweet IDs, URIs, or objects.
|
74
74
|
# @param options [Hash] A customizable set of options.
|
75
|
-
# @option options [Symbol, String] :method Requests users via a GET request instead of the standard POST request if set to ':get'.
|
76
75
|
# @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.
|
77
76
|
def statuses(*args)
|
78
77
|
arguments = Twitter::Arguments.new(args)
|
79
|
-
request_method = arguments.options.delete(:method) || :post
|
80
78
|
flat_pmap(arguments.each_slice(MAX_TWEETS_PER_REQUEST)) do |tweets|
|
81
|
-
|
79
|
+
perform_post_with_objects('/1.1/statuses/lookup.json', arguments.options.merge(:id => tweets.collect { |u| extract_id(u) }.join(',')), Twitter::Tweet)
|
82
80
|
end
|
83
81
|
end
|
84
82
|
|
@@ -99,7 +97,7 @@ module Twitter
|
|
99
97
|
def destroy_status(*args)
|
100
98
|
arguments = Twitter::Arguments.new(args)
|
101
99
|
pmap(arguments) do |tweet|
|
102
|
-
|
100
|
+
perform_post_with_object("/1.1/statuses/destroy/#{extract_id(tweet)}.json", arguments.options, Twitter::Tweet)
|
103
101
|
end
|
104
102
|
end
|
105
103
|
alias_method :destroy_tweet, :destroy_status
|
@@ -157,7 +155,7 @@ module Twitter
|
|
157
155
|
hash = options.dup
|
158
156
|
hash[:in_reply_to_status_id] = hash.delete(:in_reply_to_status).id unless hash[:in_reply_to_status].nil?
|
159
157
|
hash[:place_id] = hash.delete(:place).woeid unless hash[:place].nil?
|
160
|
-
|
158
|
+
perform_post_with_object('/1.1/statuses/update.json', hash.merge(:status => status), Twitter::Tweet)
|
161
159
|
end
|
162
160
|
|
163
161
|
# Retweets the specified Tweets as the authenticating user
|
@@ -232,7 +230,7 @@ module Twitter
|
|
232
230
|
hash = options.dup
|
233
231
|
hash[:in_reply_to_status_id] = hash.delete(:in_reply_to_status).id unless hash[:in_reply_to_status].nil?
|
234
232
|
hash[:place_id] = hash.delete(:place).woeid unless hash[:place].nil?
|
235
|
-
|
233
|
+
perform_post_with_object('/1.1/statuses/update_with_media.json', hash.merge('media[]' => media, 'status' => status), Twitter::Tweet)
|
236
234
|
end
|
237
235
|
|
238
236
|
# Returns oEmbed for a Tweet
|
@@ -253,7 +251,7 @@ module Twitter
|
|
253
251
|
# @option options [String] :lang Language code for the rendered embed. This will affect the text and localization of the rendered HTML.
|
254
252
|
def oembed(tweet, options = {})
|
255
253
|
options[:id] = extract_id(tweet)
|
256
|
-
|
254
|
+
perform_get_with_object('/1.1/statuses/oembed.json', options, Twitter::OEmbed)
|
257
255
|
end
|
258
256
|
|
259
257
|
# Returns oEmbeds for Tweets
|
@@ -297,13 +295,13 @@ module Twitter
|
|
297
295
|
def retweeters_ids(*args)
|
298
296
|
arguments = Twitter::Arguments.new(args)
|
299
297
|
arguments.options[:id] ||= extract_id(arguments.first)
|
300
|
-
|
298
|
+
perform_get_with_cursor('/1.1/statuses/retweeters/ids.json', arguments.options, :ids)
|
301
299
|
end
|
302
300
|
|
303
301
|
private
|
304
302
|
|
305
303
|
def post_retweet(tweet, options)
|
306
|
-
response =
|
304
|
+
response = perform_post("/1.1/statuses/retweet/#{extract_id(tweet)}.json", options)
|
307
305
|
Twitter::Tweet.new(response)
|
308
306
|
end
|
309
307
|
end
|
@@ -24,7 +24,7 @@ module Twitter
|
|
24
24
|
# @param user [Integer, String, Twitter::User] A Twitter user ID, screen name, URI, or object.
|
25
25
|
# @param options [Hash] A customizable set of options.
|
26
26
|
def following_followers_of(*args)
|
27
|
-
cursor_from_response_with_user(:users, Twitter::User,
|
27
|
+
cursor_from_response_with_user(:users, Twitter::User, '/users/following_followers_of.json', args)
|
28
28
|
end
|
29
29
|
|
30
30
|
# Returns Tweets count for a URI
|
@@ -36,7 +36,7 @@ module Twitter
|
|
36
36
|
# @param uri [String, URI] A URI.
|
37
37
|
# @param options [Hash] A customizable set of options.
|
38
38
|
def tweet_count(uri, options = {})
|
39
|
-
connection = Faraday.new('https://cdn.api.twitter.com', connection_options
|
39
|
+
connection = Faraday.new('https://cdn.api.twitter.com', connection_options)
|
40
40
|
connection.get('/1/urls/count.json', options.merge(:url => uri.to_s)).body[:count]
|
41
41
|
end
|
42
42
|
end
|
data/lib/twitter/rest/users.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'twitter/arguments'
|
2
2
|
require 'twitter/error'
|
3
3
|
require 'twitter/profile_banner'
|
4
|
-
require 'twitter/request'
|
4
|
+
require 'twitter/rest/request'
|
5
5
|
require 'twitter/rest/utils'
|
6
6
|
require 'twitter/settings'
|
7
7
|
require 'twitter/user'
|
@@ -32,7 +32,7 @@ module Twitter
|
|
32
32
|
# @option options [String] :lang The language which Twitter should render in for this user. The language must be specified by the appropriate two letter ISO 639-1 representation. Currently supported languages are provided by {https://dev.twitter.com/docs/api/1.1/get/help/languages GET help/languages}.
|
33
33
|
def settings(options = {})
|
34
34
|
request_method = options.size.zero? ? :get : :post
|
35
|
-
response =
|
35
|
+
response = perform_request(request_method.to_sym, '/1.1/account/settings.json', options)
|
36
36
|
# https://dev.twitter.com/issues/59
|
37
37
|
response.update(:trend_location => response.fetch(:trend_location, []).first)
|
38
38
|
Twitter::Settings.new(response)
|
@@ -48,7 +48,7 @@ module Twitter
|
|
48
48
|
# @param options [Hash] A customizable set of options.
|
49
49
|
# @option options [Boolean, String, Integer] :skip_status Do not include user's Tweets when set to true, 't' or 1.
|
50
50
|
def verify_credentials(options = {})
|
51
|
-
|
51
|
+
perform_get_with_object('/1.1/account/verify_credentials.json', options, Twitter::User)
|
52
52
|
end
|
53
53
|
alias_method :current_user, :verify_credentials
|
54
54
|
|
@@ -62,7 +62,7 @@ module Twitter
|
|
62
62
|
# @param device [String] Must be one of: 'sms', 'none'.
|
63
63
|
# @param options [Hash] A customizable set of options.
|
64
64
|
def update_delivery_device(device, options = {})
|
65
|
-
|
65
|
+
perform_post_with_object('/1.1/account/update_delivery_device.json', options.merge(:device => device), Twitter::User)
|
66
66
|
end
|
67
67
|
|
68
68
|
# Sets values that users are able to set under the "Account" tab of their settings page
|
@@ -79,7 +79,7 @@ module Twitter
|
|
79
79
|
# @option options [String] :location The city or country describing where the user of the account is located. The contents are not normalized or geocoded in any way. Maximum of 30 characters.
|
80
80
|
# @option options [String] :description A description of the user owning the account. Maximum of 160 characters.
|
81
81
|
def update_profile(options = {})
|
82
|
-
|
82
|
+
perform_post_with_object('/1.1/account/update_profile.json', options, Twitter::User)
|
83
83
|
end
|
84
84
|
|
85
85
|
# Updates the authenticating user's profile background image
|
@@ -93,7 +93,7 @@ module Twitter
|
|
93
93
|
# @param options [Hash] A customizable set of options.
|
94
94
|
# @option options [Boolean] :tile Whether or not to tile the background image. If set to true the background image will be displayed tiled. The image will not be tiled otherwise.
|
95
95
|
def update_profile_background_image(image, options = {})
|
96
|
-
|
96
|
+
perform_post_with_object('/1.1/account/update_profile_background_image.json', options.merge(:image => image), Twitter::User)
|
97
97
|
end
|
98
98
|
|
99
99
|
# Sets one or more hex values that control the color scheme of the authenticating user's profile
|
@@ -110,7 +110,7 @@ module Twitter
|
|
110
110
|
# @option options [String] :profile_sidebar_fill_color Profile sidebar's background color.
|
111
111
|
# @option options [String] :profile_sidebar_border_color Profile sidebar's border color.
|
112
112
|
def update_profile_colors(options = {})
|
113
|
-
|
113
|
+
perform_post_with_object('/1.1/account/update_profile_colors.json', options, Twitter::User)
|
114
114
|
end
|
115
115
|
|
116
116
|
# Updates the authenticating user's profile image
|
@@ -125,7 +125,7 @@ module Twitter
|
|
125
125
|
# @param image [File] The avatar image for the profile, base64-encoded. Must be a valid GIF, JPG, or PNG image of less than 700 kilobytes in size. Images with width larger than 500 pixels will be scaled down. Animated GIFs will be converted to a static GIF of the first frame, removing the animation.
|
126
126
|
# @param options [Hash] A customizable set of options.
|
127
127
|
def update_profile_image(image, options = {})
|
128
|
-
|
128
|
+
perform_post_with_object('/1.1/account/update_profile_image.json', options.merge(:image => image), Twitter::User)
|
129
129
|
end
|
130
130
|
|
131
131
|
# Returns an array of user objects that the authenticating user is blocking
|
@@ -138,7 +138,7 @@ module Twitter
|
|
138
138
|
# @param options [Hash] A customizable set of options.
|
139
139
|
# @option options [Boolean, String, Integer] :skip_status Do not include user's Tweets when set to true, 't' or 1.
|
140
140
|
def blocked(options = {})
|
141
|
-
|
141
|
+
perform_get_with_cursor('/1.1/blocks/list.json', options, :users, Twitter::User)
|
142
142
|
end
|
143
143
|
deprecate_alias :blocking, :blocked
|
144
144
|
|
@@ -154,7 +154,7 @@ module Twitter
|
|
154
154
|
def blocked_ids(*args)
|
155
155
|
arguments = Twitter::Arguments.new(args)
|
156
156
|
merge_user!(arguments.options, arguments.pop)
|
157
|
-
|
157
|
+
perform_get_with_cursor('/1.1/blocks/ids.json', arguments.options, :ids)
|
158
158
|
end
|
159
159
|
|
160
160
|
# Returns true if the authenticating user is blocking a target user
|
@@ -226,12 +226,10 @@ module Twitter
|
|
226
226
|
# @overload users(*users, options)
|
227
227
|
# @param users [Enumerable<Integer, String, Twitter::User>] A collection of Twitter user IDs, screen names, or objects.
|
228
228
|
# @param options [Hash] A customizable set of options.
|
229
|
-
# @option options [Symbol, String] :method Requests users via a GET request instead of the standard POST request if set to ':get'.
|
230
229
|
def users(*args)
|
231
230
|
arguments = Twitter::Arguments.new(args)
|
232
|
-
request_method = arguments.options.delete(:method) || :post
|
233
231
|
flat_pmap(arguments.each_slice(MAX_USERS_PER_REQUEST)) do |users|
|
234
|
-
|
232
|
+
perform_post_with_objects('/1.1/users/lookup.json', merge_users(arguments.options, users), Twitter::User)
|
235
233
|
end
|
236
234
|
end
|
237
235
|
|
@@ -255,7 +253,7 @@ module Twitter
|
|
255
253
|
arguments = Twitter::Arguments.new(args)
|
256
254
|
if arguments.last || user_id?
|
257
255
|
merge_user!(arguments.options, arguments.pop || user_id)
|
258
|
-
|
256
|
+
perform_get_with_object('/1.1/users/show.json', arguments.options, Twitter::User)
|
259
257
|
else
|
260
258
|
verify_credentials(arguments.options)
|
261
259
|
end
|
@@ -270,7 +268,7 @@ module Twitter
|
|
270
268
|
# @param user [Integer, String, Twitter::User] A Twitter user ID, screen name, URI, or object.
|
271
269
|
def user?(user, options = {})
|
272
270
|
merge_user!(options, user)
|
273
|
-
|
271
|
+
perform_get('/1.1/users/show.json', options)
|
274
272
|
true
|
275
273
|
rescue Twitter::Error::NotFound
|
276
274
|
false
|
@@ -288,7 +286,7 @@ module Twitter
|
|
288
286
|
# @option options [Integer] :count The number of people to retrieve. Maxiumum of 20 allowed per page.
|
289
287
|
# @option options [Integer] :page Specifies the page of results to retrieve.
|
290
288
|
def user_search(query, options = {})
|
291
|
-
|
289
|
+
perform_get_with_objects('/1.1/users/search.json', options.merge(:q => query), Twitter::User)
|
292
290
|
end
|
293
291
|
|
294
292
|
# Returns an array of users that the specified user can contribute to
|
@@ -336,7 +334,7 @@ module Twitter
|
|
336
334
|
# @return [nil]
|
337
335
|
# @param options [Hash] A customizable set of options.
|
338
336
|
def remove_profile_banner(options = {})
|
339
|
-
|
337
|
+
perform_post('/1.1/account/remove_profile_banner.json', options)
|
340
338
|
true
|
341
339
|
end
|
342
340
|
deprecate_alias :profile_banner_remove, :remove_profile_banner
|
@@ -359,7 +357,7 @@ module Twitter
|
|
359
357
|
# @option options [Integer] :offset_left The number of pixels by which to offset the uploaded image from the left. Use with height, width, and offset_top to select the desired region of the image to use.
|
360
358
|
# @option options [Integer] :offset_top The number of pixels by which to offset the uploaded image from the top. Use with height, width, and offset_left to select the desired region of the image to use.
|
361
359
|
def update_profile_banner(banner, options = {})
|
362
|
-
|
360
|
+
perform_post('/1.1/account/update_profile_banner.json', options.merge(:banner => banner))
|
363
361
|
true
|
364
362
|
end
|
365
363
|
|
@@ -377,7 +375,7 @@ module Twitter
|
|
377
375
|
def profile_banner(*args)
|
378
376
|
arguments = Twitter::Arguments.new(args)
|
379
377
|
merge_user!(arguments.options, arguments.pop || user_id) unless arguments.options[:user_id] || arguments.options[:screen_name]
|
380
|
-
|
378
|
+
perform_get_with_object('/1.1/users/profile_banner.json', arguments.options, Twitter::ProfileBanner)
|
381
379
|
end
|
382
380
|
|
383
381
|
# Mutes the users specified by the authenticating user
|
@@ -422,7 +420,7 @@ module Twitter
|
|
422
420
|
# @param options [Hash] A customizable set of options.
|
423
421
|
# @option options [Boolean, String, Integer] :skip_status Do not include user's Tweets when set to true, 't' or 1.
|
424
422
|
def muted(options = {})
|
425
|
-
|
423
|
+
perform_get_with_cursor('/1.1/mutes/users/list.json', options, :users, Twitter::User)
|
426
424
|
end
|
427
425
|
deprecate_alias :muting, :muted
|
428
426
|
|
@@ -438,7 +436,7 @@ module Twitter
|
|
438
436
|
def muted_ids(*args)
|
439
437
|
arguments = Twitter::Arguments.new(args)
|
440
438
|
merge_user!(arguments.options, arguments.pop)
|
441
|
-
|
439
|
+
perform_get_with_cursor('/1.1/mutes/users/ids.json', arguments.options, :ids)
|
442
440
|
end
|
443
441
|
end
|
444
442
|
end
|
data/lib/twitter/rest/utils.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
require 'addressable/uri'
|
2
2
|
require 'twitter/arguments'
|
3
|
-
require 'twitter/
|
3
|
+
require 'twitter/cursor'
|
4
|
+
require 'twitter/rest/request'
|
4
5
|
require 'twitter/user'
|
5
6
|
require 'twitter/utils'
|
6
7
|
|
@@ -30,32 +31,81 @@ module Twitter
|
|
30
31
|
end
|
31
32
|
end
|
32
33
|
|
34
|
+
# @param path [String]
|
35
|
+
# @param options [Hash]
|
36
|
+
def perform_get(path, options = {})
|
37
|
+
perform_request(:get, path, options)
|
38
|
+
end
|
39
|
+
|
40
|
+
# @param path [String]
|
41
|
+
# @param options [Hash]
|
42
|
+
# @param klass [Class]
|
43
|
+
def perform_post(path, options = {})
|
44
|
+
perform_request(:post, path, options)
|
45
|
+
end
|
46
|
+
|
33
47
|
# @param request_method [Symbol]
|
48
|
+
# @param path [String]
|
49
|
+
# @param options [Hash]
|
50
|
+
def perform_request(request_method, path, options = {})
|
51
|
+
Twitter::REST::Request.new(self, request_method, path, options).perform
|
52
|
+
end
|
53
|
+
|
54
|
+
# @param path [String]
|
55
|
+
# @param options [Hash]
|
56
|
+
# @param klass [Class]
|
57
|
+
def perform_get_with_object(path, options, klass)
|
58
|
+
perform_request_with_object(:get, path, options, klass)
|
59
|
+
end
|
60
|
+
|
34
61
|
# @param path [String]
|
35
62
|
# @param options [Hash]
|
36
63
|
# @param klass [Class]
|
37
|
-
def
|
38
|
-
|
39
|
-
request.perform_with_object(klass)
|
64
|
+
def perform_post_with_object(path, options, klass)
|
65
|
+
perform_request_with_object(:post, path, options, klass)
|
40
66
|
end
|
41
67
|
|
42
68
|
# @param request_method [Symbol]
|
43
69
|
# @param path [String]
|
44
70
|
# @param options [Hash]
|
45
71
|
# @param klass [Class]
|
46
|
-
def
|
47
|
-
|
48
|
-
|
72
|
+
def perform_request_with_object(request_method, path, options, klass)
|
73
|
+
response = perform_request(request_method, path, options)
|
74
|
+
klass.new(response)
|
75
|
+
end
|
76
|
+
|
77
|
+
# @param path [String]
|
78
|
+
# @param options [Hash]
|
79
|
+
# @param klass [Class]
|
80
|
+
def perform_get_with_objects(path, options, klass)
|
81
|
+
perform_request_with_objects(:get, path, options, klass)
|
82
|
+
end
|
83
|
+
|
84
|
+
# @param path [String]
|
85
|
+
# @param options [Hash]
|
86
|
+
# @param klass [Class]
|
87
|
+
def perform_post_with_objects(path, options, klass)
|
88
|
+
perform_request_with_objects(:post, path, options, klass)
|
49
89
|
end
|
50
90
|
|
51
91
|
# @param request_method [Symbol]
|
52
92
|
# @param path [String]
|
53
93
|
# @param options [Hash]
|
54
94
|
# @param klass [Class]
|
55
|
-
def
|
95
|
+
def perform_request_with_objects(request_method, path, options, klass)
|
96
|
+
perform_request(request_method, path, options).collect do |element|
|
97
|
+
klass.new(element)
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
# @param path [String]
|
102
|
+
# @param options [Hash]
|
103
|
+
# @collection_name [Symbol]
|
104
|
+
# @param klass [Class]
|
105
|
+
def perform_get_with_cursor(path, options, collection_name, klass = nil)
|
56
106
|
merge_default_cursor!(options)
|
57
|
-
request = Twitter::Request.new(self,
|
58
|
-
|
107
|
+
request = Twitter::REST::Request.new(self, :get, path, options)
|
108
|
+
Twitter::Cursor.new(collection_name.to_sym, klass, request)
|
59
109
|
end
|
60
110
|
|
61
111
|
# @param request_method [Symbol]
|
@@ -65,7 +115,7 @@ module Twitter
|
|
65
115
|
def parallel_users_from_response(request_method, path, args)
|
66
116
|
arguments = Twitter::Arguments.new(args)
|
67
117
|
pmap(arguments) do |user|
|
68
|
-
|
118
|
+
perform_request_with_object(request_method, path, merge_user(arguments.options, user), Twitter::User)
|
69
119
|
end
|
70
120
|
end
|
71
121
|
|
@@ -76,7 +126,7 @@ module Twitter
|
|
76
126
|
def users_from_response(request_method, path, args)
|
77
127
|
arguments = Twitter::Arguments.new(args)
|
78
128
|
merge_user!(arguments.options, arguments.pop || user_id) unless arguments.options[:user_id] || arguments.options[:screen_name]
|
79
|
-
|
129
|
+
perform_request_with_objects(request_method, path, arguments.options, Twitter::User)
|
80
130
|
end
|
81
131
|
|
82
132
|
# @param klass [Class]
|
@@ -87,7 +137,7 @@ module Twitter
|
|
87
137
|
def objects_from_response_with_user(klass, request_method, path, args)
|
88
138
|
arguments = Twitter::Arguments.new(args)
|
89
139
|
merge_user!(arguments.options, arguments.pop)
|
90
|
-
|
140
|
+
perform_request_with_objects(request_method, path, arguments.options, klass)
|
91
141
|
end
|
92
142
|
|
93
143
|
# @param klass [Class]
|
@@ -98,20 +148,19 @@ module Twitter
|
|
98
148
|
def parallel_objects_from_response(klass, request_method, path, args)
|
99
149
|
arguments = Twitter::Arguments.new(args)
|
100
150
|
pmap(arguments) do |object|
|
101
|
-
|
151
|
+
perform_request_with_object(request_method, path, arguments.options.merge(:id => extract_id(object)), klass)
|
102
152
|
end
|
103
153
|
end
|
104
154
|
|
105
155
|
# @param collection_name [Symbol]
|
106
156
|
# @param klass [Class]
|
107
|
-
# @param request_method [Symbol]
|
108
157
|
# @param path [String]
|
109
158
|
# @param args [Array]
|
110
159
|
# @return [Twitter::Cursor]
|
111
|
-
def cursor_from_response_with_user(collection_name, klass,
|
160
|
+
def cursor_from_response_with_user(collection_name, klass, path, args) # rubocop:disable ParameterLists
|
112
161
|
arguments = Twitter::Arguments.new(args)
|
113
162
|
merge_user!(arguments.options, arguments.pop || user_id) unless arguments.options[:user_id] || arguments.options[:screen_name]
|
114
|
-
|
163
|
+
perform_get_with_cursor(path, arguments.options, collection_name, klass)
|
115
164
|
end
|
116
165
|
|
117
166
|
def user_id
|