twitter 5.6.0 → 5.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (93) hide show
  1. data.tar.gz.sig +0 -0
  2. data/.yardopts +1 -0
  3. data/CHANGELOG.md +8 -0
  4. data/README.md +3 -3
  5. data/Rakefile +1 -1
  6. data/lib/twitter/base.rb +0 -8
  7. data/lib/twitter/client.rb +2 -1
  8. data/lib/twitter/cursor.rb +2 -15
  9. data/lib/twitter/error.rb +90 -18
  10. data/lib/twitter/geo_results.rb +0 -10
  11. data/lib/twitter/request.rb +4 -4
  12. data/lib/twitter/rest/api.rb +43 -0
  13. data/lib/twitter/rest/client.rb +10 -44
  14. data/lib/twitter/rest/direct_messages.rb +138 -0
  15. data/lib/twitter/rest/favorites.rb +108 -0
  16. data/lib/twitter/rest/friends_and_followers.rb +281 -0
  17. data/lib/twitter/rest/help.rb +56 -0
  18. data/lib/twitter/rest/lists.rb +497 -0
  19. data/lib/twitter/rest/oauth.rb +65 -0
  20. data/lib/twitter/rest/places_and_geo.rb +84 -0
  21. data/lib/twitter/rest/request/multipart_with_file.rb +5 -5
  22. data/lib/twitter/rest/response/parse_json.rb +2 -4
  23. data/lib/twitter/rest/response/raise_error.rb +24 -15
  24. data/lib/twitter/rest/saved_searches.rb +93 -0
  25. data/lib/twitter/rest/search.rb +37 -0
  26. data/lib/twitter/rest/spam_reporting.rb +27 -0
  27. data/lib/twitter/rest/suggested_users.rb +49 -0
  28. data/lib/twitter/rest/timelines.rb +200 -0
  29. data/lib/twitter/rest/trends.rb +57 -0
  30. data/lib/twitter/rest/tweets.rb +309 -0
  31. data/lib/twitter/rest/undocumented.rb +49 -0
  32. data/lib/twitter/rest/users.rb +383 -0
  33. data/lib/twitter/rest/utils.rb +205 -0
  34. data/lib/twitter/search_results.rb +2 -13
  35. data/lib/twitter/trend_results.rb +0 -10
  36. data/lib/twitter/version.rb +1 -1
  37. data/spec/helper.rb +1 -1
  38. data/spec/twitter/error_spec.rb +26 -42
  39. data/spec/twitter/rest/{api/direct_messages_spec.rb → direct_messages_spec.rb} +1 -1
  40. data/spec/twitter/rest/{api/favorites_spec.rb → favorites_spec.rb} +1 -1
  41. data/spec/twitter/rest/{api/friends_and_followers_spec.rb → friends_and_followers_spec.rb} +1 -1
  42. data/spec/twitter/rest/{api/geo_spec.rb → geo_spec.rb} +1 -1
  43. data/spec/twitter/rest/{api/help_spec.rb → help_spec.rb} +1 -1
  44. data/spec/twitter/rest/{api/lists_spec.rb → lists_spec.rb} +1 -1
  45. data/spec/twitter/rest/{api/oauth_spec.rb → oauth_spec.rb} +4 -8
  46. data/spec/twitter/rest/{api/saved_searches_spec.rb → saved_searches_spec.rb} +1 -1
  47. data/spec/twitter/rest/{api/search_spec.rb → search_spec.rb} +1 -1
  48. data/spec/twitter/rest/{api/spam_reporting_spec.rb → spam_reporting_spec.rb} +1 -1
  49. data/spec/twitter/rest/{api/suggested_users_spec.rb → suggested_users_spec.rb} +1 -1
  50. data/spec/twitter/rest/{api/timelines_spec.rb → timelines_spec.rb} +1 -1
  51. data/spec/twitter/rest/{api/trends_spec.rb → trends_spec.rb} +1 -1
  52. data/spec/twitter/rest/{api/tweets_spec.rb → tweets_spec.rb} +74 -5
  53. data/spec/twitter/rest/{api/undocumented_spec.rb → undocumented_spec.rb} +1 -1
  54. data/spec/twitter/rest/{api/users_spec.rb → users_spec.rb} +5 -5
  55. data/spec/twitter/tweet_spec.rb +1 -1
  56. data/twitter.gemspec +0 -1
  57. metadata +247 -237
  58. metadata.gz.sig +0 -0
  59. checksums.yaml +0 -7
  60. checksums.yaml.gz.sig +0 -0
  61. data/lib/twitter/error/already_favorited.rb +0 -10
  62. data/lib/twitter/error/already_posted.rb +0 -10
  63. data/lib/twitter/error/already_retweeted.rb +0 -10
  64. data/lib/twitter/error/bad_gateway.rb +0 -10
  65. data/lib/twitter/error/bad_request.rb +0 -10
  66. data/lib/twitter/error/configuration_error.rb +0 -8
  67. data/lib/twitter/error/forbidden.rb +0 -10
  68. data/lib/twitter/error/gateway_timeout.rb +0 -10
  69. data/lib/twitter/error/internal_server_error.rb +0 -10
  70. data/lib/twitter/error/not_acceptable.rb +0 -10
  71. data/lib/twitter/error/not_found.rb +0 -10
  72. data/lib/twitter/error/request_timeout.rb +0 -10
  73. data/lib/twitter/error/service_unavailable.rb +0 -10
  74. data/lib/twitter/error/too_many_requests.rb +0 -12
  75. data/lib/twitter/error/unauthorized.rb +0 -10
  76. data/lib/twitter/error/unprocessable_entity.rb +0 -10
  77. data/lib/twitter/rest/api/direct_messages.rb +0 -140
  78. data/lib/twitter/rest/api/favorites.rb +0 -115
  79. data/lib/twitter/rest/api/friends_and_followers.rb +0 -284
  80. data/lib/twitter/rest/api/help.rb +0 -58
  81. data/lib/twitter/rest/api/lists.rb +0 -500
  82. data/lib/twitter/rest/api/oauth.rb +0 -67
  83. data/lib/twitter/rest/api/places_and_geo.rb +0 -86
  84. data/lib/twitter/rest/api/saved_searches.rb +0 -95
  85. data/lib/twitter/rest/api/search.rb +0 -39
  86. data/lib/twitter/rest/api/spam_reporting.rb +0 -29
  87. data/lib/twitter/rest/api/suggested_users.rb +0 -51
  88. data/lib/twitter/rest/api/timelines.rb +0 -202
  89. data/lib/twitter/rest/api/trends.rb +0 -58
  90. data/lib/twitter/rest/api/tweets.rb +0 -297
  91. data/lib/twitter/rest/api/undocumented.rb +0 -51
  92. data/lib/twitter/rest/api/users.rb +0 -383
  93. data/lib/twitter/rest/api/utils.rb +0 -212
@@ -1,284 +0,0 @@
1
- require 'twitter/arguments'
2
- require 'twitter/cursor'
3
- require 'twitter/error/forbidden'
4
- require 'twitter/relationship'
5
- require 'twitter/request'
6
- require 'twitter/rest/api/utils'
7
- require 'twitter/user'
8
- require 'twitter/utils'
9
-
10
- module Twitter
11
- module REST
12
- module API
13
- module FriendsAndFollowers
14
- include Twitter::REST::API::Utils
15
- include Twitter::Utils
16
-
17
- # @see https://dev.twitter.com/docs/api/1.1/get/friends/ids
18
- # @rate_limited Yes
19
- # @authentication Requires user context
20
- # @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
21
- # @return [Twitter::Cursor]
22
- # @overload friend_ids(options = {})
23
- # Returns an array of numeric IDs for every user the authenticated user is following
24
- #
25
- # @param options [Hash] A customizable set of options.
26
- # @option options [Integer] :cursor (-1) Breaks the results into pages. This is recommended for users who are following many users. Provide a value of -1 to begin paging. Provide values as returned in the response body's next_cursor and previous_cursor attributes to page back and forth in the list.
27
- # @overload friend_ids(user, options = {})
28
- # Returns an array of numeric IDs for every user the specified user is following
29
- #
30
- # @param user [Integer, String, Twitter::User] A Twitter user ID, screen name, URI, or object.
31
- # @param options [Hash] A customizable set of options.
32
- # @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.
33
- def friend_ids(*args)
34
- cursor_from_response_with_user(:ids, nil, :get, '/1.1/friends/ids.json', args)
35
- end
36
-
37
- # @see https://dev.twitter.com/docs/api/1.1/get/followers/ids
38
- # @rate_limited Yes
39
- # @authentication Requires user context
40
- # @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
41
- # @return [Twitter::Cursor]
42
- # @overload follower_ids(options = {})
43
- # Returns an array of numeric IDs for every user following the authenticated user
44
- #
45
- # @param options [Hash] A customizable set of options.
46
- # @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.
47
- # @overload follower_ids(user, options = {})
48
- # Returns an array of numeric IDs for every user following the specified user
49
- #
50
- # @param user [Integer, String, Twitter::User] A Twitter user ID, screen name, URI, or object.
51
- # @param options [Hash] A customizable set of options.
52
- # @option options [Integer] :cursor (-1) Breaks the results into pages. This is recommended for users who are following many users. Provide a value of -1 to begin paging. Provide values as returned in the response body's next_cursor and previous_cursor attributes to page back and forth in the list.
53
- def follower_ids(*args)
54
- cursor_from_response_with_user(:ids, nil, :get, '/1.1/followers/ids.json', args)
55
- end
56
-
57
- # 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.
58
- #
59
- # @see https://dev.twitter.com/docs/api/1.1/get/friendships/lookup
60
- # @rate_limited Yes
61
- # @authentication Requires user context
62
- # @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
63
- # @return [Array<Twitter::User>] The requested users.
64
- # @overload friendships(*users)
65
- # @param users [Enumerable<Integer, String, Twitter::User>] A collection of Twitter user IDs, screen names, or objects.
66
- # @overload friendships(*users, options)
67
- # @param users [Enumerable<Integer, String, Twitter::User>] A collection of Twitter user IDs, screen names, or objects.
68
- # @param options [Hash] A customizable set of options.
69
- def friendships(*args)
70
- arguments = Twitter::Arguments.new(args)
71
- merge_users!(arguments.options, arguments)
72
- perform_with_objects(:get, '/1.1/friendships/lookup.json', arguments.options, Twitter::User)
73
- end
74
-
75
- # Returns an array of numeric IDs for every user who has a pending request to follow the authenticating user
76
- #
77
- # @see https://dev.twitter.com/docs/api/1.1/get/friendships/incoming
78
- # @rate_limited Yes
79
- # @authentication Requires user context
80
- # @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
81
- # @return [Twitter::Cursor]
82
- # @param options [Hash] A customizable set of options.
83
- # @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.
84
- def friendships_incoming(options = {})
85
- perform_with_cursor(:get, '/1.1/friendships/incoming.json', options, :ids)
86
- end
87
-
88
- # Returns an array of numeric IDs for every protected user for whom the authenticating user has a pending follow request
89
- #
90
- # @see https://dev.twitter.com/docs/api/1.1/get/friendships/outgoing
91
- # @rate_limited Yes
92
- # @authentication Requires user context
93
- # @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
94
- # @return [Twitter::Cursor]
95
- # @param options [Hash] A customizable set of options.
96
- # @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.
97
- def friendships_outgoing(options = {})
98
- perform_with_cursor(:get, '/1.1/friendships/outgoing.json', options, :ids)
99
- end
100
-
101
- # Allows the authenticating user to follow the specified users, unless they are already followed
102
- #
103
- # @see https://dev.twitter.com/docs/api/1.1/post/friendships/create
104
- # @rate_limited Yes
105
- # @authentication Requires user context
106
- # @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
107
- # @return [Array<Twitter::User>] The followed users.
108
- # @overload follow(*users)
109
- # @param users [Enumerable<Integer, String, Twitter::User>] A collection of Twitter user IDs, screen names, or objects.
110
- # @overload follow(*users, options)
111
- # @param users [Enumerable<Integer, String, Twitter::User>] A collection of Twitter user IDs, screen names, or objects.
112
- # @param options [Hash] A customizable set of options.
113
- # @option options [Boolean] :follow (false) Enable notifications for the target user.
114
- def follow(*args)
115
- arguments = Twitter::Arguments.new(args)
116
- existing_friends = Thread.new do
117
- friend_ids.to_a
118
- end
119
- new_friends = Thread.new do
120
- users(args).collect(&:id)
121
- end
122
- follow!(new_friends.value - existing_friends.value, arguments.options)
123
- end
124
- alias_method :create_friendship, :follow
125
- deprecate_alias :friendship_create, :follow
126
-
127
- # Allows the authenticating user to follow the specified users
128
- #
129
- # @see https://dev.twitter.com/docs/api/1.1/post/friendships/create
130
- # @rate_limited No
131
- # @authentication Requires user context
132
- # @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
133
- # @return [Array<Twitter::User>] The followed users.
134
- # @overload follow!(*users)
135
- # @param users [Enumerable<Integer, String, Twitter::User>] A collection of Twitter user IDs, screen names, or objects.
136
- # @overload follow!(*users, options)
137
- # @param users [Enumerable<Integer, String, Twitter::User>] A collection of Twitter user IDs, screen names, or objects.
138
- # @param options [Hash] A customizable set of options.
139
- # @option options [Boolean] :follow (false) Enable notifications for the target user.
140
- def follow!(*args)
141
- arguments = Twitter::Arguments.new(args)
142
- parallel_map(arguments) do |user|
143
- perform_with_object(:post, '/1.1/friendships/create.json', merge_user(arguments.options, user), Twitter::User)
144
- end.compact
145
- end
146
- alias_method :create_friendship!, :follow!
147
- deprecate_alias :friendship_create!, :follow!
148
-
149
- # Allows the authenticating user to unfollow the specified users
150
- #
151
- # @see https://dev.twitter.com/docs/api/1.1/post/friendships/destroy
152
- # @rate_limited No
153
- # @authentication Requires user context
154
- # @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
155
- # @return [Array<Twitter::User>] The unfollowed users.
156
- # @overload unfollow(*users)
157
- # @param users [Enumerable<Integer, String, Twitter::User>] A collection of Twitter user IDs, screen names, or objects.
158
- # @overload unfollow(*users, options)
159
- # @param users [Enumerable<Integer, String, Twitter::User>] A collection of Twitter user IDs, screen names, or objects.
160
- # @param options [Hash] A customizable set of options.
161
- def unfollow(*args)
162
- parallel_user_objects_from_response(:post, '/1.1/friendships/destroy.json', args)
163
- end
164
- alias_method :destroy_friendship, :unfollow
165
- deprecate_alias :friendship_destroy, :unfollow
166
-
167
- # Allows one to enable or disable retweets and device notifications from the specified user.
168
- #
169
- # @see https://dev.twitter.com/docs/api/1.1/post/friendships/update
170
- # @rate_limited No
171
- # @authentication Requires user context
172
- # @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
173
- # @return [Twitter::Relationship]
174
- # @param user [Integer, String, Twitter::User] A Twitter user ID, screen name, URI, or object.
175
- # @param options [Hash] A customizable set of options.
176
- # @option options [Boolean] :device Enable/disable device notifications from the target user.
177
- # @option options [Boolean] :retweets Enable/disable retweets from the target user.
178
- def friendship_update(user, options = {})
179
- merge_user!(options, user)
180
- perform_with_object(:post, '/1.1/friendships/update.json', options, Twitter::Relationship)
181
- end
182
-
183
- # Returns detailed information about the relationship between two users
184
- #
185
- # @see https://dev.twitter.com/docs/api/1.1/get/friendships/show
186
- # @rate_limited Yes
187
- # @authentication Requires user context
188
- # @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
189
- # @return [Twitter::Relationship]
190
- # @param source [Integer, String, Twitter::User] The Twitter user ID, screen name, or object of the source user.
191
- # @param target [Integer, String, Twitter::User] The Twitter user ID, screen name, or object of the target user.
192
- # @param options [Hash] A customizable set of options.
193
- def friendship(source, target, options = {})
194
- merge_user!(options, source, 'source')
195
- options[:source_id] = options.delete(:source_user_id) unless options[:source_user_id].nil?
196
- merge_user!(options, target, 'target')
197
- options[:target_id] = options.delete(:target_user_id) unless options[:target_user_id].nil?
198
- perform_with_object(:get, '/1.1/friendships/show.json', options, Twitter::Relationship)
199
- end
200
- alias_method :friendship_show, :friendship
201
- alias_method :relationship, :friendship
202
-
203
- # Test for the existence of friendship between two users
204
- #
205
- # @see https://dev.twitter.com/docs/api/1.1/get/friendships/show
206
- # @rate_limited Yes
207
- # @authentication Requires user context
208
- # @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
209
- # @return [Boolean] true if user_a follows user_b, otherwise false.
210
- # @param source [Integer, String, Twitter::User] The Twitter user ID, screen name, or object of the source user.
211
- # @param target [Integer, String, Twitter::User] The Twitter user ID, screen name, or object of the target user.
212
- # @param options [Hash] A customizable set of options.
213
- def friendship?(source, target, options = {})
214
- friendship(source, target, options).source.following?
215
- end
216
-
217
- # Returns a cursored collection of user objects for users following the specified user.
218
- #
219
- # @see https://dev.twitter.com/docs/api/1.1/get/followers/list
220
- # @rate_limited Yes
221
- # @authentication Requires user context
222
- # @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
223
- # @return [Twitter::Cursor]
224
- # @overload followers(options = {})
225
- # Returns a cursored collection of user objects for users following the authenticated user.
226
- #
227
- # @param options [Hash] A customizable set of options.
228
- # @option options [Integer] :cursor (-1) Breaks the results into pages. This is recommended for users who are following many users. Provide a value of -1 to begin paging. Provide values as returned in the response body's next_cursor and previous_cursor attributes to page back and forth in the list.
229
- # @option options [Boolean, String, Integer] :skip_status Do not include contributee's Tweets when set to true, 't' or 1.
230
- # @option options [Boolean, String, Integer] :include_user_entities The user entities node will be disincluded when set to false.
231
- # @overload followers(user, options = {})
232
- # Returns a cursored collection of user objects for users following the specified user.
233
- #
234
- # @param user [Integer, String, Twitter::User] A Twitter user ID, screen name, URI, or object.
235
- # @param options [Hash] A customizable set of options.
236
- # @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.
237
- # @option options [Boolean, String, Integer] :skip_status Do not include contributee's Tweets when set to true, 't' or 1.
238
- # @option options [Boolean, String, Integer] :include_user_entities The user entities node will be disincluded when set to false.
239
- def followers(*args)
240
- cursor_from_response_with_user(:users, Twitter::User, :get, '/1.1/followers/list.json', args)
241
- end
242
-
243
- # Returns a cursored collection of user objects for every user the specified user is following (otherwise known as their "friends").
244
- #
245
- # @see https://dev.twitter.com/docs/api/1.1/get/friendships/show
246
- # @rate_limited Yes
247
- # @authentication Requires user context
248
- # @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
249
- # @return [Twitter::Cursor]
250
- # @overload friends(options = {})
251
- # Returns a cursored collection of user objects for every user the authenticated user is following (otherwise known as their "friends").
252
- #
253
- # @param options [Hash] A customizable set of options.
254
- # @option options [Integer] :cursor (-1) Breaks the results into pages. This is recommended for users who are following many users. Provide a value of -1 to begin paging. Provide values as returned in the response body's next_cursor and previous_cursor attributes to page back and forth in the list.
255
- # @option options [Boolean, String, Integer] :skip_status Do not include contributee's Tweets when set to true, 't' or 1.
256
- # @option options [Boolean, String, Integer] :include_user_entities The user entities node will be disincluded when set to false.
257
- # @overload friends(user, options = {})
258
- # Returns a cursored collection of user objects for every user the specified user is following (otherwise known as their "friends").
259
- #
260
- # @param user [Integer, String, Twitter::User] A Twitter user ID, screen name, URI, or object.
261
- # @param options [Hash] A customizable set of options.
262
- # @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.
263
- # @option options [Boolean, String, Integer] :skip_status Do not include contributee's Tweets when set to true, 't' or 1.
264
- # @option options [Boolean, String, Integer] :include_user_entities The user entities node will be disincluded when set to false.
265
- def friends(*args)
266
- cursor_from_response_with_user(:users, Twitter::User, :get, '/1.1/friends/list.json', args)
267
- end
268
- alias_method :following, :friends
269
-
270
- # Returns a collection of user IDs that the currently authenticated user does not want to receive retweets from.
271
- # @see https://dev.twitter.com/docs/api/1.1/get/friendships/no_retweets/ids
272
- # @rate_limited Yes
273
- # @authentication Requires user context
274
- # @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
275
- # @return [Array<Integer>]
276
- # @param options [Hash] A customizable set of options.
277
- def no_retweet_ids(options = {})
278
- get('/1.1/friendships/no_retweets/ids.json', options)[:body].collect(&:to_i)
279
- end
280
- alias_method :no_retweets_ids, :no_retweet_ids
281
- end
282
- end
283
- end
284
- end
@@ -1,58 +0,0 @@
1
- require 'twitter/configuration'
2
- require 'twitter/language'
3
- require 'twitter/request'
4
- require 'twitter/rest/api/utils'
5
-
6
- module Twitter
7
- module REST
8
- module API
9
- module Help
10
- include Twitter::REST::API::Utils
11
-
12
- # Returns the current configuration used by Twitter
13
- #
14
- # @see https://dev.twitter.com/docs/api/1.1/get/help/configuration
15
- # @rate_limited Yes
16
- # @authentication Requires user context
17
- # @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
18
- # @return [Twitter::Configuration] Twitter's configuration.
19
- def configuration(options = {})
20
- perform_with_object(:get, '/1.1/help/configuration.json', options, Twitter::Configuration)
21
- end
22
-
23
- # Returns the list of languages supported by Twitter
24
- #
25
- # @see https://dev.twitter.com/docs/api/1.1/get/help/languages
26
- # @rate_limited Yes
27
- # @authentication Requires user context
28
- # @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
29
- # @return [Array<Twitter::Language>]
30
- def languages(options = {})
31
- perform_with_objects(:get, '/1.1/help/languages.json', options, Twitter::Language)
32
- end
33
-
34
- # Returns {https://twitter.com/privacy Twitter's Privacy Policy}
35
- #
36
- # @see https://dev.twitter.com/docs/api/1.1/get/help/privacy
37
- # @rate_limited Yes
38
- # @authentication Requires user context
39
- # @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
40
- # @return [String]
41
- def privacy(options = {})
42
- get('/1.1/help/privacy.json', options)[:body][:privacy]
43
- end
44
-
45
- # Returns {https://twitter.com/tos Twitter's Terms of Service}
46
- #
47
- # @see https://dev.twitter.com/docs/api/1.1/get/help/tos
48
- # @rate_limited Yes
49
- # @authentication Requires user context
50
- # @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
51
- # @return [String]
52
- def tos(options = {})
53
- get('/1.1/help/tos.json', options)[:body][:tos]
54
- end
55
- end
56
- end
57
- end
58
- end
@@ -1,500 +0,0 @@
1
- require 'twitter/arguments'
2
- require 'twitter/cursor'
3
- require 'twitter/error/forbidden'
4
- require 'twitter/error/not_found'
5
- require 'twitter/list'
6
- require 'twitter/request'
7
- require 'twitter/rest/api/utils'
8
- require 'twitter/tweet'
9
- require 'twitter/user'
10
- require 'twitter/utils'
11
-
12
- module Twitter
13
- module REST
14
- module API
15
- module Lists
16
- include Twitter::REST::API::Utils
17
- include Twitter::Utils
18
- MAX_USERS_PER_REQUEST = 100
19
- URI_SUBSTRING = '://'
20
-
21
- # Returns all lists the authenticating or specified user subscribes to, including their own
22
- #
23
- # @see https://dev.twitter.com/docs/api/1.1/get/lists/list
24
- # @rate_limited Yes
25
- # @authentication Requires user context
26
- # @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
27
- # @return [Array<Twitter::List>]
28
- # @overload lists(options = {})
29
- # @param options [Hash] A customizable set of options.
30
- # @option options [Boolean] :reverse Set this to true if you would like owned lists to be returned first.
31
- # @overload lists(user, options = {})
32
- # @param user [Integer, String, Twitter::User] A Twitter user ID, screen name, URI, or object.
33
- # @param options [Hash] A customizable set of options.
34
- # @option options [Boolean] :reverse Set this to true if you would like owned lists to be returned first.
35
- def lists(*args)
36
- objects_from_response_with_user(Twitter::List, :get, '/1.1/lists/list.json', args)
37
- end
38
- alias_method :lists_subscribed_to, :lists
39
-
40
- # Show tweet timeline for members of the specified list
41
- #
42
- # @see https://dev.twitter.com/docs/api/1.1/get/lists/statuses
43
- # @rate_limited Yes
44
- # @authentication Requires user context
45
- # @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
46
- # @return [Array<Twitter::Tweet>]
47
- # @overload list_timeline(list, options = {})
48
- # @param list [Integer, String, Twitter::List] A Twitter list ID, slug, URI, or object.
49
- # @param options [Hash] A customizable set of options.
50
- # @option options [Integer] :since_id Returns results with an ID greater than (that is, more recent than) the specified ID.
51
- # @option options [Integer] :max_id Returns results with an ID less than (that is, older than) or equal to the specified ID.
52
- # @option options [Integer] :count The number of results to retrieve.
53
- # @overload list_timeline(user, list, options = {})
54
- # @param user [Integer, String, Twitter::User] A Twitter user ID, screen name, URI, or object.
55
- # @param list [Integer, String, Twitter::List] A Twitter list ID, slug, URI, or object.
56
- # @param options [Hash] A customizable set of options.
57
- # @option options [Integer] :since_id Returns results with an ID greater than (that is, more recent than) the specified ID.
58
- # @option options [Integer] :max_id Returns results with an ID less than (that is, older than) or equal to the specified ID.
59
- # @option options [Integer] :count The number of results to retrieve.
60
- def list_timeline(*args)
61
- arguments = Twitter::Arguments.new(args)
62
- merge_list!(arguments.options, arguments.pop)
63
- merge_owner!(arguments.options, arguments.pop)
64
- perform_with_objects(:get, '/1.1/lists/statuses.json', arguments.options, Twitter::Tweet)
65
- end
66
-
67
- # Removes the specified member from the list
68
- #
69
- # @see https://dev.twitter.com/docs/api/1.1/post/lists/members/destroy
70
- # @rate_limited No
71
- # @authentication Requires user context
72
- # @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
73
- # @return [Twitter::List] The list.
74
- # @overload remove_list_member(list, user_to_remove, options = {})
75
- # @param list [Integer, String, Twitter::List] A Twitter list ID, slug, URI, or object.
76
- # @param user_to_remove [Integer, String] The user id or screen name of the list member to remove.
77
- # @param options [Hash] A customizable set of options.
78
- # @overload remove_list_member(user, list, user_to_remove, options = {})
79
- # @param user [Integer, String, Twitter::User] A Twitter user ID, screen name, URI, or object.
80
- # @param list [Integer, String, Twitter::List] A Twitter list ID, slug, URI, or object.
81
- # @param user_to_remove [Integer, String] The user id or screen name of the list member to remove.
82
- # @param options [Hash] A customizable set of options.
83
- def remove_list_member(*args)
84
- list_from_response_with_user(:post, '/1.1/lists/members/destroy.json', args)
85
- end
86
- deprecate_alias :list_remove_member, :remove_list_member
87
-
88
- # List the lists the specified user has been added to
89
- #
90
- # @see https://dev.twitter.com/docs/api/1.1/get/lists/memberships
91
- # @rate_limited Yes
92
- # @authentication Requires user context
93
- # @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
94
- # @return [Twitter::Cursor]
95
- # @overload memberships(options = {})
96
- # @param options [Hash] A customizable set of options.
97
- # @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.
98
- # @option options [Boolean, String, Integer] :filter_to_owned_lists When set to true, t or 1, will return just lists the authenticating user owns, and the user represented by user_id or screen_name is a member of.
99
- # @overload memberships(user, options = {})
100
- # @param user [Integer, String, Twitter::User] A Twitter user ID, screen name, URI, or object.
101
- # @param options [Hash] A customizable set of options.
102
- # @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.
103
- # @option options [Boolean, String, Integer] :filter_to_owned_lists When set to true, t or 1, will return just lists the authenticating user owns, and the user represented by user_id or screen_name is a member of.
104
- def memberships(*args)
105
- cursor_from_response_with_user(:lists, Twitter::List, :get, '/1.1/lists/memberships.json', args)
106
- end
107
-
108
- # Returns the subscribers of the specified list
109
- #
110
- # @see https://dev.twitter.com/docs/api/1.1/get/lists/subscribers
111
- # @rate_limited Yes
112
- # @authentication Requires user context
113
- # @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
114
- # @return [Twitter::Cursor] The subscribers of the specified list.
115
- # @overload list_subscribers(list, options = {})
116
- # @param list [Integer, String, Twitter::List] A Twitter list ID, slug, URI, or object.
117
- # @param options [Hash] A customizable set of options.
118
- # @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.
119
- # @overload list_subscribers(user, list, options = {})
120
- # @param user [Integer, String, Twitter::User] A Twitter user ID, screen name, URI, or object.
121
- # @param list [Integer, String, Twitter::List] A Twitter list ID, slug, URI, or object.
122
- # @param options [Hash] A customizable set of options.
123
- # @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.
124
- def list_subscribers(*args)
125
- cursor_from_response_with_list(:get, '/1.1/lists/subscribers.json', args)
126
- end
127
-
128
- # Make the authenticated user follow the specified list
129
- #
130
- # @see https://dev.twitter.com/docs/api/1.1/post/lists/subscribers/create
131
- # @rate_limited No
132
- # @authentication Requires user context
133
- # @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
134
- # @return [Twitter::List] The specified list.
135
- # @overload list_subscribe(list, options = {})
136
- # @param list [Integer, String, Twitter::List] A Twitter list ID, slug, URI, or object.
137
- # @param options [Hash] A customizable set of options.
138
- # @overload list_subscribe(user, list, options = {})
139
- # @param user [Integer, String, Twitter::User] A Twitter user ID, screen name, URI, or object.
140
- # @param list [Integer, String, Twitter::List] A Twitter list ID, slug, URI, or object.
141
- # @param options [Hash] A customizable set of options.
142
- def list_subscribe(*args)
143
- list_from_response(:post, '/1.1/lists/subscribers/create.json', args)
144
- end
145
-
146
- # Check if a user is a subscriber of the specified list
147
- #
148
- # @see https://dev.twitter.com/docs/api/1.1/get/lists/subscribers/show
149
- # @rate_limited Yes
150
- # @authentication Requires user context
151
- # @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
152
- # @return [Boolean] true if user is a subscriber of the specified list, otherwise false.
153
- # @overload list_subscriber?(list, user_to_check, options = {})
154
- # @param list [Integer, String, Twitter::List] A Twitter list ID, slug, URI, or object.
155
- # @param user_to_check [Integer, String, Twitter::User] A Twitter user ID, screen name, URI, or object.
156
- # @param options [Hash] A customizable set of options.
157
- # @overload list_subscriber?(user, list, user_to_check, options = {})
158
- # @param user [Integer, String, Twitter::User] A Twitter user ID, screen name, URI, or object.
159
- # @param list [Integer, String, Twitter::List] A Twitter list ID, slug, URI, or object.
160
- # @param user_to_check [Integer, String, Twitter::User] A Twitter user ID, screen name, URI, or object.
161
- # @param options [Hash] A customizable set of options.
162
- # @return [Boolean] true if user is a subscriber of the specified list, otherwise false.
163
- def list_subscriber?(*args)
164
- list_user?(:get, '/1.1/lists/subscribers/show.json', args)
165
- end
166
-
167
- # Unsubscribes the authenticated user form the specified list
168
- #
169
- # @see https://dev.twitter.com/docs/api/1.1/post/lists/subscribers/destroy
170
- # @rate_limited No
171
- # @authentication Requires user context
172
- # @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
173
- # @return [Twitter::List] The specified list.
174
- # @overload list_unsubscribe(list, options = {})
175
- # @param list [Integer, String, Twitter::List] A Twitter list ID, slug, URI, or object.
176
- # @param options [Hash] A customizable set of options.
177
- # @overload list_unsubscribe(user, list, options = {})
178
- # @param user [Integer, String, Twitter::User] A Twitter user ID, screen name, URI, or object.
179
- # @param list [Integer, String, Twitter::List] A Twitter list ID, slug, URI, or object.
180
- # @param options [Hash] A customizable set of options.
181
- def list_unsubscribe(*args)
182
- list_from_response(:post, '/1.1/lists/subscribers/destroy.json', args)
183
- end
184
-
185
- # Adds specified members to a list
186
- #
187
- # @see https://dev.twitter.com/docs/api/1.1/post/lists/members/create_all
188
- # @note Lists are limited to having 500 members, and you are limited to adding up to 100 members to a list at a time with this method.
189
- # @rate_limited No
190
- # @authentication Requires user context
191
- # @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
192
- # @return [Twitter::List] The list.
193
- # @overload add_list_members(list, users, options = {})
194
- # @param list [Integer, String, Twitter::List] A Twitter list ID, slug, URI, or object.
195
- # @param users [Enumerable<Integer, String, Twitter::User>] A collection of Twitter user IDs, screen names, or objects.
196
- # @param options [Hash] A customizable set of options.
197
- # @overload add_list_members(user, list, users, options = {})
198
- # @param user [Integer, String, Twitter::User] A Twitter user ID, screen name, URI, or object.
199
- # @param list [Integer, String, Twitter::List] A Twitter list ID, slug, URI, or object.
200
- # @param users [Enumerable<Integer, String, Twitter::User>] A collection of Twitter user IDs, screen names, or objects.
201
- # @param options [Hash] A customizable set of options.
202
- def add_list_members(*args)
203
- list_from_response_with_users(:post, '/1.1/lists/members/create_all.json', args)
204
- end
205
- deprecate_alias :list_add_members, :add_list_members
206
-
207
- # Check if a user is a member of the specified list
208
- #
209
- # @see https://dev.twitter.com/docs/api/1.1/get/lists/members/show
210
- # @authentication Requires user context
211
- # @rate_limited Yes
212
- # @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
213
- # @return [Boolean] true if user is a member of the specified list, otherwise false.
214
- # @overload list_member?(list, user_to_check, options = {})
215
- # @param list [Integer, String, Twitter::List] A Twitter list ID, slug, URI, or object.
216
- # @param user_to_check [Integer, String] The user ID or screen name of the list member.
217
- # @param options [Hash] A customizable set of options.
218
- # @overload list_member?(user, list, user_to_check, options = {})
219
- # @param user [Integer, String, Twitter::User] A Twitter user ID, screen name, URI, or object.
220
- # @param list [Integer, String, Twitter::List] A Twitter list ID, slug, URI, or object.
221
- # @param user_to_check [Integer, String] The user ID or screen name of the list member.
222
- # @param options [Hash] A customizable set of options.
223
- def list_member?(*args)
224
- list_user?(:get, '/1.1/lists/members/show.json', args)
225
- end
226
-
227
- # Returns the members of the specified list
228
- #
229
- # @see https://dev.twitter.com/docs/api/1.1/get/lists/members
230
- # @rate_limited Yes
231
- # @authentication Requires user context
232
- # @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
233
- # @return [Twitter::Cursor]
234
- # @overload list_members(list, options = {})
235
- # @param list [Integer, String, Twitter::List] A Twitter list ID, slug, URI, or object.
236
- # @param options [Hash] A customizable set of options.
237
- # @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.
238
- # @overload list_members(user, list, options = {})
239
- # @param user [Integer, String, Twitter::User] A Twitter user ID, screen name, URI, or object.
240
- # @param list [Integer, String, Twitter::List] A Twitter list ID, slug, URI, or object.
241
- # @param options [Hash] A customizable set of options.
242
- # @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.
243
- def list_members(*args)
244
- cursor_from_response_with_list(:get, '/1.1/lists/members.json', args)
245
- end
246
-
247
- # Add a member to a list
248
- #
249
- # @see https://dev.twitter.com/docs/api/1.1/post/lists/members/create
250
- # @note Lists are limited to having 500 members.
251
- # @rate_limited No
252
- # @authentication Requires user context
253
- # @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
254
- # @return [Twitter::List] The list.
255
- # @overload add_list_member(list, user_to_add, options = {})
256
- # @param list [Integer, String, Twitter::List] A Twitter list ID, slug, URI, or object.
257
- # @param user_to_add [Integer, String] The user id or screen name to add to the list.
258
- # @param options [Hash] A customizable set of options.
259
- # @overload add_list_member(user, list, user_to_add, options = {})
260
- # @param user [Integer, String, Twitter::User] A Twitter user ID, screen name, URI, or object.
261
- # @param list [Integer, String, Twitter::List] A Twitter list ID, slug, URI, or object.
262
- # @param user_to_add [Integer, String] The user id or screen name to add to the list.
263
- # @param options [Hash] A customizable set of options.
264
- def add_list_member(*args)
265
- list_from_response_with_user(:post, '/1.1/lists/members/create.json', args)
266
- end
267
- deprecate_alias :list_add_member, :add_list_member
268
-
269
- # Deletes the specified list
270
- #
271
- # @see https://dev.twitter.com/docs/api/1.1/post/lists/destroy
272
- # @note Must be owned by the authenticated user.
273
- # @rate_limited No
274
- # @authentication Requires user context
275
- # @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
276
- # @return [Twitter::List] The deleted list.
277
- # @overload destroy_list(list, options = {})
278
- # @param list [Integer, String, Twitter::List] A Twitter list ID, slug, URI, or object.
279
- # @param options [Hash] A customizable set of options.
280
- # @overload destroy_list(user, list, options = {})
281
- # @param user [Integer, String, Twitter::User] A Twitter user ID, screen name, URI, or object.
282
- # @param list [Integer, String, Twitter::List] A Twitter list ID, slug, URI, or object.
283
- # @param options [Hash] A customizable set of options.
284
- def destroy_list(*args)
285
- list_from_response(:post, '/1.1/lists/destroy.json', args)
286
- end
287
- deprecate_alias :list_destroy, :destroy_list
288
-
289
- # Updates the specified list
290
- #
291
- # @see https://dev.twitter.com/docs/api/1.1/post/lists/update
292
- # @rate_limited No
293
- # @authentication Requires user context
294
- # @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
295
- # @return [Twitter::List] The created list.
296
- # @overload list_update(list, options = {})
297
- # @param list [Integer, String, Twitter::List] A Twitter list ID, slug, URI, or object.
298
- # @param options [Hash] A customizable set of options.
299
- # @option options [String] :mode ('public') Whether your list is public or private. Values can be 'public' or 'private'.
300
- # @option options [String] :description The description to give the list.
301
- # @overload list_update(user, list, options = {})
302
- # @param user [Integer, String, Twitter::User] A Twitter user ID, screen name, URI, or object.
303
- # @param list [Integer, String, Twitter::List] A Twitter list ID, slug, URI, or object.
304
- # @param options [Hash] A customizable set of options.
305
- # @option options [String] :mode ('public') Whether your list is public or private. Values can be 'public' or 'private'.
306
- # @option options [String] :description The description to give the list.
307
- def list_update(*args)
308
- list_from_response(:post, '/1.1/lists/update.json', args)
309
- end
310
-
311
- # Creates a new list for the authenticated user
312
- #
313
- # @see https://dev.twitter.com/docs/api/1.1/post/lists/create
314
- # @note Accounts are limited to 20 lists.
315
- # @rate_limited No
316
- # @authentication Requires user context
317
- # @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
318
- # @return [Twitter::List] The created list.
319
- # @param name [String] The name for the list.
320
- # @param options [Hash] A customizable set of options.
321
- # @option options [String] :mode ('public') Whether your list is public or private. Values can be 'public' or 'private'.
322
- # @option options [String] :description The description to give the list.
323
- def create_list(name, options = {})
324
- perform_with_object(:post, '/1.1/lists/create.json', options.merge(:name => name), Twitter::List)
325
- end
326
- deprecate_alias :list_create, :create_list
327
-
328
- # Show the specified list
329
- #
330
- # @see https://dev.twitter.com/docs/api/1.1/get/lists/show
331
- # @note Private lists will only be shown if the authenticated user owns the specified list.
332
- # @rate_limited Yes
333
- # @authentication Requires user context
334
- # @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
335
- # @return [Twitter::List] The specified list.
336
- # @overload list(list, options = {})
337
- # @param list [Integer, String, Twitter::List] A Twitter list ID, slug, URI, or object.
338
- # @param options [Hash] A customizable set of options.
339
- # @overload list(user, list, options = {})
340
- # @param user [Integer, String, Twitter::User] A Twitter user ID, screen name, URI, or object.
341
- # @param list [Integer, String, Twitter::List] A Twitter list ID, slug, URI, or object.
342
- # @param options [Hash] A customizable set of options.
343
- def list(*args)
344
- list_from_response(:get, '/1.1/lists/show.json', args)
345
- end
346
-
347
- # List the lists the specified user follows
348
- #
349
- # @see https://dev.twitter.com/docs/api/1.1/get/lists/subscriptions
350
- # @rate_limited Yes
351
- # @authentication Requires user context
352
- # @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
353
- # @return [Twitter::Cursor]
354
- # @overload subscriptions(options = {})
355
- # @param options [Hash] A customizable set of options.
356
- # @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.
357
- # @overload subscriptions(user, options = {})
358
- # @param user [Integer, String, Twitter::User] A Twitter user ID, screen name, URI, or object.
359
- # @param options [Hash] A customizable set of options.
360
- # @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.
361
- def subscriptions(*args)
362
- cursor_from_response_with_user(:lists, Twitter::List, :get, '/1.1/lists/subscriptions.json', args)
363
- end
364
-
365
- # Removes specified members from the list
366
- #
367
- # @see https://dev.twitter.com/docs/api/1.1/post/lists/members/destroy_all
368
- # @rate_limited No
369
- # @authentication Requires user context
370
- # @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
371
- # @return [Twitter::List] The list.
372
- # @overload remove_list_members(list, users, options = {})
373
- # @param list [Integer, String, Twitter::List] A Twitter list ID, slug, URI, or object.
374
- # @param users [Enumerable<Integer, String, Twitter::User>] A collection of Twitter user IDs, screen names, or objects.
375
- # @param options [Hash] A customizable set of options.
376
- # @overload remove_list_members(user, list, users, options = {})
377
- # @param user [Integer, String, Twitter::User] A Twitter user ID, screen name, URI, or object.
378
- # @param list [Integer, String, Twitter::List] A Twitter list ID, slug, URI, or object.
379
- # @param users [Enumerable<Integer, String, Twitter::User>] A collection of Twitter user IDs, screen names, or objects.
380
- # @param options [Hash] A customizable set of options.
381
- def remove_list_members(*args)
382
- list_from_response_with_users(:post, '/1.1/lists/members/destroy_all.json', args)
383
- end
384
- deprecate_alias :list_remove_members, :remove_list_members
385
-
386
- # Returns the lists owned by the specified Twitter user
387
- #
388
- # @see https://dev.twitter.com/docs/api/1.1/get/lists/ownerships
389
- # @rate_limited Yes
390
- # @authentication Requires user context
391
- # @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
392
- # @return [Array<Twitter::List>]
393
- # @overload owned_lists(options = {})
394
- # @param options [Hash] A customizable set of options.
395
- # @option options [Integer] :count The amount of results to return per page. Defaults to 20. No more than 1000 results will ever be returned in a single page.
396
- # @overload owned_lists(user, options = {})
397
- # @param user [Integer, String, Twitter::User] A Twitter user ID, screen name, URI, or object.
398
- # @param options [Hash] A customizable set of options.
399
- # @option options [Integer] :count The amount of results to return per page. Defaults to 20. No more than 1000 results will ever be returned in a single page.
400
- def owned_lists(*args)
401
- cursor_from_response_with_user(:lists, Twitter::List, :get, '/1.1/lists/ownerships.json', args)
402
- end
403
- deprecate_alias :lists_ownerships, :owned_lists
404
- deprecate_alias :lists_owned, :owned_lists
405
-
406
- private
407
-
408
- # @param request_method [Symbol]
409
- # @param path [String]
410
- # @param args [Array]
411
- # @return [Array<Twitter::User>]
412
- def list_from_response(request_method, path, args)
413
- arguments = Twitter::Arguments.new(args)
414
- merge_list!(arguments.options, arguments.pop)
415
- merge_owner!(arguments.options, arguments.pop)
416
- perform_with_object(request_method, path, arguments.options, Twitter::List)
417
- end
418
-
419
- def cursor_from_response_with_list(request_method, path, args)
420
- arguments = Twitter::Arguments.new(args)
421
- merge_list!(arguments.options, arguments.pop)
422
- merge_owner!(arguments.options, arguments.pop)
423
- perform_with_cursor(request_method, path, arguments.options, :users, Twitter::User)
424
- end
425
-
426
- def list_user?(request_method, path, args)
427
- arguments = Twitter::Arguments.new(args)
428
- merge_user!(arguments.options, arguments.pop)
429
- merge_list!(arguments.options, arguments.pop)
430
- merge_owner!(arguments.options, arguments.pop)
431
- send(request_method.to_sym, path, arguments.options)
432
- true
433
- rescue Twitter::Error::NotFound, Twitter::Error::Forbidden
434
- false
435
- end
436
-
437
- def list_from_response_with_user(request_method, path, args)
438
- arguments = Twitter::Arguments.new(args)
439
- merge_user!(arguments.options, arguments.pop)
440
- merge_list!(arguments.options, arguments.pop)
441
- merge_owner!(arguments.options, arguments.pop)
442
- perform_with_object(request_method, path, arguments.options, Twitter::List)
443
- end
444
-
445
- def list_from_response_with_users(request_method, path, args)
446
- arguments = args.dup
447
- options = arguments.last.is_a?(::Hash) ? arguments.pop : {}
448
- members = arguments.pop
449
- merge_list!(options, arguments.pop)
450
- merge_owner!(options, arguments.pop)
451
- parallel_map(members.flatten.each_slice(MAX_USERS_PER_REQUEST)) do |users|
452
- perform_with_object(request_method, path, merge_users(options, users), Twitter::List)
453
- end.last
454
- end
455
-
456
- # Take a list and merge it into the hash with the correct key
457
- #
458
- # @param hash [Hash]
459
- # @param list [Integer, String, URI, Twitter::List] A Twitter list ID, slug, URI, or object.
460
- # @return [Hash]
461
- def merge_list!(hash, list) # rubocop:disable MethodLength
462
- case list
463
- when Integer
464
- hash[:list_id] = list
465
- when String
466
- if list[URI_SUBSTRING]
467
- list = list.split('/')
468
- hash[:slug] = list.pop
469
- hash[:owner_screen_name] = list.pop
470
- else
471
- hash[:slug] = list
472
- end
473
- when URI
474
- list = list.path.split('/')
475
- hash[:slug] = list.pop
476
- hash[:owner_screen_name] = list.pop
477
- when Twitter::List
478
- hash[:list_id] = list.id
479
- merge_owner!(hash, list.user)
480
- end
481
- hash
482
- end
483
-
484
- # Take an owner and merge it into the hash with the correct key
485
- #
486
- # @param hash [Hash]
487
- # @param user[Integer, String, Twitter::User] A Twitter user ID, screen_name, or object.
488
- # @return [Hash]
489
- def merge_owner!(hash, user)
490
- unless hash[:owner_id] || hash[:owner_screen_name]
491
- user ||= screen_name
492
- merge_user!(hash, user, 'owner')
493
- hash[:owner_id] = hash.delete(:owner_user_id) unless hash[:owner_user_id].nil?
494
- end
495
- hash
496
- end
497
- end
498
- end
499
- end
500
- end