twitter 5.6.0 → 5.7.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.
- data.tar.gz.sig +0 -0
- data/.yardopts +1 -0
- data/CHANGELOG.md +8 -0
- data/README.md +3 -3
- data/Rakefile +1 -1
- data/lib/twitter/base.rb +0 -8
- data/lib/twitter/client.rb +2 -1
- data/lib/twitter/cursor.rb +2 -15
- data/lib/twitter/error.rb +90 -18
- data/lib/twitter/geo_results.rb +0 -10
- data/lib/twitter/request.rb +4 -4
- data/lib/twitter/rest/api.rb +43 -0
- data/lib/twitter/rest/client.rb +10 -44
- data/lib/twitter/rest/direct_messages.rb +138 -0
- data/lib/twitter/rest/favorites.rb +108 -0
- data/lib/twitter/rest/friends_and_followers.rb +281 -0
- data/lib/twitter/rest/help.rb +56 -0
- data/lib/twitter/rest/lists.rb +497 -0
- data/lib/twitter/rest/oauth.rb +65 -0
- data/lib/twitter/rest/places_and_geo.rb +84 -0
- data/lib/twitter/rest/request/multipart_with_file.rb +5 -5
- data/lib/twitter/rest/response/parse_json.rb +2 -4
- data/lib/twitter/rest/response/raise_error.rb +24 -15
- data/lib/twitter/rest/saved_searches.rb +93 -0
- data/lib/twitter/rest/search.rb +37 -0
- data/lib/twitter/rest/spam_reporting.rb +27 -0
- data/lib/twitter/rest/suggested_users.rb +49 -0
- data/lib/twitter/rest/timelines.rb +200 -0
- data/lib/twitter/rest/trends.rb +57 -0
- data/lib/twitter/rest/tweets.rb +309 -0
- data/lib/twitter/rest/undocumented.rb +49 -0
- data/lib/twitter/rest/users.rb +383 -0
- data/lib/twitter/rest/utils.rb +205 -0
- data/lib/twitter/search_results.rb +2 -13
- data/lib/twitter/trend_results.rb +0 -10
- data/lib/twitter/version.rb +1 -1
- data/spec/helper.rb +1 -1
- data/spec/twitter/error_spec.rb +26 -42
- data/spec/twitter/rest/{api/direct_messages_spec.rb → direct_messages_spec.rb} +1 -1
- data/spec/twitter/rest/{api/favorites_spec.rb → favorites_spec.rb} +1 -1
- data/spec/twitter/rest/{api/friends_and_followers_spec.rb → friends_and_followers_spec.rb} +1 -1
- data/spec/twitter/rest/{api/geo_spec.rb → geo_spec.rb} +1 -1
- data/spec/twitter/rest/{api/help_spec.rb → help_spec.rb} +1 -1
- data/spec/twitter/rest/{api/lists_spec.rb → lists_spec.rb} +1 -1
- data/spec/twitter/rest/{api/oauth_spec.rb → oauth_spec.rb} +4 -8
- data/spec/twitter/rest/{api/saved_searches_spec.rb → saved_searches_spec.rb} +1 -1
- data/spec/twitter/rest/{api/search_spec.rb → search_spec.rb} +1 -1
- data/spec/twitter/rest/{api/spam_reporting_spec.rb → spam_reporting_spec.rb} +1 -1
- data/spec/twitter/rest/{api/suggested_users_spec.rb → suggested_users_spec.rb} +1 -1
- data/spec/twitter/rest/{api/timelines_spec.rb → timelines_spec.rb} +1 -1
- data/spec/twitter/rest/{api/trends_spec.rb → trends_spec.rb} +1 -1
- data/spec/twitter/rest/{api/tweets_spec.rb → tweets_spec.rb} +74 -5
- data/spec/twitter/rest/{api/undocumented_spec.rb → undocumented_spec.rb} +1 -1
- data/spec/twitter/rest/{api/users_spec.rb → users_spec.rb} +5 -5
- data/spec/twitter/tweet_spec.rb +1 -1
- data/twitter.gemspec +0 -1
- metadata +247 -237
- metadata.gz.sig +0 -0
- checksums.yaml +0 -7
- checksums.yaml.gz.sig +0 -0
- data/lib/twitter/error/already_favorited.rb +0 -10
- data/lib/twitter/error/already_posted.rb +0 -10
- data/lib/twitter/error/already_retweeted.rb +0 -10
- data/lib/twitter/error/bad_gateway.rb +0 -10
- data/lib/twitter/error/bad_request.rb +0 -10
- data/lib/twitter/error/configuration_error.rb +0 -8
- data/lib/twitter/error/forbidden.rb +0 -10
- data/lib/twitter/error/gateway_timeout.rb +0 -10
- data/lib/twitter/error/internal_server_error.rb +0 -10
- data/lib/twitter/error/not_acceptable.rb +0 -10
- data/lib/twitter/error/not_found.rb +0 -10
- data/lib/twitter/error/request_timeout.rb +0 -10
- data/lib/twitter/error/service_unavailable.rb +0 -10
- data/lib/twitter/error/too_many_requests.rb +0 -12
- data/lib/twitter/error/unauthorized.rb +0 -10
- data/lib/twitter/error/unprocessable_entity.rb +0 -10
- data/lib/twitter/rest/api/direct_messages.rb +0 -140
- data/lib/twitter/rest/api/favorites.rb +0 -115
- data/lib/twitter/rest/api/friends_and_followers.rb +0 -284
- data/lib/twitter/rest/api/help.rb +0 -58
- data/lib/twitter/rest/api/lists.rb +0 -500
- data/lib/twitter/rest/api/oauth.rb +0 -67
- data/lib/twitter/rest/api/places_and_geo.rb +0 -86
- data/lib/twitter/rest/api/saved_searches.rb +0 -95
- data/lib/twitter/rest/api/search.rb +0 -39
- data/lib/twitter/rest/api/spam_reporting.rb +0 -29
- data/lib/twitter/rest/api/suggested_users.rb +0 -51
- data/lib/twitter/rest/api/timelines.rb +0 -202
- data/lib/twitter/rest/api/trends.rb +0 -58
- data/lib/twitter/rest/api/tweets.rb +0 -297
- data/lib/twitter/rest/api/undocumented.rb +0 -51
- data/lib/twitter/rest/api/users.rb +0 -383
- data/lib/twitter/rest/api/utils.rb +0 -212
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
require 'twitter/arguments'
|
|
2
|
+
require 'twitter/direct_message'
|
|
3
|
+
require 'twitter/request'
|
|
4
|
+
require 'twitter/rest/utils'
|
|
5
|
+
require 'twitter/user'
|
|
6
|
+
require 'twitter/utils'
|
|
7
|
+
|
|
8
|
+
module Twitter
|
|
9
|
+
module REST
|
|
10
|
+
module DirectMessages
|
|
11
|
+
include Twitter::REST::Utils
|
|
12
|
+
include Twitter::Utils
|
|
13
|
+
|
|
14
|
+
# Returns the 20 most recent direct messages sent to the authenticating user
|
|
15
|
+
#
|
|
16
|
+
# @see https://dev.twitter.com/docs/api/1.1/get/direct_messages
|
|
17
|
+
# @note This method requires an access token with RWD (read, write & direct message) permissions. Consult The Application Permission Model for more information.
|
|
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 [Array<Twitter::DirectMessage>] Direct messages sent to the authenticating user.
|
|
22
|
+
# @param options [Hash] A customizable set of options.
|
|
23
|
+
# @option options [Integer] :since_id Returns results with an ID greater than (that is, more recent than) the specified ID.
|
|
24
|
+
# @option options [Integer] :max_id Returns results with an ID less than (that is, older than) or equal to the specified ID.
|
|
25
|
+
# @option options [Integer] :count Specifies the number of records to retrieve. Must be less than or equal to 200.
|
|
26
|
+
# @option options [Integer] :page Specifies the page of results to retrieve.
|
|
27
|
+
def direct_messages_received(options = {})
|
|
28
|
+
perform_with_objects(:get, '/1.1/direct_messages.json', options, Twitter::DirectMessage)
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
# Returns the 20 most recent direct messages sent by the authenticating user
|
|
32
|
+
#
|
|
33
|
+
# @see https://dev.twitter.com/docs/api/1.1/get/direct_messages/sent
|
|
34
|
+
# @note This method requires an access token with RWD (read, write & direct message) permissions. Consult The Application Permission Model for more information.
|
|
35
|
+
# @rate_limited Yes
|
|
36
|
+
# @authentication Requires user context
|
|
37
|
+
# @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
|
|
38
|
+
# @return [Array<Twitter::DirectMessage>] Direct messages sent by the authenticating user.
|
|
39
|
+
# @param options [Hash] A customizable set of options.
|
|
40
|
+
# @option options [Integer] :since_id Returns results with an ID greater than (that is, more recent than) the specified ID.
|
|
41
|
+
# @option options [Integer] :max_id Returns results with an ID less than (that is, older than) or equal to the specified ID.
|
|
42
|
+
# @option options [Integer] :count Specifies the number of records to retrieve. Must be less than or equal to 200.
|
|
43
|
+
# @option options [Integer] :page Specifies the page of results to retrieve.
|
|
44
|
+
def direct_messages_sent(options = {})
|
|
45
|
+
perform_with_objects(:get, '/1.1/direct_messages/sent.json', options, Twitter::DirectMessage)
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
# Returns a direct message
|
|
49
|
+
#
|
|
50
|
+
# @see https://dev.twitter.com/docs/api/1.1/get/direct_messages/show
|
|
51
|
+
# @note This method requires an access token with RWD (read, write & direct message) permissions. Consult The Application Permission Model for more information.
|
|
52
|
+
# @rate_limited Yes
|
|
53
|
+
# @authentication Requires user context
|
|
54
|
+
# @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
|
|
55
|
+
# @return [Twitter::DirectMessage] The requested messages.
|
|
56
|
+
# @param id [Integer] A direct message ID.
|
|
57
|
+
# @param options [Hash] A customizable set of options.
|
|
58
|
+
def direct_message(id, options = {})
|
|
59
|
+
options[:id] = id
|
|
60
|
+
perform_with_object(:get, '/1.1/direct_messages/show.json', options, Twitter::DirectMessage)
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
# @note This method requires an access token with RWD (read, write & direct message) permissions. Consult The Application Permission Model for more information.
|
|
64
|
+
# @rate_limited Yes
|
|
65
|
+
# @authentication Requires user context
|
|
66
|
+
# @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
|
|
67
|
+
# @return [Array<Twitter::DirectMessage>] The requested messages.
|
|
68
|
+
# @overload direct_messages(options = {})
|
|
69
|
+
# Returns the 20 most recent direct messages sent to the authenticating user
|
|
70
|
+
#
|
|
71
|
+
# @see https://dev.twitter.com/docs/api/1.1/get/direct_messages
|
|
72
|
+
# @param options [Hash] A customizable set of options.
|
|
73
|
+
# @option options [Integer] :since_id Returns results with an ID greater than (that is, more recent than) the specified ID.
|
|
74
|
+
# @option options [Integer] :max_id Returns results with an ID less than (that is, older than) or equal to the specified ID.
|
|
75
|
+
# @option options [Integer] :count Specifies the number of records to retrieve. Must be less than or equal to 200.
|
|
76
|
+
# @option options [Integer] :page Specifies the page of results to retrieve.
|
|
77
|
+
# @overload direct_messages(*ids)
|
|
78
|
+
# Returns direct messages
|
|
79
|
+
#
|
|
80
|
+
# @see https://dev.twitter.com/docs/api/1.1/get/direct_messages/show
|
|
81
|
+
# @param ids [Enumerable<Integer>] A collection of direct message IDs.
|
|
82
|
+
# @overload direct_messages(*ids, options)
|
|
83
|
+
# Returns direct messages
|
|
84
|
+
#
|
|
85
|
+
# @see https://dev.twitter.com/docs/api/1.1/get/direct_messages/show
|
|
86
|
+
# @param ids [Enumerable<Integer>] A collection of direct message IDs.
|
|
87
|
+
# @param options [Hash] A customizable set of options.
|
|
88
|
+
def direct_messages(*args)
|
|
89
|
+
arguments = Twitter::Arguments.new(args)
|
|
90
|
+
if arguments.empty?
|
|
91
|
+
direct_messages_received(arguments.options)
|
|
92
|
+
else
|
|
93
|
+
parallel_map(arguments) do |id|
|
|
94
|
+
direct_message(id, arguments.options)
|
|
95
|
+
end
|
|
96
|
+
end
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
# Destroys direct messages
|
|
100
|
+
#
|
|
101
|
+
# @see https://dev.twitter.com/docs/api/1.1/post/direct_messages/destroy
|
|
102
|
+
# @note This method requires an access token with RWD (read, write & direct message) permissions. Consult The Application Permission Model for more information.
|
|
103
|
+
# @rate_limited No
|
|
104
|
+
# @authentication Requires user context
|
|
105
|
+
# @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
|
|
106
|
+
# @return [Array<Twitter::DirectMessage>] Deleted direct message.
|
|
107
|
+
# @overload destroy_direct_message(*ids)
|
|
108
|
+
# @param ids [Enumerable<Integer>] A collection of direct message IDs.
|
|
109
|
+
# @overload destroy_direct_message(*ids, options)
|
|
110
|
+
# @param ids [Enumerable<Integer>] A collection of direct message IDs.
|
|
111
|
+
# @param options [Hash] A customizable set of options.
|
|
112
|
+
def destroy_direct_message(*args)
|
|
113
|
+
parallel_objects_from_response(Twitter::DirectMessage, :post, '/1.1/direct_messages/destroy.json', args)
|
|
114
|
+
end
|
|
115
|
+
deprecate_alias :direct_message_destroy, :destroy_direct_message
|
|
116
|
+
|
|
117
|
+
# Sends a new direct message to the specified user from the authenticating user
|
|
118
|
+
#
|
|
119
|
+
# @see https://dev.twitter.com/docs/api/1.1/post/direct_messages/new
|
|
120
|
+
# @rate_limited No
|
|
121
|
+
# @authentication Requires user context
|
|
122
|
+
# @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
|
|
123
|
+
# @return [Twitter::DirectMessage] The sent message.
|
|
124
|
+
# @param user [Integer, String, Twitter::User] A Twitter user ID, screen name, URI, or object.
|
|
125
|
+
# @param text [String] The text of your direct message, up to 140 characters.
|
|
126
|
+
# @param options [Hash] A customizable set of options.
|
|
127
|
+
def create_direct_message(user, text, options = {})
|
|
128
|
+
merge_user!(options, user)
|
|
129
|
+
options[:text] = text
|
|
130
|
+
perform_with_object(:post, '/1.1/direct_messages/new.json', options, Twitter::DirectMessage)
|
|
131
|
+
end
|
|
132
|
+
alias_method :d, :create_direct_message
|
|
133
|
+
alias_method :m, :create_direct_message
|
|
134
|
+
alias_method :dm, :create_direct_message
|
|
135
|
+
deprecate_alias :direct_message_create, :create_direct_message
|
|
136
|
+
end
|
|
137
|
+
end
|
|
138
|
+
end
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
require 'twitter/arguments'
|
|
2
|
+
require 'twitter/error'
|
|
3
|
+
require 'twitter/request'
|
|
4
|
+
require 'twitter/rest/utils'
|
|
5
|
+
require 'twitter/tweet'
|
|
6
|
+
require 'twitter/user'
|
|
7
|
+
require 'twitter/utils'
|
|
8
|
+
|
|
9
|
+
module Twitter
|
|
10
|
+
module REST
|
|
11
|
+
module Favorites
|
|
12
|
+
include Twitter::REST::Utils
|
|
13
|
+
include Twitter::Utils
|
|
14
|
+
|
|
15
|
+
# @see https://dev.twitter.com/docs/api/1.1/get/favorites/list
|
|
16
|
+
# @rate_limited Yes
|
|
17
|
+
# @authentication Requires user context
|
|
18
|
+
# @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
|
|
19
|
+
# @return [Array<Twitter::Tweet>] favorite Tweets.
|
|
20
|
+
# @overload favorites(options = {})
|
|
21
|
+
# Returns the 20 most recent favorite Tweets for the authenticating user
|
|
22
|
+
#
|
|
23
|
+
# @param options [Hash] A customizable set of options.
|
|
24
|
+
# @option options [Integer] :count Specifies the number of records to retrieve. Must be less than or equal to 100.
|
|
25
|
+
# @option options [Integer] :since_id Returns results with an ID greater than (that is, more recent than) the specified ID.
|
|
26
|
+
# @overload favorites(user, options = {})
|
|
27
|
+
# Returns the 20 most recent favorite Tweets for the specified user
|
|
28
|
+
#
|
|
29
|
+
# @param user [Integer, String, Twitter::User] A Twitter user ID, screen name, URI, or object.
|
|
30
|
+
# @param options [Hash] A customizable set of options.
|
|
31
|
+
# @option options [Integer] :count Specifies the number of records to retrieve. Must be less than or equal to 100.
|
|
32
|
+
# @option options [Integer] :since_id Returns results with an ID greater than (that is, more recent than) the specified ID.
|
|
33
|
+
def favorites(*args)
|
|
34
|
+
arguments = Twitter::Arguments.new(args)
|
|
35
|
+
merge_user!(arguments.options, arguments.pop) if arguments.last
|
|
36
|
+
perform_with_objects(:get, '/1.1/favorites/list.json', arguments.options, Twitter::Tweet)
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
# Un-favorites the specified Tweets as the authenticating user
|
|
40
|
+
#
|
|
41
|
+
# @see https://dev.twitter.com/docs/api/1.1/post/favorites/destroy
|
|
42
|
+
# @rate_limited No
|
|
43
|
+
# @authentication Requires user context
|
|
44
|
+
# @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
|
|
45
|
+
# @return [Array<Twitter::Tweet>] The un-favorited Tweets.
|
|
46
|
+
# @overload unfavorite(*tweets)
|
|
47
|
+
# @param tweets [Enumerable<Integer, String, URI, Twitter::Tweet>] A collection of Tweet IDs, URIs, or objects.
|
|
48
|
+
# @overload unfavorite(*tweets, options)
|
|
49
|
+
# @param tweets [Enumerable<Integer, String, URI, Twitter::Tweet>] A collection of Tweet IDs, URIs, or objects.
|
|
50
|
+
# @param options [Hash] A customizable set of options.
|
|
51
|
+
def unfavorite(*args)
|
|
52
|
+
parallel_objects_from_response(Twitter::Tweet, :post, '/1.1/favorites/destroy.json', args)
|
|
53
|
+
end
|
|
54
|
+
alias_method :destroy_favorite, :unfavorite
|
|
55
|
+
deprecate_alias :favorite_destroy, :unfavorite
|
|
56
|
+
|
|
57
|
+
# Favorites the specified Tweets as the authenticating user
|
|
58
|
+
#
|
|
59
|
+
# @see https://dev.twitter.com/docs/api/1.1/post/favorites/create
|
|
60
|
+
# @rate_limited No
|
|
61
|
+
# @authentication Requires user context
|
|
62
|
+
# @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
|
|
63
|
+
# @return [Array<Twitter::Tweet>] The favorited Tweets.
|
|
64
|
+
# @overload favorite(*tweets)
|
|
65
|
+
# @param tweets [Enumerable<Integer, String, URI, Twitter::Tweet>] A collection of Tweet IDs, URIs, or objects.
|
|
66
|
+
# @overload favorite(*tweets, options)
|
|
67
|
+
# @param tweets [Enumerable<Integer, String, URI, Twitter::Tweet>] A collection of Tweet IDs, URIs, or objects.
|
|
68
|
+
# @param options [Hash] A customizable set of options.
|
|
69
|
+
def favorite(*args)
|
|
70
|
+
arguments = Twitter::Arguments.new(args)
|
|
71
|
+
parallel_map(arguments) do |tweet|
|
|
72
|
+
begin
|
|
73
|
+
perform_with_object(:post, '/1.1/favorites/create.json', arguments.options.merge(:id => extract_id(tweet)), Twitter::Tweet)
|
|
74
|
+
rescue Twitter::Error::AlreadyFavorited
|
|
75
|
+
next
|
|
76
|
+
end
|
|
77
|
+
end.compact
|
|
78
|
+
end
|
|
79
|
+
alias_method :fav, :favorite
|
|
80
|
+
alias_method :fave, :favorite
|
|
81
|
+
deprecate_alias :favorite_create, :favorite
|
|
82
|
+
|
|
83
|
+
# Favorites the specified Tweets as the authenticating user and raises an error if one has already been favorited
|
|
84
|
+
#
|
|
85
|
+
# @see https://dev.twitter.com/docs/api/1.1/post/favorites/create
|
|
86
|
+
# @rate_limited No
|
|
87
|
+
# @authentication Requires user context
|
|
88
|
+
# @raise [Twitter::Error::AlreadyFavorited] Error raised when tweet has already been favorited.
|
|
89
|
+
# @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
|
|
90
|
+
# @return [Array<Twitter::Tweet>] The favorited Tweets.
|
|
91
|
+
# @overload favorite(*tweets)
|
|
92
|
+
# @param tweets [Enumerable<Integer, String, URI, Twitter::Tweet>] A collection of Tweet IDs, URIs, or objects.
|
|
93
|
+
# @overload favorite(*tweets, options)
|
|
94
|
+
# @param tweets [Enumerable<Integer, String, URI, Twitter::Tweet>] A collection of Tweet IDs, URIs, or objects.
|
|
95
|
+
# @param options [Hash] A customizable set of options.
|
|
96
|
+
def favorite!(*args)
|
|
97
|
+
arguments = Twitter::Arguments.new(args)
|
|
98
|
+
parallel_map(arguments) do |tweet|
|
|
99
|
+
perform_with_object(:post, '/1.1/favorites/create.json', arguments.options.merge(:id => extract_id(tweet)), Twitter::Tweet)
|
|
100
|
+
end
|
|
101
|
+
end
|
|
102
|
+
alias_method :create_favorite!, :favorite!
|
|
103
|
+
alias_method :fav!, :favorite!
|
|
104
|
+
alias_method :fave!, :favorite!
|
|
105
|
+
deprecate_alias :favorite_create!, :favorite!
|
|
106
|
+
end
|
|
107
|
+
end
|
|
108
|
+
end
|
|
@@ -0,0 +1,281 @@
|
|
|
1
|
+
require 'twitter/arguments'
|
|
2
|
+
require 'twitter/cursor'
|
|
3
|
+
require 'twitter/relationship'
|
|
4
|
+
require 'twitter/request'
|
|
5
|
+
require 'twitter/rest/utils'
|
|
6
|
+
require 'twitter/user'
|
|
7
|
+
require 'twitter/utils'
|
|
8
|
+
|
|
9
|
+
module Twitter
|
|
10
|
+
module REST
|
|
11
|
+
module FriendsAndFollowers
|
|
12
|
+
include Twitter::REST::Utils
|
|
13
|
+
include Twitter::Utils
|
|
14
|
+
|
|
15
|
+
# @see https://dev.twitter.com/docs/api/1.1/get/friends/ids
|
|
16
|
+
# @rate_limited Yes
|
|
17
|
+
# @authentication Requires user context
|
|
18
|
+
# @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
|
|
19
|
+
# @return [Twitter::Cursor]
|
|
20
|
+
# @overload friend_ids(options = {})
|
|
21
|
+
# Returns an array of numeric IDs for every user the authenticated user is following
|
|
22
|
+
#
|
|
23
|
+
# @param options [Hash] A customizable set of options.
|
|
24
|
+
# @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.
|
|
25
|
+
# @overload friend_ids(user, options = {})
|
|
26
|
+
# Returns an array of numeric IDs for every user the specified user is following
|
|
27
|
+
#
|
|
28
|
+
# @param user [Integer, String, Twitter::User] A Twitter user ID, screen name, URI, or object.
|
|
29
|
+
# @param options [Hash] A customizable set of options.
|
|
30
|
+
# @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.
|
|
31
|
+
def friend_ids(*args)
|
|
32
|
+
cursor_from_response_with_user(:ids, nil, :get, '/1.1/friends/ids.json', args)
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
# @see https://dev.twitter.com/docs/api/1.1/get/followers/ids
|
|
36
|
+
# @rate_limited Yes
|
|
37
|
+
# @authentication Requires user context
|
|
38
|
+
# @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
|
|
39
|
+
# @return [Twitter::Cursor]
|
|
40
|
+
# @overload follower_ids(options = {})
|
|
41
|
+
# Returns an array of numeric IDs for every user following the authenticated user
|
|
42
|
+
#
|
|
43
|
+
# @param options [Hash] A customizable set of options.
|
|
44
|
+
# @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.
|
|
45
|
+
# @overload follower_ids(user, options = {})
|
|
46
|
+
# Returns an array of numeric IDs for every user following the specified user
|
|
47
|
+
#
|
|
48
|
+
# @param user [Integer, String, Twitter::User] A Twitter user ID, screen name, URI, or object.
|
|
49
|
+
# @param options [Hash] A customizable set of options.
|
|
50
|
+
# @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.
|
|
51
|
+
def follower_ids(*args)
|
|
52
|
+
cursor_from_response_with_user(:ids, nil, :get, '/1.1/followers/ids.json', args)
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
# 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.
|
|
56
|
+
#
|
|
57
|
+
# @see https://dev.twitter.com/docs/api/1.1/get/friendships/lookup
|
|
58
|
+
# @rate_limited Yes
|
|
59
|
+
# @authentication Requires user context
|
|
60
|
+
# @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
|
|
61
|
+
# @return [Array<Twitter::User>] The requested users.
|
|
62
|
+
# @overload friendships(*users)
|
|
63
|
+
# @param users [Enumerable<Integer, String, Twitter::User>] A collection of Twitter user IDs, screen names, or objects.
|
|
64
|
+
# @overload friendships(*users, options)
|
|
65
|
+
# @param users [Enumerable<Integer, String, Twitter::User>] A collection of Twitter user IDs, screen names, or objects.
|
|
66
|
+
# @param options [Hash] A customizable set of options.
|
|
67
|
+
def friendships(*args)
|
|
68
|
+
arguments = Twitter::Arguments.new(args)
|
|
69
|
+
merge_users!(arguments.options, arguments)
|
|
70
|
+
perform_with_objects(:get, '/1.1/friendships/lookup.json', arguments.options, Twitter::User)
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
# Returns an array of numeric IDs for every user who has a pending request to follow the authenticating user
|
|
74
|
+
#
|
|
75
|
+
# @see https://dev.twitter.com/docs/api/1.1/get/friendships/incoming
|
|
76
|
+
# @rate_limited Yes
|
|
77
|
+
# @authentication Requires user context
|
|
78
|
+
# @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
|
|
79
|
+
# @return [Twitter::Cursor]
|
|
80
|
+
# @param options [Hash] A customizable set of options.
|
|
81
|
+
# @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.
|
|
82
|
+
def friendships_incoming(options = {})
|
|
83
|
+
perform_with_cursor(:get, '/1.1/friendships/incoming.json', options, :ids)
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
# Returns an array of numeric IDs for every protected user for whom the authenticating user has a pending follow request
|
|
87
|
+
#
|
|
88
|
+
# @see https://dev.twitter.com/docs/api/1.1/get/friendships/outgoing
|
|
89
|
+
# @rate_limited Yes
|
|
90
|
+
# @authentication Requires user context
|
|
91
|
+
# @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
|
|
92
|
+
# @return [Twitter::Cursor]
|
|
93
|
+
# @param options [Hash] A customizable set of options.
|
|
94
|
+
# @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.
|
|
95
|
+
def friendships_outgoing(options = {})
|
|
96
|
+
perform_with_cursor(:get, '/1.1/friendships/outgoing.json', options, :ids)
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
# Allows the authenticating user to follow the specified users, unless they are already followed
|
|
100
|
+
#
|
|
101
|
+
# @see https://dev.twitter.com/docs/api/1.1/post/friendships/create
|
|
102
|
+
# @rate_limited Yes
|
|
103
|
+
# @authentication Requires user context
|
|
104
|
+
# @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
|
|
105
|
+
# @return [Array<Twitter::User>] The followed users.
|
|
106
|
+
# @overload follow(*users)
|
|
107
|
+
# @param users [Enumerable<Integer, String, Twitter::User>] A collection of Twitter user IDs, screen names, or objects.
|
|
108
|
+
# @overload follow(*users, options)
|
|
109
|
+
# @param users [Enumerable<Integer, String, Twitter::User>] A collection of Twitter user IDs, screen names, or objects.
|
|
110
|
+
# @param options [Hash] A customizable set of options.
|
|
111
|
+
# @option options [Boolean] :follow (false) Enable notifications for the target user.
|
|
112
|
+
def follow(*args)
|
|
113
|
+
arguments = Twitter::Arguments.new(args)
|
|
114
|
+
existing_friends = Thread.new do
|
|
115
|
+
friend_ids.to_a
|
|
116
|
+
end
|
|
117
|
+
new_friends = Thread.new do
|
|
118
|
+
users(args).collect(&:id)
|
|
119
|
+
end
|
|
120
|
+
follow!(new_friends.value - existing_friends.value, arguments.options)
|
|
121
|
+
end
|
|
122
|
+
alias_method :create_friendship, :follow
|
|
123
|
+
deprecate_alias :friendship_create, :follow
|
|
124
|
+
|
|
125
|
+
# Allows the authenticating user to follow the specified users
|
|
126
|
+
#
|
|
127
|
+
# @see https://dev.twitter.com/docs/api/1.1/post/friendships/create
|
|
128
|
+
# @rate_limited No
|
|
129
|
+
# @authentication Requires user context
|
|
130
|
+
# @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
|
|
131
|
+
# @return [Array<Twitter::User>] The followed users.
|
|
132
|
+
# @overload follow!(*users)
|
|
133
|
+
# @param users [Enumerable<Integer, String, Twitter::User>] A collection of Twitter user IDs, screen names, or objects.
|
|
134
|
+
# @overload follow!(*users, options)
|
|
135
|
+
# @param users [Enumerable<Integer, String, Twitter::User>] A collection of Twitter user IDs, screen names, or objects.
|
|
136
|
+
# @param options [Hash] A customizable set of options.
|
|
137
|
+
# @option options [Boolean] :follow (false) Enable notifications for the target user.
|
|
138
|
+
def follow!(*args)
|
|
139
|
+
arguments = Twitter::Arguments.new(args)
|
|
140
|
+
parallel_map(arguments) do |user|
|
|
141
|
+
perform_with_object(:post, '/1.1/friendships/create.json', merge_user(arguments.options, user), Twitter::User)
|
|
142
|
+
end.compact
|
|
143
|
+
end
|
|
144
|
+
alias_method :create_friendship!, :follow!
|
|
145
|
+
deprecate_alias :friendship_create!, :follow!
|
|
146
|
+
|
|
147
|
+
# Allows the authenticating user to unfollow the specified users
|
|
148
|
+
#
|
|
149
|
+
# @see https://dev.twitter.com/docs/api/1.1/post/friendships/destroy
|
|
150
|
+
# @rate_limited No
|
|
151
|
+
# @authentication Requires user context
|
|
152
|
+
# @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
|
|
153
|
+
# @return [Array<Twitter::User>] The unfollowed users.
|
|
154
|
+
# @overload unfollow(*users)
|
|
155
|
+
# @param users [Enumerable<Integer, String, Twitter::User>] A collection of Twitter user IDs, screen names, or objects.
|
|
156
|
+
# @overload unfollow(*users, options)
|
|
157
|
+
# @param users [Enumerable<Integer, String, Twitter::User>] A collection of Twitter user IDs, screen names, or objects.
|
|
158
|
+
# @param options [Hash] A customizable set of options.
|
|
159
|
+
def unfollow(*args)
|
|
160
|
+
parallel_user_objects_from_response(:post, '/1.1/friendships/destroy.json', args)
|
|
161
|
+
end
|
|
162
|
+
alias_method :destroy_friendship, :unfollow
|
|
163
|
+
deprecate_alias :friendship_destroy, :unfollow
|
|
164
|
+
|
|
165
|
+
# Allows one to enable or disable retweets and device notifications from the specified user.
|
|
166
|
+
#
|
|
167
|
+
# @see https://dev.twitter.com/docs/api/1.1/post/friendships/update
|
|
168
|
+
# @rate_limited No
|
|
169
|
+
# @authentication Requires user context
|
|
170
|
+
# @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
|
|
171
|
+
# @return [Twitter::Relationship]
|
|
172
|
+
# @param user [Integer, String, Twitter::User] A Twitter user ID, screen name, URI, or object.
|
|
173
|
+
# @param options [Hash] A customizable set of options.
|
|
174
|
+
# @option options [Boolean] :device Enable/disable device notifications from the target user.
|
|
175
|
+
# @option options [Boolean] :retweets Enable/disable retweets from the target user.
|
|
176
|
+
def friendship_update(user, options = {})
|
|
177
|
+
merge_user!(options, user)
|
|
178
|
+
perform_with_object(:post, '/1.1/friendships/update.json', options, Twitter::Relationship)
|
|
179
|
+
end
|
|
180
|
+
|
|
181
|
+
# Returns detailed information about the relationship between two users
|
|
182
|
+
#
|
|
183
|
+
# @see https://dev.twitter.com/docs/api/1.1/get/friendships/show
|
|
184
|
+
# @rate_limited Yes
|
|
185
|
+
# @authentication Requires user context
|
|
186
|
+
# @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
|
|
187
|
+
# @return [Twitter::Relationship]
|
|
188
|
+
# @param source [Integer, String, Twitter::User] The Twitter user ID, screen name, or object of the source user.
|
|
189
|
+
# @param target [Integer, String, Twitter::User] The Twitter user ID, screen name, or object of the target user.
|
|
190
|
+
# @param options [Hash] A customizable set of options.
|
|
191
|
+
def friendship(source, target, options = {})
|
|
192
|
+
merge_user!(options, source, 'source')
|
|
193
|
+
options[:source_id] = options.delete(:source_user_id) unless options[:source_user_id].nil?
|
|
194
|
+
merge_user!(options, target, 'target')
|
|
195
|
+
options[:target_id] = options.delete(:target_user_id) unless options[:target_user_id].nil?
|
|
196
|
+
perform_with_object(:get, '/1.1/friendships/show.json', options, Twitter::Relationship)
|
|
197
|
+
end
|
|
198
|
+
alias_method :friendship_show, :friendship
|
|
199
|
+
alias_method :relationship, :friendship
|
|
200
|
+
|
|
201
|
+
# Test for the existence of friendship between two users
|
|
202
|
+
#
|
|
203
|
+
# @see https://dev.twitter.com/docs/api/1.1/get/friendships/show
|
|
204
|
+
# @rate_limited Yes
|
|
205
|
+
# @authentication Requires user context
|
|
206
|
+
# @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
|
|
207
|
+
# @return [Boolean] true if user_a follows user_b, otherwise false.
|
|
208
|
+
# @param source [Integer, String, Twitter::User] The Twitter user ID, screen name, or object of the source user.
|
|
209
|
+
# @param target [Integer, String, Twitter::User] The Twitter user ID, screen name, or object of the target user.
|
|
210
|
+
# @param options [Hash] A customizable set of options.
|
|
211
|
+
def friendship?(source, target, options = {})
|
|
212
|
+
friendship(source, target, options).source.following?
|
|
213
|
+
end
|
|
214
|
+
|
|
215
|
+
# Returns a cursored collection of user objects for users following the specified user.
|
|
216
|
+
#
|
|
217
|
+
# @see https://dev.twitter.com/docs/api/1.1/get/followers/list
|
|
218
|
+
# @rate_limited Yes
|
|
219
|
+
# @authentication Requires user context
|
|
220
|
+
# @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
|
|
221
|
+
# @return [Twitter::Cursor]
|
|
222
|
+
# @overload followers(options = {})
|
|
223
|
+
# Returns a cursored collection of user objects for users following the authenticated user.
|
|
224
|
+
#
|
|
225
|
+
# @param options [Hash] A customizable set of options.
|
|
226
|
+
# @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.
|
|
227
|
+
# @option options [Boolean, String, Integer] :skip_status Do not include contributee's Tweets when set to true, 't' or 1.
|
|
228
|
+
# @option options [Boolean, String, Integer] :include_user_entities The user entities node will be disincluded when set to false.
|
|
229
|
+
# @overload followers(user, options = {})
|
|
230
|
+
# Returns a cursored collection of user objects for users following the specified user.
|
|
231
|
+
#
|
|
232
|
+
# @param user [Integer, String, Twitter::User] A Twitter user ID, screen name, URI, or object.
|
|
233
|
+
# @param options [Hash] A customizable set of options.
|
|
234
|
+
# @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.
|
|
235
|
+
# @option options [Boolean, String, Integer] :skip_status Do not include contributee's Tweets when set to true, 't' or 1.
|
|
236
|
+
# @option options [Boolean, String, Integer] :include_user_entities The user entities node will be disincluded when set to false.
|
|
237
|
+
def followers(*args)
|
|
238
|
+
cursor_from_response_with_user(:users, Twitter::User, :get, '/1.1/followers/list.json', args)
|
|
239
|
+
end
|
|
240
|
+
|
|
241
|
+
# Returns a cursored collection of user objects for every user the specified user is following (otherwise known as their "friends").
|
|
242
|
+
#
|
|
243
|
+
# @see https://dev.twitter.com/docs/api/1.1/get/friendships/show
|
|
244
|
+
# @rate_limited Yes
|
|
245
|
+
# @authentication Requires user context
|
|
246
|
+
# @raise [Twittera:Error::Unauthorized] Error raised when supplied user credentials are not valid.
|
|
247
|
+
# @return [Twitter::Cursor]
|
|
248
|
+
# @overload friends(options = {})
|
|
249
|
+
# Returns a cursored collection of user objects for every user the authenticated user is following (otherwise known as their "friends").
|
|
250
|
+
#
|
|
251
|
+
# @param options [Hash] A customizable set of options.
|
|
252
|
+
# @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.
|
|
253
|
+
# @option options [Boolean, String, Integer] :skip_status Do not include contributee's Tweets when set to true, 't' or 1.
|
|
254
|
+
# @option options [Boolean, String, Integer] :include_user_entities The user entities node will be disincluded when set to false.
|
|
255
|
+
# @overload friends(user, options = {})
|
|
256
|
+
# Returns a cursored collection of user objects for every user the specified user is following (otherwise known as their "friends").
|
|
257
|
+
#
|
|
258
|
+
# @param user [Integer, String, Twitter::User] A Twitter user ID, screen name, URI, or object.
|
|
259
|
+
# @param options [Hash] A customizable set of options.
|
|
260
|
+
# @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.
|
|
261
|
+
# @option options [Boolean, String, Integer] :skip_status Do not include contributee's Tweets when set to true, 't' or 1.
|
|
262
|
+
# @option options [Boolean, String, Integer] :include_user_entities The user entities node will be disincluded when set to false.
|
|
263
|
+
def friends(*args)
|
|
264
|
+
cursor_from_response_with_user(:users, Twitter::User, :get, '/1.1/friends/list.json', args)
|
|
265
|
+
end
|
|
266
|
+
alias_method :following, :friends
|
|
267
|
+
|
|
268
|
+
# Returns a collection of user IDs that the currently authenticated user does not want to receive retweets from.
|
|
269
|
+
# @see https://dev.twitter.com/docs/api/1.1/get/friendships/no_retweets/ids
|
|
270
|
+
# @rate_limited Yes
|
|
271
|
+
# @authentication Requires user context
|
|
272
|
+
# @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
|
|
273
|
+
# @return [Array<Integer>]
|
|
274
|
+
# @param options [Hash] A customizable set of options.
|
|
275
|
+
def no_retweet_ids(options = {})
|
|
276
|
+
get('/1.1/friendships/no_retweets/ids.json', options).body.collect(&:to_i)
|
|
277
|
+
end
|
|
278
|
+
alias_method :no_retweets_ids, :no_retweet_ids
|
|
279
|
+
end
|
|
280
|
+
end
|
|
281
|
+
end
|