twitter 5.8.0 → 5.9.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 +18 -0
- data/README.md +10 -36
- data/lib/twitter/base.rb +20 -3
- data/lib/twitter/basic_user.rb +6 -4
- data/lib/twitter/client.rb +2 -1
- data/lib/twitter/configuration.rb +1 -1
- data/lib/twitter/cursor.rb +1 -1
- data/lib/twitter/entities.rb +10 -6
- data/lib/twitter/enumerable.rb +2 -2
- data/lib/twitter/error.rb +7 -0
- data/lib/twitter/geo_results.rb +1 -1
- data/lib/twitter/list.rb +3 -2
- data/lib/twitter/media/photo.rb +1 -1
- data/lib/twitter/place.rb +13 -15
- data/lib/twitter/profile.rb +1 -1
- data/lib/twitter/profile_banner.rb +1 -1
- data/lib/twitter/rest/client.rb +17 -2
- data/lib/twitter/rest/friends_and_followers.rb +1 -1
- data/lib/twitter/rest/lists.rb +4 -2
- data/lib/twitter/rest/spam_reporting.rb +1 -1
- data/lib/twitter/rest/tweets.rb +17 -17
- data/lib/twitter/rest/users.rb +77 -13
- data/lib/twitter/rest/utils.rb +10 -6
- data/lib/twitter/search_results.rb +1 -1
- data/lib/twitter/settings.rb +4 -3
- data/lib/twitter/source_user.rb +3 -2
- data/lib/twitter/streaming/client.rb +7 -2
- data/lib/twitter/streaming/connection.rb +9 -2
- data/lib/twitter/streaming/response.rb +3 -3
- data/lib/twitter/suggestion.rb +1 -1
- data/lib/twitter/target_user.rb +1 -1
- data/lib/twitter/trend.rb +2 -1
- data/lib/twitter/trend_results.rb +1 -1
- data/lib/twitter/tweet.rb +4 -4
- data/lib/twitter/user.rb +60 -19
- data/lib/twitter/utils.rb +12 -5
- data/lib/twitter/version.rb +1 -1
- data/spec/fixtures/following.json +1 -1
- data/spec/fixtures/sferik.json +1 -1
- data/spec/helper.rb +14 -5
- data/spec/twitter/base_spec.rb +16 -4
- data/spec/twitter/direct_message_spec.rb +12 -13
- data/spec/twitter/entity/uri_spec.rb +2 -2
- data/spec/twitter/error_spec.rb +2 -2
- data/spec/twitter/media/photo_spec.rb +4 -4
- data/spec/twitter/oembed_spec.rb +3 -3
- data/spec/twitter/place_spec.rb +1 -1
- data/spec/twitter/rest/client_spec.rb +54 -14
- data/spec/twitter/rest/friends_and_followers_spec.rb +76 -76
- data/spec/twitter/rest/lists_spec.rb +85 -64
- data/spec/twitter/rest/timelines_spec.rb +2 -2
- data/spec/twitter/rest/tweets_spec.rb +20 -16
- data/spec/twitter/rest/undocumented_spec.rb +17 -17
- data/spec/twitter/rest/users_spec.rb +101 -17
- data/spec/twitter/streaming/client_spec.rb +1 -1
- data/spec/twitter/streaming/connection_spec.rb +32 -0
- data/spec/twitter/streaming/response_spec.rb +21 -0
- data/spec/twitter/trend_spec.rb +1 -1
- data/spec/twitter/tweet_spec.rb +14 -23
- data/spec/twitter/user_spec.rb +120 -13
- data/twitter.gemspec +3 -3
- metadata +8 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 35ccffc8468f91442ccd9eeebff411dbebf92b0a
|
4
|
+
data.tar.gz: cca2da3dc5ddff38608dbd836c3d159e4477bbe2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ef86cf848faf9325291bc7ab2405f925bbb9f187f53765d969b173cc5ec340b3252ced4ca6f5bd3257aec418414b8ebf98dc2c645bf5ae200148ac735f63463c
|
7
|
+
data.tar.gz: 81f7b4ae2818191008017355e69d1476413055b4e87f9a1c1953445aeacfc5e2267e3b255e6f403a4f41131b19f4268eaa8a058d5ba0648d735318040b7f5a60
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,21 @@
|
|
1
|
+
5.9.0
|
2
|
+
-----
|
3
|
+
* [Use expanded URIs when available](https://github.com/sferik/twitter/commit/f1d5d1f4c0ea75ebeaf9e7eb760b9efd245a5df2)
|
4
|
+
* [Deprecate `Twitter::REST::Client#middleware=` and `#connection_options`](https://github.com/sferik/twitter/commit/71b0a38670102841fda9642de586e6cb67d33083)
|
5
|
+
* [Ensure predicate methods return `false` for `Twitter::NullObject`](https://github.com/sferik/twitter/commit/f1b42bf82440f2dc0ba61761fc8f12460e20aadf)
|
6
|
+
* [Make `Twitter::Place#id` attribute accessible](https://github.com/sferik/twitter/commit/a4fa4739283a325886d44f97b2648e3b00f933b1)
|
7
|
+
* [Enable injection of custom TCP/SSL socket classes](https://github.com/sferik/twitter/commit/3629a1edfbc6b35099d4b0fc165b938a67c02d86) ([@neektza](https://twitter.com/neektza))
|
8
|
+
* [Deprecate predicate methods without question marks](https://github.com/sferik/twitter/commit/0305a8535357b6114be73e6b94744eed6b6d3bb5)
|
9
|
+
* [Deprecate `Twitter::Base#[]`](https://github.com/sferik/twitter/commit/2ab6c0d546b7c1d3635ac9c319fb5c2aa2514da0)
|
10
|
+
* [Remove statement that TweetStream is not 2.0.0-compatible](https://github.com/sferik/twitter/pull/553) ([@melaniegilman](https://twitter.com/melaniegilman))
|
11
|
+
* [Dont allow unacceptable IO objects in `Twitter::REST::Client#update_with_media`](https://github.com/sferik/twitter/commit/f22f1e2efd29200f157af041a470678cd4ef637a) ([@tim_linquist](https://twitter.com/tim_linquist))
|
12
|
+
* [Add support for new REST API endpoint for bulk lookup of Tweets by ID](https://github.com/sferik/twitter/commit/0d23c5ed65a7e7728cd096d611e5edeecdbc6e79)
|
13
|
+
* [Make the streaming API raise exceptions for status codes](https://github.com/sferik/twitter/commit/b571e03ed18cd63ec1d1a57c03e5744b284111d6) ([@eroberts](https://twitter.com/eroberts))
|
14
|
+
* [Call GET users/show if screen name has already been fetched](https://github.com/sferik/twitter/commit/0691a62ca5b43d33aa2f7b63aeb039d9155a24ed)
|
15
|
+
* [Add the ability to set user_agent and proxy](https://github.com/sferik/twitter/commit/e72185e1b0299221448650760b91c74ff1bec3e7)
|
16
|
+
* [Use (immutable) user ID instead of (mutable) screen name](https://github.com/sferik/twitter/commit/ceeccb08bbc7cc65c3e6eddaf408b236b8a98677)
|
17
|
+
* [Implement mute functionality](https://github.com/sferik/twitter/commit/dfe206cae5f2189ce2b5cd5db6307d5d5e8af4ef)
|
18
|
+
|
1
19
|
5.8.0
|
2
20
|
-----
|
3
21
|
* [Alias `Twitter::Tweet#reply?` to `Twitter::Tweet#in_reply_to_user_id?`](https://github.com/sferik/twitter/commit/57147287d25e21a5e740ee69c3e9aeec6abd1b06)
|
data/README.md
CHANGED
@@ -76,13 +76,10 @@ is now `access_token_secret` to conform to the terminology used in Twitter's
|
|
76
76
|
developer documentation.
|
77
77
|
|
78
78
|
### Streaming (Experimental)
|
79
|
-
This library now offers support for the [Twitter Streaming API][streaming].
|
80
|
-
previously recommended using [TweetStream][] for this, however [TweetStream
|
81
|
-
does not work on Ruby 2.0.0][bug].
|
79
|
+
This library now offers support for the [Twitter Streaming API][streaming].
|
82
80
|
|
83
81
|
[streaming]: https://dev.twitter.com/docs/streaming-apis
|
84
82
|
[tweetstream]: http://rubygems.org/gems/tweetstream
|
85
|
-
[bug]: https://github.com/tweetstream/tweetstream/issues/117
|
86
83
|
|
87
84
|
Site Streams are restricted to whitelisted accounts. To apply for access,
|
88
85
|
[follow the steps in the Site Streams documentation][site-streams]. [User
|
@@ -92,10 +89,9 @@ Streams][user-streams] do not require prior approval.
|
|
92
89
|
[user-streams]: https://dev.twitter.com/docs/streaming-apis/streams/user
|
93
90
|
|
94
91
|
Unlike the rest of this library, this feature is not well tested and not
|
95
|
-
recommended for production applications.
|
96
|
-
|
97
|
-
|
98
|
-
in this area are particularly welcome.
|
92
|
+
recommended for production applications. I've decided to ship it as an
|
93
|
+
experimental feature and make it more robust over time. Patches in this area are
|
94
|
+
particularly welcome.
|
99
95
|
|
100
96
|
Hopefully, by the time version 6 is released, this gem can fully replace
|
101
97
|
[TweetStream][], [em-twitter][], [twitterstream][], and [twitter-stream].
|
@@ -153,12 +149,12 @@ end
|
|
153
149
|
```
|
154
150
|
|
155
151
|
An `object` may be one of the following:
|
156
|
-
* Twitter::DirectMessage
|
157
|
-
* Twitter::Streaming::DeletedTweet
|
158
|
-
* Twitter::Streaming::Event
|
159
|
-
* Twitter::Streaming::FriendList
|
160
|
-
* Twitter::Streaming::StallWarning
|
161
|
-
* Twitter::Tweet
|
152
|
+
* `Twitter::DirectMessage`
|
153
|
+
* `Twitter::Streaming::DeletedTweet`
|
154
|
+
* `Twitter::Streaming::Event`
|
155
|
+
* `Twitter::Streaming::FriendList`
|
156
|
+
* `Twitter::Streaming::StallWarning`
|
157
|
+
* `Twitter::Tweet`
|
162
158
|
|
163
159
|
### Cursors
|
164
160
|
The `Twitter::Cursor` class has been completely redesigned with a focus on
|
@@ -388,11 +384,6 @@ at the beginning:
|
|
388
384
|
* `#saved_search_destroy` is now `#destroy_saved_search`
|
389
385
|
* `#status_destroy` is now `#destroy_status`
|
390
386
|
|
391
|
-
### Errors
|
392
|
-
The `Twitter::Error::ClientError` and `Twitter::Error::ServerError` class
|
393
|
-
hierarchy has been removed. All errors now inherit directly from
|
394
|
-
`Twitter::Error`.
|
395
|
-
|
396
387
|
### Null Objects
|
397
388
|
In version 4, methods you would expect to return a `Twitter` object would
|
398
389
|
return `nil` if that object was missing. This may have resulted in a
|
@@ -469,23 +460,6 @@ After configuration, requests can be made like so:
|
|
469
460
|
client.update("I'm tweeting with @gem!")
|
470
461
|
```
|
471
462
|
|
472
|
-
### Middleware
|
473
|
-
The Faraday middleware stack is fully configurable and is exposed as a
|
474
|
-
`Faraday::RackBuilder` object. You can modify the default middleware in-place:
|
475
|
-
|
476
|
-
```ruby
|
477
|
-
client.middleware.insert_after Twitter::Response::RaiseError, CustomMiddleware
|
478
|
-
```
|
479
|
-
|
480
|
-
A custom adapter may be set as part of a custom middleware stack:
|
481
|
-
|
482
|
-
```ruby
|
483
|
-
client.middleware = Faraday::RackBuilder.new do |faraday|
|
484
|
-
# Specify a middleware stack here
|
485
|
-
faraday.adapter :some_other_adapter
|
486
|
-
end
|
487
|
-
```
|
488
|
-
|
489
463
|
## Usage Examples
|
490
464
|
All examples require an authenticated Twitter client. See the section on <a
|
491
465
|
href="#configuration">configuration</a>.
|
data/lib/twitter/base.rb
CHANGED
@@ -25,6 +25,13 @@ module Twitter
|
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
28
|
+
def predicate_attr_reader(*attrs)
|
29
|
+
attrs.each do |attr|
|
30
|
+
define_predicate_method(attr)
|
31
|
+
deprecate_attribute_method(attr)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
28
35
|
# Define object methods from attributes
|
29
36
|
#
|
30
37
|
# @param klass [Symbol]
|
@@ -59,8 +66,6 @@ module Twitter
|
|
59
66
|
alias_method(:display_url?, :display_uri?)
|
60
67
|
end
|
61
68
|
|
62
|
-
private
|
63
|
-
|
64
69
|
# Dynamically define a method for a URI
|
65
70
|
#
|
66
71
|
# @param key1 [Symbol]
|
@@ -93,13 +98,24 @@ module Twitter
|
|
93
98
|
memoize(key1)
|
94
99
|
end
|
95
100
|
|
101
|
+
# Dynamically define a method for an attribute
|
102
|
+
#
|
103
|
+
# @param key [Symbol]
|
104
|
+
def deprecate_attribute_method(key)
|
105
|
+
define_method(key) do ||
|
106
|
+
warn "#{Kernel.caller.first}: [DEPRECATION] ##{key} is deprecated. Use ##{key}? instead."
|
107
|
+
@attrs[key]
|
108
|
+
end
|
109
|
+
memoize(key)
|
110
|
+
end
|
111
|
+
|
96
112
|
# Dynamically define a predicate method for an attribute
|
97
113
|
#
|
98
114
|
# @param key1 [Symbol]
|
99
115
|
# @param key2 [Symbol]
|
100
116
|
def define_predicate_method(key1, key2 = key1)
|
101
117
|
define_method(:"#{key1}?") do ||
|
102
|
-
|
118
|
+
!@attrs[key2].nil? && @attrs[key2] != false
|
103
119
|
end
|
104
120
|
memoize(:"#{key1}?")
|
105
121
|
end
|
@@ -117,6 +133,7 @@ module Twitter
|
|
117
133
|
#
|
118
134
|
# @param method [String, Symbol] Message to send to the object
|
119
135
|
def [](method)
|
136
|
+
warn "#{Kernel.caller.first}: [DEPRECATION] #[#{method.inspect}] is deprecated. Use ##{method} to fetch the value."
|
120
137
|
send(method.to_sym)
|
121
138
|
rescue NoMethodError
|
122
139
|
nil
|
data/lib/twitter/basic_user.rb
CHANGED
@@ -1,10 +1,12 @@
|
|
1
1
|
require 'twitter/identity'
|
2
|
+
require 'twitter/utils'
|
2
3
|
|
3
4
|
module Twitter
|
4
5
|
class BasicUser < Twitter::Identity
|
5
|
-
attr_reader :
|
6
|
-
|
7
|
-
|
8
|
-
|
6
|
+
attr_reader :screen_name
|
7
|
+
deprecate_alias :handle, :screen_name
|
8
|
+
deprecate_alias :username, :screen_name
|
9
|
+
deprecate_alias :user_name, :screen_name
|
10
|
+
predicate_attr_reader :following
|
9
11
|
end
|
10
12
|
end
|
data/lib/twitter/client.rb
CHANGED
@@ -7,7 +7,8 @@ require 'twitter/version'
|
|
7
7
|
module Twitter
|
8
8
|
class Client
|
9
9
|
include Twitter::Utils
|
10
|
-
attr_accessor :access_token, :access_token_secret, :consumer_key, :consumer_secret
|
10
|
+
attr_accessor :access_token, :access_token_secret, :consumer_key, :consumer_secret, :proxy
|
11
|
+
attr_writer :user_agent
|
11
12
|
deprecate_alias :oauth_token, :access_token
|
12
13
|
deprecate_alias :oauth_token=, :access_token=
|
13
14
|
deprecate_alias :oauth_token_secret, :access_token_secret
|
@@ -12,7 +12,7 @@ module Twitter
|
|
12
12
|
#
|
13
13
|
# @return [Array<Twitter::Size>]
|
14
14
|
def photo_sizes
|
15
|
-
|
15
|
+
@attrs.fetch(:photo_sizes, []).inject({}) do |object, (key, value)|
|
16
16
|
object[key] = Size.new(value)
|
17
17
|
object
|
18
18
|
end
|
data/lib/twitter/cursor.rb
CHANGED
data/lib/twitter/entities.rb
CHANGED
@@ -11,7 +11,7 @@ module Twitter
|
|
11
11
|
|
12
12
|
# @return [Boolean]
|
13
13
|
def entities?
|
14
|
-
!@attrs[:entities].nil? && @attrs[:entities].any? { |_, array|
|
14
|
+
!@attrs[:entities].nil? && @attrs[:entities].any? { |_, array| array.any? }
|
15
15
|
end
|
16
16
|
memoize :entities?
|
17
17
|
|
@@ -26,6 +26,7 @@ module Twitter
|
|
26
26
|
def hashtags?
|
27
27
|
hashtags.any?
|
28
28
|
end
|
29
|
+
memoize :hashtags?
|
29
30
|
|
30
31
|
# @note Must include entities in your request for this method to work
|
31
32
|
# @return [Array<Twitter::Media>]
|
@@ -38,6 +39,7 @@ module Twitter
|
|
38
39
|
def media?
|
39
40
|
media.any?
|
40
41
|
end
|
42
|
+
memoize :media?
|
41
43
|
|
42
44
|
# @note Must include entities in your request for this method to work
|
43
45
|
# @return [Array<Twitter::Entity::Symbol>]
|
@@ -50,6 +52,7 @@ module Twitter
|
|
50
52
|
def symbols?
|
51
53
|
symbols.any?
|
52
54
|
end
|
55
|
+
memoize :symbols?
|
53
56
|
|
54
57
|
# @note Must include entities in your request for this method to work
|
55
58
|
# @return [Array<Twitter::Entity::URI>]
|
@@ -76,19 +79,20 @@ module Twitter
|
|
76
79
|
def user_mentions?
|
77
80
|
user_mentions.any?
|
78
81
|
end
|
82
|
+
memoize :user_mentions?
|
79
83
|
|
80
84
|
private
|
81
85
|
|
82
86
|
# @param klass [Class]
|
83
87
|
# @param key [Symbol]
|
84
88
|
def entities(klass, key)
|
85
|
-
if
|
86
|
-
Array(@attrs[:entities][key.to_sym]).collect do |entity|
|
87
|
-
klass.new(entity)
|
88
|
-
end
|
89
|
-
else
|
89
|
+
if @attrs[:entities].nil?
|
90
90
|
warn "#{Kernel.caller.first}: To get #{key.to_s.tr('_', ' ')}, you must pass `:include_entities => true` when requesting the #{self.class}."
|
91
91
|
[]
|
92
|
+
else
|
93
|
+
@attrs[:entities].fetch(key.to_sym, []).collect do |entity|
|
94
|
+
klass.new(entity)
|
95
|
+
end
|
92
96
|
end
|
93
97
|
end
|
94
98
|
end
|
data/lib/twitter/enumerable.rb
CHANGED
@@ -3,7 +3,7 @@ module Twitter
|
|
3
3
|
include ::Enumerable
|
4
4
|
|
5
5
|
# @return [Enumerator]
|
6
|
-
def each(start = 0
|
6
|
+
def each(start = 0)
|
7
7
|
return to_enum(:each, start) unless block_given?
|
8
8
|
Array(@collection[start..-1]).each do |element|
|
9
9
|
yield(element)
|
@@ -11,7 +11,7 @@ module Twitter
|
|
11
11
|
unless last?
|
12
12
|
start = [@collection.size, start].max
|
13
13
|
fetch_next_page
|
14
|
-
each(start, &
|
14
|
+
each(start, &Proc.new)
|
15
15
|
end
|
16
16
|
self
|
17
17
|
end
|
data/lib/twitter/error.rb
CHANGED
@@ -102,6 +102,13 @@ module Twitter
|
|
102
102
|
|
103
103
|
class ConfigurationError < ::ArgumentError; end
|
104
104
|
|
105
|
+
# Raised when a Tweet includes media that doesn't have a to_io method
|
106
|
+
class UnacceptableIO < StandardError
|
107
|
+
def initialize
|
108
|
+
super('The IO object for media must respond to to_io')
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
105
112
|
# Raised when Twitter returns a 4xx HTTP status code
|
106
113
|
class ClientError < self; end
|
107
114
|
|
data/lib/twitter/geo_results.rb
CHANGED
@@ -16,7 +16,7 @@ module Twitter
|
|
16
16
|
# @return [Twitter::GeoResults]
|
17
17
|
def initialize(attrs = {})
|
18
18
|
@attrs = attrs
|
19
|
-
@collection =
|
19
|
+
@collection = @attrs[:result].fetch(:places, []).collect do |place|
|
20
20
|
Place.new(place)
|
21
21
|
end
|
22
22
|
end
|
data/lib/twitter/list.rb
CHANGED
@@ -4,9 +4,10 @@ require 'twitter/identity'
|
|
4
4
|
module Twitter
|
5
5
|
class List < Twitter::Identity
|
6
6
|
include Twitter::Creatable
|
7
|
-
attr_reader :description, :
|
8
|
-
:
|
7
|
+
attr_reader :description, :full_name, :member_count, :mode, :name, :slug,
|
8
|
+
:subscriber_count
|
9
9
|
object_attr_reader :User, :user
|
10
|
+
predicate_attr_reader :following
|
10
11
|
|
11
12
|
# @return [Addressable::URI] The URI to the list members.
|
12
13
|
def members_uri
|
data/lib/twitter/media/photo.rb
CHANGED
data/lib/twitter/place.rb
CHANGED
@@ -1,26 +1,24 @@
|
|
1
1
|
require 'equalizer'
|
2
|
-
require 'twitter/
|
2
|
+
require 'twitter/identity'
|
3
3
|
|
4
4
|
module Twitter
|
5
|
-
class Place < Twitter::
|
6
|
-
attr_reader :attributes, :country, :full_name, :name
|
7
|
-
alias_method :woe_id, :
|
5
|
+
class Place < Twitter::Identity
|
6
|
+
attr_reader :attributes, :country, :full_name, :name
|
7
|
+
alias_method :woe_id, :id
|
8
|
+
alias_method :woeid, :id
|
8
9
|
object_attr_reader :GeoFactory, :bounding_box
|
9
10
|
object_attr_reader :Place, :contained_within
|
10
11
|
alias_method :contained?, :contained_within?
|
11
12
|
uri_attr_reader :uri
|
12
13
|
|
13
|
-
#
|
14
|
-
#
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
def ==(other)
|
22
|
-
other = coerce(other) if respond_to?(:coerce, true)
|
23
|
-
super || kind_of?(self.class) && !woeid.nil? && other.respond_to?(:woeid) && woeid == other.woeid
|
14
|
+
# Initializes a new place
|
15
|
+
#
|
16
|
+
# @param attrs [Hash]
|
17
|
+
# @raise [ArgumentError] Error raised when supplied argument is missing an :id key.
|
18
|
+
# @return [Twitter::Identity]
|
19
|
+
def initialize(attrs = {})
|
20
|
+
attrs[:id] ||= attrs[:woeid]
|
21
|
+
super
|
24
22
|
end
|
25
23
|
|
26
24
|
# @return [String]
|
data/lib/twitter/profile.rb
CHANGED
@@ -11,7 +11,7 @@ module Twitter
|
|
11
11
|
private
|
12
12
|
|
13
13
|
def alias_predicate_uri_methods(method)
|
14
|
-
%w
|
14
|
+
%w[_url? _uri_https? _url_https?].each do |replacement|
|
15
15
|
alias_method_sub(method, PREDICATE_URI_METHOD_REGEX, replacement)
|
16
16
|
end
|
17
17
|
end
|
data/lib/twitter/rest/client.rb
CHANGED
@@ -19,9 +19,16 @@ module Twitter
|
|
19
19
|
class Client < Twitter::Client
|
20
20
|
include Twitter::REST::API
|
21
21
|
attr_accessor :bearer_token
|
22
|
-
attr_writer :connection_options, :middleware
|
23
22
|
ENDPOINT = 'https://api.twitter.com'
|
24
23
|
|
24
|
+
# @param connection_options [Hash]
|
25
|
+
# @return [Hash]
|
26
|
+
def connection_options=(connection_options)
|
27
|
+
warn "#{Kernel.caller.first}: [DEPRECATION] Twitter::REST::Client#connection_options= is deprecated and will be removed in version 6.0.0."
|
28
|
+
@connection_options = connection_options
|
29
|
+
end
|
30
|
+
|
31
|
+
# @return [Hash]
|
25
32
|
def connection_options
|
26
33
|
@connection_options ||= {
|
27
34
|
:builder => middleware,
|
@@ -33,9 +40,17 @@ module Twitter
|
|
33
40
|
:open_timeout => 10,
|
34
41
|
:timeout => 30,
|
35
42
|
},
|
43
|
+
:proxy => proxy
|
36
44
|
}
|
37
45
|
end
|
38
46
|
|
47
|
+
# @params middleware [Faraday::RackBuilder]
|
48
|
+
# @return [Faraday::RackBuilder]
|
49
|
+
def middleware=(middleware)
|
50
|
+
warn "#{Kernel.caller.first}: [DEPRECATION] Twitter::REST::Client#middleware= is deprecated and will be removed in version 6.0.0."
|
51
|
+
@middleware = middleware
|
52
|
+
end
|
53
|
+
|
39
54
|
# @note Faraday's middleware stack implementation is comparable to that of Rack middleware. The order of middleware is important: the first middleware on the list wraps all others, while the last middleware is the innermost one.
|
40
55
|
# @see https://github.com/technoweenie/faraday#advanced-middleware-usage
|
41
56
|
# @see http://mislav.uniqpath.com/2011/07/faraday-advanced-http/
|
@@ -93,7 +108,7 @@ module Twitter
|
|
93
108
|
rescue Faraday::Error::TimeoutError, Timeout::Error => error
|
94
109
|
raise(Twitter::Error::RequestTimeout.new(error))
|
95
110
|
rescue Faraday::Error::ClientError, JSON::ParserError => error
|
96
|
-
|
111
|
+
raise(Twitter::Error.new(error))
|
97
112
|
end
|
98
113
|
|
99
114
|
def request_headers(method, path, params = {}, signature_params = params)
|