twitter 8.1.0 → 8.3.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/LICENSE.md +1 -1
- data/README.md +173 -11
- data/lib/twitter/arguments.rb +14 -1
- data/lib/twitter/base.rb +72 -11
- data/lib/twitter/basic_user.rb +7 -1
- data/lib/twitter/client.rb +94 -3
- data/lib/twitter/creatable.rb +11 -2
- data/lib/twitter/cursor.rb +58 -11
- data/lib/twitter/direct_message.rb +32 -4
- data/lib/twitter/direct_message_event.rb +34 -10
- data/lib/twitter/direct_messages/welcome_message.rb +22 -1
- data/lib/twitter/direct_messages/welcome_message_rule.rb +7 -0
- data/lib/twitter/direct_messages/welcome_message_rule_wrapper.rb +26 -3
- data/lib/twitter/direct_messages/welcome_message_wrapper.rb +36 -11
- data/lib/twitter/entities.rb +84 -8
- data/lib/twitter/entity/hashtag.rb +7 -1
- data/lib/twitter/entity/symbol.rb +7 -1
- data/lib/twitter/entity/uri.rb +2 -1
- data/lib/twitter/entity/user_mention.rb +20 -1
- data/lib/twitter/entity.rb +7 -1
- data/lib/twitter/enumerable.rb +20 -3
- data/lib/twitter/error.rb +137 -61
- data/lib/twitter/factory.rb +9 -5
- data/lib/twitter/geo/point.rb +37 -5
- data/lib/twitter/geo/polygon.rb +1 -0
- data/lib/twitter/geo.rb +16 -2
- data/lib/twitter/geo_factory.rb +7 -3
- data/lib/twitter/geo_results.rb +39 -8
- data/lib/twitter/headers.rb +44 -7
- data/lib/twitter/identity.rb +13 -3
- data/lib/twitter/language.rb +21 -1
- data/lib/twitter/list.rb +101 -11
- data/lib/twitter/media/animated_gif.rb +1 -0
- data/lib/twitter/media/photo.rb +19 -3
- data/lib/twitter/media/video.rb +21 -3
- data/lib/twitter/media/video_info.rb +15 -1
- data/lib/twitter/media_factory.rb +7 -3
- data/lib/twitter/metadata.rb +14 -1
- data/lib/twitter/null_object.rb +16 -14
- data/lib/twitter/oembed.rb +56 -2
- data/lib/twitter/place.rb +74 -6
- data/lib/twitter/premium_search_results.rb +87 -18
- data/lib/twitter/profile.rb +100 -44
- data/lib/twitter/profile_banner.rb +9 -4
- data/lib/twitter/rate_limit.rb +32 -3
- data/lib/twitter/relationship.rb +8 -5
- data/lib/twitter/rest/account_activity.rb +55 -26
- data/lib/twitter/rest/api.rb +2 -0
- data/lib/twitter/rest/client.rb +18 -0
- data/lib/twitter/rest/direct_messages/welcome_messages.rb +89 -18
- data/lib/twitter/rest/direct_messages.rb +158 -94
- data/lib/twitter/rest/favorites.rb +57 -21
- data/lib/twitter/rest/form_encoder.rb +57 -17
- data/lib/twitter/rest/friends_and_followers.rb +101 -35
- data/lib/twitter/rest/help.rb +13 -3
- data/lib/twitter/rest/lists.rb +133 -45
- data/lib/twitter/rest/oauth.rb +23 -17
- data/lib/twitter/rest/places_and_geo.rb +44 -28
- data/lib/twitter/rest/premium_search.rb +18 -13
- data/lib/twitter/rest/request.rb +171 -53
- data/lib/twitter/rest/saved_searches.rb +22 -7
- data/lib/twitter/rest/search.rb +20 -16
- data/lib/twitter/rest/spam_reporting.rb +5 -1
- data/lib/twitter/rest/suggested_users.rb +14 -5
- data/lib/twitter/rest/timelines.rb +92 -52
- data/lib/twitter/rest/trends.rb +31 -12
- data/lib/twitter/rest/tweets.rb +145 -88
- data/lib/twitter/rest/undocumented.rb +11 -2
- data/lib/twitter/rest/upload_utils.rb +42 -26
- data/lib/twitter/rest/users.rb +150 -71
- data/lib/twitter/rest/utils.rb +135 -39
- data/lib/twitter/saved_search.rb +23 -2
- data/lib/twitter/search_results.rb +62 -17
- data/lib/twitter/settings.rb +37 -11
- data/lib/twitter/size.rb +37 -3
- data/lib/twitter/source_user.rb +4 -3
- data/lib/twitter/streaming/client.rb +60 -8
- data/lib/twitter/streaming/connection.rb +55 -8
- data/lib/twitter/streaming/deleted_tweet.rb +8 -0
- data/lib/twitter/streaming/event.rb +43 -1
- data/lib/twitter/streaming/friend_list.rb +1 -0
- data/lib/twitter/streaming/message_parser.rb +20 -10
- data/lib/twitter/streaming/response.rb +31 -5
- data/lib/twitter/streaming/stall_warning.rb +23 -0
- data/lib/twitter/suggestion.rb +25 -1
- data/lib/twitter/target_user.rb +2 -1
- data/lib/twitter/trend.rb +29 -1
- data/lib/twitter/trend_results.rb +50 -7
- data/lib/twitter/tweet.rb +180 -21
- data/lib/twitter/user.rb +289 -53
- data/lib/twitter/utils.rb +12 -13
- data/lib/twitter/variant.rb +12 -1
- data/lib/twitter/version.rb +66 -29
- data/lib/twitter.rb +6 -1
- metadata +29 -73
- data/.yardopts +0 -16
- data/CHANGELOG.md +0 -1035
- data/CONTRIBUTING.md +0 -49
- data/twitter.gemspec +0 -57
data/lib/twitter/rest/users.rb
CHANGED
|
@@ -9,164 +9,195 @@ require "twitter/utils"
|
|
|
9
9
|
|
|
10
10
|
module Twitter
|
|
11
11
|
module REST
|
|
12
|
+
# Methods for working with Twitter users
|
|
12
13
|
module Users
|
|
13
14
|
include Twitter::REST::Utils
|
|
14
15
|
include Twitter::Utils
|
|
16
|
+
|
|
17
|
+
# Maximum users per request
|
|
15
18
|
MAX_USERS_PER_REQUEST = 100
|
|
16
19
|
|
|
17
|
-
# Updates the authenticating user's settings
|
|
18
|
-
# Or, if no options supplied, returns settings (including current trend, geo and sleep time information) for the authenticating user.
|
|
20
|
+
# Updates or returns the authenticating user's settings
|
|
19
21
|
#
|
|
22
|
+
# @api public
|
|
20
23
|
# @see https://dev.twitter.com/rest/reference/post/account/settings
|
|
21
|
-
# @see https://dev.twitter.com/rest/reference/get/account/settings
|
|
22
24
|
# @rate_limited Yes
|
|
23
25
|
# @authentication Requires user context
|
|
24
26
|
# @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
|
|
27
|
+
# @example
|
|
28
|
+
# client.settings
|
|
25
29
|
# @return [Twitter::Settings]
|
|
26
30
|
# @param options [Hash] A customizable set of options.
|
|
27
|
-
# @option options [Integer] :trend_location_woeid The Yahoo! Where On Earth ID
|
|
28
|
-
# @option options [Boolean, String, Integer] :sleep_time_enabled
|
|
29
|
-
# @option options [Integer] :start_sleep_time The hour
|
|
30
|
-
# @option options [Integer] :end_sleep_time The hour
|
|
31
|
-
# @option options [String] :time_zone The timezone
|
|
32
|
-
# @option options [String] :lang The language which Twitter should render in
|
|
33
|
-
# @option options [String] :allow_contributor_request
|
|
34
|
-
# @option options [String] :current_password The user's password.
|
|
31
|
+
# @option options [Integer] :trend_location_woeid The Yahoo! Where On Earth ID.
|
|
32
|
+
# @option options [Boolean, String, Integer] :sleep_time_enabled Enable sleep time.
|
|
33
|
+
# @option options [Integer] :start_sleep_time The hour sleep time should begin.
|
|
34
|
+
# @option options [Integer] :end_sleep_time The hour sleep time should end.
|
|
35
|
+
# @option options [String] :time_zone The timezone for the user.
|
|
36
|
+
# @option options [String] :lang The language which Twitter should render in.
|
|
37
|
+
# @option options [String] :allow_contributor_request Allow others to include user.
|
|
38
|
+
# @option options [String] :current_password The user's password.
|
|
35
39
|
def settings(options = {})
|
|
36
40
|
request_method = options.empty? ? :get : :post
|
|
37
|
-
response = perform_request(request_method
|
|
41
|
+
response = perform_request(request_method, "/1.1/account/settings.json", options)
|
|
38
42
|
# https://dev.twitter.com/issues/59
|
|
39
|
-
|
|
40
|
-
|
|
43
|
+
empty_array = [] # : Array[untyped]
|
|
44
|
+
response[:trend_location] = response.fetch(:trend_location, empty_array).first
|
|
45
|
+
Settings.new(response)
|
|
41
46
|
end
|
|
42
47
|
|
|
43
|
-
# Returns the requesting user if authentication was successful
|
|
48
|
+
# Returns the requesting user if authentication was successful
|
|
44
49
|
#
|
|
50
|
+
# @api public
|
|
45
51
|
# @see https://dev.twitter.com/rest/reference/get/account/verify_credentials
|
|
46
52
|
# @rate_limited Yes
|
|
47
53
|
# @authentication Requires user context
|
|
48
54
|
# @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
|
|
55
|
+
# @example
|
|
56
|
+
# client.verify_credentials
|
|
49
57
|
# @return [Twitter::User] The authenticated user.
|
|
50
58
|
# @param options [Hash] A customizable set of options.
|
|
51
|
-
# @option options [Boolean, String, Integer] :skip_status Do not include user's Tweets
|
|
59
|
+
# @option options [Boolean, String, Integer] :skip_status Do not include user's Tweets.
|
|
52
60
|
def verify_credentials(options = {})
|
|
53
|
-
perform_get_with_object("/1.1/account/verify_credentials.json", options,
|
|
61
|
+
perform_get_with_object("/1.1/account/verify_credentials.json", options, User)
|
|
54
62
|
end
|
|
55
63
|
|
|
56
64
|
# Sets which device Twitter delivers updates to for the authenticating user
|
|
57
65
|
#
|
|
66
|
+
# @api public
|
|
58
67
|
# @see https://dev.twitter.com/rest/reference/post/account/update_delivery_device
|
|
59
68
|
# @rate_limited No
|
|
60
69
|
# @authentication Requires user context
|
|
61
70
|
# @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
|
|
71
|
+
# @example
|
|
72
|
+
# client.update_delivery_device('sms')
|
|
62
73
|
# @return [Twitter::User] The authenticated user.
|
|
63
74
|
# @param device [String] Must be one of: 'sms', 'none'.
|
|
64
75
|
# @param options [Hash] A customizable set of options.
|
|
65
76
|
def update_delivery_device(device, options = {})
|
|
66
|
-
perform_post_with_object("/1.1/account/update_delivery_device.json", options.merge(device:),
|
|
77
|
+
perform_post_with_object("/1.1/account/update_delivery_device.json", options.merge(device:), User)
|
|
67
78
|
end
|
|
68
79
|
|
|
69
|
-
# Sets values that users
|
|
80
|
+
# Sets values that users can set in their profile settings
|
|
70
81
|
#
|
|
82
|
+
# @api public
|
|
71
83
|
# @see https://dev.twitter.com/rest/reference/post/account/update_profile
|
|
72
84
|
# @note Only the options specified will be updated.
|
|
73
85
|
# @rate_limited No
|
|
74
86
|
# @authentication Requires user context
|
|
75
87
|
# @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
|
|
88
|
+
# @example
|
|
89
|
+
# client.update_profile(name: 'Erik Michaels-Ober')
|
|
76
90
|
# @return [Twitter::User] The authenticated user.
|
|
77
91
|
# @param options [Hash] A customizable set of options.
|
|
78
|
-
# @option options [String] :name Full name associated with the profile.
|
|
79
|
-
# @option options [String] :url URL associated with the profile.
|
|
80
|
-
# @option options [String] :location The city or country describing
|
|
81
|
-
# @option options [String] :description A description of the user
|
|
82
|
-
# @option options [String] :profile_link_color A hex value
|
|
92
|
+
# @option options [String] :name Full name associated with the profile.
|
|
93
|
+
# @option options [String] :url URL associated with the profile.
|
|
94
|
+
# @option options [String] :location The city or country describing the user's location.
|
|
95
|
+
# @option options [String] :description A description of the user.
|
|
96
|
+
# @option options [String] :profile_link_color A hex value for link color.
|
|
83
97
|
def update_profile(options = {})
|
|
84
|
-
perform_post_with_object("/1.1/account/update_profile.json", options,
|
|
98
|
+
perform_post_with_object("/1.1/account/update_profile.json", options, User)
|
|
85
99
|
end
|
|
86
100
|
|
|
87
101
|
# Updates the authenticating user's profile background image
|
|
88
102
|
#
|
|
103
|
+
# @api public
|
|
89
104
|
# @see https://dev.twitter.com/rest/reference/post/account/update_profile_background_image
|
|
90
105
|
# @rate_limited No
|
|
91
106
|
# @authentication Requires user context
|
|
92
107
|
# @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
|
|
108
|
+
# @example
|
|
109
|
+
# client.update_profile_background_image(File.new('/path/to/image.png'))
|
|
93
110
|
# @return [Twitter::User] The authenticated user.
|
|
94
|
-
# @param image [File] The background image for the profile
|
|
111
|
+
# @param image [File] The background image for the profile.
|
|
95
112
|
# @param options [Hash] A customizable set of options.
|
|
96
|
-
# @option options [Boolean] :tile Whether or not to tile the background image.
|
|
113
|
+
# @option options [Boolean] :tile Whether or not to tile the background image.
|
|
97
114
|
def update_profile_background_image(image, options = {})
|
|
98
115
|
post_profile_image("/1.1/account/update_profile_background_image.json", image, options)
|
|
99
116
|
end
|
|
100
117
|
|
|
101
118
|
# Updates the authenticating user's profile image
|
|
102
119
|
#
|
|
120
|
+
# @api public
|
|
103
121
|
# @see https://dev.twitter.com/rest/reference/post/account/update_profile_image
|
|
104
|
-
# @note
|
|
105
|
-
# @note This method asynchronously processes the uploaded file before updating the user's profile image URL. You can either update your local cache the next time you request the user's information, or, at least 5 seconds after uploading the image, ask for the updated URL using GET users/show.
|
|
122
|
+
# @note This method expects raw multipart data, not a URL to an image.
|
|
106
123
|
# @rate_limited No
|
|
107
124
|
# @authentication Requires user context
|
|
108
125
|
# @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
|
|
126
|
+
# @example
|
|
127
|
+
# client.update_profile_image(File.new('/path/to/avatar.png'))
|
|
109
128
|
# @return [Twitter::User] The authenticated user.
|
|
110
|
-
# @param image [File] The avatar image for the profile
|
|
129
|
+
# @param image [File] The avatar image for the profile.
|
|
111
130
|
# @param options [Hash] A customizable set of options.
|
|
112
131
|
def update_profile_image(image, options = {})
|
|
113
132
|
post_profile_image("/1.1/account/update_profile_image.json", image, options)
|
|
114
133
|
end
|
|
115
134
|
|
|
116
|
-
# Returns
|
|
135
|
+
# Returns users that the authenticating user is blocking
|
|
117
136
|
#
|
|
137
|
+
# @api public
|
|
118
138
|
# @see https://dev.twitter.com/rest/reference/get/blocks/list
|
|
119
139
|
# @rate_limited Yes
|
|
120
140
|
# @authentication Requires user context
|
|
121
141
|
# @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
|
|
142
|
+
# @example
|
|
143
|
+
# client.blocked
|
|
122
144
|
# @return [Array<Twitter::User>] User objects that the authenticating user is blocking.
|
|
123
145
|
# @param options [Hash] A customizable set of options.
|
|
124
|
-
# @option options [Boolean, String, Integer] :skip_status Do not include user's Tweets
|
|
146
|
+
# @option options [Boolean, String, Integer] :skip_status Do not include user's Tweets.
|
|
125
147
|
def blocked(options = {})
|
|
126
|
-
perform_get_with_cursor("/1.1/blocks/list.json", options, :users,
|
|
148
|
+
perform_get_with_cursor("/1.1/blocks/list.json", options, :users, User)
|
|
127
149
|
end
|
|
128
150
|
|
|
129
|
-
# Returns
|
|
151
|
+
# Returns user IDs the authenticating user is blocking
|
|
130
152
|
#
|
|
153
|
+
# @api public
|
|
131
154
|
# @see https://dev.twitter.com/rest/reference/get/blocks/ids
|
|
132
155
|
# @rate_limited Yes
|
|
133
156
|
# @authentication Requires user context
|
|
134
157
|
# @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
|
|
158
|
+
# @example
|
|
159
|
+
# client.blocked_ids
|
|
135
160
|
# @return [Twitter::Cursor] Numeric user IDs the authenticating user is blocking.
|
|
136
161
|
# @overload blocked_ids(options = {})
|
|
137
162
|
# @param options [Hash] A customizable set of options.
|
|
138
163
|
def blocked_ids(*args)
|
|
139
|
-
arguments =
|
|
164
|
+
arguments = Arguments.new(args)
|
|
140
165
|
merge_user!(arguments.options, arguments.pop)
|
|
141
166
|
perform_get_with_cursor("/1.1/blocks/ids.json", arguments.options, :ids)
|
|
142
167
|
end
|
|
143
168
|
|
|
144
169
|
# Returns true if the authenticating user is blocking a target user
|
|
145
170
|
#
|
|
171
|
+
# @api public
|
|
146
172
|
# @see https://dev.twitter.com/rest/reference/get/blocks/ids
|
|
147
173
|
# @rate_limited Yes
|
|
148
174
|
# @authentication Requires user context
|
|
149
175
|
# @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
|
|
150
|
-
# @
|
|
176
|
+
# @example
|
|
177
|
+
# client.block?('sferik')
|
|
178
|
+
# @return [Boolean] true if the authenticating user is blocking the target user.
|
|
151
179
|
# @param user [Integer, String, URI, Twitter::User] A Twitter user ID, screen name, URI, or object.
|
|
152
180
|
# @param options [Hash] A customizable set of options.
|
|
153
181
|
def block?(user, options = {})
|
|
154
182
|
user_id =
|
|
155
183
|
case user
|
|
156
|
-
when Integer
|
|
157
|
-
when String, URI
|
|
158
|
-
when
|
|
184
|
+
when Integer then user
|
|
185
|
+
when String, URI then user(user).id
|
|
186
|
+
when User then user.id
|
|
159
187
|
end
|
|
160
188
|
blocked_ids(options).collect(&:to_i).include?(user_id)
|
|
161
189
|
end
|
|
162
190
|
|
|
163
191
|
# Blocks the users specified by the authenticating user
|
|
164
192
|
#
|
|
193
|
+
# @api public
|
|
165
194
|
# @see https://dev.twitter.com/rest/reference/post/blocks/create
|
|
166
195
|
# @note Destroys a friendship to the blocked user if it exists.
|
|
167
196
|
# @rate_limited Yes
|
|
168
197
|
# @authentication Requires user context
|
|
169
198
|
# @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
|
|
199
|
+
# @example
|
|
200
|
+
# client.block('sferik')
|
|
170
201
|
# @return [Array<Twitter::User>] The blocked users.
|
|
171
202
|
# @overload block(*users)
|
|
172
203
|
# @param users [Enumerable<Integer, String, Twitter::User>] A collection of Twitter user IDs, screen names, or objects.
|
|
@@ -179,10 +210,13 @@ module Twitter
|
|
|
179
210
|
|
|
180
211
|
# Un-blocks the users specified by the authenticating user
|
|
181
212
|
#
|
|
213
|
+
# @api public
|
|
182
214
|
# @see https://dev.twitter.com/rest/reference/post/blocks/destroy
|
|
183
215
|
# @rate_limited No
|
|
184
216
|
# @authentication Requires user context
|
|
185
217
|
# @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
|
|
218
|
+
# @example
|
|
219
|
+
# client.unblock('sferik')
|
|
186
220
|
# @return [Array<Twitter::User>] The un-blocked users.
|
|
187
221
|
# @overload unblock(*users)
|
|
188
222
|
# @param users [Enumerable<Integer, String, Twitter::User>] A collection of Twitter user IDs, screen names, or objects.
|
|
@@ -195,10 +229,13 @@ module Twitter
|
|
|
195
229
|
|
|
196
230
|
# Returns extended information for up to 100 users
|
|
197
231
|
#
|
|
232
|
+
# @api public
|
|
198
233
|
# @see https://dev.twitter.com/rest/reference/get/users/lookup
|
|
199
234
|
# @rate_limited Yes
|
|
200
235
|
# @authentication Required
|
|
201
236
|
# @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
|
|
237
|
+
# @example
|
|
238
|
+
# client.users('sferik', 'pengwynn')
|
|
202
239
|
# @return [Array<Twitter::User>] The requested users.
|
|
203
240
|
# @overload users(*users)
|
|
204
241
|
# @param users [Enumerable<Integer, String, Twitter::User>] A collection of Twitter user IDs, screen names, or objects.
|
|
@@ -206,16 +243,21 @@ module Twitter
|
|
|
206
243
|
# @param users [Enumerable<Integer, String, Twitter::User>] A collection of Twitter user IDs, screen names, or objects.
|
|
207
244
|
# @param options [Hash] A customizable set of options.
|
|
208
245
|
def users(*args)
|
|
209
|
-
arguments =
|
|
246
|
+
arguments = Arguments.new(args)
|
|
210
247
|
flat_pmap(arguments.each_slice(MAX_USERS_PER_REQUEST)) do |users|
|
|
211
|
-
perform_get_with_objects("/1.1/users/lookup.json", merge_users(arguments.options, users),
|
|
248
|
+
perform_get_with_objects("/1.1/users/lookup.json", merge_users(arguments.options, users), User)
|
|
212
249
|
end
|
|
213
250
|
end
|
|
214
251
|
|
|
252
|
+
# Returns extended information for a given user
|
|
253
|
+
#
|
|
254
|
+
# @api public
|
|
215
255
|
# @see https://dev.twitter.com/rest/reference/get/users/show
|
|
216
256
|
# @rate_limited Yes
|
|
217
257
|
# @authentication Requires user context
|
|
218
258
|
# @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
|
|
259
|
+
# @example
|
|
260
|
+
# client.user('sferik')
|
|
219
261
|
# @return [Twitter::User] The requested user.
|
|
220
262
|
# @overload user(options = {})
|
|
221
263
|
# Returns extended information for the authenticated user
|
|
@@ -229,10 +271,10 @@ module Twitter
|
|
|
229
271
|
# @param options [Hash] A customizable set of options.
|
|
230
272
|
# @option options [Boolean, String, Integer] :skip_status Do not include user's Tweets when set to true, 't' or 1.
|
|
231
273
|
def user(*args)
|
|
232
|
-
arguments =
|
|
274
|
+
arguments = Arguments.new(args)
|
|
233
275
|
if arguments.last || user_id?
|
|
234
276
|
merge_user!(arguments.options, arguments.pop || user_id)
|
|
235
|
-
perform_get_with_object("/1.1/users/show.json", arguments.options,
|
|
277
|
+
perform_get_with_object("/1.1/users/show.json", arguments.options, User)
|
|
236
278
|
else
|
|
237
279
|
verify_credentials(arguments.options)
|
|
238
280
|
end
|
|
@@ -240,9 +282,12 @@ module Twitter
|
|
|
240
282
|
|
|
241
283
|
# Returns true if the specified user exists
|
|
242
284
|
#
|
|
285
|
+
# @api public
|
|
243
286
|
# @rate_limited Yes
|
|
244
287
|
# @authentication Requires user context
|
|
245
288
|
# @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
|
|
289
|
+
# @example
|
|
290
|
+
# client.user?('sferik')
|
|
246
291
|
# @return [Boolean] true if the user exists, otherwise false.
|
|
247
292
|
# @param user [Integer, String, Twitter::User] A Twitter user ID, screen name, URI, or object.
|
|
248
293
|
def user?(user, options = {})
|
|
@@ -256,26 +301,31 @@ module Twitter
|
|
|
256
301
|
|
|
257
302
|
# Returns users that match the given query
|
|
258
303
|
#
|
|
304
|
+
# @api public
|
|
259
305
|
# @see https://dev.twitter.com/rest/reference/get/users/search
|
|
260
306
|
# @rate_limited Yes
|
|
261
307
|
# @authentication Requires user context
|
|
262
308
|
# @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
|
|
309
|
+
# @example
|
|
310
|
+
# client.user_search('Erik Michaels-Ober')
|
|
263
311
|
# @return [Array<Twitter::User>]
|
|
264
312
|
# @param query [String] The search query to run against people search.
|
|
265
313
|
# @param options [Hash] A customizable set of options.
|
|
266
|
-
# @option options [Integer] :count The number of people to retrieve.
|
|
314
|
+
# @option options [Integer] :count The number of people to retrieve.
|
|
267
315
|
# @option options [Integer] :page Specifies the page of results to retrieve.
|
|
268
316
|
def user_search(query, options = {})
|
|
269
|
-
options
|
|
270
|
-
perform_get_with_objects("/1.1/users/search.json", options.merge(q: query), Twitter::User)
|
|
317
|
+
perform_get_with_objects("/1.1/users/search.json", options.merge(q: query), User)
|
|
271
318
|
end
|
|
272
319
|
|
|
273
|
-
# Returns
|
|
320
|
+
# Returns users that the specified user can contribute to
|
|
274
321
|
#
|
|
322
|
+
# @api public
|
|
275
323
|
# @see https://dev.twitter.com/rest/reference/get/users/contributees
|
|
276
324
|
# @rate_limited Yes
|
|
277
325
|
# @authentication Requires user context
|
|
278
326
|
# @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
|
|
327
|
+
# @example
|
|
328
|
+
# client.contributees
|
|
279
329
|
# @return [Array<Twitter::User>]
|
|
280
330
|
# @overload contributees(options = {})
|
|
281
331
|
# @param options [Hash] A customizable set of options.
|
|
@@ -288,12 +338,15 @@ module Twitter
|
|
|
288
338
|
users_from_response(:get, "/1.1/users/contributees.json", args)
|
|
289
339
|
end
|
|
290
340
|
|
|
291
|
-
# Returns
|
|
341
|
+
# Returns users who can contribute to the specified account
|
|
292
342
|
#
|
|
343
|
+
# @api public
|
|
293
344
|
# @see https://dev.twitter.com/rest/reference/get/users/contributors
|
|
294
345
|
# @rate_limited Yes
|
|
295
346
|
# @authentication Requires user context
|
|
296
347
|
# @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
|
|
348
|
+
# @example
|
|
349
|
+
# client.contributors
|
|
297
350
|
# @return [Array<Twitter::User>]
|
|
298
351
|
# @overload contributors(options = {})
|
|
299
352
|
# @param options [Hash] A customizable set of options.
|
|
@@ -308,12 +361,16 @@ module Twitter
|
|
|
308
361
|
|
|
309
362
|
# Removes the authenticating user's profile banner image
|
|
310
363
|
#
|
|
364
|
+
# @api public
|
|
311
365
|
# @see https://dev.twitter.com/rest/reference/post/account/remove_profile_banner
|
|
312
366
|
# @rate_limited No
|
|
313
367
|
# @authentication Requires user context
|
|
314
368
|
# @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
|
|
369
|
+
# @example
|
|
370
|
+
# client.remove_profile_banner
|
|
315
371
|
# @return [nil]
|
|
316
372
|
# @param options [Hash] A customizable set of options.
|
|
373
|
+
# rubocop:disable Naming/PredicateMethod
|
|
317
374
|
def remove_profile_banner(options = {})
|
|
318
375
|
perform_post("/1.1/account/remove_profile_banner.json", options)
|
|
319
376
|
true
|
|
@@ -321,49 +378,58 @@ module Twitter
|
|
|
321
378
|
|
|
322
379
|
# Updates the authenticating user's profile banner image
|
|
323
380
|
#
|
|
381
|
+
# @api public
|
|
324
382
|
# @see https://dev.twitter.com/rest/reference/post/account/update_profile_banner
|
|
325
|
-
# @note
|
|
326
|
-
# @note Profile banner images are processed asynchronously. The profile_banner_url and its variant sizes will not necessary be available directly after upload.
|
|
383
|
+
# @note For best results, upload an image that is exactly 1252px by 626px.
|
|
327
384
|
# @rate_limited No
|
|
328
385
|
# @authentication Requires user context
|
|
329
|
-
# @raise [Twitter::Error::BadRequest] Error raised when
|
|
386
|
+
# @raise [Twitter::Error::BadRequest] Error raised when image was not provided.
|
|
330
387
|
# @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
|
|
331
|
-
# @raise [Twitter::Error::UnprocessableEntity] Error raised when
|
|
388
|
+
# @raise [Twitter::Error::UnprocessableEntity] Error raised when image is too large.
|
|
389
|
+
# @example
|
|
390
|
+
# client.update_profile_banner(File.new('/path/to/banner.png'))
|
|
332
391
|
# @return [nil]
|
|
333
|
-
# @param banner [File] The
|
|
392
|
+
# @param banner [File] The image data being uploaded as the profile banner.
|
|
334
393
|
# @param options [Hash] A customizable set of options.
|
|
335
|
-
# @option options [Integer] :width The width of the preferred section
|
|
336
|
-
# @option options [Integer] :height The height of the preferred section
|
|
337
|
-
# @option options [Integer] :offset_left The
|
|
338
|
-
# @option options [Integer] :offset_top The
|
|
394
|
+
# @option options [Integer] :width The width of the preferred section.
|
|
395
|
+
# @option options [Integer] :height The height of the preferred section.
|
|
396
|
+
# @option options [Integer] :offset_left The offset from the left.
|
|
397
|
+
# @option options [Integer] :offset_top The offset from the top.
|
|
339
398
|
def update_profile_banner(banner, options = {})
|
|
340
399
|
perform_post("/1.1/account/update_profile_banner.json", options.merge(banner:))
|
|
341
400
|
true
|
|
342
401
|
end
|
|
402
|
+
# rubocop:enable Naming/PredicateMethod
|
|
343
403
|
|
|
344
|
-
# Returns the
|
|
404
|
+
# Returns the profile banner size variations for a user
|
|
345
405
|
#
|
|
406
|
+
# @api public
|
|
346
407
|
# @see https://dev.twitter.com/rest/reference/get/users/profile_banner
|
|
347
|
-
# @note If the user has not uploaded a profile banner, a HTTP 404
|
|
408
|
+
# @note If the user has not uploaded a profile banner, a HTTP 404 is served.
|
|
348
409
|
# @rate_limited Yes
|
|
349
410
|
# @authentication Requires user context
|
|
350
411
|
# @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
|
|
412
|
+
# @example
|
|
413
|
+
# client.profile_banner('sferik')
|
|
351
414
|
# @return [Twitter::ProfileBanner]
|
|
352
415
|
# @overload profile_banner(options = {})
|
|
353
416
|
# @overload profile_banner(user, options = {})
|
|
354
417
|
# @param user [Integer, String, Twitter::User] A Twitter user ID, screen name, URI, or object.
|
|
355
418
|
def profile_banner(*args)
|
|
356
|
-
arguments =
|
|
357
|
-
merge_user!(arguments.options, arguments.pop || user_id) unless arguments.options
|
|
358
|
-
perform_get_with_object("/1.1/users/profile_banner.json", arguments.options,
|
|
419
|
+
arguments = Arguments.new(args)
|
|
420
|
+
merge_user!(arguments.options, arguments.pop || user_id) unless arguments.options.key?(:user_id) || arguments.options.key?(:screen_name)
|
|
421
|
+
perform_get_with_object("/1.1/users/profile_banner.json", arguments.options, ProfileBanner)
|
|
359
422
|
end
|
|
360
423
|
|
|
361
424
|
# Mutes the users specified by the authenticating user
|
|
362
425
|
#
|
|
426
|
+
# @api public
|
|
363
427
|
# @see https://dev.twitter.com/rest/reference/post/mutes/users/create
|
|
364
428
|
# @rate_limited Yes
|
|
365
429
|
# @authentication Requires user context
|
|
366
430
|
# @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
|
|
431
|
+
# @example
|
|
432
|
+
# client.mute('sferik')
|
|
367
433
|
# @return [Array<Twitter::User>] The muted users.
|
|
368
434
|
# @overload mute(*users)
|
|
369
435
|
# @param users [Enumerable<Integer, String, Twitter::User>] A collection of Twitter user IDs, screen names, or objects.
|
|
@@ -374,12 +440,15 @@ module Twitter
|
|
|
374
440
|
parallel_users_from_response(:post, "/1.1/mutes/users/create.json", args)
|
|
375
441
|
end
|
|
376
442
|
|
|
377
|
-
# Un-mutes the user specified by the authenticating user
|
|
443
|
+
# Un-mutes the user specified by the authenticating user
|
|
378
444
|
#
|
|
445
|
+
# @api public
|
|
379
446
|
# @see https://dev.twitter.com/rest/reference/post/mutes/users/destroy
|
|
380
447
|
# @rate_limited Yes
|
|
381
448
|
# @authentication Requires user context
|
|
382
449
|
# @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
|
|
450
|
+
# @example
|
|
451
|
+
# client.unmute('sferik')
|
|
383
452
|
# @return [Array<Twitter::User>] The un-muted users.
|
|
384
453
|
# @overload unmute(*users)
|
|
385
454
|
# @param users [Enumerable<Integer, String, Twitter::User>] A collection of Twitter user IDs, screen names, or objects.
|
|
@@ -390,39 +459,49 @@ module Twitter
|
|
|
390
459
|
parallel_users_from_response(:post, "/1.1/mutes/users/destroy.json", args)
|
|
391
460
|
end
|
|
392
461
|
|
|
393
|
-
# Returns
|
|
462
|
+
# Returns users that the authenticating user is muting
|
|
394
463
|
#
|
|
464
|
+
# @api public
|
|
395
465
|
# @see https://dev.twitter.com/rest/reference/get/mutes/users/list
|
|
396
466
|
# @rate_limited Yes
|
|
397
467
|
# @authentication Requires user context
|
|
398
468
|
# @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
|
|
469
|
+
# @example
|
|
470
|
+
# client.muted
|
|
399
471
|
# @return [Array<Twitter::User>] User objects that the authenticating user is muting.
|
|
400
472
|
# @param options [Hash] A customizable set of options.
|
|
401
|
-
# @option options [Boolean, String, Integer] :skip_status Do not include user's Tweets
|
|
473
|
+
# @option options [Boolean, String, Integer] :skip_status Do not include user's Tweets.
|
|
402
474
|
def muted(options = {})
|
|
403
|
-
perform_get_with_cursor("/1.1/mutes/users/list.json", options, :users,
|
|
475
|
+
perform_get_with_cursor("/1.1/mutes/users/list.json", options, :users, User)
|
|
404
476
|
end
|
|
405
477
|
|
|
406
|
-
# Returns
|
|
478
|
+
# Returns user IDs the authenticating user is muting
|
|
407
479
|
#
|
|
480
|
+
# @api public
|
|
408
481
|
# @see https://dev.twitter.com/rest/reference/get/mutes/users/ids
|
|
409
482
|
# @rate_limited Yes
|
|
410
483
|
# @authentication Requires user context
|
|
411
484
|
# @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
|
|
485
|
+
# @example
|
|
486
|
+
# client.muted_ids
|
|
412
487
|
# @return [Twitter::Cursor] Numeric user IDs the authenticating user is muting
|
|
413
488
|
# @overload muted_ids(options = {})
|
|
414
489
|
# @param options [Hash] A customizable set of options.
|
|
415
490
|
def muted_ids(*args)
|
|
416
|
-
arguments =
|
|
491
|
+
arguments = Arguments.new(args)
|
|
417
492
|
merge_user!(arguments.options, arguments.pop)
|
|
418
493
|
perform_get_with_cursor("/1.1/mutes/users/ids.json", arguments.options, :ids)
|
|
419
494
|
end
|
|
420
495
|
|
|
421
|
-
|
|
496
|
+
private
|
|
422
497
|
|
|
498
|
+
# Posts a profile image update
|
|
499
|
+
#
|
|
500
|
+
# @api private
|
|
501
|
+
# @return [Twitter::User]
|
|
423
502
|
def post_profile_image(path, image, options)
|
|
424
|
-
response =
|
|
425
|
-
|
|
503
|
+
response = Request.new(self, :multipart_post, path, options.merge(key: :image, file: image)).perform
|
|
504
|
+
User.new(response)
|
|
426
505
|
end
|
|
427
506
|
end
|
|
428
507
|
end
|