twitter 8.2.0 → 8.3.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.
Files changed (100) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE.md +1 -1
  3. data/README.md +172 -10
  4. data/lib/twitter/arguments.rb +14 -1
  5. data/lib/twitter/base.rb +72 -11
  6. data/lib/twitter/basic_user.rb +7 -1
  7. data/lib/twitter/client.rb +94 -3
  8. data/lib/twitter/creatable.rb +11 -2
  9. data/lib/twitter/cursor.rb +58 -11
  10. data/lib/twitter/direct_message.rb +32 -4
  11. data/lib/twitter/direct_message_event.rb +34 -10
  12. data/lib/twitter/direct_messages/welcome_message.rb +22 -1
  13. data/lib/twitter/direct_messages/welcome_message_rule.rb +7 -0
  14. data/lib/twitter/direct_messages/welcome_message_rule_wrapper.rb +26 -3
  15. data/lib/twitter/direct_messages/welcome_message_wrapper.rb +36 -11
  16. data/lib/twitter/entities.rb +84 -8
  17. data/lib/twitter/entity/hashtag.rb +7 -1
  18. data/lib/twitter/entity/symbol.rb +7 -1
  19. data/lib/twitter/entity/uri.rb +2 -1
  20. data/lib/twitter/entity/user_mention.rb +20 -1
  21. data/lib/twitter/entity.rb +7 -1
  22. data/lib/twitter/enumerable.rb +20 -3
  23. data/lib/twitter/error.rb +137 -61
  24. data/lib/twitter/factory.rb +9 -5
  25. data/lib/twitter/geo/point.rb +37 -5
  26. data/lib/twitter/geo/polygon.rb +1 -0
  27. data/lib/twitter/geo.rb +16 -2
  28. data/lib/twitter/geo_factory.rb +7 -3
  29. data/lib/twitter/geo_results.rb +39 -8
  30. data/lib/twitter/headers.rb +44 -7
  31. data/lib/twitter/identity.rb +13 -3
  32. data/lib/twitter/language.rb +21 -1
  33. data/lib/twitter/list.rb +101 -11
  34. data/lib/twitter/media/animated_gif.rb +1 -0
  35. data/lib/twitter/media/photo.rb +19 -3
  36. data/lib/twitter/media/video.rb +21 -3
  37. data/lib/twitter/media/video_info.rb +15 -1
  38. data/lib/twitter/media_factory.rb +7 -3
  39. data/lib/twitter/metadata.rb +14 -1
  40. data/lib/twitter/null_object.rb +16 -14
  41. data/lib/twitter/oembed.rb +56 -2
  42. data/lib/twitter/place.rb +74 -6
  43. data/lib/twitter/premium_search_results.rb +87 -18
  44. data/lib/twitter/profile.rb +100 -44
  45. data/lib/twitter/profile_banner.rb +9 -4
  46. data/lib/twitter/rate_limit.rb +32 -3
  47. data/lib/twitter/relationship.rb +8 -5
  48. data/lib/twitter/rest/account_activity.rb +55 -26
  49. data/lib/twitter/rest/api.rb +2 -0
  50. data/lib/twitter/rest/client.rb +18 -0
  51. data/lib/twitter/rest/direct_messages/welcome_messages.rb +89 -18
  52. data/lib/twitter/rest/direct_messages.rb +158 -94
  53. data/lib/twitter/rest/favorites.rb +57 -21
  54. data/lib/twitter/rest/form_encoder.rb +57 -17
  55. data/lib/twitter/rest/friends_and_followers.rb +101 -35
  56. data/lib/twitter/rest/help.rb +13 -3
  57. data/lib/twitter/rest/lists.rb +133 -45
  58. data/lib/twitter/rest/oauth.rb +23 -17
  59. data/lib/twitter/rest/places_and_geo.rb +44 -28
  60. data/lib/twitter/rest/premium_search.rb +18 -13
  61. data/lib/twitter/rest/request.rb +171 -53
  62. data/lib/twitter/rest/saved_searches.rb +22 -7
  63. data/lib/twitter/rest/search.rb +20 -16
  64. data/lib/twitter/rest/spam_reporting.rb +5 -1
  65. data/lib/twitter/rest/suggested_users.rb +14 -5
  66. data/lib/twitter/rest/timelines.rb +92 -52
  67. data/lib/twitter/rest/trends.rb +31 -12
  68. data/lib/twitter/rest/tweets.rb +145 -88
  69. data/lib/twitter/rest/undocumented.rb +11 -2
  70. data/lib/twitter/rest/upload_utils.rb +42 -26
  71. data/lib/twitter/rest/users.rb +150 -71
  72. data/lib/twitter/rest/utils.rb +135 -39
  73. data/lib/twitter/saved_search.rb +23 -2
  74. data/lib/twitter/search_results.rb +62 -17
  75. data/lib/twitter/settings.rb +37 -11
  76. data/lib/twitter/size.rb +37 -3
  77. data/lib/twitter/source_user.rb +4 -3
  78. data/lib/twitter/streaming/client.rb +60 -8
  79. data/lib/twitter/streaming/connection.rb +55 -8
  80. data/lib/twitter/streaming/deleted_tweet.rb +8 -0
  81. data/lib/twitter/streaming/event.rb +43 -1
  82. data/lib/twitter/streaming/friend_list.rb +1 -0
  83. data/lib/twitter/streaming/message_parser.rb +20 -10
  84. data/lib/twitter/streaming/response.rb +31 -5
  85. data/lib/twitter/streaming/stall_warning.rb +23 -0
  86. data/lib/twitter/suggestion.rb +25 -1
  87. data/lib/twitter/target_user.rb +2 -1
  88. data/lib/twitter/trend.rb +29 -1
  89. data/lib/twitter/trend_results.rb +50 -7
  90. data/lib/twitter/tweet.rb +180 -21
  91. data/lib/twitter/user.rb +289 -53
  92. data/lib/twitter/utils.rb +12 -13
  93. data/lib/twitter/variant.rb +12 -1
  94. data/lib/twitter/version.rb +66 -29
  95. data/lib/twitter.rb +6 -1
  96. metadata +23 -57
  97. data/.yardopts +0 -16
  98. data/CHANGELOG.md +0 -1040
  99. data/CONTRIBUTING.md +0 -49
  100. data/twitter.gemspec +0 -40
@@ -7,14 +7,20 @@ require "twitter/utils"
7
7
 
8
8
  module Twitter
9
9
  module REST
10
+ # Methods for working with favorite tweets
10
11
  module Favorites
11
12
  include Twitter::REST::Utils
12
13
  include Twitter::Utils
13
14
 
15
+ # Returns favorite Tweets for the user
16
+ #
17
+ # @api public
14
18
  # @see https://dev.twitter.com/rest/reference/get/favorites/list
15
19
  # @rate_limited Yes
16
20
  # @authentication Requires user context
17
21
  # @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
22
+ # @example
23
+ # client.favorites
18
24
  # @return [Array<Twitter::Tweet>] favorite Tweets.
19
25
  # @overload favorites(options = {})
20
26
  # Returns the 20 most recent favorite Tweets for the authenticating user
@@ -30,17 +36,20 @@ module Twitter
30
36
  # @option options [Integer] :count Specifies the number of records to retrieve. Must be less than or equal to 200.
31
37
  # @option options [Integer] :since_id Returns results with an ID greater than (that is, more recent than) the specified ID.
32
38
  def favorites(*args)
33
- arguments = Twitter::Arguments.new(args)
39
+ arguments = Arguments.new(args)
34
40
  merge_user!(arguments.options, arguments.pop) if arguments.last
35
- perform_get_with_objects("/1.1/favorites/list.json", arguments.options, Twitter::Tweet)
41
+ perform_get_with_objects("/1.1/favorites/list.json", arguments.options, Tweet)
36
42
  end
37
43
 
38
44
  # Un-favorites the specified Tweets as the authenticating user
39
45
  #
46
+ # @api public
40
47
  # @see https://dev.twitter.com/rest/reference/post/favorites/destroy
41
48
  # @rate_limited No
42
49
  # @authentication Requires user context
43
50
  # @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
51
+ # @example
52
+ # client.unfavorite(25938088801)
44
53
  # @return [Array<Twitter::Tweet>] The un-favorited Tweets.
45
54
  # @overload unfavorite(*tweets)
46
55
  # @param tweets [Enumerable<Integer, String, URI, Twitter::Tweet>] A collection of Tweet IDs, URIs, or objects.
@@ -48,22 +57,28 @@ module Twitter
48
57
  # @param tweets [Enumerable<Integer, String, URI, Twitter::Tweet>] A collection of Tweet IDs, URIs, or objects.
49
58
  # @param options [Hash] A customizable set of options.
50
59
  def unfavorite(*args)
51
- arguments = Twitter::Arguments.new(args)
60
+ arguments = Arguments.new(args)
52
61
  pmap(arguments) do |tweet|
53
- perform_post_with_object("/1.1/favorites/destroy.json", arguments.options.merge(id: extract_id(tweet)), Twitter::Tweet)
54
- rescue Twitter::Error::NotFound
55
- next
62
+ perform_post_with_object("/1.1/favorites/destroy.json", arguments.options.merge(id: extract_id(tweet)), Tweet)
63
+ rescue Error::NotFound
64
+ nil
56
65
  end.compact
57
66
  end
58
- alias destroy_favorite unfavorite
67
+ # @!method destroy_favorite
68
+ # @api public
69
+ # @see #unfavorite
70
+ alias_method :destroy_favorite, :unfavorite
59
71
 
60
- # Un-favorites the specified Tweets as the authenticating user and raises an error if one is not found
72
+ # Un-favorites the specified Tweets and raises an error if not found
61
73
  #
74
+ # @api public
62
75
  # @see https://dev.twitter.com/rest/reference/post/favorites/destroy
63
76
  # @rate_limited No
64
77
  # @authentication Requires user context
65
78
  # @raise [Twitter::Error::NotFound] Error raised when tweet does not exist or has been deleted.
66
79
  # @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
80
+ # @example
81
+ # client.unfavorite!(25938088801)
67
82
  # @return [Array<Twitter::Tweet>] The un-favorited Tweets.
68
83
  # @overload unfavorite!(*tweets)
69
84
  # @param tweets [Enumerable<Integer, String, URI, Twitter::Tweet>] A collection of Tweet IDs, URIs, or objects.
@@ -71,15 +86,18 @@ module Twitter
71
86
  # @param tweets [Enumerable<Integer, String, URI, Twitter::Tweet>] A collection of Tweet IDs, URIs, or objects.
72
87
  # @param options [Hash] A customizable set of options.
73
88
  def unfavorite!(*args)
74
- parallel_objects_from_response(Twitter::Tweet, :post, "/1.1/favorites/destroy.json", args)
89
+ parallel_objects_from_response(Tweet, :post, "/1.1/favorites/destroy.json", args)
75
90
  end
76
91
 
77
92
  # Favorites the specified Tweets as the authenticating user
78
93
  #
94
+ # @api public
79
95
  # @see https://dev.twitter.com/rest/reference/post/favorites/create
80
96
  # @rate_limited No
81
97
  # @authentication Requires user context
82
98
  # @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
99
+ # @example
100
+ # client.favorite(25938088801)
83
101
  # @return [Array<Twitter::Tweet>] The favorited Tweets.
84
102
  # @overload favorite(*tweets)
85
103
  # @param tweets [Enumerable<Integer, String, URI, Twitter::Tweet>] A collection of Tweet IDs, URIs, or objects.
@@ -87,24 +105,33 @@ module Twitter
87
105
  # @param tweets [Enumerable<Integer, String, URI, Twitter::Tweet>] A collection of Tweet IDs, URIs, or objects.
88
106
  # @param options [Hash] A customizable set of options.
89
107
  def favorite(*args)
90
- arguments = Twitter::Arguments.new(args)
108
+ arguments = Arguments.new(args)
91
109
  pmap(arguments) do |tweet|
92
- perform_post_with_object("/1.1/favorites/create.json", arguments.options.merge(id: extract_id(tweet)), Twitter::Tweet)
93
- rescue Twitter::Error::AlreadyFavorited, Twitter::Error::NotFound
94
- next
110
+ perform_post_with_object("/1.1/favorites/create.json", arguments.options.merge(id: extract_id(tweet)), Tweet)
111
+ rescue Error::AlreadyFavorited, Error::NotFound
112
+ nil
95
113
  end.compact
96
114
  end
97
- alias fav favorite
98
- alias fave favorite
115
+ # @!method fav
116
+ # @api public
117
+ # @see #favorite
118
+ alias_method :fav, :favorite
119
+ # @!method fave
120
+ # @api public
121
+ # @see #favorite
122
+ alias_method :fave, :favorite
99
123
 
100
- # Favorites the specified Tweets as the authenticating user and raises an error if one has already been favorited
124
+ # Favorites the specified Tweets and raises an error if already favorited
101
125
  #
126
+ # @api public
102
127
  # @see https://dev.twitter.com/rest/reference/post/favorites/create
103
128
  # @rate_limited No
104
129
  # @authentication Requires user context
105
130
  # @raise [Twitter::Error::AlreadyFavorited] Error raised when tweet has already been favorited.
106
131
  # @raise [Twitter::Error::NotFound] Error raised when tweet does not exist or has been deleted.
107
132
  # @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
133
+ # @example
134
+ # client.favorite!(25938088801)
108
135
  # @return [Array<Twitter::Tweet>] The favorited Tweets.
109
136
  # @overload favorite!(*tweets)
110
137
  # @param tweets [Enumerable<Integer, String, URI, Twitter::Tweet>] A collection of Tweet IDs, URIs, or objects.
@@ -112,14 +139,23 @@ module Twitter
112
139
  # @param tweets [Enumerable<Integer, String, URI, Twitter::Tweet>] A collection of Tweet IDs, URIs, or objects.
113
140
  # @param options [Hash] A customizable set of options.
114
141
  def favorite!(*args)
115
- arguments = Twitter::Arguments.new(args)
142
+ arguments = Arguments.new(args)
116
143
  pmap(arguments) do |tweet|
117
- perform_post_with_object("/1.1/favorites/create.json", arguments.options.merge(id: extract_id(tweet)), Twitter::Tweet)
144
+ perform_post_with_object("/1.1/favorites/create.json", arguments.options.merge(id: extract_id(tweet)), Tweet)
118
145
  end
119
146
  end
120
- alias create_favorite! favorite!
121
- alias fav! favorite!
122
- alias fave! favorite!
147
+ # @!method create_favorite!
148
+ # @api public
149
+ # @see #favorite!
150
+ alias_method :create_favorite!, :favorite!
151
+ # @!method fav!
152
+ # @api public
153
+ # @see #favorite!
154
+ alias_method :fav!, :favorite!
155
+ # @!method fave!
156
+ # @api public
157
+ # @see #favorite!
158
+ alias_method :fave!, :favorite!
123
159
  end
124
160
  end
125
161
  end
@@ -1,27 +1,67 @@
1
1
  module Twitter
2
2
  module REST
3
+ # Encodes form data for HTTP requests
3
4
  class FormEncoder
5
+ # Characters that don't need to be escaped
4
6
  UNESCAPED_CHARS = /[^a-z0-9\-._~]/i
5
7
 
8
+ # Encodes data hash into form-encoded string
9
+ #
10
+ # @api public
11
+ # @example
12
+ # Twitter::REST::FormEncoder.encode(name: "test", value: 123)
13
+ # @param data [Hash] The data to encode
14
+ # @return [String]
6
15
  def self.encode(data)
7
- data.collect do |k, v|
8
- if v.nil?
9
- ::URI::DEFAULT_PARSER.escape(k.to_s, UNESCAPED_CHARS)
10
- elsif v.respond_to?(:to_ary)
11
- v.to_ary.collect do |w|
12
- str = ::URI::DEFAULT_PARSER.escape(k.to_s, UNESCAPED_CHARS)
13
- unless w.nil?
14
- str << "="
15
- str << ::URI::DEFAULT_PARSER.escape(w.to_s, UNESCAPED_CHARS)
16
- end
17
- end.join("&")
18
- else
19
- str = ::URI::DEFAULT_PARSER.escape(k.to_s, UNESCAPED_CHARS)
20
- str << "="
21
- str << ::URI::DEFAULT_PARSER.escape(v.to_s, UNESCAPED_CHARS)
22
- end
23
- end.join("&")
16
+ data.collect { |k, v| encode_pair(k, v) }.join("&")
24
17
  end
18
+
19
+ # Encodes a key-value pair
20
+ #
21
+ # @api private
22
+ # @param key [Object] The key to encode
23
+ # @param value [Object] The value to encode
24
+ # @return [String]
25
+ def self.encode_pair(key, value)
26
+ if value.nil?
27
+ escape(key)
28
+ elsif value.respond_to?(:to_ary)
29
+ encode_array(key, value.to_ary)
30
+ else
31
+ "#{escape(key)}=#{escape(value)}"
32
+ end
33
+ end
34
+
35
+ # Encodes an array of values with the same key
36
+ #
37
+ # @api private
38
+ # @param key [Object] The key to encode
39
+ # @param array [Array] The array of values
40
+ # @return [String]
41
+ def self.encode_array(key, array)
42
+ array.collect { |item| encode_array_item(key, item) }
43
+ end
44
+
45
+ # Encodes a single array item
46
+ #
47
+ # @api private
48
+ # @param key [Object] The key to encode
49
+ # @param item [Object] The item to encode
50
+ # @return [String]
51
+ def self.encode_array_item(key, item)
52
+ item.nil? ? escape(key) : "#{escape(key)}=#{escape(item)}"
53
+ end
54
+
55
+ # URI escapes a value
56
+ #
57
+ # @api private
58
+ # @param value [Object] The value to escape
59
+ # @return [String]
60
+ def self.escape(value)
61
+ URI::DEFAULT_PARSER.escape(value.to_s, UNESCAPED_CHARS) # steep:ignore UnknownConstant
62
+ end
63
+
64
+ private_class_method :encode_pair, :encode_array, :encode_array_item, :escape
25
65
  end
26
66
  end
27
67
  end
@@ -8,14 +8,20 @@ require "twitter/utils"
8
8
 
9
9
  module Twitter
10
10
  module REST
11
+ # Methods for working with friends and followers
11
12
  module FriendsAndFollowers
12
13
  include Twitter::REST::Utils
13
14
  include Twitter::Utils
14
15
 
16
+ # Returns IDs of users the specified user is following
17
+ #
18
+ # @api public
15
19
  # @see https://dev.twitter.com/rest/reference/get/friends/ids
16
20
  # @rate_limited Yes
17
21
  # @authentication Requires user context
18
22
  # @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
23
+ # @example
24
+ # client.friend_ids
19
25
  # @return [Twitter::Cursor]
20
26
  # @overload friend_ids(options = {})
21
27
  # Returns an array of numeric IDs for every user the authenticated user is following
@@ -30,10 +36,15 @@ module Twitter
30
36
  cursor_from_response_with_user(:ids, nil, "/1.1/friends/ids.json", args)
31
37
  end
32
38
 
39
+ # Returns IDs of users following the specified user
40
+ #
41
+ # @api public
33
42
  # @see https://dev.twitter.com/rest/reference/get/followers/ids
34
43
  # @rate_limited Yes
35
44
  # @authentication Requires user context
36
45
  # @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
46
+ # @example
47
+ # client.follower_ids
37
48
  # @return [Twitter::Cursor]
38
49
  # @overload follower_ids(options = {})
39
50
  # Returns an array of numeric IDs for every user following the authenticated user
@@ -48,12 +59,15 @@ module Twitter
48
59
  cursor_from_response_with_user(:ids, nil, "/1.1/followers/ids.json", args)
49
60
  end
50
61
 
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.
62
+ # Returns the relationship of the authenticating user to the users
52
63
  #
64
+ # @api public
53
65
  # @see https://dev.twitter.com/rest/reference/get/friendships/lookup
54
66
  # @rate_limited Yes
55
67
  # @authentication Requires user context
56
68
  # @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
69
+ # @example
70
+ # client.friendships('sferik', 'pengwynn')
57
71
  # @return [Array<Twitter::User>] The requested users.
58
72
  # @overload friendships(*users)
59
73
  # @param users [Enumerable<Integer, String, Twitter::User>] A collection of Twitter user IDs, screen names, or objects.
@@ -61,41 +75,50 @@ module Twitter
61
75
  # @param users [Enumerable<Integer, String, Twitter::User>] A collection of Twitter user IDs, screen names, or objects.
62
76
  # @param options [Hash] A customizable set of options.
63
77
  def friendships(*args)
64
- arguments = Twitter::Arguments.new(args)
78
+ arguments = Arguments.new(args)
65
79
  merge_users!(arguments.options, arguments)
66
- perform_get_with_objects("/1.1/friendships/lookup.json", arguments.options, Twitter::User)
80
+ perform_get_with_objects("/1.1/friendships/lookup.json", arguments.options, User)
67
81
  end
68
82
 
69
- # Returns an array of numeric IDs for every user who has a pending request to follow the authenticating user
83
+ # Returns IDs of users with pending follow requests
70
84
  #
85
+ # @api public
71
86
  # @see https://dev.twitter.com/rest/reference/get/friendships/incoming
72
87
  # @rate_limited Yes
73
88
  # @authentication Requires user context
74
89
  # @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
90
+ # @example
91
+ # client.friendships_incoming
75
92
  # @return [Twitter::Cursor]
76
93
  # @param options [Hash] A customizable set of options.
77
94
  def friendships_incoming(options = {})
78
95
  perform_get_with_cursor("/1.1/friendships/incoming.json", options, :ids)
79
96
  end
80
97
 
81
- # Returns an array of numeric IDs for every protected user for whom the authenticating user has a pending follow request
98
+ # Returns IDs of protected users with pending follow requests
82
99
  #
100
+ # @api public
83
101
  # @see https://dev.twitter.com/rest/reference/get/friendships/outgoing
84
102
  # @rate_limited Yes
85
103
  # @authentication Requires user context
86
104
  # @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
105
+ # @example
106
+ # client.friendships_outgoing
87
107
  # @return [Twitter::Cursor]
88
108
  # @param options [Hash] A customizable set of options.
89
109
  def friendships_outgoing(options = {})
90
110
  perform_get_with_cursor("/1.1/friendships/outgoing.json", options, :ids)
91
111
  end
92
112
 
93
- # Allows the authenticating user to follow the specified users, unless they are already followed
113
+ # Follows the specified users unless they are already followed
94
114
  #
115
+ # @api public
95
116
  # @see https://dev.twitter.com/rest/reference/post/friendships/create
96
117
  # @rate_limited Yes
97
118
  # @authentication Requires user context
98
119
  # @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
120
+ # @example
121
+ # client.follow('sferik')
99
122
  # @return [Array<Twitter::User>] The followed users.
100
123
  # @overload follow(*users)
101
124
  # @param users [Enumerable<Integer, String, Twitter::User>] A collection of Twitter user IDs, screen names, or objects.
@@ -104,23 +127,26 @@ module Twitter
104
127
  # @param options [Hash] A customizable set of options.
105
128
  # @option options [Boolean] :follow (false) Enable notifications for the target user.
106
129
  def follow(*args)
107
- arguments = Twitter::Arguments.new(args)
108
- existing_friends = Thread.new do
109
- friend_ids.to_a
110
- end
111
- new_friends = Thread.new do
112
- users(args).collect(&:id)
113
- end
114
- follow!(new_friends.value - existing_friends.value, arguments.options)
130
+ arguments = Arguments.new(args)
131
+ existing_friends = friend_ids.to_a
132
+ new_friends = users(args).collect(&:id) # steep:ignore NoMethod
133
+
134
+ follow!(new_friends - existing_friends, arguments.options)
115
135
  end
116
- alias create_friendship follow
136
+ # @!method create_friendship
137
+ # @api public
138
+ # @see #follow
139
+ alias_method :create_friendship, :follow
117
140
 
118
- # Allows the authenticating user to follow the specified users
141
+ # Follows the specified users
119
142
  #
143
+ # @api public
120
144
  # @see https://dev.twitter.com/rest/reference/post/friendships/create
121
145
  # @rate_limited No
122
146
  # @authentication Requires user context
123
147
  # @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
148
+ # @example
149
+ # client.follow!('sferik')
124
150
  # @return [Array<Twitter::User>] The followed users.
125
151
  # @overload follow!(*users)
126
152
  # @param users [Enumerable<Integer, String, Twitter::User>] A collection of Twitter user IDs, screen names, or objects.
@@ -129,19 +155,25 @@ module Twitter
129
155
  # @param options [Hash] A customizable set of options.
130
156
  # @option options [Boolean] :follow (false) Enable notifications for the target user.
131
157
  def follow!(*args)
132
- arguments = Twitter::Arguments.new(args)
158
+ arguments = Arguments.new(args)
133
159
  pmap(arguments) do |user|
134
- perform_post_with_object("/1.1/friendships/create.json", merge_user(arguments.options, user), Twitter::User)
135
- end.compact
160
+ perform_post_with_object("/1.1/friendships/create.json", merge_user(arguments.options, user), User) # steep:ignore ArgumentTypeMismatch
161
+ end
136
162
  end
137
- alias create_friendship! follow!
163
+ # @!method create_friendship!
164
+ # @api public
165
+ # @see #follow!
166
+ alias_method :create_friendship!, :follow!
138
167
 
139
- # Allows the authenticating user to unfollow the specified users
168
+ # Unfollows the specified users
140
169
  #
170
+ # @api public
141
171
  # @see https://dev.twitter.com/rest/reference/post/friendships/destroy
142
172
  # @rate_limited No
143
173
  # @authentication Requires user context
144
174
  # @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
175
+ # @example
176
+ # client.unfollow('sferik')
145
177
  # @return [Array<Twitter::User>] The unfollowed users.
146
178
  # @overload unfollow(*users)
147
179
  # @param users [Enumerable<Integer, String, Twitter::User>] A collection of Twitter user IDs, screen names, or objects.
@@ -151,14 +183,20 @@ module Twitter
151
183
  def unfollow(*args)
152
184
  parallel_users_from_response(:post, "/1.1/friendships/destroy.json", args)
153
185
  end
154
- alias destroy_friendship unfollow
186
+ # @!method destroy_friendship
187
+ # @api public
188
+ # @see #unfollow
189
+ alias_method :destroy_friendship, :unfollow
155
190
 
156
- # Allows one to enable or disable retweets and device notifications from the specified user.
191
+ # Enables or disables retweets and notifications from the user
157
192
  #
193
+ # @api public
158
194
  # @see https://dev.twitter.com/rest/reference/post/friendships/update
159
195
  # @rate_limited No
160
196
  # @authentication Requires user context
161
197
  # @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
198
+ # @example
199
+ # client.friendship_update('sferik', retweets: false)
162
200
  # @return [Twitter::Relationship]
163
201
  # @param user [Integer, String, Twitter::User] A Twitter user ID, screen name, URI, or object.
164
202
  # @param options [Hash] A customizable set of options.
@@ -166,15 +204,18 @@ module Twitter
166
204
  # @option options [Boolean] :retweets Enable/disable retweets from the target user.
167
205
  def friendship_update(user, options = {})
168
206
  merge_user!(options, user)
169
- perform_post_with_object("/1.1/friendships/update.json", options, Twitter::Relationship)
207
+ perform_post_with_object("/1.1/friendships/update.json", options, Relationship)
170
208
  end
171
209
 
172
210
  # Returns detailed information about the relationship between two users
173
211
  #
212
+ # @api public
174
213
  # @see https://dev.twitter.com/rest/reference/get/friendships/show
175
214
  # @rate_limited Yes
176
215
  # @authentication Requires user context
177
216
  # @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
217
+ # @example
218
+ # client.friendship('sferik', 'pengwynn')
178
219
  # @return [Twitter::Relationship]
179
220
  # @param source [Integer, String, Twitter::User] The Twitter user ID, screen name, or object of the source user.
180
221
  # @param target [Integer, String, Twitter::User] The Twitter user ID, screen name, or object of the target user.
@@ -185,17 +226,26 @@ module Twitter
185
226
  options[:source_id] = options.delete(:source_user_id) unless options[:source_user_id].nil?
186
227
  merge_user!(options, target, "target")
187
228
  options[:target_id] = options.delete(:target_user_id) unless options[:target_user_id].nil?
188
- perform_get_with_object("/1.1/friendships/show.json", options, Twitter::Relationship)
229
+ perform_get_with_object("/1.1/friendships/show.json", options, Relationship)
189
230
  end
190
- alias friendship_show friendship
191
- alias relationship friendship
231
+ # @!method friendship_show
232
+ # @api public
233
+ # @see #friendship
234
+ alias_method :friendship_show, :friendship
235
+ # @!method relationship
236
+ # @api public
237
+ # @see #friendship
238
+ alias_method :relationship, :friendship
192
239
 
193
- # Test for the existence of friendship between two users
240
+ # Tests for the existence of friendship between two users
194
241
  #
242
+ # @api public
195
243
  # @see https://dev.twitter.com/rest/reference/get/friendships/show
196
244
  # @rate_limited Yes
197
245
  # @authentication Requires user context
198
246
  # @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
247
+ # @example
248
+ # client.friendship?('sferik', 'pengwynn')
199
249
  # @return [Boolean] true if user_a follows user_b, otherwise false.
200
250
  # @param source [Integer, String, Twitter::User] The Twitter user ID, screen name, or object of the source user.
201
251
  # @param target [Integer, String, Twitter::User] The Twitter user ID, screen name, or object of the target user.
@@ -204,12 +254,15 @@ module Twitter
204
254
  friendship(source, target, options).source.following?
205
255
  end
206
256
 
207
- # Returns a cursored collection of user objects for users following the specified user.
257
+ # Returns a collection of users following the specified user
208
258
  #
259
+ # @api public
209
260
  # @see https://dev.twitter.com/rest/reference/get/followers/list
210
261
  # @rate_limited Yes
211
262
  # @authentication Requires user context
212
263
  # @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
264
+ # @example
265
+ # client.followers
213
266
  # @return [Twitter::Cursor]
214
267
  # @overload followers(options = {})
215
268
  # Returns a cursored collection of user objects for users following the authenticated user.
@@ -225,15 +278,18 @@ module Twitter
225
278
  # @option options [Boolean, String, Integer] :skip_status Do not include contributee's Tweets when set to true, 't' or 1.
226
279
  # @option options [Boolean, String, Integer] :include_user_entities The user entities node will be disincluded when set to false.
227
280
  def followers(*args)
228
- cursor_from_response_with_user(:users, Twitter::User, "/1.1/followers/list.json", args)
281
+ cursor_from_response_with_user(:users, User, "/1.1/followers/list.json", args)
229
282
  end
230
283
 
231
- # Returns a cursored collection of user objects for every user the specified user is following (otherwise known as their "friends").
284
+ # Returns a collection of users the specified user is following
232
285
  #
286
+ # @api public
233
287
  # @see https://dev.twitter.com/rest/reference/get/friends/list
234
288
  # @rate_limited Yes
235
289
  # @authentication Requires user context
236
290
  # @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
291
+ # @example
292
+ # client.friends
237
293
  # @return [Twitter::Cursor]
238
294
  # @overload friends(options = {})
239
295
  # Returns a cursored collection of user objects for every user the authenticated user is following (otherwise known as their "friends").
@@ -249,21 +305,31 @@ module Twitter
249
305
  # @option options [Boolean, String, Integer] :skip_status Do not include contributee's Tweets when set to true, 't' or 1.
250
306
  # @option options [Boolean, String, Integer] :include_user_entities The user entities node will be disincluded when set to false.
251
307
  def friends(*args)
252
- cursor_from_response_with_user(:users, Twitter::User, "/1.1/friends/list.json", args)
308
+ cursor_from_response_with_user(:users, User, "/1.1/friends/list.json", args)
253
309
  end
254
- alias following friends
310
+ # @!method following
311
+ # @api public
312
+ # @see #friends
313
+ alias_method :following, :friends
255
314
 
256
- # Returns a collection of user IDs that the currently authenticated user does not want to receive retweets from.
315
+ # Returns IDs of users you don't want to receive retweets from
316
+ #
317
+ # @api public
257
318
  # @see https://dev.twitter.com/rest/reference/get/friendships/no_retweets/ids
258
319
  # @rate_limited Yes
259
320
  # @authentication Requires user context
260
321
  # @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
322
+ # @example
323
+ # client.no_retweet_ids
261
324
  # @return [Array<Integer>]
262
325
  # @param options [Hash] A customizable set of options.
263
326
  def no_retweet_ids(options = {})
264
327
  perform_get("/1.1/friendships/no_retweets/ids.json", options).collect(&:to_i)
265
328
  end
266
- alias no_retweets_ids no_retweet_ids
329
+ # @!method no_retweets_ids
330
+ # @api public
331
+ # @see #no_retweet_ids
332
+ alias_method :no_retweets_ids, :no_retweet_ids
267
333
  end
268
334
  end
269
335
  end
@@ -4,37 +4,47 @@ require "twitter/rest/utils"
4
4
 
5
5
  module Twitter
6
6
  module REST
7
+ # Methods for accessing Twitter help resources
7
8
  module Help
8
9
  include Twitter::REST::Utils
9
10
 
10
11
  # Returns the list of languages supported by Twitter
11
12
  #
13
+ # @api public
12
14
  # @see https://dev.twitter.com/rest/reference/get/help/languages
13
15
  # @rate_limited Yes
14
16
  # @authentication Requires user context
15
17
  # @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
18
+ # @example
19
+ # client.languages
16
20
  # @return [Array<Twitter::Language>]
17
21
  def languages(options = {})
18
- perform_get_with_objects("/1.1/help/languages.json", options, Twitter::Language)
22
+ perform_get_with_objects("/1.1/help/languages.json", options, Language)
19
23
  end
20
24
 
21
- # Returns {https://twitter.com/privacy Twitter's Privacy Policy}
25
+ # Returns Twitter's Privacy Policy
22
26
  #
27
+ # @api public
23
28
  # @see https://dev.twitter.com/rest/reference/get/help/privacy
24
29
  # @rate_limited Yes
25
30
  # @authentication Requires user context
26
31
  # @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
32
+ # @example
33
+ # client.privacy
27
34
  # @return [String]
28
35
  def privacy(options = {})
29
36
  perform_get("/1.1/help/privacy.json", options)[:privacy]
30
37
  end
31
38
 
32
- # Returns {https://twitter.com/tos Twitter's Terms of Service}
39
+ # Returns Twitter's Terms of Service
33
40
  #
41
+ # @api public
34
42
  # @see https://dev.twitter.com/rest/reference/get/help/tos
35
43
  # @rate_limited Yes
36
44
  # @authentication Requires user context
37
45
  # @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
46
+ # @example
47
+ # client.tos
38
48
  # @return [String]
39
49
  def tos(options = {})
40
50
  perform_get("/1.1/help/tos.json", options)[:tos]