twitter 6.2.0 → 8.0.0.rc.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +32 -10
- data/LICENSE.md +1 -1
- data/README.md +9 -14
- data/lib/twitter/base.rb +11 -11
- data/lib/twitter/basic_user.rb +3 -2
- data/lib/twitter/client.rb +8 -8
- data/lib/twitter/creatable.rb +7 -3
- data/lib/twitter/cursor.rb +15 -5
- data/lib/twitter/direct_message.rb +4 -3
- data/lib/twitter/direct_message_event.rb +44 -0
- data/lib/twitter/direct_messages/welcome_message.rb +17 -0
- data/lib/twitter/direct_messages/welcome_message_rule.rb +12 -0
- data/lib/twitter/direct_messages/welcome_message_rule_wrapper.rb +36 -0
- data/lib/twitter/direct_messages/welcome_message_wrapper.rb +42 -0
- data/lib/twitter/entities.rb +6 -6
- data/lib/twitter/entity/hashtag.rb +1 -1
- data/lib/twitter/entity/symbol.rb +1 -1
- data/lib/twitter/entity/uri.rb +1 -1
- data/lib/twitter/entity/user_mention.rb +1 -1
- data/lib/twitter/entity.rb +1 -1
- data/lib/twitter/enumerable.rb +15 -6
- data/lib/twitter/error.rb +52 -9
- data/lib/twitter/factory.rb +1 -1
- data/lib/twitter/geo/point.rb +1 -1
- data/lib/twitter/geo/polygon.rb +1 -1
- data/lib/twitter/geo.rb +2 -2
- data/lib/twitter/geo_factory.rb +3 -3
- data/lib/twitter/geo_results.rb +2 -2
- data/lib/twitter/headers.rb +4 -4
- data/lib/twitter/identity.rb +2 -2
- data/lib/twitter/language.rb +1 -1
- data/lib/twitter/list.rb +3 -2
- data/lib/twitter/media/animated_gif.rb +1 -1
- data/lib/twitter/media/photo.rb +2 -2
- data/lib/twitter/media/video.rb +3 -3
- data/lib/twitter/media/video_info.rb +2 -2
- data/lib/twitter/media_factory.rb +4 -4
- data/lib/twitter/metadata.rb +1 -1
- data/lib/twitter/null_object.rb +19 -5
- data/lib/twitter/oembed.rb +2 -1
- data/lib/twitter/place.rb +3 -3
- data/lib/twitter/premium_search_results.rb +67 -0
- data/lib/twitter/profile.rb +6 -6
- data/lib/twitter/profile_banner.rb +2 -2
- data/lib/twitter/rate_limit.rb +6 -6
- data/lib/twitter/relationship.rb +2 -1
- data/lib/twitter/rest/account_activity.rb +99 -0
- data/lib/twitter/rest/api.rb +22 -16
- data/lib/twitter/rest/client.rb +4 -4
- data/lib/twitter/rest/direct_messages/welcome_messages.rb +90 -0
- data/lib/twitter/rest/direct_messages.rb +136 -47
- data/lib/twitter/rest/favorites.rb +17 -21
- data/lib/twitter/rest/form_encoder.rb +27 -0
- data/lib/twitter/rest/friends_and_followers.rb +21 -21
- data/lib/twitter/rest/help.rb +6 -18
- data/lib/twitter/rest/lists.rb +33 -32
- data/lib/twitter/rest/oauth.rb +8 -8
- data/lib/twitter/rest/places_and_geo.rb +6 -6
- data/lib/twitter/rest/premium_search.rb +34 -0
- data/lib/twitter/rest/request.rb +64 -31
- data/lib/twitter/rest/saved_searches.rb +6 -6
- data/lib/twitter/rest/search.rb +6 -5
- data/lib/twitter/rest/spam_reporting.rb +3 -3
- data/lib/twitter/rest/suggested_users.rb +5 -5
- data/lib/twitter/rest/timelines.rb +8 -7
- data/lib/twitter/rest/trends.rb +7 -7
- data/lib/twitter/rest/tweets.rb +20 -53
- data/lib/twitter/rest/undocumented.rb +7 -7
- data/lib/twitter/rest/upload_utils.rb +68 -0
- data/lib/twitter/rest/users.rb +32 -32
- data/lib/twitter/rest/utils.rb +41 -24
- data/lib/twitter/saved_search.rb +2 -2
- data/lib/twitter/search_results.rb +10 -9
- data/lib/twitter/settings.rb +2 -1
- data/lib/twitter/size.rb +2 -2
- data/lib/twitter/source_user.rb +1 -1
- data/lib/twitter/streaming/client.rb +19 -15
- data/lib/twitter/streaming/connection.rb +19 -7
- data/lib/twitter/streaming/message_parser.rb +7 -7
- data/lib/twitter/streaming/response.rb +12 -10
- data/lib/twitter/suggestion.rb +3 -3
- data/lib/twitter/target_user.rb +1 -1
- data/lib/twitter/trend.rb +3 -2
- data/lib/twitter/trend_results.rb +5 -5
- data/lib/twitter/tweet.rb +13 -4
- data/lib/twitter/user.rb +9 -9
- data/lib/twitter/utils.rb +6 -4
- data/lib/twitter/variant.rb +2 -1
- data/lib/twitter/version.rb +4 -4
- data/lib/twitter.rb +36 -31
- data/twitter.gemspec +19 -19
- metadata +33 -37
- data/lib/twitter/configuration.rb +0 -27
@@ -1,10 +1,10 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require
|
4
|
-
require
|
5
|
-
require
|
6
|
-
require
|
7
|
-
require
|
1
|
+
require "twitter/arguments"
|
2
|
+
require "twitter/cursor"
|
3
|
+
require "twitter/relationship"
|
4
|
+
require "twitter/rest/request"
|
5
|
+
require "twitter/rest/utils"
|
6
|
+
require "twitter/user"
|
7
|
+
require "twitter/utils"
|
8
8
|
|
9
9
|
module Twitter
|
10
10
|
module REST
|
@@ -27,7 +27,7 @@ module Twitter
|
|
27
27
|
# @param user [Integer, String, Twitter::User] A Twitter user ID, screen name, URI, or object.
|
28
28
|
# @param options [Hash] A customizable set of options.
|
29
29
|
def friend_ids(*args)
|
30
|
-
cursor_from_response_with_user(:ids, nil,
|
30
|
+
cursor_from_response_with_user(:ids, nil, "/1.1/friends/ids.json", args)
|
31
31
|
end
|
32
32
|
|
33
33
|
# @see https://dev.twitter.com/rest/reference/get/followers/ids
|
@@ -45,7 +45,7 @@ module Twitter
|
|
45
45
|
# @param user [Integer, String, Twitter::User] A Twitter user ID, screen name, URI, or object.
|
46
46
|
# @param options [Hash] A customizable set of options.
|
47
47
|
def follower_ids(*args)
|
48
|
-
cursor_from_response_with_user(:ids, nil,
|
48
|
+
cursor_from_response_with_user(:ids, nil, "/1.1/followers/ids.json", args)
|
49
49
|
end
|
50
50
|
|
51
51
|
# 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.
|
@@ -63,7 +63,7 @@ module Twitter
|
|
63
63
|
def friendships(*args)
|
64
64
|
arguments = Twitter::Arguments.new(args)
|
65
65
|
merge_users!(arguments.options, arguments)
|
66
|
-
perform_get_with_objects(
|
66
|
+
perform_get_with_objects("/1.1/friendships/lookup.json", arguments.options, Twitter::User)
|
67
67
|
end
|
68
68
|
|
69
69
|
# Returns an array of numeric IDs for every user who has a pending request to follow the authenticating user
|
@@ -75,7 +75,7 @@ module Twitter
|
|
75
75
|
# @return [Twitter::Cursor]
|
76
76
|
# @param options [Hash] A customizable set of options.
|
77
77
|
def friendships_incoming(options = {})
|
78
|
-
perform_get_with_cursor(
|
78
|
+
perform_get_with_cursor("/1.1/friendships/incoming.json", options, :ids)
|
79
79
|
end
|
80
80
|
|
81
81
|
# Returns an array of numeric IDs for every protected user for whom the authenticating user has a pending follow request
|
@@ -87,7 +87,7 @@ module Twitter
|
|
87
87
|
# @return [Twitter::Cursor]
|
88
88
|
# @param options [Hash] A customizable set of options.
|
89
89
|
def friendships_outgoing(options = {})
|
90
|
-
perform_get_with_cursor(
|
90
|
+
perform_get_with_cursor("/1.1/friendships/outgoing.json", options, :ids)
|
91
91
|
end
|
92
92
|
|
93
93
|
# Allows the authenticating user to follow the specified users, unless they are already followed
|
@@ -131,7 +131,7 @@ module Twitter
|
|
131
131
|
def follow!(*args)
|
132
132
|
arguments = Twitter::Arguments.new(args)
|
133
133
|
pmap(arguments) do |user|
|
134
|
-
perform_post_with_object(
|
134
|
+
perform_post_with_object("/1.1/friendships/create.json", merge_user(arguments.options, user), Twitter::User)
|
135
135
|
end.compact
|
136
136
|
end
|
137
137
|
alias create_friendship! follow!
|
@@ -149,7 +149,7 @@ module Twitter
|
|
149
149
|
# @param users [Enumerable<Integer, String, Twitter::User>] A collection of Twitter user IDs, screen names, or objects.
|
150
150
|
# @param options [Hash] A customizable set of options.
|
151
151
|
def unfollow(*args)
|
152
|
-
parallel_users_from_response(:post,
|
152
|
+
parallel_users_from_response(:post, "/1.1/friendships/destroy.json", args)
|
153
153
|
end
|
154
154
|
alias destroy_friendship unfollow
|
155
155
|
|
@@ -166,7 +166,7 @@ module Twitter
|
|
166
166
|
# @option options [Boolean] :retweets Enable/disable retweets from the target user.
|
167
167
|
def friendship_update(user, options = {})
|
168
168
|
merge_user!(options, user)
|
169
|
-
perform_post_with_object(
|
169
|
+
perform_post_with_object("/1.1/friendships/update.json", options, Twitter::Relationship)
|
170
170
|
end
|
171
171
|
|
172
172
|
# Returns detailed information about the relationship between two users
|
@@ -181,11 +181,11 @@ module Twitter
|
|
181
181
|
# @param options [Hash] A customizable set of options.
|
182
182
|
def friendship(source, target, options = {})
|
183
183
|
options = options.dup
|
184
|
-
merge_user!(options, source,
|
184
|
+
merge_user!(options, source, "source")
|
185
185
|
options[:source_id] = options.delete(:source_user_id) unless options[:source_user_id].nil?
|
186
|
-
merge_user!(options, target,
|
186
|
+
merge_user!(options, target, "target")
|
187
187
|
options[:target_id] = options.delete(:target_user_id) unless options[:target_user_id].nil?
|
188
|
-
perform_get_with_object(
|
188
|
+
perform_get_with_object("/1.1/friendships/show.json", options, Twitter::Relationship)
|
189
189
|
end
|
190
190
|
alias friendship_show friendship
|
191
191
|
alias relationship friendship
|
@@ -225,7 +225,7 @@ module Twitter
|
|
225
225
|
# @option options [Boolean, String, Integer] :skip_status Do not include contributee's Tweets when set to true, 't' or 1.
|
226
226
|
# @option options [Boolean, String, Integer] :include_user_entities The user entities node will be disincluded when set to false.
|
227
227
|
def followers(*args)
|
228
|
-
cursor_from_response_with_user(:users, Twitter::User,
|
228
|
+
cursor_from_response_with_user(:users, Twitter::User, "/1.1/followers/list.json", args)
|
229
229
|
end
|
230
230
|
|
231
231
|
# Returns a cursored collection of user objects for every user the specified user is following (otherwise known as their "friends").
|
@@ -249,7 +249,7 @@ module Twitter
|
|
249
249
|
# @option options [Boolean, String, Integer] :skip_status Do not include contributee's Tweets when set to true, 't' or 1.
|
250
250
|
# @option options [Boolean, String, Integer] :include_user_entities The user entities node will be disincluded when set to false.
|
251
251
|
def friends(*args)
|
252
|
-
cursor_from_response_with_user(:users, Twitter::User,
|
252
|
+
cursor_from_response_with_user(:users, Twitter::User, "/1.1/friends/list.json", args)
|
253
253
|
end
|
254
254
|
alias following friends
|
255
255
|
|
@@ -261,7 +261,7 @@ module Twitter
|
|
261
261
|
# @return [Array<Integer>]
|
262
262
|
# @param options [Hash] A customizable set of options.
|
263
263
|
def no_retweet_ids(options = {})
|
264
|
-
perform_get(
|
264
|
+
perform_get("/1.1/friendships/no_retweets/ids.json", options).collect(&:to_i)
|
265
265
|
end
|
266
266
|
alias no_retweets_ids no_retweet_ids
|
267
267
|
end
|
data/lib/twitter/rest/help.rb
CHANGED
@@ -1,24 +1,12 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require
|
4
|
-
require 'twitter/rest/utils'
|
1
|
+
require "twitter/language"
|
2
|
+
require "twitter/rest/request"
|
3
|
+
require "twitter/rest/utils"
|
5
4
|
|
6
5
|
module Twitter
|
7
6
|
module REST
|
8
7
|
module Help
|
9
8
|
include Twitter::REST::Utils
|
10
9
|
|
11
|
-
# Returns the current configuration used by Twitter
|
12
|
-
#
|
13
|
-
# @see https://dev.twitter.com/rest/reference/get/help/configuration
|
14
|
-
# @rate_limited Yes
|
15
|
-
# @authentication Requires user context
|
16
|
-
# @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
|
17
|
-
# @return [Twitter::Configuration] Twitter's configuration.
|
18
|
-
def configuration(options = {})
|
19
|
-
perform_get_with_object('/1.1/help/configuration.json', options, Twitter::Configuration)
|
20
|
-
end
|
21
|
-
|
22
10
|
# Returns the list of languages supported by Twitter
|
23
11
|
#
|
24
12
|
# @see https://dev.twitter.com/rest/reference/get/help/languages
|
@@ -27,7 +15,7 @@ module Twitter
|
|
27
15
|
# @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
|
28
16
|
# @return [Array<Twitter::Language>]
|
29
17
|
def languages(options = {})
|
30
|
-
perform_get_with_objects(
|
18
|
+
perform_get_with_objects("/1.1/help/languages.json", options, Twitter::Language)
|
31
19
|
end
|
32
20
|
|
33
21
|
# Returns {https://twitter.com/privacy Twitter's Privacy Policy}
|
@@ -38,7 +26,7 @@ module Twitter
|
|
38
26
|
# @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
|
39
27
|
# @return [String]
|
40
28
|
def privacy(options = {})
|
41
|
-
perform_get(
|
29
|
+
perform_get("/1.1/help/privacy.json", options)[:privacy]
|
42
30
|
end
|
43
31
|
|
44
32
|
# Returns {https://twitter.com/tos Twitter's Terms of Service}
|
@@ -49,7 +37,7 @@ module Twitter
|
|
49
37
|
# @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
|
50
38
|
# @return [String]
|
51
39
|
def tos(options = {})
|
52
|
-
perform_get(
|
40
|
+
perform_get("/1.1/help/tos.json", options)[:tos]
|
53
41
|
end
|
54
42
|
end
|
55
43
|
end
|
data/lib/twitter/rest/lists.rb
CHANGED
@@ -1,14 +1,14 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require
|
4
|
-
require
|
5
|
-
require
|
6
|
-
require
|
7
|
-
require
|
8
|
-
require
|
9
|
-
require
|
10
|
-
require
|
11
|
-
require
|
1
|
+
require "addressable/uri"
|
2
|
+
require "twitter/arguments"
|
3
|
+
require "twitter/cursor"
|
4
|
+
require "twitter/error"
|
5
|
+
require "twitter/list"
|
6
|
+
require "twitter/rest/request"
|
7
|
+
require "twitter/rest/utils"
|
8
|
+
require "twitter/tweet"
|
9
|
+
require "twitter/user"
|
10
|
+
require "twitter/utils"
|
11
|
+
require "uri"
|
12
12
|
|
13
13
|
module Twitter
|
14
14
|
module REST
|
@@ -32,7 +32,7 @@ module Twitter
|
|
32
32
|
# @param options [Hash] A customizable set of options.
|
33
33
|
# @option options [Boolean] :reverse Set this to true if you would like owned lists to be returned first.
|
34
34
|
def lists(*args)
|
35
|
-
objects_from_response_with_user(Twitter::List, :get,
|
35
|
+
objects_from_response_with_user(Twitter::List, :get, "/1.1/lists/list.json", args)
|
36
36
|
end
|
37
37
|
alias lists_subscribed_to lists
|
38
38
|
|
@@ -61,7 +61,7 @@ module Twitter
|
|
61
61
|
arguments = Twitter::Arguments.new(args)
|
62
62
|
merge_list!(arguments.options, arguments.pop)
|
63
63
|
merge_owner!(arguments.options, arguments.pop)
|
64
|
-
perform_get_with_objects(
|
64
|
+
perform_get_with_objects("/1.1/lists/statuses.json", arguments.options, Twitter::Tweet)
|
65
65
|
end
|
66
66
|
|
67
67
|
# Removes the specified member from the list
|
@@ -82,7 +82,7 @@ module Twitter
|
|
82
82
|
# @param user_to_remove [Integer, String] The user id or screen name of the list member to remove.
|
83
83
|
# @param options [Hash] A customizable set of options.
|
84
84
|
def remove_list_member(*args)
|
85
|
-
list_from_response_with_user(
|
85
|
+
list_from_response_with_user("/1.1/lists/members/destroy.json", args)
|
86
86
|
end
|
87
87
|
|
88
88
|
# List the lists the specified user has been added to
|
@@ -102,7 +102,7 @@ module Twitter
|
|
102
102
|
# @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.
|
103
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
104
|
def memberships(*args)
|
105
|
-
cursor_from_response_with_user(:lists, Twitter::List,
|
105
|
+
cursor_from_response_with_user(:lists, Twitter::List, "/1.1/lists/memberships.json", args)
|
106
106
|
end
|
107
107
|
|
108
108
|
# Returns the subscribers of the specified list
|
@@ -121,7 +121,7 @@ module Twitter
|
|
121
121
|
# @param list [Integer, String, Twitter::List] A Twitter list ID, slug, URI, or object.
|
122
122
|
# @param options [Hash] A customizable set of options.
|
123
123
|
def list_subscribers(*args)
|
124
|
-
cursor_from_response_with_list(
|
124
|
+
cursor_from_response_with_list("/1.1/lists/subscribers.json", args)
|
125
125
|
end
|
126
126
|
|
127
127
|
# Make the authenticated user follow the specified list
|
@@ -140,7 +140,7 @@ module Twitter
|
|
140
140
|
# @param list [Integer, String, Twitter::List] A Twitter list ID, slug, URI, or object.
|
141
141
|
# @param options [Hash] A customizable set of options.
|
142
142
|
def list_subscribe(*args)
|
143
|
-
list_from_response(:post,
|
143
|
+
list_from_response(:post, "/1.1/lists/subscribers/create.json", args)
|
144
144
|
end
|
145
145
|
|
146
146
|
# Check if a user is a subscriber of the specified list
|
@@ -162,7 +162,7 @@ module Twitter
|
|
162
162
|
# @param options [Hash] A customizable set of options.
|
163
163
|
# @return [Boolean] true if user is a subscriber of the specified list, otherwise false.
|
164
164
|
def list_subscriber?(*args)
|
165
|
-
list_user?(:get,
|
165
|
+
list_user?(:get, "/1.1/lists/subscribers/show.json", args)
|
166
166
|
end
|
167
167
|
|
168
168
|
# Unsubscribes the authenticated user form the specified list
|
@@ -181,7 +181,7 @@ module Twitter
|
|
181
181
|
# @param list [Integer, String, Twitter::List] A Twitter list ID, slug, URI, or object.
|
182
182
|
# @param options [Hash] A customizable set of options.
|
183
183
|
def list_unsubscribe(*args)
|
184
|
-
list_from_response(:post,
|
184
|
+
list_from_response(:post, "/1.1/lists/subscribers/destroy.json", args)
|
185
185
|
end
|
186
186
|
|
187
187
|
# Adds specified members to a list
|
@@ -204,7 +204,7 @@ module Twitter
|
|
204
204
|
# @param users [Enumerable<Integer, String, Twitter::User>] A collection of Twitter user IDs, screen names, or objects.
|
205
205
|
# @param options [Hash] A customizable set of options.
|
206
206
|
def add_list_members(*args)
|
207
|
-
list_from_response_with_users(
|
207
|
+
list_from_response_with_users("/1.1/lists/members/create_all.json", args)
|
208
208
|
end
|
209
209
|
|
210
210
|
# Check if a user is a member of the specified list
|
@@ -225,7 +225,7 @@ module Twitter
|
|
225
225
|
# @param user_to_check [Integer, String] The user ID or screen name of the list member.
|
226
226
|
# @param options [Hash] A customizable set of options.
|
227
227
|
def list_member?(*args)
|
228
|
-
list_user?(:get,
|
228
|
+
list_user?(:get, "/1.1/lists/members/show.json", args)
|
229
229
|
end
|
230
230
|
|
231
231
|
# Returns the members of the specified list
|
@@ -244,7 +244,7 @@ module Twitter
|
|
244
244
|
# @param list [Integer, String, Twitter::List] A Twitter list ID, slug, URI, or object.
|
245
245
|
# @param options [Hash] A customizable set of options.
|
246
246
|
def list_members(*args)
|
247
|
-
cursor_from_response_with_list(
|
247
|
+
cursor_from_response_with_list("/1.1/lists/members.json", args)
|
248
248
|
end
|
249
249
|
|
250
250
|
# Add a member to a list
|
@@ -266,7 +266,7 @@ module Twitter
|
|
266
266
|
# @param user_to_add [Integer, String] The user id or screen name to add to the list.
|
267
267
|
# @param options [Hash] A customizable set of options.
|
268
268
|
def add_list_member(*args)
|
269
|
-
list_from_response_with_user(
|
269
|
+
list_from_response_with_user("/1.1/lists/members/create.json", args)
|
270
270
|
end
|
271
271
|
|
272
272
|
# Deletes the specified list
|
@@ -286,7 +286,7 @@ module Twitter
|
|
286
286
|
# @param list [Integer, String, Twitter::List] A Twitter list ID, slug, URI, or object.
|
287
287
|
# @param options [Hash] A customizable set of options.
|
288
288
|
def destroy_list(*args)
|
289
|
-
list_from_response(:post,
|
289
|
+
list_from_response(:post, "/1.1/lists/destroy.json", args)
|
290
290
|
end
|
291
291
|
|
292
292
|
# Updates the specified list
|
@@ -309,7 +309,7 @@ module Twitter
|
|
309
309
|
# @option options [String] :mode ('public') Whether your list is public or private. Values can be 'public' or 'private'.
|
310
310
|
# @option options [String] :description The description to give the list.
|
311
311
|
def list_update(*args)
|
312
|
-
list_from_response(:post,
|
312
|
+
list_from_response(:post, "/1.1/lists/update.json", args)
|
313
313
|
end
|
314
314
|
|
315
315
|
# Creates a new list for the authenticated user
|
@@ -325,7 +325,7 @@ module Twitter
|
|
325
325
|
# @option options [String] :mode ('public') Whether your list is public or private. Values can be 'public' or 'private'.
|
326
326
|
# @option options [String] :description The description to give the list.
|
327
327
|
def create_list(name, options = {})
|
328
|
-
perform_post_with_object(
|
328
|
+
perform_post_with_object("/1.1/lists/create.json", options.merge(name: name), Twitter::List)
|
329
329
|
end
|
330
330
|
|
331
331
|
# Show the specified list
|
@@ -345,7 +345,7 @@ module Twitter
|
|
345
345
|
# @param list [Integer, String, Twitter::List] A Twitter list ID, slug, URI, or object.
|
346
346
|
# @param options [Hash] A customizable set of options.
|
347
347
|
def list(*args)
|
348
|
-
list_from_response(:get,
|
348
|
+
list_from_response(:get, "/1.1/lists/show.json", args)
|
349
349
|
end
|
350
350
|
|
351
351
|
# List the lists the specified user follows
|
@@ -361,7 +361,7 @@ module Twitter
|
|
361
361
|
# @param user [Integer, String, Twitter::User] A Twitter user ID, screen name, URI, or object.
|
362
362
|
# @param options [Hash] A customizable set of options.
|
363
363
|
def subscriptions(*args)
|
364
|
-
cursor_from_response_with_user(:lists, Twitter::List,
|
364
|
+
cursor_from_response_with_user(:lists, Twitter::List, "/1.1/lists/subscriptions.json", args)
|
365
365
|
end
|
366
366
|
|
367
367
|
# Removes specified members from the list
|
@@ -382,7 +382,7 @@ module Twitter
|
|
382
382
|
# @param users [Enumerable<Integer, String, Twitter::User>] A collection of Twitter user IDs, screen names, or objects.
|
383
383
|
# @param options [Hash] A customizable set of options.
|
384
384
|
def remove_list_members(*args)
|
385
|
-
list_from_response_with_users(
|
385
|
+
list_from_response_with_users("/1.1/lists/members/destroy_all.json", args)
|
386
386
|
end
|
387
387
|
|
388
388
|
# Returns the lists owned by the specified Twitter user
|
@@ -400,7 +400,7 @@ module Twitter
|
|
400
400
|
# @param options [Hash] A customizable set of options.
|
401
401
|
# @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.
|
402
402
|
def owned_lists(*args)
|
403
|
-
cursor_from_response_with_user(:lists, Twitter::List,
|
403
|
+
cursor_from_response_with_user(:lists, Twitter::List, "/1.1/lists/ownerships.json", args)
|
404
404
|
end
|
405
405
|
|
406
406
|
private
|
@@ -467,7 +467,7 @@ module Twitter
|
|
467
467
|
end
|
468
468
|
|
469
469
|
def merge_slug_and_owner!(hash, path)
|
470
|
-
list = path.split(
|
470
|
+
list = path.split("/")
|
471
471
|
hash[:slug] = list.pop
|
472
472
|
hash[:owner_screen_name] = list.pop unless list.empty?
|
473
473
|
end
|
@@ -484,8 +484,9 @@ module Twitter
|
|
484
484
|
# @return [Hash]
|
485
485
|
def merge_owner!(hash, user)
|
486
486
|
return hash if hash[:owner_id] || hash[:owner_screen_name]
|
487
|
+
|
487
488
|
if user
|
488
|
-
merge_user!(hash, user,
|
489
|
+
merge_user!(hash, user, "owner")
|
489
490
|
hash[:owner_id] = hash.delete(:owner_user_id) unless hash[:owner_user_id].nil?
|
490
491
|
else
|
491
492
|
hash[:owner_id] = user_id
|
data/lib/twitter/rest/oauth.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require "twitter/headers"
|
2
|
+
require "twitter/rest/utils"
|
3
3
|
|
4
4
|
module Twitter
|
5
5
|
module REST
|
@@ -24,11 +24,11 @@ module Twitter
|
|
24
24
|
def token(options = {})
|
25
25
|
options = options.dup
|
26
26
|
options[:bearer_token_request] = true
|
27
|
-
options[:grant_type] ||=
|
28
|
-
url =
|
27
|
+
options[:grant_type] ||= "client_credentials"
|
28
|
+
url = "https://api.twitter.com/oauth2/token"
|
29
29
|
headers = Twitter::Headers.new(self, :post, url, options).request_headers
|
30
30
|
response = HTTP.headers(headers).post(url, form: options)
|
31
|
-
response.parse[
|
31
|
+
response.parse["access_token"]
|
32
32
|
end
|
33
33
|
alias bearer_token token
|
34
34
|
|
@@ -44,7 +44,7 @@ module Twitter
|
|
44
44
|
def invalidate_token(access_token, options = {})
|
45
45
|
options = options.dup
|
46
46
|
options[:access_token] = access_token
|
47
|
-
perform_post(
|
47
|
+
perform_post("/oauth2/invalidate_token", options)[:access_token]
|
48
48
|
end
|
49
49
|
|
50
50
|
# Allows a registered application to revoke an issued OAuth 2 Bearer Token by presenting its client credentials.
|
@@ -55,8 +55,8 @@ module Twitter
|
|
55
55
|
# @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
|
56
56
|
# @return [String] The token string.
|
57
57
|
def reverse_token
|
58
|
-
options = {x_auth_mode:
|
59
|
-
url =
|
58
|
+
options = {x_auth_mode: "reverse_auth"}
|
59
|
+
url = "https://api.twitter.com/oauth/request_token"
|
60
60
|
auth_header = Twitter::Headers.new(self, :post, url, options).oauth_auth_header.to_s
|
61
61
|
HTTP.headers(authorization: auth_header).post(url, params: options).to_s
|
62
62
|
end
|
@@ -1,6 +1,6 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require
|
1
|
+
require "twitter/geo_results"
|
2
|
+
require "twitter/place"
|
3
|
+
require "twitter/rest/utils"
|
4
4
|
|
5
5
|
module Twitter
|
6
6
|
module REST
|
@@ -35,7 +35,7 @@ module Twitter
|
|
35
35
|
# @option options [Integer] :max_results A hint as to the number of results to return. This does not guarantee that the number of results returned will equal max_results, but instead informs how many "nearby" results to return. Ideally, only pass in the number of places you intend to display to the user here.
|
36
36
|
# @return [Array<Twitter::Place>]
|
37
37
|
def reverse_geocode(options = {})
|
38
|
-
perform_get_with_object(
|
38
|
+
perform_get_with_object("/1.1/geo/reverse_geocode.json", options, Twitter::GeoResults)
|
39
39
|
end
|
40
40
|
|
41
41
|
# Search for places that can be attached to a {Twitter::REST::Tweets#update}
|
@@ -56,7 +56,7 @@ module Twitter
|
|
56
56
|
# @option options [String] :"attribute:street_address" This option searches for places which have this given street address. There are other well-known and application-specific attributes available. Custom attributes are also permitted.
|
57
57
|
# @return [Array<Twitter::Place>]
|
58
58
|
def geo_search(options = {})
|
59
|
-
perform_get_with_object(
|
59
|
+
perform_get_with_object("/1.1/geo/search.json", options, Twitter::GeoResults)
|
60
60
|
end
|
61
61
|
alias places_nearby geo_search
|
62
62
|
|
@@ -75,7 +75,7 @@ module Twitter
|
|
75
75
|
# @option options [String] :"attribute:street_address" This option searches for places which have this given street address. There are other well-known and application-specific attributes available. Custom attributes are also permitted.
|
76
76
|
# @return [Array<Twitter::Place>]
|
77
77
|
def similar_places(options = {})
|
78
|
-
perform_get_with_object(
|
78
|
+
perform_get_with_object("/1.1/geo/similar_places.json", options, Twitter::GeoResults)
|
79
79
|
end
|
80
80
|
alias places_similar similar_places
|
81
81
|
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require "twitter/rest/request"
|
2
|
+
require "twitter/premium_search_results"
|
3
|
+
|
4
|
+
module Twitter
|
5
|
+
module REST
|
6
|
+
module PremiumSearch
|
7
|
+
MAX_TWEETS_PER_REQUEST = 100
|
8
|
+
|
9
|
+
# Returns tweets from the 30-Day API that match a specified query.
|
10
|
+
#
|
11
|
+
# @see https://developer.twitter.com/en/docs/tweets/search/overview/premium
|
12
|
+
# @see https://developer.twitter.com/en/docs/tweets/search/api-reference/premium-search.html#DataEndpoint
|
13
|
+
# @rate_limited Yes
|
14
|
+
# @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
|
15
|
+
# @param query [String] A search term.
|
16
|
+
# @param options [Hash] A customizable set of options.
|
17
|
+
# @option options [String] :tag Tags can be used to segregate rules and their matching data into different logical groups.
|
18
|
+
# @option options [Integer] :maxResults The maximum number of search results to be returned by a request. A number between 10 and the system limit (currently 500, 100 for Sandbox environments). By default, a request response will return 100 results
|
19
|
+
# @option options [String] :fromDate The oldest UTC timestamp (from most recent 30 days) from which the Tweets will be provided. Date should be formatted as yyyymmddhhmm.
|
20
|
+
# @option options [String] :toDate The latest, most recent UTC timestamp to which the activities will be provided. Date should be formatted as yyyymmddhhmm.
|
21
|
+
# @option request_config [String] :product Indicates the search endpoint you are making requests to, either 30day or fullarchive. Default 30day
|
22
|
+
# @return [Twitter::PremiumSearchResults] Return tweets that match a specified query with search metadata
|
23
|
+
def premium_search(query, options = {}, request_config = {})
|
24
|
+
options = options.clone
|
25
|
+
options[:maxResults] ||= MAX_TWEETS_PER_REQUEST
|
26
|
+
request_config[:request_method] = :json_post if request_config[:request_method].nil? || request_config[:request_method] == :post
|
27
|
+
request_config[:product] ||= "30day"
|
28
|
+
path = "/1.1/tweets/search/#{request_config[:product]}/#{dev_environment}.json"
|
29
|
+
request = Twitter::REST::Request.new(self, request_config[:request_method], path, options.merge(query: query))
|
30
|
+
Twitter::PremiumSearchResults.new(request, request_config)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|