twitter 5.12.0 → 5.13.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +10 -0
- data/lib/twitter/base.rb +6 -2
- data/lib/twitter/client.rb +4 -11
- data/lib/twitter/cursor.rb +5 -5
- data/lib/twitter/headers.rb +62 -0
- data/lib/twitter/null_object.rb +5 -0
- data/lib/twitter/rest/api.rb +2 -0
- data/lib/twitter/rest/client.rb +14 -69
- data/lib/twitter/rest/direct_messages.rb +4 -5
- data/lib/twitter/rest/favorites.rb +3 -4
- data/lib/twitter/rest/friends_and_followers.rb +12 -12
- data/lib/twitter/rest/help.rb +5 -5
- data/lib/twitter/rest/lists.rb +21 -21
- data/lib/twitter/rest/media.rb +4 -3
- data/lib/twitter/rest/oauth.rb +4 -4
- data/lib/twitter/rest/places_and_geo.rb +4 -5
- data/lib/twitter/rest/request.rb +44 -0
- data/lib/twitter/rest/request/multipart_with_file.rb +1 -1
- data/lib/twitter/rest/saved_searches.rb +4 -5
- data/lib/twitter/rest/search.rb +3 -4
- data/lib/twitter/rest/spam_reporting.rb +0 -1
- data/lib/twitter/rest/suggested_users.rb +3 -4
- data/lib/twitter/rest/timelines.rb +3 -4
- data/lib/twitter/rest/trends.rb +4 -4
- data/lib/twitter/rest/tweets.rb +10 -12
- data/lib/twitter/rest/undocumented.rb +2 -2
- data/lib/twitter/rest/users.rb +19 -21
- data/lib/twitter/rest/utils.rb +66 -17
- data/lib/twitter/search_results.rb +5 -5
- data/lib/twitter/streaming/client.rb +4 -2
- data/lib/twitter/user.rb +0 -1
- data/lib/twitter/version.rb +1 -1
- metadata +4 -3
- data/lib/twitter/request.rb +0 -47
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5ac32438db7519853d565182ecedbd9e7415fe2e
|
4
|
+
data.tar.gz: 490c6967d1ad7cbc9242274dd81fbd3e053705b0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a19f77b9d88cf2aa0a62e8c73a409e53a5d408905532ea1cfe962cbd51860a5197111595095fcd1aa7bf9dbc8f87528a104b81f4bfaa78df8a74e954f7adfc06
|
7
|
+
data.tar.gz: 55f3dab2b04e6685fe6cc3b831870680eac59637590d8d04543f85b2a4b8cdea8e37d14a45e66eda23827171b749bde6091e082ab7f2ca854da711d093bcd5c0
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,13 @@
|
|
1
|
+
5.13.0
|
2
|
+
------
|
3
|
+
* [Deprecate `Twitter::REST::Client#get` and `Twitter::REST::Client#post`](https://github.com/sferik/twitter/commit/65773c7d741098490f4164fae9e4433365cd4292)
|
4
|
+
* [Rename `Twitter::REST::Client::URL_PREFIX` to `Twitter::REST::Client::BASE_URL`](https://github.com/sferik/twitter/commit/73e2b9be19acf1403f324e5be48a550d3756d822)
|
5
|
+
* [Extract `Twitter::Headers` class](https://github.com/sferik/twitter/commit/e0d4c36bade95253b98b3ee657af409bfeadbbb6)
|
6
|
+
* [Move `Twitter::Request` to `Twitter::REST::Request`](https://github.com/sferik/twitter/commit/a46d9f21067724c437d40c7cb9c609f6cd304df1)
|
7
|
+
* [Add `Twitter::REST::Request#rate_limit`](https://github.com/sferik/twitter/commit/0c9f9d6a15835a0260a5a56a8aaffdc3f3e39eed)
|
8
|
+
* [Rename `Twitter::REST::Utils` methods](https://github.com/sferik/twitter/commit/2b1cceca0d37a038d3afd0b5763f2308b3db1b2d)
|
9
|
+
* [Update default `User-Agent` to comply with Section 5.5.3 of RFC 7231](https://github.com/sferik/twitter/commit/e5eb8d451d8be2d2751e6dda132c65039e5c879c)
|
10
|
+
|
1
11
|
5.12.0
|
2
12
|
------
|
3
13
|
* [Rescue `Twitter::Error::NotFound` for safe `#favorite` and `#retweet`](https://github.com/sferik/twitter/commit/5e6223df20217fd6b0ac78b44b0defdb46d1e018)
|
data/lib/twitter/base.rb
CHANGED
@@ -85,7 +85,7 @@ module Twitter
|
|
85
85
|
# @param key2 [Symbol]
|
86
86
|
def define_attribute_method(key1, klass = nil, key2 = nil)
|
87
87
|
define_method(key1) do ||
|
88
|
-
if
|
88
|
+
if attr_falsey_or_empty?(key1)
|
89
89
|
NullObject.new
|
90
90
|
else
|
91
91
|
if klass.nil?
|
@@ -114,7 +114,7 @@ module Twitter
|
|
114
114
|
# @param key2 [Symbol]
|
115
115
|
def define_predicate_method(key1, key2 = key1)
|
116
116
|
define_method(:"#{key1}?") do ||
|
117
|
-
|
117
|
+
!attr_falsey_or_empty?(key2)
|
118
118
|
end
|
119
119
|
memoize(:"#{key1}?")
|
120
120
|
end
|
@@ -140,6 +140,10 @@ module Twitter
|
|
140
140
|
|
141
141
|
private
|
142
142
|
|
143
|
+
def attr_falsey_or_empty?(key)
|
144
|
+
@attrs[key].nil? || @attrs[key] == false || @attrs[key].respond_to?(:empty?) && @attrs[key].empty?
|
145
|
+
end
|
146
|
+
|
143
147
|
def attrs_for_object(key1, key2 = nil)
|
144
148
|
if key2.nil?
|
145
149
|
@attrs[key1]
|
data/lib/twitter/client.rb
CHANGED
@@ -1,5 +1,3 @@
|
|
1
|
-
require 'addressable/uri'
|
2
|
-
require 'simple_oauth'
|
3
1
|
require 'twitter/error'
|
4
2
|
require 'twitter/utils'
|
5
3
|
require 'twitter/version'
|
@@ -23,7 +21,7 @@ module Twitter
|
|
23
21
|
instance_variable_set("@#{key}", value)
|
24
22
|
end
|
25
23
|
yield(self) if block_given?
|
26
|
-
|
24
|
+
validate_credentials!
|
27
25
|
end
|
28
26
|
|
29
27
|
# @return [Boolean]
|
@@ -33,7 +31,7 @@ module Twitter
|
|
33
31
|
|
34
32
|
# @return [String]
|
35
33
|
def user_agent
|
36
|
-
@user_agent ||= "
|
34
|
+
@user_agent ||= "TwitterRubyGem/#{Twitter::Version}"
|
37
35
|
end
|
38
36
|
|
39
37
|
# @return [Hash]
|
@@ -59,16 +57,11 @@ module Twitter
|
|
59
57
|
#
|
60
58
|
# @raise [Twitter::Error::ConfigurationError] Error is raised when
|
61
59
|
# supplied twitter credentials are not a String or Boolean.
|
62
|
-
def
|
60
|
+
def validate_credentials!
|
63
61
|
credentials.each do |credential, value|
|
64
62
|
next if value.nil? || value == true || value == false || value.is_a?(String)
|
65
|
-
fail(Twitter::Error::ConfigurationError.new("Invalid #{credential} specified: #{value.inspect} must be a
|
63
|
+
fail(Twitter::Error::ConfigurationError.new("Invalid #{credential} specified: #{value.inspect} must be a String."))
|
66
64
|
end
|
67
65
|
end
|
68
|
-
|
69
|
-
def oauth_auth_header(method, uri, params = {})
|
70
|
-
uri = Addressable::URI.parse(uri)
|
71
|
-
SimpleOAuth::Header.new(method, uri, params, credentials)
|
72
|
-
end
|
73
66
|
end
|
74
67
|
end
|
data/lib/twitter/cursor.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'twitter/enumerable'
|
2
|
+
require 'twitter/rest/request'
|
2
3
|
require 'twitter/utils'
|
3
4
|
|
4
5
|
module Twitter
|
@@ -13,12 +14,11 @@ module Twitter
|
|
13
14
|
|
14
15
|
# Initializes a new Cursor
|
15
16
|
#
|
16
|
-
# @param attrs [Hash]
|
17
17
|
# @param key [String, Symbol] The key to fetch the data from the response
|
18
18
|
# @param klass [Class] The class to instantiate objects in the response
|
19
|
-
# @param request [Twitter::Request]
|
19
|
+
# @param request [Twitter::REST::Request]
|
20
20
|
# @return [Twitter::Cursor]
|
21
|
-
def initialize(
|
21
|
+
def initialize(key, klass, request)
|
22
22
|
@key = key.to_sym
|
23
23
|
@klass = klass
|
24
24
|
@client = request.client
|
@@ -26,7 +26,7 @@ module Twitter
|
|
26
26
|
@path = request.path
|
27
27
|
@options = request.options
|
28
28
|
@collection = []
|
29
|
-
self.attrs =
|
29
|
+
self.attrs = request.perform
|
30
30
|
end
|
31
31
|
|
32
32
|
private
|
@@ -44,7 +44,7 @@ module Twitter
|
|
44
44
|
|
45
45
|
# @return [Hash]
|
46
46
|
def fetch_next_page
|
47
|
-
response =
|
47
|
+
response = Twitter::REST::Request.new(@client, @request_method, @path, @options.merge(:cursor => next_cursor)).perform
|
48
48
|
self.attrs = response
|
49
49
|
end
|
50
50
|
|
@@ -0,0 +1,62 @@
|
|
1
|
+
require 'addressable/uri'
|
2
|
+
require 'base64'
|
3
|
+
require 'simple_oauth'
|
4
|
+
|
5
|
+
module Twitter
|
6
|
+
class Headers
|
7
|
+
def initialize(client, request_method, url, options = {})
|
8
|
+
@client = client
|
9
|
+
@request_method = request_method.to_sym
|
10
|
+
@uri = Addressable::URI.parse(url)
|
11
|
+
@options = options
|
12
|
+
@signature_options = @request_method == :post && @options.values.any? { |value| value.respond_to?(:to_io) } ? {} : @options
|
13
|
+
end
|
14
|
+
|
15
|
+
def oauth_auth_header
|
16
|
+
SimpleOAuth::Header.new(@request_method, @uri, @signature_options, @client.credentials)
|
17
|
+
end
|
18
|
+
|
19
|
+
def request_headers
|
20
|
+
bearer_token_request = @options.delete(:bearer_token_request)
|
21
|
+
headers = {}
|
22
|
+
if bearer_token_request
|
23
|
+
headers[:accept] = '*/*'
|
24
|
+
headers[:authorization] = bearer_token_credentials_auth_header
|
25
|
+
headers[:content_type] = 'application/x-www-form-urlencoded; charset=UTF-8'
|
26
|
+
else
|
27
|
+
headers[:authorization] = auth_header
|
28
|
+
end
|
29
|
+
headers
|
30
|
+
end
|
31
|
+
|
32
|
+
private
|
33
|
+
|
34
|
+
def auth_header
|
35
|
+
if @client.user_token?
|
36
|
+
oauth_auth_header.to_s
|
37
|
+
else
|
38
|
+
@client.bearer_token = @client.token unless @client.bearer_token?
|
39
|
+
bearer_auth_header
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def bearer_auth_header
|
44
|
+
bearer_token = @client.bearer_token
|
45
|
+
token = bearer_token.is_a?(Twitter::Token) && bearer_token.bearer? ? bearer_token.access_token : bearer_token
|
46
|
+
"Bearer #{token}"
|
47
|
+
end
|
48
|
+
|
49
|
+
# Generates authentication header for a bearer token request
|
50
|
+
#
|
51
|
+
# @return [String]
|
52
|
+
def bearer_token_credentials_auth_header
|
53
|
+
basic_auth_token = strict_encode64("#{@client.consumer_key}:#{@client.consumer_secret}")
|
54
|
+
"Basic #{basic_auth_token}"
|
55
|
+
end
|
56
|
+
|
57
|
+
# Base64.strict_encode64 is not available on Ruby 1.8.7
|
58
|
+
def strict_encode64(str)
|
59
|
+
Base64.encode64(str).gsub("\n", '')
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
data/lib/twitter/null_object.rb
CHANGED
@@ -9,6 +9,11 @@ module Twitter
|
|
9
9
|
config.define_implicit_conversions
|
10
10
|
config.predicates_return false
|
11
11
|
|
12
|
+
# TODO: Add when support for Ruby 1.8.7 is dropped
|
13
|
+
# def !
|
14
|
+
# true
|
15
|
+
# end
|
16
|
+
|
12
17
|
def instance_of?(klass)
|
13
18
|
fail(TypeError.new('class or module required')) unless klass.is_a?(Class)
|
14
19
|
self.class == klass
|
data/lib/twitter/rest/api.rb
CHANGED
@@ -18,6 +18,8 @@ require 'twitter/rest/users'
|
|
18
18
|
|
19
19
|
module Twitter
|
20
20
|
module REST
|
21
|
+
# @note All methods have been separated into modules and follow the same grouping used in {http://dev.twitter.com/doc the Twitter API Documentation}.
|
22
|
+
# @see https://dev.twitter.com/overview/general/things-every-developer-should-know
|
21
23
|
module API
|
22
24
|
include Twitter::REST::DirectMessages
|
23
25
|
include Twitter::REST::Favorites
|
data/lib/twitter/rest/client.rb
CHANGED
@@ -1,31 +1,26 @@
|
|
1
|
-
require 'base64'
|
2
1
|
require 'faraday'
|
3
2
|
require 'faraday/request/multipart'
|
4
|
-
require 'json'
|
5
|
-
require 'timeout'
|
6
3
|
require 'twitter/client'
|
7
|
-
require 'twitter/error'
|
8
4
|
require 'twitter/rest/api'
|
5
|
+
require 'twitter/rest/request'
|
9
6
|
require 'twitter/rest/request/multipart_with_file'
|
10
7
|
require 'twitter/rest/response/parse_json'
|
11
8
|
require 'twitter/rest/response/raise_error'
|
9
|
+
require 'twitter/rest/utils'
|
12
10
|
|
13
11
|
module Twitter
|
14
12
|
module REST
|
15
|
-
# Wrapper for the Twitter REST API
|
16
|
-
#
|
17
|
-
# @note All methods have been separated into modules and follow the same grouping used in {http://dev.twitter.com/doc the Twitter API Documentation}.
|
18
|
-
# @see http://dev.twitter.com/pages/every_developer
|
19
13
|
class Client < Twitter::Client
|
20
14
|
include Twitter::REST::API
|
15
|
+
BASE_URL = 'https://api.twitter.com'
|
16
|
+
URL_PREFIX = BASE_URL
|
17
|
+
ENDPOINT = BASE_URL
|
21
18
|
attr_accessor :bearer_token
|
22
|
-
URL_PREFIX = 'https://api.twitter.com'
|
23
|
-
ENDPOINT = URL_PREFIX
|
24
19
|
|
25
20
|
# @param connection_options [Hash]
|
26
21
|
# @return [Hash]
|
27
22
|
def connection_options=(connection_options)
|
28
|
-
warn "#{Kernel.caller.first}: [DEPRECATION]
|
23
|
+
warn "#{Kernel.caller.first}: [DEPRECATION] #{self.class.name}##{__method__} is deprecated and will be removed."
|
29
24
|
@connection_options = connection_options
|
30
25
|
end
|
31
26
|
|
@@ -48,7 +43,7 @@ module Twitter
|
|
48
43
|
# @params middleware [Faraday::RackBuilder]
|
49
44
|
# @return [Faraday::RackBuilder]
|
50
45
|
def middleware=(middleware)
|
51
|
-
warn "#{Kernel.caller.first}: [DEPRECATION]
|
46
|
+
warn "#{Kernel.caller.first}: [DEPRECATION] #{self.class.name}##{__method__} is deprecated and will be removed."
|
52
47
|
@middleware = middleware
|
53
48
|
end
|
54
49
|
|
@@ -74,15 +69,15 @@ module Twitter
|
|
74
69
|
end
|
75
70
|
|
76
71
|
# Perform an HTTP GET request
|
77
|
-
def get(path,
|
78
|
-
|
79
|
-
|
72
|
+
def get(path, options = {})
|
73
|
+
warn "#{Kernel.caller.first}: [DEPRECATION] #{self.class.name}##{__method__} is deprecated. Use Twitter::REST::Request#perform instead."
|
74
|
+
perform_get(path, options)
|
80
75
|
end
|
81
76
|
|
82
77
|
# Perform an HTTP POST request
|
83
|
-
def post(path,
|
84
|
-
|
85
|
-
|
78
|
+
def post(path, options = {})
|
79
|
+
warn "#{Kernel.caller.first}: [DEPRECATION] #{self.class.name}##{__method__} is deprecated. Use Twitter::REST::Request#perform instead."
|
80
|
+
perform_post(path, options)
|
86
81
|
end
|
87
82
|
|
88
83
|
# @return [Boolean]
|
@@ -95,61 +90,11 @@ module Twitter
|
|
95
90
|
super || bearer_token?
|
96
91
|
end
|
97
92
|
|
98
|
-
private
|
99
|
-
|
100
93
|
# Returns a Faraday::Connection object
|
101
94
|
#
|
102
95
|
# @return [Faraday::Connection]
|
103
96
|
def connection
|
104
|
-
@connection ||= Faraday.new(
|
105
|
-
end
|
106
|
-
|
107
|
-
def request(method, path, params = {}, headers = {})
|
108
|
-
connection.send(method.to_sym, path, params) { |request| request.headers.update(headers) }.env
|
109
|
-
rescue Faraday::Error::TimeoutError, Timeout::Error => error
|
110
|
-
raise(Twitter::Error::RequestTimeout.new(error))
|
111
|
-
rescue Faraday::Error::ClientError, JSON::ParserError => error
|
112
|
-
raise(Twitter::Error.new(error))
|
113
|
-
end
|
114
|
-
|
115
|
-
def request_headers(method, url, params = {}, signature_params = params)
|
116
|
-
bearer_token_request = params.delete(:bearer_token_request)
|
117
|
-
headers = {}
|
118
|
-
if bearer_token_request
|
119
|
-
headers[:accept] = '*/*'
|
120
|
-
headers[:authorization] = bearer_token_credentials_auth_header
|
121
|
-
headers[:content_type] = 'application/x-www-form-urlencoded; charset=UTF-8'
|
122
|
-
else
|
123
|
-
headers[:authorization] = auth_header(method, url, params, signature_params)
|
124
|
-
end
|
125
|
-
headers
|
126
|
-
end
|
127
|
-
|
128
|
-
def auth_header(method, url, params = {}, signature_params = params)
|
129
|
-
if !user_token?
|
130
|
-
@bearer_token = token unless bearer_token?
|
131
|
-
bearer_auth_header
|
132
|
-
else
|
133
|
-
oauth_auth_header(method, url, signature_params).to_s
|
134
|
-
end
|
135
|
-
end
|
136
|
-
|
137
|
-
# Generates authentication header for a bearer token request
|
138
|
-
#
|
139
|
-
# @return [String]
|
140
|
-
def bearer_token_credentials_auth_header
|
141
|
-
basic_auth_token = strict_encode64("#{@consumer_key}:#{@consumer_secret}")
|
142
|
-
"Basic #{basic_auth_token}"
|
143
|
-
end
|
144
|
-
|
145
|
-
def bearer_auth_header
|
146
|
-
token = bearer_token.is_a?(Twitter::Token) && bearer_token.bearer? ? bearer_token.access_token : bearer_token
|
147
|
-
"Bearer #{token}"
|
148
|
-
end
|
149
|
-
|
150
|
-
# Base64.strict_encode64 is not available on Ruby 1.8.7
|
151
|
-
def strict_encode64(str)
|
152
|
-
Base64.encode64(str).gsub("\n", '')
|
97
|
+
@connection ||= Faraday.new(BASE_URL, connection_options)
|
153
98
|
end
|
154
99
|
end
|
155
100
|
end
|
@@ -1,6 +1,5 @@
|
|
1
1
|
require 'twitter/arguments'
|
2
2
|
require 'twitter/direct_message'
|
3
|
-
require 'twitter/request'
|
4
3
|
require 'twitter/rest/utils'
|
5
4
|
require 'twitter/user'
|
6
5
|
require 'twitter/utils'
|
@@ -25,7 +24,7 @@ module Twitter
|
|
25
24
|
# @option options [Integer] :count Specifies the number of records to retrieve. Must be less than or equal to 200.
|
26
25
|
# @option options [Integer] :page Specifies the page of results to retrieve.
|
27
26
|
def direct_messages_received(options = {})
|
28
|
-
|
27
|
+
perform_get_with_objects('/1.1/direct_messages.json', options, Twitter::DirectMessage)
|
29
28
|
end
|
30
29
|
|
31
30
|
# Returns the 20 most recent direct messages sent by the authenticating user
|
@@ -42,7 +41,7 @@ module Twitter
|
|
42
41
|
# @option options [Integer] :count Specifies the number of records to retrieve. Must be less than or equal to 200.
|
43
42
|
# @option options [Integer] :page Specifies the page of results to retrieve.
|
44
43
|
def direct_messages_sent(options = {})
|
45
|
-
|
44
|
+
perform_get_with_objects('/1.1/direct_messages/sent.json', options, Twitter::DirectMessage)
|
46
45
|
end
|
47
46
|
|
48
47
|
# Returns a direct message
|
@@ -57,7 +56,7 @@ module Twitter
|
|
57
56
|
# @param options [Hash] A customizable set of options.
|
58
57
|
def direct_message(id, options = {})
|
59
58
|
options[:id] = id
|
60
|
-
|
59
|
+
perform_get_with_object('/1.1/direct_messages/show.json', options, Twitter::DirectMessage)
|
61
60
|
end
|
62
61
|
|
63
62
|
# @note This method requires an access token with RWD (read, write & direct message) permissions. Consult The Application Permission Model for more information.
|
@@ -127,7 +126,7 @@ module Twitter
|
|
127
126
|
def create_direct_message(user, text, options = {})
|
128
127
|
merge_user!(options, user)
|
129
128
|
options[:text] = text
|
130
|
-
|
129
|
+
perform_post_with_object('/1.1/direct_messages/new.json', options, Twitter::DirectMessage)
|
131
130
|
end
|
132
131
|
alias_method :d, :create_direct_message
|
133
132
|
alias_method :m, :create_direct_message
|
@@ -1,6 +1,5 @@
|
|
1
1
|
require 'twitter/arguments'
|
2
2
|
require 'twitter/error'
|
3
|
-
require 'twitter/request'
|
4
3
|
require 'twitter/rest/utils'
|
5
4
|
require 'twitter/tweet'
|
6
5
|
require 'twitter/user'
|
@@ -33,7 +32,7 @@ module Twitter
|
|
33
32
|
def favorites(*args)
|
34
33
|
arguments = Twitter::Arguments.new(args)
|
35
34
|
merge_user!(arguments.options, arguments.pop) if arguments.last
|
36
|
-
|
35
|
+
perform_get_with_objects('/1.1/favorites/list.json', arguments.options, Twitter::Tweet)
|
37
36
|
end
|
38
37
|
|
39
38
|
# Un-favorites the specified Tweets as the authenticating user
|
@@ -70,7 +69,7 @@ module Twitter
|
|
70
69
|
arguments = Twitter::Arguments.new(args)
|
71
70
|
pmap(arguments) do |tweet|
|
72
71
|
begin
|
73
|
-
|
72
|
+
perform_post_with_object('/1.1/favorites/create.json', arguments.options.merge(:id => extract_id(tweet)), Twitter::Tweet)
|
74
73
|
rescue Twitter::Error::AlreadyFavorited, Twitter::Error::NotFound
|
75
74
|
next
|
76
75
|
end
|
@@ -97,7 +96,7 @@ module Twitter
|
|
97
96
|
def favorite!(*args)
|
98
97
|
arguments = Twitter::Arguments.new(args)
|
99
98
|
pmap(arguments) do |tweet|
|
100
|
-
|
99
|
+
perform_post_with_object('/1.1/favorites/create.json', arguments.options.merge(:id => extract_id(tweet)), Twitter::Tweet)
|
101
100
|
end
|
102
101
|
end
|
103
102
|
alias_method :create_favorite!, :favorite!
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'twitter/arguments'
|
2
2
|
require 'twitter/cursor'
|
3
3
|
require 'twitter/relationship'
|
4
|
-
require 'twitter/request'
|
4
|
+
require 'twitter/rest/request'
|
5
5
|
require 'twitter/rest/utils'
|
6
6
|
require 'twitter/user'
|
7
7
|
require 'twitter/utils'
|
@@ -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/docs/api/1.1/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
|
-
|
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
|
-
|
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
|
-
|
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
|
@@ -132,7 +132,7 @@ module Twitter
|
|
132
132
|
def follow!(*args)
|
133
133
|
arguments = Twitter::Arguments.new(args)
|
134
134
|
pmap(arguments) do |user|
|
135
|
-
|
135
|
+
perform_post_with_object('/1.1/friendships/create.json', merge_user(arguments.options, user), Twitter::User)
|
136
136
|
end.compact
|
137
137
|
end
|
138
138
|
alias_method :create_friendship!, :follow!
|
@@ -169,7 +169,7 @@ module Twitter
|
|
169
169
|
# @option options [Boolean] :retweets Enable/disable retweets from the target user.
|
170
170
|
def friendship_update(user, options = {})
|
171
171
|
merge_user!(options, user)
|
172
|
-
|
172
|
+
perform_post_with_object('/1.1/friendships/update.json', options, Twitter::Relationship)
|
173
173
|
end
|
174
174
|
|
175
175
|
# Returns detailed information about the relationship between two users
|
@@ -187,7 +187,7 @@ module Twitter
|
|
187
187
|
options[:source_id] = options.delete(:source_user_id) unless options[:source_user_id].nil?
|
188
188
|
merge_user!(options, target, 'target')
|
189
189
|
options[:target_id] = options.delete(:target_user_id) unless options[:target_user_id].nil?
|
190
|
-
|
190
|
+
perform_get_with_object('/1.1/friendships/show.json', options, Twitter::Relationship)
|
191
191
|
end
|
192
192
|
alias_method :friendship_show, :friendship
|
193
193
|
alias_method :relationship, :friendship
|
@@ -227,7 +227,7 @@ module Twitter
|
|
227
227
|
# @option options [Boolean, String, Integer] :skip_status Do not include contributee's Tweets when set to true, 't' or 1.
|
228
228
|
# @option options [Boolean, String, Integer] :include_user_entities The user entities node will be disincluded when set to false.
|
229
229
|
def followers(*args)
|
230
|
-
cursor_from_response_with_user(:users, Twitter::User,
|
230
|
+
cursor_from_response_with_user(:users, Twitter::User, '/1.1/followers/list.json', args)
|
231
231
|
end
|
232
232
|
|
233
233
|
# Returns a cursored collection of user objects for every user the specified user is following (otherwise known as their "friends").
|
@@ -251,7 +251,7 @@ module Twitter
|
|
251
251
|
# @option options [Boolean, String, Integer] :skip_status Do not include contributee's Tweets when set to true, 't' or 1.
|
252
252
|
# @option options [Boolean, String, Integer] :include_user_entities The user entities node will be disincluded when set to false.
|
253
253
|
def friends(*args)
|
254
|
-
cursor_from_response_with_user(:users, Twitter::User,
|
254
|
+
cursor_from_response_with_user(:users, Twitter::User, '/1.1/friends/list.json', args)
|
255
255
|
end
|
256
256
|
alias_method :following, :friends
|
257
257
|
|
@@ -263,7 +263,7 @@ module Twitter
|
|
263
263
|
# @return [Array<Integer>]
|
264
264
|
# @param options [Hash] A customizable set of options.
|
265
265
|
def no_retweet_ids(options = {})
|
266
|
-
|
266
|
+
perform_get('/1.1/friendships/no_retweets/ids.json', options).collect(&:to_i)
|
267
267
|
end
|
268
268
|
alias_method :no_retweets_ids, :no_retweet_ids
|
269
269
|
end
|