twitter 4.4.2 → 4.4.3

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.
Files changed (72) hide show
  1. data/CHANGELOG.md +7 -0
  2. data/lib/twitter.rb +1 -1
  3. data/lib/twitter/api/arguments.rb +13 -0
  4. data/lib/twitter/api/direct_messages.rb +8 -7
  5. data/lib/twitter/api/favorites.rb +11 -10
  6. data/lib/twitter/api/friends_and_followers.rb +16 -31
  7. data/lib/twitter/api/help.rb +1 -1
  8. data/lib/twitter/api/lists.rb +41 -51
  9. data/lib/twitter/api/places_and_geo.rb +5 -5
  10. data/lib/twitter/api/saved_searches.rb +9 -8
  11. data/lib/twitter/api/spam_reporting.rb +1 -1
  12. data/lib/twitter/api/suggested_users.rb +6 -5
  13. data/lib/twitter/api/timelines.rb +6 -8
  14. data/lib/twitter/api/trends.rb +3 -3
  15. data/lib/twitter/api/tweets.rb +14 -13
  16. data/lib/twitter/api/undocumented.rb +7 -9
  17. data/lib/twitter/api/users.rb +22 -19
  18. data/lib/twitter/api/utils.rb +61 -62
  19. data/lib/twitter/base.rb +0 -1
  20. data/lib/twitter/configurable.rb +24 -5
  21. data/lib/twitter/core_ext/kernel.rb +0 -5
  22. data/lib/twitter/cursor.rb +1 -1
  23. data/lib/twitter/default.rb +9 -5
  24. data/lib/twitter/error/configuration_error.rb +8 -0
  25. data/lib/twitter/tweet.rb +6 -3
  26. data/lib/twitter/version.rb +1 -1
  27. data/spec/fixtures/about_me.json +1 -1
  28. data/spec/fixtures/by_friends.json +1 -1
  29. data/spec/fixtures/category.json +1 -1
  30. data/spec/fixtures/contributees.json +1 -1
  31. data/spec/fixtures/direct_messages.json +1 -1
  32. data/spec/fixtures/followers_list.json +1 -1
  33. data/spec/fixtures/followers_list2.json +1 -1
  34. data/spec/fixtures/friends_list.json +1 -1
  35. data/spec/fixtures/friends_list2.json +1 -1
  36. data/spec/fixtures/lists.json +1 -1
  37. data/spec/fixtures/locations.json +1 -1
  38. data/spec/fixtures/members.json +1 -1
  39. data/spec/fixtures/memberships.json +1 -1
  40. data/spec/fixtures/memberships2.json +1 -1
  41. data/spec/fixtures/retweets.json +1 -1
  42. data/spec/fixtures/search.json +1 -1
  43. data/spec/fixtures/search_malformed.json +1 -1
  44. data/spec/fixtures/subscriptions.json +1 -1
  45. data/spec/fixtures/subscriptions2.json +1 -1
  46. data/spec/fixtures/user_timeline.json +1 -1
  47. data/spec/fixtures/users_list.json +1 -1
  48. data/spec/fixtures/users_list2.json +1 -1
  49. data/spec/twitter/api/favorites_spec.rb +4 -4
  50. data/spec/twitter/api/friends_and_followers_spec.rb +32 -28
  51. data/spec/twitter/api/suggested_users_spec.rb +1 -1
  52. data/spec/twitter/api/tweets_spec.rb +4 -4
  53. data/spec/twitter/api/users_spec.rb +6 -6
  54. data/spec/twitter/client_spec.rb +1 -1
  55. data/spec/twitter_spec.rb +24 -0
  56. data/twitter.gemspec +3 -4
  57. metadata +10 -48
  58. data/spec/fixtures/all.json +0 -1
  59. data/spec/fixtures/contributors.json +0 -1
  60. data/spec/fixtures/enhance_your_calm.text +0 -11
  61. data/spec/fixtures/favorites.json +0 -1
  62. data/spec/fixtures/image_facets.json +0 -1
  63. data/spec/fixtures/media_timeline.json +0 -1
  64. data/spec/fixtures/profile_image.text +0 -24
  65. data/spec/fixtures/recommendations.json +0 -1
  66. data/spec/fixtures/related_results.json +0 -1
  67. data/spec/fixtures/retweeted_status.json +0 -1
  68. data/spec/fixtures/retweeters_of.json +0 -1
  69. data/spec/fixtures/status_with_media.json +0 -104
  70. data/spec/fixtures/trends_current.json +0 -1
  71. data/spec/fixtures/trends_daily.json +0 -1
  72. data/spec/fixtures/trends_weekly.json +0 -1
@@ -1,3 +1,10 @@
1
+ 4.4.3
2
+ -----
3
+ * [Add `Twitter::API::Arguments` class; remove `extract_options!` helper method](https://github.com/sferik/twitter/commit/65972c599ced8da27fbbfa72aeead92464355583)
4
+ * [Ensure credentials set via `Twitter.configure` are of a valid type](https://github.com/sferik/twitter/commit/fc152dbe56b99639896bcaaf7fe158659e8c50b9)
5
+ * [Delegate `Twitter::Tweet#profile_image_url` and `Twitter::Tweet#profile_image_url_https` to `Twitter::Tweet#user`](https://github.com/sferik/twitter/commit/7bd6f8f589a91a8c82363d07da77ec012890c6cb)
6
+ * [Fix timeout bug; lock `faraday` dependency to version < 0.10](https://github.com/sferik/twitter/commit/01e2781e4a78137ca4e5e6d3e4faf2552ee9ec76)
7
+
1
8
  4.4.2
2
9
  -----
3
10
  * [Fix to `Twitter::API::FriendsAndFollowers#friends` and `Twitter::API::FriendsAndFollowers#followers`](https://github.com/sferik/twitter/commit/d97438f5de89a1a15ad8ff5e67e8e0c7d412911f) ([@nbraem](https://twitter.com/nbraem))
@@ -38,7 +38,7 @@ module Twitter
38
38
  #
39
39
  # @return [Twitter::Client]
40
40
  def client
41
- @client = Twitter::Client.new(options) unless defined?(@client) && @client.cache_key == options.hash
41
+ @client = Twitter::Client.new(options) unless defined?(@client) && @client.hash == options.hash
42
42
  @client
43
43
  end
44
44
 
@@ -0,0 +1,13 @@
1
+ module Twitter
2
+ module API
3
+ class Arguments < Array
4
+ attr_reader :options
5
+
6
+ def initialize(args)
7
+ @options = args.last.is_a?(::Hash) ? args.pop : {}
8
+ super(args)
9
+ end
10
+
11
+ end
12
+ end
13
+ end
@@ -1,3 +1,4 @@
1
+ require 'twitter/api/arguments'
1
2
  require 'twitter/api/utils'
2
3
  require 'twitter/direct_message'
3
4
  require 'twitter/user'
@@ -23,7 +24,7 @@ module Twitter
23
24
  # @example Return the 20 most recent direct messages sent to the authenticating user
24
25
  # Twitter.direct_messages_received
25
26
  def direct_messages_received(options={})
26
- collection_from_response(Twitter::DirectMessage, :get, "/1.1/direct_messages.json", options)
27
+ objects_from_response(Twitter::DirectMessage, :get, "/1.1/direct_messages.json", options)
27
28
  end
28
29
 
29
30
  # Returns the 20 most recent direct messages sent by the authenticating user
@@ -42,7 +43,7 @@ module Twitter
42
43
  # @example Return the 20 most recent direct messages sent by the authenticating user
43
44
  # Twitter.direct_messages_sent
44
45
  def direct_messages_sent(options={})
45
- collection_from_response(Twitter::DirectMessage, :get, "/1.1/direct_messages/sent.json", options)
46
+ objects_from_response(Twitter::DirectMessage, :get, "/1.1/direct_messages/sent.json", options)
46
47
  end
47
48
 
48
49
  # Returns a direct message
@@ -92,12 +93,12 @@ module Twitter
92
93
  # @param ids [Array<Integer>, Set<Integer>] An array of Tweet IDs.
93
94
  # @param options [Hash] A customizable set of options.
94
95
  def direct_messages(*args)
95
- options = extract_options!(args)
96
- if args.empty?
97
- direct_messages_received(options)
96
+ arguments = Twitter::API::Arguments.new(args)
97
+ if arguments.empty?
98
+ direct_messages_received(arguments.options)
98
99
  else
99
- args.flatten.threaded_map do |id|
100
- direct_message(id, options)
100
+ arguments.flatten.threaded_map do |id|
101
+ direct_message(id, arguments.options)
101
102
  end
102
103
  end
103
104
  end
@@ -1,3 +1,4 @@
1
+ require 'twitter/api/arguments'
1
2
  require 'twitter/api/utils'
2
3
  require 'twitter/error/already_favorited'
3
4
  require 'twitter/error/forbidden'
@@ -32,11 +33,11 @@ module Twitter
32
33
  # @example Return the 20 most recent favorite Tweets for @sferik
33
34
  # Twitter.favorites('sferik')
34
35
  def favorites(*args)
35
- options = extract_options!(args)
36
- if user = args.pop
37
- merge_user!(options, user)
36
+ arguments = Twitter::API::Arguments.new(args)
37
+ if user = arguments.pop
38
+ merge_user!(arguments.options, user)
38
39
  end
39
- collection_from_response(Twitter::Tweet, :get, "/1.1/favorites/list.json", options)
40
+ objects_from_response(Twitter::Tweet, :get, "/1.1/favorites/list.json", arguments.options)
40
41
  end
41
42
  alias favourites favorites
42
43
 
@@ -76,10 +77,10 @@ module Twitter
76
77
  # @param ids [Array<Integer>, Set<Integer>] An array of Tweet IDs.
77
78
  # @param options [Hash] A customizable set of options.
78
79
  def favorite(*args)
79
- options = extract_options!(args)
80
- args.flatten.threaded_map do |id|
80
+ arguments = Twitter::API::Arguments.new(args)
81
+ arguments.flatten.threaded_map do |id|
81
82
  begin
82
- object_from_response(Twitter::Tweet, :post, "/1.1/favorites/create.json", options.merge(:id => id))
83
+ object_from_response(Twitter::Tweet, :post, "/1.1/favorites/create.json", arguments.options.merge(:id => id))
83
84
  rescue Twitter::Error::Forbidden => error
84
85
  raise unless error.message == Twitter::Error::AlreadyFavorited::MESSAGE
85
86
  end
@@ -106,10 +107,10 @@ module Twitter
106
107
  # @param ids [Array<Integer>, Set<Integer>] An array of Tweet IDs.
107
108
  # @param options [Hash] A customizable set of options.
108
109
  def favorite!(*args)
109
- options = extract_options!(args)
110
- args.flatten.threaded_map do |id|
110
+ arguments = Twitter::API::Arguments.new(args)
111
+ arguments.flatten.threaded_map do |id|
111
112
  begin
112
- object_from_response(Twitter::Tweet, :post, "/1.1/favorites/create.json", options.merge(:id => id))
113
+ object_from_response(Twitter::Tweet, :post, "/1.1/favorites/create.json", arguments.options.merge(:id => id))
113
114
  rescue Twitter::Error::Forbidden => error
114
115
  handle_forbidden_error(Twitter::Error::AlreadyFavorited, error)
115
116
  end
@@ -1,3 +1,4 @@
1
+ require 'twitter/api/arguments'
1
2
  require 'twitter/api/utils'
2
3
  require 'twitter/cursor'
3
4
  require 'twitter/error/forbidden'
@@ -31,7 +32,7 @@ module Twitter
31
32
  # Twitter.friend_ids('sferik')
32
33
  # Twitter.friend_ids(7505382) # Same as above
33
34
  def friend_ids(*args)
34
- ids_from_response(:get, "/1.1/friends/ids.json", args, :friend_ids)
35
+ cursor_from_response_with_user(:ids, nil, :get, "/1.1/friends/ids.json", args, :friend_ids)
35
36
  end
36
37
 
37
38
  # @see https://dev.twitter.com/docs/api/1.1/get/followers/ids
@@ -56,7 +57,7 @@ module Twitter
56
57
  # Twitter.follower_ids('sferik')
57
58
  # Twitter.follower_ids(7505382) # Same as above
58
59
  def follower_ids(*args)
59
- ids_from_response(:get, "/1.1/followers/ids.json", args, :follower_ids)
60
+ cursor_from_response_with_user(:ids, nil, :get, "/1.1/followers/ids.json", args, :follower_ids)
60
61
  end
61
62
 
62
63
  # Returns the relationship of the authenticating user to the comma separated list of up to 100 screen_names or user_ids provided. Values for connections can be: following, following_requested, followed_by, none.
@@ -76,9 +77,9 @@ module Twitter
76
77
  # @param users [Array<Integer, String, Twitter::User>, Set<Integer, String, Twitter::User>] An array of Twitter user IDs, screen names, or objects.
77
78
  # @param options [Hash] A customizable set of options.
78
79
  def friendships(*args)
79
- options = extract_options!(args)
80
- merge_users!(options, Array(args))
81
- collection_from_response(Twitter::User, :get, "/1.1/friendships/lookup.json", options)
80
+ arguments = Twitter::API::Arguments.new(args)
81
+ merge_users!(arguments.options, arguments)
82
+ objects_from_response(Twitter::User, :get, "/1.1/friendships/lookup.json", arguments.options)
82
83
  end
83
84
 
84
85
  # Returns an array of numeric IDs for every user who has a pending request to follow the authenticating user
@@ -93,7 +94,6 @@ module Twitter
93
94
  # @example Return an array of numeric IDs for every user who has a pending request to follow the authenticating user
94
95
  # Twitter.friendships_incoming
95
96
  def friendships_incoming(options={})
96
- merge_default_cursor!(options)
97
97
  cursor_from_response(:ids, nil, :get, "/1.1/friendships/incoming.json", options, :friendships_incoming)
98
98
  end
99
99
 
@@ -109,7 +109,6 @@ module Twitter
109
109
  # @example Return an array of numeric IDs for every protected user for whom the authenticating user has a pending follow request
110
110
  # Twitter.friendships_outgoing
111
111
  def friendships_outgoing(options={})
112
- merge_default_cursor!(options)
113
112
  cursor_from_response(:ids, nil, :get, "/1.1/friendships/outgoing.json", options, :friendships_outgoing)
114
113
  end
115
114
 
@@ -129,17 +128,17 @@ module Twitter
129
128
  # @param options [Hash] A customizable set of options.
130
129
  # @option options [Boolean] :follow (false) Enable notifications for the target user.
131
130
  def follow(*args)
132
- options = extract_options!(args)
131
+ arguments = Twitter::API::Arguments.new(args)
133
132
  # Twitter always turns on notifications if the "follow" option is present, even if it's set to false
134
133
  # so only send follow if it's true
135
- options[:follow] = true if !!options.delete(:follow)
134
+ arguments.options[:follow] = true if !!arguments.options.delete(:follow)
136
135
  existing_friends = Thread.new do
137
136
  friend_ids.ids
138
137
  end
139
138
  new_friends = Thread.new do
140
139
  users(args).map(&:id)
141
140
  end
142
- follow!(new_friends.value - existing_friends.value, options)
141
+ follow!(new_friends.value - existing_friends.value, arguments.options)
143
142
  end
144
143
  alias friendship_create follow
145
144
 
@@ -159,14 +158,13 @@ module Twitter
159
158
  # @param options [Hash] A customizable set of options.
160
159
  # @option options [Boolean] :follow (false) Enable notifications for the target user.
161
160
  def follow!(*args)
162
- options = extract_options!(args)
161
+ arguments = Twitter::API::Arguments.new(args)
163
162
  # Twitter always turns on notifications if the "follow" option is present, even if it's set to false
164
163
  # so only send follow if it's true
165
- options[:follow] = true if !!options.delete(:follow)
166
- args.flatten.threaded_map do |user|
164
+ arguments.options[:follow] = true if !!arguments.options.delete(:follow)
165
+ arguments.flatten.threaded_map do |user|
167
166
  begin
168
- merge_user!(options, user)
169
- object_from_response(Twitter::User, :post, "/1.1/friendships/create.json", options)
167
+ object_from_response(Twitter::User, :post, "/1.1/friendships/create.json", merge_user(arguments.options, user))
170
168
  rescue Twitter::Error::Forbidden
171
169
  # This error will be raised if the user doesn't have permission to
172
170
  # follow list_member, for whatever reason.
@@ -190,7 +188,7 @@ module Twitter
190
188
  # @param users [Array<Integer, String, Twitter::User>, Set<Integer, String, Twitter::User>] An array of Twitter user IDs, screen names, or objects.
191
189
  # @param options [Hash] A customizable set of options.
192
190
  def unfollow(*args)
193
- threaded_users_from_response(:post, "/1.1/friendships/destroy.json", args)
191
+ threaded_user_objects_from_response(:post, "/1.1/friendships/destroy.json", args)
194
192
  end
195
193
  alias friendship_destroy unfollow
196
194
 
@@ -282,7 +280,7 @@ module Twitter
282
280
  # Twitter.followers('sferik')
283
281
  # Twitter.followers(7505382) # Same as above
284
282
  def followers(*args)
285
- friends_or_followers_from_response(:get, "/1.1/followers/list.json", args, :followers)
283
+ cursor_from_response_with_user(:users, Twitter::User, :get, "/1.1/followers/list.json", args, :followers)
286
284
  end
287
285
 
288
286
  # Returns a cursored collection of user objects for every user the specified user is following (otherwise known as their "friends").
@@ -313,23 +311,10 @@ module Twitter
313
311
  # Twitter.friends('sferik')
314
312
  # Twitter.friends(7505382) # Same as above
315
313
  def friends(*args)
316
- friends_or_followers_from_response(:get, "/1.1/friends/list.json", args, :friends)
314
+ cursor_from_response_with_user(:users, Twitter::User, :get, "/1.1/friends/list.json", args, :friends)
317
315
  end
318
316
  alias following friends
319
317
 
320
- private
321
-
322
- # @param request_method [Symbol]
323
- # @param path [String]
324
- # @param args [Array]
325
- # @return [Array<Integer>]
326
- def friends_or_followers_from_response(request_method, path, args, calling_method)
327
- options = extract_options!(args)
328
- merge_default_cursor!(options)
329
- merge_user!(options, args.pop || screen_name) unless options[:user_id] || options[:screen_name]
330
- cursor_from_response(:users, Twitter::User, request_method, path, options, calling_method)
331
- end
332
-
333
318
  end
334
319
  end
335
320
  end
@@ -30,7 +30,7 @@ module Twitter
30
30
  # @example Return the list of languages Twitter supports
31
31
  # Twitter.languages
32
32
  def languages(options={})
33
- collection_from_response(Twitter::Language, :get, "/1.1/help/languages.json", options)
33
+ objects_from_response(Twitter::Language, :get, "/1.1/help/languages.json", options)
34
34
  end
35
35
 
36
36
  # Returns {https://twitter.com/privacy Twitter's Privacy Policy}
@@ -1,4 +1,6 @@
1
+ require 'twitter/api/arguments'
1
2
  require 'twitter/api/utils'
3
+ require 'twitter/core_ext/enumerable'
2
4
  require 'twitter/cursor'
3
5
  require 'twitter/error/forbidden'
4
6
  require 'twitter/error/not_found'
@@ -30,7 +32,7 @@ module Twitter
30
32
  # Twitter.lists('sferik')
31
33
  # Twitter.lists(7505382)
32
34
  def lists(*args)
33
- objects_from_response(Twitter::List, :get, "/1.1/lists/list.json", args)
35
+ objects_from_response_with_user(Twitter::List, :get, "/1.1/lists/list.json", args)
34
36
  end
35
37
  alias lists_subscribed_to lists
36
38
 
@@ -63,10 +65,10 @@ module Twitter
63
65
  # Twitter.list_timeline(7505382, 'presidents')
64
66
  # Twitter.list_timeline(7505382, 8863586)
65
67
  def list_timeline(*args)
66
- options = extract_options!(args)
67
- merge_list!(options, args.pop)
68
- merge_owner!(options, args.pop || screen_name) unless options[:owner_id] || options[:owner_screen_name]
69
- collection_from_response(Twitter::Tweet, :get, "/1.1/lists/statuses.json", options)
68
+ arguments = Twitter::API::Arguments.new(args)
69
+ merge_list!(arguments.options, arguments.pop)
70
+ merge_owner!(arguments.options, arguments.pop || screen_name) unless arguments.options[:owner_id] || arguments.options[:owner_screen_name]
71
+ objects_from_response(Twitter::Tweet, :get, "/1.1/lists/statuses.json", arguments.options)
70
72
  end
71
73
 
72
74
  # Removes the specified member from the list
@@ -95,7 +97,7 @@ module Twitter
95
97
  # Twitter.list_remove_member('sferik', 8863586, 'BarackObama')
96
98
  # Twitter.list_remove_member(7505382, 'presidents', 813286)
97
99
  def list_remove_member(*args)
98
- list_modify_member(:post, "/1.1/lists/members/destroy.json", args)
100
+ list_from_response_with_user(:post, "/1.1/lists/members/destroy.json", args)
99
101
  end
100
102
 
101
103
  # List the lists the specified user has been added to
@@ -120,7 +122,7 @@ module Twitter
120
122
  # Twitter.memberships('sferik')
121
123
  # Twitter.memberships(7505382)
122
124
  def memberships(*args)
123
- lists_from_response(:get, "/1.1/lists/memberships.json", args, :memberships)
125
+ cursor_from_response_with_user(:lists, Twitter::List, :get, "/1.1/lists/memberships.json", args, :memberships)
124
126
  end
125
127
 
126
128
  # Returns the subscribers of the specified list
@@ -147,7 +149,7 @@ module Twitter
147
149
  # Twitter.list_subscribers('sferik', 8863586)
148
150
  # Twitter.list_subscribers(7505382, 'presidents')
149
151
  def list_subscribers(*args)
150
- list_users(:get, "/1.1/lists/subscribers.json", args, :list_subscribers)
152
+ cursor_from_response_with_list(:get, "/1.1/lists/subscribers.json", args, :list_subscribers)
151
153
  end
152
154
 
153
155
  # Make the authenticated user follow the specified list
@@ -260,7 +262,7 @@ module Twitter
260
262
  # Twitter.list_add_members(7505382, 8863586, ['BarackObama', 'pengwynn'])
261
263
  # Twitter.list_add_members(7505382, 8863586, [813286, 18755393])
262
264
  def list_add_members(*args)
263
- list_modify_members(:post, "/1.1/lists/members/create_all.json", args)
265
+ list_from_response_with_users(:post, "/1.1/lists/members/create_all.json", args)
264
266
  end
265
267
 
266
268
  # Check if a user is a member of the specified list
@@ -315,7 +317,7 @@ module Twitter
315
317
  # Twitter.list_members(7505382, 'presidents')
316
318
  # Twitter.list_members(7505382, 8863586)
317
319
  def list_members(*args)
318
- list_users(:get, "/1.1/lists/members.json", args, :list_members)
320
+ cursor_from_response_with_list(:get, "/1.1/lists/members.json", args, :list_members)
319
321
  end
320
322
 
321
323
  # Add a member to a list
@@ -344,7 +346,7 @@ module Twitter
344
346
  # Twitter.list_add_member(7505382, 'presidents', 813286)
345
347
  # Twitter.list_add_member(7505382, 8863586, 813286)
346
348
  def list_add_member(*args)
347
- list_modify_member(:post, "/1.1/lists/members/create.json", args)
349
+ list_from_response_with_user(:post, "/1.1/lists/members/create.json", args)
348
350
  end
349
351
 
350
352
  # Deletes the specified list
@@ -469,7 +471,7 @@ module Twitter
469
471
  # Twitter.subscriptions('sferik')
470
472
  # Twitter.subscriptions(7505382)
471
473
  def subscriptions(*args)
472
- lists_from_response(:get, "/1.1/lists/subscriptions.json", args, :subscriptions)
474
+ cursor_from_response_with_user(:lists, Twitter::List, :get, "/1.1/lists/subscriptions.json", args, :subscriptions)
473
475
  end
474
476
 
475
477
  # Removes specified members from the list
@@ -501,7 +503,7 @@ module Twitter
501
503
  # Twitter.list_remove_members(7505382, 8863586, ['BarackObama', 'pengwynn'])
502
504
  # Twitter.list_remove_members(7505382, 8863586, [813286, 18755393])
503
505
  def list_remove_members(*args)
504
- list_modify_members(:post, "/1.1/lists/members/destroy_all.json", args)
506
+ list_from_response_with_users(:post, "/1.1/lists/members/destroy_all.json", args)
505
507
  end
506
508
 
507
509
  private
@@ -511,57 +513,45 @@ module Twitter
511
513
  # @param args [Array]
512
514
  # @return [Array<Twitter::User>]
513
515
  def list_from_response(request_method, path, args)
514
- options = extract_options!(args)
515
- merge_list!(options, args.pop)
516
- merge_owner!(options, args.pop || screen_name) unless options[:owner_id] || options[:owner_screen_name]
517
- object_from_response(Twitter::List, request_method, path, options)
516
+ arguments = Twitter::API::Arguments.new(args)
517
+ merge_list!(arguments.options, arguments.pop)
518
+ merge_owner!(arguments.options, arguments.pop || screen_name) unless arguments.options[:owner_id] || arguments.options[:owner_screen_name]
519
+ object_from_response(Twitter::List, request_method, path, arguments.options)
518
520
  end
519
521
 
520
- # @param request_method [Symbol]
521
- # @param path [String]
522
- # @param args [Array]
523
- # @return [Array<Twitter::List>]
524
- def lists_from_response(request_method, path, args, calling_method)
525
- options = extract_options!(args)
526
- merge_default_cursor!(options)
527
- merge_user!(options, args.pop || screen_name) unless options[:user_id] || options[:screen_name]
528
- cursor_from_response(:lists, Twitter::List, request_method, path, options, calling_method)
529
- end
530
-
531
- def list_users(request_method, path, args, calling_method)
532
- options = extract_options!(args)
533
- merge_default_cursor!(options)
534
- merge_list!(options, args.pop)
535
- merge_owner!(options, args.pop || screen_name) unless options[:owner_id] || options[:owner_screen_name]
536
- cursor_from_response(:users, Twitter::User, request_method, path, options, calling_method)
522
+ def cursor_from_response_with_list(request_method, path, args, calling_method)
523
+ arguments = Twitter::API::Arguments.new(args)
524
+ merge_list!(arguments.options, arguments.pop)
525
+ merge_owner!(arguments.options, arguments.pop || screen_name) unless arguments.options[:owner_id] || arguments.options[:owner_screen_name]
526
+ cursor_from_response(:users, Twitter::User, request_method, path, arguments.options, calling_method)
537
527
  end
538
528
 
539
529
  def list_user?(request_method, path, args)
540
- options = extract_options!(args)
541
- merge_user!(options, args.pop)
542
- merge_list!(options, args.pop)
543
- merge_owner!(options, args.pop || screen_name) unless options[:owner_id] || options[:owner_screen_name]
544
- send(request_method.to_sym, path, options)
530
+ arguments = Twitter::API::Arguments.new(args)
531
+ merge_user!(arguments.options, arguments.pop)
532
+ merge_list!(arguments.options, arguments.pop)
533
+ merge_owner!(arguments.options, arguments.pop || screen_name) unless arguments.options[:owner_id] || arguments.options[:owner_screen_name]
534
+ send(request_method.to_sym, path, arguments.options)
545
535
  true
546
536
  rescue Twitter::Error::NotFound, Twitter::Error::Forbidden
547
537
  false
548
538
  end
549
539
 
550
- def list_modify_member(request_method, path, args)
551
- options = extract_options!(args)
552
- merge_user!(options, args.pop)
553
- merge_list!(options, args.pop)
554
- merge_owner!(options, args.pop || screen_name) unless options[:owner_id] || options[:owner_screen_name]
555
- object_from_response(Twitter::List, request_method, path, options)
540
+ def list_from_response_with_user(request_method, path, args)
541
+ arguments = Twitter::API::Arguments.new(args)
542
+ merge_user!(arguments.options, arguments.pop)
543
+ merge_list!(arguments.options, arguments.pop)
544
+ merge_owner!(arguments.options, arguments.pop || screen_name) unless arguments.options[:owner_id] || arguments.options[:owner_screen_name]
545
+ object_from_response(Twitter::List, request_method, path, arguments.options)
556
546
  end
557
547
 
558
- def list_modify_members(request_method, path, args)
559
- options = extract_options!(args)
560
- members = args.pop
561
- merge_list!(options, args.pop)
562
- merge_owner!(options, args.pop || screen_name) unless options[:owner_id] || options[:owner_screen_name]
548
+ def list_from_response_with_users(request_method, path, args)
549
+ arguments = Twitter::API::Arguments.new(args)
550
+ members = arguments.pop
551
+ merge_list!(arguments.options, arguments.pop)
552
+ merge_owner!(arguments.options, arguments.pop || screen_name) unless arguments.options[:owner_id] || arguments.options[:owner_screen_name]
563
553
  members.flatten.each_slice(MAX_USERS_PER_REQUEST).threaded_map do |users|
564
- object_from_response(Twitter::List, request_method, path, merge_users(options, users))
554
+ object_from_response(Twitter::List, request_method, path, merge_users(arguments.options, users))
565
555
  end.last
566
556
  end
567
557
 
@@ -38,7 +38,7 @@ module Twitter
38
38
  # @example Return an array of places within the specified region
39
39
  # Twitter.reverse_geocode(:lat => "37.7821120598956", :long => "-122.400612831116")
40
40
  def reverse_geocode(options={})
41
- geo_collection_from_response(:get, "/1.1/geo/reverse_geocode.json", options)
41
+ geo_objects_from_response(:get, "/1.1/geo/reverse_geocode.json", options)
42
42
  end
43
43
 
44
44
  # Search for places that can be attached to a {Twitter::API::Tweets#update}
@@ -61,7 +61,7 @@ module Twitter
61
61
  # @example Return an array of places near the IP address 74.125.19.104
62
62
  # Twitter.geo_search(:ip => "74.125.19.104")
63
63
  def geo_search(options={})
64
- geo_collection_from_response(:get, "/1.1/geo/search.json", options)
64
+ geo_objects_from_response(:get, "/1.1/geo/search.json", options)
65
65
  end
66
66
  alias places_nearby geo_search
67
67
 
@@ -82,7 +82,7 @@ module Twitter
82
82
  # @example Return an array of places similar to Twitter HQ
83
83
  # Twitter.similar_places(:lat => "37.7821120598956", :long => "-122.400612831116", :name => "Twitter HQ")
84
84
  def similar_places(options={})
85
- geo_collection_from_response(:get, "/1.1/geo/similar_places.json", options)
85
+ geo_objects_from_response(:get, "/1.1/geo/similar_places.json", options)
86
86
  end
87
87
  alias places_similar similar_places
88
88
 
@@ -112,8 +112,8 @@ module Twitter
112
112
  # @param path [String]
113
113
  # @param params [Hash]
114
114
  # @return [Array]
115
- def geo_collection_from_response(request_method, path, params={})
116
- collection_from_array(Twitter::Place, send(request_method.to_sym, path, params)[:body][:result][:places])
115
+ def geo_objects_from_response(request_method, path, params={})
116
+ objects_from_array(Twitter::Place, send(request_method.to_sym, path, params)[:body][:result][:places])
117
117
  end
118
118
 
119
119
  end