twitter 5.1.0 → 5.2.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/.yardopts +2 -0
- data/CHANGELOG.md +14 -1
- data/CONTRIBUTING.md +2 -2
- data/README.md +30 -20
- data/Rakefile +26 -5
- data/lib/twitter/arguments.rb +0 -1
- data/lib/twitter/base.rb +13 -16
- data/lib/twitter/basic_user.rb +3 -3
- data/lib/twitter/client.rb +7 -8
- data/lib/twitter/configuration.rb +5 -5
- data/lib/twitter/core_ext/enumerable.rb +0 -2
- data/lib/twitter/core_ext/kernel.rb +0 -2
- data/lib/twitter/creatable.rb +0 -1
- data/lib/twitter/cursor.rb +7 -10
- data/lib/twitter/direct_message.rb +1 -1
- data/lib/twitter/entity/uri.rb +2 -2
- data/lib/twitter/enumerable.rb +1 -2
- data/lib/twitter/error/already_favorited.rb +1 -1
- data/lib/twitter/error/already_posted.rb +1 -1
- data/lib/twitter/error/already_retweeted.rb +1 -1
- data/lib/twitter/error/too_many_requests.rb +2 -2
- data/lib/twitter/error.rb +4 -6
- data/lib/twitter/factory.rb +2 -6
- data/lib/twitter/geo/point.rb +3 -5
- data/lib/twitter/geo.rb +1 -1
- data/lib/twitter/geo_factory.rb +1 -5
- data/lib/twitter/geo_results.rb +5 -8
- data/lib/twitter/identity.rb +1 -2
- data/lib/twitter/list.rb +4 -5
- data/lib/twitter/media/photo.rb +1 -2
- data/lib/twitter/media_factory.rb +1 -5
- data/lib/twitter/null_object.rb +4 -6
- data/lib/twitter/oembed.rb +1 -1
- data/lib/twitter/place.rb +17 -6
- data/lib/twitter/profile_banner.rb +1 -3
- data/lib/twitter/rate_limit.rb +1 -3
- data/lib/twitter/relationship.rb +1 -2
- data/lib/twitter/rest/api/direct_messages.rb +13 -14
- data/lib/twitter/rest/api/favorites.rb +10 -11
- data/lib/twitter/rest/api/friends_and_followers.rb +36 -36
- data/lib/twitter/rest/api/help.rb +8 -9
- data/lib/twitter/rest/api/lists.rb +62 -63
- data/lib/twitter/rest/api/oauth.rb +3 -4
- data/lib/twitter/rest/api/places_and_geo.rb +9 -10
- data/lib/twitter/rest/api/saved_searches.rb +5 -6
- data/lib/twitter/rest/api/search.rb +2 -3
- data/lib/twitter/rest/api/spam_reporting.rb +1 -2
- data/lib/twitter/rest/api/suggested_users.rb +4 -5
- data/lib/twitter/rest/api/timelines.rb +17 -18
- data/lib/twitter/rest/api/trends.rb +10 -11
- data/lib/twitter/rest/api/tweets.rb +15 -16
- data/lib/twitter/rest/api/undocumented.rb +6 -7
- data/lib/twitter/rest/api/users.rb +51 -52
- data/lib/twitter/rest/api/utils.rb +23 -30
- data/lib/twitter/rest/client.rb +8 -9
- data/lib/twitter/rest/request/multipart_with_file.rb +0 -1
- data/lib/twitter/rest/response/parse_error_json.rb +0 -2
- data/lib/twitter/rest/response/parse_json.rb +0 -2
- data/lib/twitter/rest/response/raise_error.rb +1 -3
- data/lib/twitter/search_results.rb +12 -15
- data/lib/twitter/settings.rb +2 -2
- data/lib/twitter/size.rb +2 -2
- data/lib/twitter/source_user.rb +1 -1
- data/lib/twitter/streaming/client.rb +71 -18
- data/lib/twitter/streaming/connection.rb +1 -3
- data/lib/twitter/streaming/deleted_tweet.rb +8 -0
- data/lib/twitter/streaming/event.rb +8 -8
- data/lib/twitter/streaming/friend_list.rb +2 -9
- data/lib/twitter/streaming/message_parser.rb +13 -7
- data/lib/twitter/streaming/response.rb +0 -2
- data/lib/twitter/streaming/stall_warning.rb +7 -0
- data/lib/twitter/suggestion.rb +0 -1
- data/lib/twitter/token.rb +2 -3
- data/lib/twitter/trend_results.rb +5 -8
- data/lib/twitter/tweet.rb +16 -24
- data/lib/twitter/user.rb +30 -32
- data/lib/twitter/version.rb +1 -4
- data/spec/fixtures/track_streaming_user.json +2 -1
- data/spec/helper.rb +6 -2
- data/spec/twitter/base_spec.rb +9 -9
- data/spec/twitter/basic_user_spec.rb +6 -6
- data/spec/twitter/configuration_spec.rb +4 -4
- data/spec/twitter/cursor_spec.rb +27 -27
- data/spec/twitter/direct_message_spec.rb +36 -36
- data/spec/twitter/entity/uri_spec.rb +27 -27
- data/spec/twitter/error_spec.rb +21 -21
- data/spec/twitter/geo/point_spec.rb +9 -9
- data/spec/twitter/geo/polygon_spec.rb +5 -5
- data/spec/twitter/geo_factory_spec.rb +7 -7
- data/spec/twitter/geo_results_spec.rb +11 -11
- data/spec/twitter/geo_spec.rb +5 -5
- data/spec/twitter/identifiable_spec.rb +9 -9
- data/spec/twitter/list_spec.rb +38 -38
- data/spec/twitter/media/photo_spec.rb +54 -54
- data/spec/twitter/media_factory_spec.rb +5 -5
- data/spec/twitter/null_object_spec.rb +6 -6
- data/spec/twitter/oembed_spec.rb +65 -65
- data/spec/twitter/place_spec.rb +89 -60
- data/spec/twitter/profile_banner_spec.rb +3 -3
- data/spec/twitter/rate_limit_spec.rb +18 -18
- data/spec/twitter/relationship_spec.rb +16 -16
- data/spec/twitter/rest/api/direct_messages_spec.rb +61 -61
- data/spec/twitter/rest/api/favorites_spec.rb +93 -93
- data/spec/twitter/rest/api/friends_and_followers_spec.rb +349 -349
- data/spec/twitter/rest/api/geo_spec.rb +33 -33
- data/spec/twitter/rest/api/help_spec.rb +24 -24
- data/spec/twitter/rest/api/lists_spec.rb +487 -487
- data/spec/twitter/rest/api/oauth_spec.rb +30 -30
- data/spec/twitter/rest/api/saved_searches_spec.rb +40 -40
- data/spec/twitter/rest/api/search_spec.rb +16 -16
- data/spec/twitter/rest/api/spam_reporting_spec.rb +9 -9
- data/spec/twitter/rest/api/suggested_users_spec.rb +23 -23
- data/spec/twitter/rest/api/timelines_spec.rb +58 -58
- data/spec/twitter/rest/api/trends_spec.rb +26 -26
- data/spec/twitter/rest/api/tweets_spec.rb +284 -284
- data/spec/twitter/rest/api/undocumented_spec.rb +51 -51
- data/spec/twitter/rest/api/users_spec.rb +360 -360
- data/spec/twitter/rest/client_spec.rb +99 -103
- data/spec/twitter/saved_search_spec.rb +16 -16
- data/spec/twitter/search_results_spec.rb +44 -44
- data/spec/twitter/settings_spec.rb +8 -8
- data/spec/twitter/size_spec.rb +5 -5
- data/spec/twitter/source_user_spec.rb +6 -6
- data/spec/twitter/streaming/client_spec.rb +53 -49
- data/spec/twitter/streaming/deleted_tweet_spec.rb +23 -0
- data/spec/twitter/streaming/event_spec.rb +20 -22
- data/spec/twitter/streaming/friend_list_spec.rb +11 -0
- data/spec/twitter/streaming/message_parser_spec.rb +54 -0
- data/spec/twitter/suggestion_spec.rb +11 -11
- data/spec/twitter/target_user_spec.rb +6 -6
- data/spec/twitter/token_spec.rb +4 -4
- data/spec/twitter/trend_results_spec.rb +30 -30
- data/spec/twitter/trend_spec.rb +20 -20
- data/spec/twitter/tweet_spec.rb +170 -173
- data/spec/twitter/user_spec.rb +179 -179
- data/twitter.gemspec +2 -2
- data.tar.gz.sig +0 -0
- metadata +21 -4
- metadata.gz.sig +2 -3
data/lib/twitter/geo_factory.rb
CHANGED
|
@@ -4,19 +4,15 @@ require 'twitter/geo/polygon'
|
|
|
4
4
|
|
|
5
5
|
module Twitter
|
|
6
6
|
class GeoFactory < Twitter::Factory
|
|
7
|
-
|
|
8
7
|
class << self
|
|
9
|
-
|
|
10
8
|
# Construct a new geo object
|
|
11
9
|
#
|
|
12
10
|
# @param attrs [Hash]
|
|
13
11
|
# @raise [IndexError] Error raised when supplied argument is missing a :type key.
|
|
14
12
|
# @return [Twitter::Geo]
|
|
15
|
-
def new(attrs={})
|
|
13
|
+
def new(attrs = {})
|
|
16
14
|
super(:type, Geo, attrs)
|
|
17
15
|
end
|
|
18
|
-
|
|
19
16
|
end
|
|
20
|
-
|
|
21
17
|
end
|
|
22
18
|
end
|
data/lib/twitter/geo_results.rb
CHANGED
|
@@ -4,27 +4,25 @@ module Twitter
|
|
|
4
4
|
class GeoResults
|
|
5
5
|
include Twitter::Enumerable
|
|
6
6
|
attr_reader :attrs
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
alias_method :to_h, :attrs
|
|
8
|
+
alias_method :to_hash, :attrs
|
|
9
|
+
alias_method :to_hsh, :attrs
|
|
10
10
|
|
|
11
11
|
class << self
|
|
12
|
-
|
|
13
12
|
# Construct a new GeoResults object from a response hash
|
|
14
13
|
#
|
|
15
14
|
# @param response [Hash]
|
|
16
15
|
# @return [Twitter::Base]
|
|
17
|
-
def from_response(response={})
|
|
16
|
+
def from_response(response = {})
|
|
18
17
|
new(response[:body])
|
|
19
18
|
end
|
|
20
|
-
|
|
21
19
|
end
|
|
22
20
|
|
|
23
21
|
# Initializes a new GeoResults object
|
|
24
22
|
#
|
|
25
23
|
# @param attrs [Hash]
|
|
26
24
|
# @return [Twitter::GeoResults]
|
|
27
|
-
def initialize(attrs={})
|
|
25
|
+
def initialize(attrs = {})
|
|
28
26
|
@attrs = attrs
|
|
29
27
|
@collection = Array(@attrs[:result][:places]).map do |place|
|
|
30
28
|
Place.new(place)
|
|
@@ -35,6 +33,5 @@ module Twitter
|
|
|
35
33
|
def token
|
|
36
34
|
@attrs[:token]
|
|
37
35
|
end
|
|
38
|
-
|
|
39
36
|
end
|
|
40
37
|
end
|
data/lib/twitter/identity.rb
CHANGED
|
@@ -11,10 +11,9 @@ module Twitter
|
|
|
11
11
|
# @param attrs [Hash]
|
|
12
12
|
# @raise [ArgumentError] Error raised when supplied argument is missing an :id key.
|
|
13
13
|
# @return [Twitter::Identity]
|
|
14
|
-
def initialize(attrs={})
|
|
14
|
+
def initialize(attrs = {})
|
|
15
15
|
attrs.fetch(:id)
|
|
16
16
|
super
|
|
17
17
|
end
|
|
18
|
-
|
|
19
18
|
end
|
|
20
19
|
end
|
data/lib/twitter/list.rb
CHANGED
|
@@ -5,7 +5,7 @@ module Twitter
|
|
|
5
5
|
class List < Twitter::Identity
|
|
6
6
|
include Twitter::Creatable
|
|
7
7
|
attr_reader :description, :following, :full_name, :member_count,
|
|
8
|
-
|
|
8
|
+
:mode, :name, :slug, :subscriber_count
|
|
9
9
|
object_attr_reader :User, :user
|
|
10
10
|
|
|
11
11
|
# @return [Addressable::URI] The URI to the list members.
|
|
@@ -13,21 +13,20 @@ module Twitter
|
|
|
13
13
|
Addressable::URI.parse("https://twitter.com/#{user.screen_name}/#{slug}/members")
|
|
14
14
|
end
|
|
15
15
|
memoize :members_uri
|
|
16
|
-
|
|
16
|
+
alias_method :members_url, :members_uri
|
|
17
17
|
|
|
18
18
|
# @return [Addressable::URI] The URI to the list subscribers.
|
|
19
19
|
def subscribers_uri
|
|
20
20
|
Addressable::URI.parse("https://twitter.com/#{user.screen_name}/#{slug}/subscribers")
|
|
21
21
|
end
|
|
22
22
|
memoize :subscribers_uri
|
|
23
|
-
|
|
23
|
+
alias_method :subscribers_url, :subscribers_uri
|
|
24
24
|
|
|
25
25
|
# @return [Addressable::URI] The URI to the list.
|
|
26
26
|
def uri
|
|
27
27
|
Addressable::URI.parse("https://twitter.com/#{user.screen_name}/#{slug}")
|
|
28
28
|
end
|
|
29
29
|
memoize :uri
|
|
30
|
-
|
|
31
|
-
|
|
30
|
+
alias_method :url, :uri
|
|
32
31
|
end
|
|
33
32
|
end
|
data/lib/twitter/media/photo.rb
CHANGED
|
@@ -11,13 +11,12 @@ module Twitter
|
|
|
11
11
|
#
|
|
12
12
|
# @return [Array<Twitter::Size>]
|
|
13
13
|
def sizes
|
|
14
|
-
Array(@attrs[:sizes]).
|
|
14
|
+
Array(@attrs[:sizes]).reduce({}) do |object, (key, value)|
|
|
15
15
|
object[key] = Size.new(value)
|
|
16
16
|
object
|
|
17
17
|
end
|
|
18
18
|
end
|
|
19
19
|
memoize :sizes
|
|
20
|
-
|
|
21
20
|
end
|
|
22
21
|
end
|
|
23
22
|
end
|
|
@@ -3,19 +3,15 @@ require 'twitter/media/photo'
|
|
|
3
3
|
|
|
4
4
|
module Twitter
|
|
5
5
|
class MediaFactory < Twitter::Factory
|
|
6
|
-
|
|
7
6
|
class << self
|
|
8
|
-
|
|
9
7
|
# Construct a new media object
|
|
10
8
|
#
|
|
11
9
|
# @param attrs [Hash]
|
|
12
10
|
# @raise [IndexError] Error raised when supplied argument is missing a :type key.
|
|
13
11
|
# @return [Twitter::Media]
|
|
14
|
-
def new(attrs={})
|
|
12
|
+
def new(attrs = {})
|
|
15
13
|
super(:type, Media, attrs)
|
|
16
14
|
end
|
|
17
|
-
|
|
18
15
|
end
|
|
19
|
-
|
|
20
16
|
end
|
|
21
17
|
end
|
data/lib/twitter/null_object.rb
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
module Twitter
|
|
2
2
|
class NullObject
|
|
3
|
-
|
|
4
3
|
# @return [TrueClass] This method always returns true.
|
|
5
4
|
def nil?
|
|
6
5
|
true
|
|
@@ -12,14 +11,13 @@ module Twitter
|
|
|
12
11
|
end
|
|
13
12
|
|
|
14
13
|
# @return [TrueClass] This method always returns true.
|
|
15
|
-
def respond_to?(method_name, include_private=false)
|
|
14
|
+
def respond_to?(method_name, include_private = false)
|
|
16
15
|
true
|
|
17
|
-
end if RUBY_VERSION <
|
|
16
|
+
end if RUBY_VERSION < '1.9'
|
|
18
17
|
|
|
19
18
|
# @return [TrueClass] This method always returns true.
|
|
20
|
-
def respond_to_missing?(method_name, include_private=false)
|
|
19
|
+
def respond_to_missing?(method_name, include_private = false)
|
|
21
20
|
true
|
|
22
|
-
end if RUBY_VERSION >=
|
|
23
|
-
|
|
21
|
+
end if RUBY_VERSION >= '1.9'
|
|
24
22
|
end
|
|
25
23
|
end
|
data/lib/twitter/oembed.rb
CHANGED
data/lib/twitter/place.rb
CHANGED
|
@@ -3,17 +3,29 @@ require 'twitter/base'
|
|
|
3
3
|
|
|
4
4
|
module Twitter
|
|
5
5
|
class Place < Twitter::Base
|
|
6
|
-
include Equalizer.new(:woeid)
|
|
7
6
|
attr_reader :attributes, :country, :full_name, :name, :woeid
|
|
8
|
-
|
|
7
|
+
alias_method :woe_id, :woeid
|
|
9
8
|
object_attr_reader :GeoFactory, :bounding_box
|
|
10
9
|
object_attr_reader :Place, :contained_within
|
|
11
|
-
|
|
10
|
+
alias_method :contained?, :contained_within?
|
|
12
11
|
uri_attr_reader :uri
|
|
13
12
|
|
|
13
|
+
# @param other [Twitter::Place]
|
|
14
|
+
# @return [Boolean]
|
|
15
|
+
def eql?(other)
|
|
16
|
+
super || instance_of?(other.class) && !woeid.nil? && other.respond_to?(:woeid) && woeid.eql?(other.woeid)
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
# @param other [Twitter::Place]
|
|
20
|
+
# @return [Boolean]
|
|
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
|
|
24
|
+
end
|
|
25
|
+
|
|
14
26
|
# @return [String]
|
|
15
27
|
def country_code
|
|
16
|
-
@attrs[:country_code] || @attrs[:countryCode]
|
|
28
|
+
@attrs[:country_code] || @attrs[:countryCode] # rubocop:disable SymbolName
|
|
17
29
|
end
|
|
18
30
|
memoize :country_code
|
|
19
31
|
|
|
@@ -25,9 +37,8 @@ module Twitter
|
|
|
25
37
|
|
|
26
38
|
# @return [String]
|
|
27
39
|
def place_type
|
|
28
|
-
@attrs[:place_type] || @attrs[:placeType] && @attrs[:placeType][:name]
|
|
40
|
+
@attrs[:place_type] || @attrs[:placeType] && @attrs[:placeType][:name] # rubocop:disable SymbolName
|
|
29
41
|
end
|
|
30
42
|
memoize :place_type
|
|
31
|
-
|
|
32
43
|
end
|
|
33
44
|
end
|
|
@@ -2,17 +2,15 @@ require 'twitter/base'
|
|
|
2
2
|
|
|
3
3
|
module Twitter
|
|
4
4
|
class ProfileBanner < Twitter::Base
|
|
5
|
-
|
|
6
5
|
# Returns an array of photo sizes
|
|
7
6
|
#
|
|
8
7
|
# @return [Array<Twitter::Size>]
|
|
9
8
|
def sizes
|
|
10
|
-
Array(@attrs[:sizes]).
|
|
9
|
+
Array(@attrs[:sizes]).reduce({}) do |object, (key, value)|
|
|
11
10
|
object[key] = Size.new(value)
|
|
12
11
|
object
|
|
13
12
|
end
|
|
14
13
|
end
|
|
15
14
|
memoize :sizes
|
|
16
|
-
|
|
17
15
|
end
|
|
18
16
|
end
|
data/lib/twitter/rate_limit.rb
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
module Twitter
|
|
2
2
|
class RateLimit < Twitter::Base
|
|
3
|
-
|
|
4
3
|
# @return [Integer]
|
|
5
4
|
def limit
|
|
6
5
|
limit = @attrs['x-rate-limit-limit']
|
|
@@ -26,7 +25,6 @@ module Twitter
|
|
|
26
25
|
def reset_in
|
|
27
26
|
[(reset_at - Time.now).ceil, 0].max if reset_at
|
|
28
27
|
end
|
|
29
|
-
|
|
30
|
-
|
|
28
|
+
alias_method :retry_after, :reset_in
|
|
31
29
|
end
|
|
32
30
|
end
|
data/lib/twitter/relationship.rb
CHANGED
|
@@ -22,8 +22,8 @@ module Twitter
|
|
|
22
22
|
# @option options [Integer] :max_id Returns results with an ID less than (that is, older than) or equal to the specified ID.
|
|
23
23
|
# @option options [Integer] :count Specifies the number of records to retrieve. Must be less than or equal to 200.
|
|
24
24
|
# @option options [Integer] :page Specifies the page of results to retrieve.
|
|
25
|
-
def direct_messages_received(options={})
|
|
26
|
-
objects_from_response(Twitter::DirectMessage, :get,
|
|
25
|
+
def direct_messages_received(options = {})
|
|
26
|
+
objects_from_response(Twitter::DirectMessage, :get, '/1.1/direct_messages.json', options)
|
|
27
27
|
end
|
|
28
28
|
|
|
29
29
|
# Returns the 20 most recent direct messages sent by the authenticating user
|
|
@@ -39,8 +39,8 @@ module Twitter
|
|
|
39
39
|
# @option options [Integer] :max_id Returns results with an ID less than (that is, older than) or equal to the specified ID.
|
|
40
40
|
# @option options [Integer] :count Specifies the number of records to retrieve. Must be less than or equal to 200.
|
|
41
41
|
# @option options [Integer] :page Specifies the page of results to retrieve.
|
|
42
|
-
def direct_messages_sent(options={})
|
|
43
|
-
objects_from_response(Twitter::DirectMessage, :get,
|
|
42
|
+
def direct_messages_sent(options = {})
|
|
43
|
+
objects_from_response(Twitter::DirectMessage, :get, '/1.1/direct_messages/sent.json', options)
|
|
44
44
|
end
|
|
45
45
|
|
|
46
46
|
# Returns a direct message
|
|
@@ -53,9 +53,9 @@ module Twitter
|
|
|
53
53
|
# @return [Twitter::DirectMessage] The requested messages.
|
|
54
54
|
# @param id [Integer] A direct message ID.
|
|
55
55
|
# @param options [Hash] A customizable set of options.
|
|
56
|
-
def direct_message(id, options={})
|
|
56
|
+
def direct_message(id, options = {})
|
|
57
57
|
options[:id] = id
|
|
58
|
-
object_from_response(Twitter::DirectMessage, :get,
|
|
58
|
+
object_from_response(Twitter::DirectMessage, :get, '/1.1/direct_messages/show.json', options)
|
|
59
59
|
end
|
|
60
60
|
|
|
61
61
|
# @note This method requires an access token with RWD (read, write & direct message) permissions. Consult The Application Permission Model for more information.
|
|
@@ -63,7 +63,7 @@ module Twitter
|
|
|
63
63
|
# @authentication Requires user context
|
|
64
64
|
# @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
|
|
65
65
|
# @return [Array<Twitter::DirectMessage>] The requested messages.
|
|
66
|
-
# @overload direct_messages(options={})
|
|
66
|
+
# @overload direct_messages(options = {})
|
|
67
67
|
# Returns the 20 most recent direct messages sent to the authenticating user
|
|
68
68
|
#
|
|
69
69
|
# @see https://dev.twitter.com/docs/api/1.1/get/direct_messages
|
|
@@ -108,7 +108,7 @@ module Twitter
|
|
|
108
108
|
# @param ids [Enumerable<Integer>] A collection of direct message IDs.
|
|
109
109
|
# @param options [Hash] A customizable set of options.
|
|
110
110
|
def destroy_direct_message(*args)
|
|
111
|
-
threaded_objects_from_response(Twitter::DirectMessage, :post,
|
|
111
|
+
threaded_objects_from_response(Twitter::DirectMessage, :post, '/1.1/direct_messages/destroy.json', args)
|
|
112
112
|
end
|
|
113
113
|
deprecate_alias :direct_message_destroy, :destroy_direct_message
|
|
114
114
|
|
|
@@ -122,16 +122,15 @@ module Twitter
|
|
|
122
122
|
# @param user [Integer, String, Twitter::User] A Twitter user ID, screen name, URI, or object.
|
|
123
123
|
# @param text [String] The text of your direct message, up to 140 characters.
|
|
124
124
|
# @param options [Hash] A customizable set of options.
|
|
125
|
-
def create_direct_message(user, text, options={})
|
|
125
|
+
def create_direct_message(user, text, options = {})
|
|
126
126
|
merge_user!(options, user)
|
|
127
127
|
options[:text] = text
|
|
128
|
-
object_from_response(Twitter::DirectMessage, :post,
|
|
128
|
+
object_from_response(Twitter::DirectMessage, :post, '/1.1/direct_messages/new.json', options)
|
|
129
129
|
end
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
130
|
+
alias_method :d, :create_direct_message
|
|
131
|
+
alias_method :m, :create_direct_message
|
|
132
|
+
alias_method :dm, :create_direct_message
|
|
133
133
|
deprecate_alias :direct_message_create, :create_direct_message
|
|
134
|
-
|
|
135
134
|
end
|
|
136
135
|
end
|
|
137
136
|
end
|
|
@@ -32,7 +32,7 @@ module Twitter
|
|
|
32
32
|
def favorites(*args)
|
|
33
33
|
arguments = Twitter::Arguments.new(args)
|
|
34
34
|
merge_user!(arguments.options, arguments.pop) if arguments.last
|
|
35
|
-
objects_from_response(Twitter::Tweet, :get,
|
|
35
|
+
objects_from_response(Twitter::Tweet, :get, '/1.1/favorites/list.json', arguments.options)
|
|
36
36
|
end
|
|
37
37
|
|
|
38
38
|
# Un-favorites the specified Tweets as the authenticating user
|
|
@@ -48,9 +48,9 @@ module Twitter
|
|
|
48
48
|
# @param tweets [Enumerable<Integer, String, URI, Twitter::Tweet>] A collection of Tweet IDs, URIs, or objects.
|
|
49
49
|
# @param options [Hash] A customizable set of options.
|
|
50
50
|
def unfavorite(*args)
|
|
51
|
-
threaded_objects_from_response(Twitter::Tweet, :post,
|
|
51
|
+
threaded_objects_from_response(Twitter::Tweet, :post, '/1.1/favorites/destroy.json', args)
|
|
52
52
|
end
|
|
53
|
-
|
|
53
|
+
alias_method :destroy_favorite, :unfavorite
|
|
54
54
|
deprecate_alias :favorite_destroy, :unfavorite
|
|
55
55
|
|
|
56
56
|
# Favorites the specified Tweets as the authenticating user
|
|
@@ -70,14 +70,14 @@ module Twitter
|
|
|
70
70
|
arguments.flatten.threaded_map do |tweet|
|
|
71
71
|
id = extract_id(tweet)
|
|
72
72
|
begin
|
|
73
|
-
object_from_response(Twitter::Tweet, :post,
|
|
73
|
+
object_from_response(Twitter::Tweet, :post, '/1.1/favorites/create.json', arguments.options.merge(:id => id))
|
|
74
74
|
rescue Twitter::Error::Forbidden => error
|
|
75
75
|
raise unless error.message == Twitter::Error::AlreadyFavorited::MESSAGE
|
|
76
76
|
end
|
|
77
77
|
end.compact
|
|
78
78
|
end
|
|
79
|
-
|
|
80
|
-
|
|
79
|
+
alias_method :fav, :favorite
|
|
80
|
+
alias_method :fave, :favorite
|
|
81
81
|
deprecate_alias :favorite_create, :favorite
|
|
82
82
|
|
|
83
83
|
# Favorites the specified Tweets as the authenticating user and raises an error if one has already been favorited
|
|
@@ -98,17 +98,16 @@ module Twitter
|
|
|
98
98
|
arguments.flatten.threaded_map do |tweet|
|
|
99
99
|
id = extract_id(tweet)
|
|
100
100
|
begin
|
|
101
|
-
object_from_response(Twitter::Tweet, :post,
|
|
101
|
+
object_from_response(Twitter::Tweet, :post, '/1.1/favorites/create.json', arguments.options.merge(:id => id))
|
|
102
102
|
rescue Twitter::Error::Forbidden => error
|
|
103
103
|
handle_forbidden_error(Twitter::Error::AlreadyFavorited, error)
|
|
104
104
|
end
|
|
105
105
|
end
|
|
106
106
|
end
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
107
|
+
alias_method :create_favorite!, :favorite!
|
|
108
|
+
alias_method :fav!, :favorite!
|
|
109
|
+
alias_method :fave!, :favorite!
|
|
110
110
|
deprecate_alias :favorite_create!, :favorite!
|
|
111
|
-
|
|
112
111
|
end
|
|
113
112
|
end
|
|
114
113
|
end
|
|
@@ -16,19 +16,19 @@ module Twitter
|
|
|
16
16
|
# @authentication Requires user context
|
|
17
17
|
# @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
|
|
18
18
|
# @return [Twitter::Cursor]
|
|
19
|
-
# @overload friend_ids(options={})
|
|
19
|
+
# @overload friend_ids(options = {})
|
|
20
20
|
# Returns an array of numeric IDs for every user the authenticated user is following
|
|
21
21
|
#
|
|
22
22
|
# @param options [Hash] A customizable set of options.
|
|
23
23
|
# @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.
|
|
24
|
-
# @overload friend_ids(user, options={})
|
|
24
|
+
# @overload friend_ids(user, options = {})
|
|
25
25
|
# Returns an array of numeric IDs for every user the specified user is following
|
|
26
26
|
#
|
|
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
|
# @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.
|
|
30
30
|
def friend_ids(*args)
|
|
31
|
-
cursor_from_response_with_user(:ids, nil, :get,
|
|
31
|
+
cursor_from_response_with_user(:ids, nil, :get, '/1.1/friends/ids.json', args)
|
|
32
32
|
end
|
|
33
33
|
|
|
34
34
|
# @see https://dev.twitter.com/docs/api/1.1/get/followers/ids
|
|
@@ -36,19 +36,19 @@ module Twitter
|
|
|
36
36
|
# @authentication Requires user context
|
|
37
37
|
# @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
|
|
38
38
|
# @return [Twitter::Cursor]
|
|
39
|
-
# @overload follower_ids(options={})
|
|
39
|
+
# @overload follower_ids(options = {})
|
|
40
40
|
# Returns an array of numeric IDs for every user following the authenticated user
|
|
41
41
|
#
|
|
42
42
|
# @param options [Hash] A customizable set of options.
|
|
43
43
|
# @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.
|
|
44
|
-
# @overload follower_ids(user, options={})
|
|
44
|
+
# @overload follower_ids(user, options = {})
|
|
45
45
|
# Returns an array of numeric IDs for every user following the specified user
|
|
46
46
|
#
|
|
47
47
|
# @param user [Integer, String, Twitter::User] A Twitter user ID, screen name, URI, or object.
|
|
48
48
|
# @param options [Hash] A customizable set of options.
|
|
49
49
|
# @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.
|
|
50
50
|
def follower_ids(*args)
|
|
51
|
-
cursor_from_response_with_user(:ids, nil, :get,
|
|
51
|
+
cursor_from_response_with_user(:ids, nil, :get, '/1.1/followers/ids.json', args)
|
|
52
52
|
end
|
|
53
53
|
|
|
54
54
|
# 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.
|
|
@@ -66,7 +66,7 @@ module Twitter
|
|
|
66
66
|
def friendships(*args)
|
|
67
67
|
arguments = Twitter::Arguments.new(args)
|
|
68
68
|
merge_users!(arguments.options, arguments)
|
|
69
|
-
objects_from_response(Twitter::User, :get,
|
|
69
|
+
objects_from_response(Twitter::User, :get, '/1.1/friendships/lookup.json', arguments.options)
|
|
70
70
|
end
|
|
71
71
|
|
|
72
72
|
# Returns an array of numeric IDs for every user who has a pending request to follow the authenticating user
|
|
@@ -78,8 +78,8 @@ module Twitter
|
|
|
78
78
|
# @return [Twitter::Cursor]
|
|
79
79
|
# @param options [Hash] A customizable set of options.
|
|
80
80
|
# @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.
|
|
81
|
-
def friendships_incoming(options={})
|
|
82
|
-
cursor_from_response(:ids, nil, :get,
|
|
81
|
+
def friendships_incoming(options = {})
|
|
82
|
+
cursor_from_response(:ids, nil, :get, '/1.1/friendships/incoming.json', options)
|
|
83
83
|
end
|
|
84
84
|
|
|
85
85
|
# Returns an array of numeric IDs for every protected user for whom the authenticating user has a pending follow request
|
|
@@ -91,8 +91,8 @@ module Twitter
|
|
|
91
91
|
# @return [Twitter::Cursor]
|
|
92
92
|
# @param options [Hash] A customizable set of options.
|
|
93
93
|
# @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.
|
|
94
|
-
def friendships_outgoing(options={})
|
|
95
|
-
cursor_from_response(:ids, nil, :get,
|
|
94
|
+
def friendships_outgoing(options = {})
|
|
95
|
+
cursor_from_response(:ids, nil, :get, '/1.1/friendships/outgoing.json', options)
|
|
96
96
|
end
|
|
97
97
|
|
|
98
98
|
# Allows the authenticating user to follow the specified users, unless they are already followed
|
|
@@ -118,7 +118,7 @@ module Twitter
|
|
|
118
118
|
end
|
|
119
119
|
follow!(new_friends.value - existing_friends.value, arguments.options)
|
|
120
120
|
end
|
|
121
|
-
|
|
121
|
+
alias_method :create_friendship, :follow
|
|
122
122
|
deprecate_alias :friendship_create, :follow
|
|
123
123
|
|
|
124
124
|
# Allows the authenticating user to follow the specified users
|
|
@@ -138,14 +138,15 @@ module Twitter
|
|
|
138
138
|
arguments = Twitter::Arguments.new(args)
|
|
139
139
|
arguments.flatten.threaded_map do |user|
|
|
140
140
|
begin
|
|
141
|
-
object_from_response(Twitter::User, :post,
|
|
141
|
+
object_from_response(Twitter::User, :post, '/1.1/friendships/create.json', merge_user(arguments.options, user))
|
|
142
142
|
rescue Twitter::Error::Forbidden
|
|
143
143
|
# This error will be raised if the user doesn't have permission to
|
|
144
144
|
# follow list_member, for whatever reason.
|
|
145
|
+
next
|
|
145
146
|
end
|
|
146
147
|
end.compact
|
|
147
148
|
end
|
|
148
|
-
|
|
149
|
+
alias_method :create_friendship!, :follow!
|
|
149
150
|
deprecate_alias :friendship_create!, :follow!
|
|
150
151
|
|
|
151
152
|
# Allows the authenticating user to unfollow the specified users
|
|
@@ -161,9 +162,9 @@ module Twitter
|
|
|
161
162
|
# @param users [Enumerable<Integer, String, Twitter::User>] A collection of Twitter user IDs, screen names, or objects.
|
|
162
163
|
# @param options [Hash] A customizable set of options.
|
|
163
164
|
def unfollow(*args)
|
|
164
|
-
threaded_user_objects_from_response(:post,
|
|
165
|
+
threaded_user_objects_from_response(:post, '/1.1/friendships/destroy.json', args)
|
|
165
166
|
end
|
|
166
|
-
|
|
167
|
+
alias_method :destroy_friendship, :unfollow
|
|
167
168
|
deprecate_alias :friendship_destroy, :unfollow
|
|
168
169
|
|
|
169
170
|
# Allows one to enable or disable retweets and device notifications from the specified user.
|
|
@@ -177,9 +178,9 @@ module Twitter
|
|
|
177
178
|
# @param options [Hash] A customizable set of options.
|
|
178
179
|
# @option options [Boolean] :device Enable/disable device notifications from the target user.
|
|
179
180
|
# @option options [Boolean] :retweets Enable/disable retweets from the target user.
|
|
180
|
-
def friendship_update(user, options={})
|
|
181
|
+
def friendship_update(user, options = {})
|
|
181
182
|
merge_user!(options, user)
|
|
182
|
-
object_from_response(Twitter::Relationship, :post,
|
|
183
|
+
object_from_response(Twitter::Relationship, :post, '/1.1/friendships/update.json', options)
|
|
183
184
|
end
|
|
184
185
|
|
|
185
186
|
# Returns detailed information about the relationship between two users
|
|
@@ -192,15 +193,15 @@ module Twitter
|
|
|
192
193
|
# @param source [Integer, String, Twitter::User] The Twitter user ID, screen name, or object of the source user.
|
|
193
194
|
# @param target [Integer, String, Twitter::User] The Twitter user ID, screen name, or object of the target user.
|
|
194
195
|
# @param options [Hash] A customizable set of options.
|
|
195
|
-
def friendship(source, target, options={})
|
|
196
|
-
merge_user!(options, source,
|
|
196
|
+
def friendship(source, target, options = {})
|
|
197
|
+
merge_user!(options, source, 'source')
|
|
197
198
|
options[:source_id] = options.delete(:source_user_id) unless options[:source_user_id].nil?
|
|
198
|
-
merge_user!(options, target,
|
|
199
|
+
merge_user!(options, target, 'target')
|
|
199
200
|
options[:target_id] = options.delete(:target_user_id) unless options[:target_user_id].nil?
|
|
200
|
-
object_from_response(Twitter::Relationship, :get,
|
|
201
|
+
object_from_response(Twitter::Relationship, :get, '/1.1/friendships/show.json', options)
|
|
201
202
|
end
|
|
202
|
-
|
|
203
|
-
|
|
203
|
+
alias_method :friendship_show, :friendship
|
|
204
|
+
alias_method :relationship, :friendship
|
|
204
205
|
|
|
205
206
|
# Test for the existence of friendship between two users
|
|
206
207
|
#
|
|
@@ -212,7 +213,7 @@ module Twitter
|
|
|
212
213
|
# @param source [Integer, String, Twitter::User] The Twitter user ID, screen name, or object of the source user.
|
|
213
214
|
# @param target [Integer, String, Twitter::User] The Twitter user ID, screen name, or object of the target user.
|
|
214
215
|
# @param options [Hash] A customizable set of options.
|
|
215
|
-
def friendship?(source, target, options={})
|
|
216
|
+
def friendship?(source, target, options = {})
|
|
216
217
|
friendship(source, target, options).source.following?
|
|
217
218
|
end
|
|
218
219
|
|
|
@@ -223,14 +224,14 @@ module Twitter
|
|
|
223
224
|
# @authentication Requires user context
|
|
224
225
|
# @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
|
|
225
226
|
# @return [Twitter::Cursor]
|
|
226
|
-
# @overload followers(options={})
|
|
227
|
+
# @overload followers(options = {})
|
|
227
228
|
# Returns a cursored collection of user objects for users following the authenticated user.
|
|
228
229
|
#
|
|
229
230
|
# @param options [Hash] A customizable set of options.
|
|
230
231
|
# @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.
|
|
231
232
|
# @option options [Boolean, String, Integer] :skip_status Do not include contributee's Tweets when set to true, 't' or 1.
|
|
232
233
|
# @option options [Boolean, String, Integer] :include_user_entities The user entities node will be disincluded when set to false.
|
|
233
|
-
# @overload followers(user, options={})
|
|
234
|
+
# @overload followers(user, options = {})
|
|
234
235
|
# Returns a cursored collection of user objects for users following the specified user.
|
|
235
236
|
#
|
|
236
237
|
# @param user [Integer, String, Twitter::User] A Twitter user ID, screen name, URI, or object.
|
|
@@ -239,7 +240,7 @@ module Twitter
|
|
|
239
240
|
# @option options [Boolean, String, Integer] :skip_status Do not include contributee's Tweets when set to true, 't' or 1.
|
|
240
241
|
# @option options [Boolean, String, Integer] :include_user_entities The user entities node will be disincluded when set to false.
|
|
241
242
|
def followers(*args)
|
|
242
|
-
cursor_from_response_with_user(:users, Twitter::User, :get,
|
|
243
|
+
cursor_from_response_with_user(:users, Twitter::User, :get, '/1.1/followers/list.json', args)
|
|
243
244
|
end
|
|
244
245
|
|
|
245
246
|
# Returns a cursored collection of user objects for every user the specified user is following (otherwise known as their "friends").
|
|
@@ -249,14 +250,14 @@ module Twitter
|
|
|
249
250
|
# @authentication Requires user context
|
|
250
251
|
# @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
|
|
251
252
|
# @return [Twitter::Cursor]
|
|
252
|
-
# @overload friends(options={})
|
|
253
|
+
# @overload friends(options = {})
|
|
253
254
|
# Returns a cursored collection of user objects for every user the authenticated user is following (otherwise known as their "friends").
|
|
254
255
|
#
|
|
255
256
|
# @param options [Hash] A customizable set of options.
|
|
256
257
|
# @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.
|
|
257
258
|
# @option options [Boolean, String, Integer] :skip_status Do not include contributee's Tweets when set to true, 't' or 1.
|
|
258
259
|
# @option options [Boolean, String, Integer] :include_user_entities The user entities node will be disincluded when set to false.
|
|
259
|
-
# @overload friends(user, options={})
|
|
260
|
+
# @overload friends(user, options = {})
|
|
260
261
|
# Returns a cursored collection of user objects for every user the specified user is following (otherwise known as their "friends").
|
|
261
262
|
#
|
|
262
263
|
# @param user [Integer, String, Twitter::User] A Twitter user ID, screen name, URI, or object.
|
|
@@ -265,9 +266,9 @@ module Twitter
|
|
|
265
266
|
# @option options [Boolean, String, Integer] :skip_status Do not include contributee's Tweets when set to true, 't' or 1.
|
|
266
267
|
# @option options [Boolean, String, Integer] :include_user_entities The user entities node will be disincluded when set to false.
|
|
267
268
|
def friends(*args)
|
|
268
|
-
cursor_from_response_with_user(:users, Twitter::User, :get,
|
|
269
|
+
cursor_from_response_with_user(:users, Twitter::User, :get, '/1.1/friends/list.json', args)
|
|
269
270
|
end
|
|
270
|
-
|
|
271
|
+
alias_method :following, :friends
|
|
271
272
|
|
|
272
273
|
# Returns a collection of user IDs that the currently authenticated user does not want to receive retweets from.
|
|
273
274
|
# @see https://dev.twitter.com/docs/api/1.1/get/friendships/no_retweets/ids
|
|
@@ -276,11 +277,10 @@ module Twitter
|
|
|
276
277
|
# @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
|
|
277
278
|
# @return [Array<Integer>]
|
|
278
279
|
# @param options [Hash] A customizable set of options.
|
|
279
|
-
def no_retweet_ids(options={})
|
|
280
|
-
get(
|
|
280
|
+
def no_retweet_ids(options = {})
|
|
281
|
+
get('/1.1/friendships/no_retweets/ids.json', options)[:body].map(&:to_i)
|
|
281
282
|
end
|
|
282
|
-
|
|
283
|
-
|
|
283
|
+
alias_method :no_retweets_ids, :no_retweet_ids
|
|
284
284
|
end
|
|
285
285
|
end
|
|
286
286
|
end
|