twitter 5.6.0 → 5.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (93) hide show
  1. data.tar.gz.sig +0 -0
  2. data/.yardopts +1 -0
  3. data/CHANGELOG.md +8 -0
  4. data/README.md +3 -3
  5. data/Rakefile +1 -1
  6. data/lib/twitter/base.rb +0 -8
  7. data/lib/twitter/client.rb +2 -1
  8. data/lib/twitter/cursor.rb +2 -15
  9. data/lib/twitter/error.rb +90 -18
  10. data/lib/twitter/geo_results.rb +0 -10
  11. data/lib/twitter/request.rb +4 -4
  12. data/lib/twitter/rest/api.rb +43 -0
  13. data/lib/twitter/rest/client.rb +10 -44
  14. data/lib/twitter/rest/direct_messages.rb +138 -0
  15. data/lib/twitter/rest/favorites.rb +108 -0
  16. data/lib/twitter/rest/friends_and_followers.rb +281 -0
  17. data/lib/twitter/rest/help.rb +56 -0
  18. data/lib/twitter/rest/lists.rb +497 -0
  19. data/lib/twitter/rest/oauth.rb +65 -0
  20. data/lib/twitter/rest/places_and_geo.rb +84 -0
  21. data/lib/twitter/rest/request/multipart_with_file.rb +5 -5
  22. data/lib/twitter/rest/response/parse_json.rb +2 -4
  23. data/lib/twitter/rest/response/raise_error.rb +24 -15
  24. data/lib/twitter/rest/saved_searches.rb +93 -0
  25. data/lib/twitter/rest/search.rb +37 -0
  26. data/lib/twitter/rest/spam_reporting.rb +27 -0
  27. data/lib/twitter/rest/suggested_users.rb +49 -0
  28. data/lib/twitter/rest/timelines.rb +200 -0
  29. data/lib/twitter/rest/trends.rb +57 -0
  30. data/lib/twitter/rest/tweets.rb +309 -0
  31. data/lib/twitter/rest/undocumented.rb +49 -0
  32. data/lib/twitter/rest/users.rb +383 -0
  33. data/lib/twitter/rest/utils.rb +205 -0
  34. data/lib/twitter/search_results.rb +2 -13
  35. data/lib/twitter/trend_results.rb +0 -10
  36. data/lib/twitter/version.rb +1 -1
  37. data/spec/helper.rb +1 -1
  38. data/spec/twitter/error_spec.rb +26 -42
  39. data/spec/twitter/rest/{api/direct_messages_spec.rb → direct_messages_spec.rb} +1 -1
  40. data/spec/twitter/rest/{api/favorites_spec.rb → favorites_spec.rb} +1 -1
  41. data/spec/twitter/rest/{api/friends_and_followers_spec.rb → friends_and_followers_spec.rb} +1 -1
  42. data/spec/twitter/rest/{api/geo_spec.rb → geo_spec.rb} +1 -1
  43. data/spec/twitter/rest/{api/help_spec.rb → help_spec.rb} +1 -1
  44. data/spec/twitter/rest/{api/lists_spec.rb → lists_spec.rb} +1 -1
  45. data/spec/twitter/rest/{api/oauth_spec.rb → oauth_spec.rb} +4 -8
  46. data/spec/twitter/rest/{api/saved_searches_spec.rb → saved_searches_spec.rb} +1 -1
  47. data/spec/twitter/rest/{api/search_spec.rb → search_spec.rb} +1 -1
  48. data/spec/twitter/rest/{api/spam_reporting_spec.rb → spam_reporting_spec.rb} +1 -1
  49. data/spec/twitter/rest/{api/suggested_users_spec.rb → suggested_users_spec.rb} +1 -1
  50. data/spec/twitter/rest/{api/timelines_spec.rb → timelines_spec.rb} +1 -1
  51. data/spec/twitter/rest/{api/trends_spec.rb → trends_spec.rb} +1 -1
  52. data/spec/twitter/rest/{api/tweets_spec.rb → tweets_spec.rb} +74 -5
  53. data/spec/twitter/rest/{api/undocumented_spec.rb → undocumented_spec.rb} +1 -1
  54. data/spec/twitter/rest/{api/users_spec.rb → users_spec.rb} +5 -5
  55. data/spec/twitter/tweet_spec.rb +1 -1
  56. data/twitter.gemspec +0 -1
  57. metadata +247 -237
  58. metadata.gz.sig +0 -0
  59. checksums.yaml +0 -7
  60. checksums.yaml.gz.sig +0 -0
  61. data/lib/twitter/error/already_favorited.rb +0 -10
  62. data/lib/twitter/error/already_posted.rb +0 -10
  63. data/lib/twitter/error/already_retweeted.rb +0 -10
  64. data/lib/twitter/error/bad_gateway.rb +0 -10
  65. data/lib/twitter/error/bad_request.rb +0 -10
  66. data/lib/twitter/error/configuration_error.rb +0 -8
  67. data/lib/twitter/error/forbidden.rb +0 -10
  68. data/lib/twitter/error/gateway_timeout.rb +0 -10
  69. data/lib/twitter/error/internal_server_error.rb +0 -10
  70. data/lib/twitter/error/not_acceptable.rb +0 -10
  71. data/lib/twitter/error/not_found.rb +0 -10
  72. data/lib/twitter/error/request_timeout.rb +0 -10
  73. data/lib/twitter/error/service_unavailable.rb +0 -10
  74. data/lib/twitter/error/too_many_requests.rb +0 -12
  75. data/lib/twitter/error/unauthorized.rb +0 -10
  76. data/lib/twitter/error/unprocessable_entity.rb +0 -10
  77. data/lib/twitter/rest/api/direct_messages.rb +0 -140
  78. data/lib/twitter/rest/api/favorites.rb +0 -115
  79. data/lib/twitter/rest/api/friends_and_followers.rb +0 -284
  80. data/lib/twitter/rest/api/help.rb +0 -58
  81. data/lib/twitter/rest/api/lists.rb +0 -500
  82. data/lib/twitter/rest/api/oauth.rb +0 -67
  83. data/lib/twitter/rest/api/places_and_geo.rb +0 -86
  84. data/lib/twitter/rest/api/saved_searches.rb +0 -95
  85. data/lib/twitter/rest/api/search.rb +0 -39
  86. data/lib/twitter/rest/api/spam_reporting.rb +0 -29
  87. data/lib/twitter/rest/api/suggested_users.rb +0 -51
  88. data/lib/twitter/rest/api/timelines.rb +0 -202
  89. data/lib/twitter/rest/api/trends.rb +0 -58
  90. data/lib/twitter/rest/api/tweets.rb +0 -297
  91. data/lib/twitter/rest/api/undocumented.rb +0 -51
  92. data/lib/twitter/rest/api/users.rb +0 -383
  93. data/lib/twitter/rest/api/utils.rb +0 -212
@@ -1,58 +0,0 @@
1
- require 'twitter/place'
2
- require 'twitter/request'
3
- require 'twitter/rest/api/utils'
4
- require 'twitter/trend_results'
5
-
6
- module Twitter
7
- module REST
8
- module API
9
- module Trends
10
- include Twitter::REST::API::Utils
11
-
12
- # Returns the top 10 trending topics for a specific WOEID
13
- #
14
- # @see https://dev.twitter.com/docs/api/1.1/get/trends/place
15
- # @rate_limited Yes
16
- # @authentication Requires user context
17
- # @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
18
- # @param id [Integer] The {https://developer.yahoo.com/geo/geoplanet Yahoo! Where On Earth ID} of the location to return trending information for. WOEIDs can be retrieved by calling {Twitter::REST::API::Trends#trends_available}. Global information is available by using 1 as the WOEID.
19
- # @param options [Hash] A customizable set of options.
20
- # @option options [String] :exclude Setting this equal to 'hashtags' will remove all hashtags from the trends list.
21
- # @return [Array<Twitter::Trend>]
22
- def trends(id = 1, options = {})
23
- options[:id] = id
24
- perform_with_object(:get, '/1.1/trends/place.json', options, Twitter::TrendResults)
25
- end
26
- alias_method :local_trends, :trends
27
- alias_method :trends_place, :trends
28
-
29
- # Returns the locations that Twitter has trending topic information for
30
- #
31
- # @see https://dev.twitter.com/docs/api/1.1/get/trends/available
32
- # @rate_limited Yes
33
- # @authentication Requires user context
34
- # @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
35
- # @param options [Hash] A customizable set of options.
36
- # @return [Array<Twitter::Place>]
37
- def trends_available(options = {})
38
- perform_with_objects(:get, '/1.1/trends/available.json', options, Twitter::Place)
39
- end
40
- alias_method :trend_locations, :trends_available
41
-
42
- # Returns the locations that Twitter has trending topic information for, closest to a specified location.
43
- #
44
- # @see https://dev.twitter.com/docs/api/1.1/get/trends/closest
45
- # @rate_limited Yes
46
- # @authentication Requires user context
47
- # @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
48
- # @param options [Hash] A customizable set of options.
49
- # @option options [Float] :lat If provided with a :long option the available trend locations will be sorted by distance, nearest to furthest, to the co-ordinate pair. The valid ranges for latitude are -90.0 to +90.0 (North is positive) inclusive.
50
- # @option options [Float] :long If provided with a :lat option the available trend locations will be sorted by distance, nearest to furthest, to the co-ordinate pair. The valid ranges for longitude are -180.0 to +180.0 (East is positive) inclusive.
51
- # @return [Array<Twitter::Place>]
52
- def trends_closest(options = {})
53
- perform_with_objects(:get, '/1.1/trends/closest.json', options, Twitter::Place)
54
- end
55
- end
56
- end
57
- end
58
- end
@@ -1,297 +0,0 @@
1
- require 'twitter/arguments'
2
- require 'twitter/error/already_posted'
3
- require 'twitter/error/already_retweeted'
4
- require 'twitter/error/forbidden'
5
- require 'twitter/oembed'
6
- require 'twitter/request'
7
- require 'twitter/rest/api/utils'
8
- require 'twitter/tweet'
9
- require 'twitter/utils'
10
-
11
- module Twitter
12
- module REST
13
- module API
14
- module Tweets
15
- include Twitter::REST::API::Utils
16
- include Twitter::Utils
17
-
18
- # Returns up to 100 of the first retweets of a given tweet
19
- #
20
- # @see https://dev.twitter.com/docs/api/1.1/get/statuses/retweets/:id
21
- # @rate_limited Yes
22
- # @authentication Requires user context
23
- # @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
24
- # @return [Array<Twitter::Tweet>]
25
- # @param tweet [Integer, String, URI, Twitter::Tweet] A Tweet ID, URI, or object.
26
- # @param options [Hash] A customizable set of options.
27
- # @option options [Integer] :count Specifies the number of records to retrieve. Must be less than or equal to 100.
28
- # @option options [Boolean, String, Integer] :trim_user Each tweet returned in a timeline will include a user object with only the author's numerical ID when set to true, 't' or 1.
29
- def retweets(tweet, options = {})
30
- perform_with_objects(:get, "/1.1/statuses/retweets/#{extract_id(tweet)}.json", options, Twitter::Tweet)
31
- end
32
-
33
- # Show up to 100 users who retweeted the Tweet
34
- #
35
- # @see https://dev.twitter.com/docs/api/1.1/get/statuses/retweets/:id
36
- # @rate_limited Yes
37
- # @authentication Requires user context
38
- # @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
39
- # @return [Array]
40
- # @param tweet [Integer, String, URI, Twitter::Tweet] A Tweet ID, URI, or object.
41
- # @param options [Hash] A customizable set of options.
42
- # @option options [Integer] :count Specifies the number of records to retrieve. Must be less than or equal to 100.
43
- # @option options [Boolean, String, Integer] :trim_user Each tweet returned in a timeline will include a user object with only the author's numerical ID when set to true, 't' or 1.
44
- # @option options [Boolean] :ids_only ('false') Only return user ids instead of full user objects.
45
- def retweeters_of(tweet, options = {})
46
- ids_only = !!options.delete(:ids_only)
47
- retweeters = retweets(tweet, options).collect(&:user)
48
- ids_only ? retweeters.collect(&:id) : retweeters
49
- end
50
-
51
- # Returns a Tweet
52
- #
53
- # @see https://dev.twitter.com/docs/api/1.1/get/statuses/show/:id
54
- # @rate_limited Yes
55
- # @authentication Requires user context
56
- # @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
57
- # @raise [Twitter::Error::Forbidden] Error raised when supplied status is over 140 characters.
58
- # @return [Twitter::Tweet] The requested Tweet.
59
- # @param tweet [Integer, String, URI, Twitter::Tweet] A Tweet ID, URI, or object.
60
- # @param options [Hash] A customizable set of options.
61
- # @option options [Boolean, String, Integer] :trim_user Each tweet returned in a timeline will include a user object with only the author's numerical ID when set to true, 't' or 1.
62
- def status(tweet, options = {})
63
- perform_with_object(:get, "/1.1/statuses/show/#{extract_id(tweet)}.json", options, Twitter::Tweet)
64
- end
65
-
66
- # Returns Tweets
67
- #
68
- # @see https://dev.twitter.com/docs/api/1.1/get/statuses/show/:id
69
- # @rate_limited Yes
70
- # @authentication Requires user context
71
- # @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
72
- # @return [Array<Twitter::Tweet>] The requested Tweets.
73
- # @overload statuses(*tweets)
74
- # @param tweets [Enumerable<Integer, String, URI, Twitter::Tweet>] A collection of Tweet IDs, URIs, or objects.
75
- # @overload statuses(*tweets, options)
76
- # @param tweets [Enumerable<Integer, String, URI, Twitter::Tweet>] A collection of Tweet IDs, URIs, or objects.
77
- # @param options [Hash] A customizable set of options.
78
- # @option options [Boolean, String, Integer] :trim_user Each tweet returned in a timeline will include a user object with only the author's numerical ID when set to true, 't' or 1.
79
- def statuses(*args)
80
- parallel_tweets_from_response(:get, '/1.1/statuses/show', args)
81
- end
82
-
83
- # Destroys the specified Tweets
84
- #
85
- # @see https://dev.twitter.com/docs/api/1.1/post/statuses/destroy/:id
86
- # @note The authenticating user must be the author of the specified Tweets.
87
- # @rate_limited No
88
- # @authentication Requires user context
89
- # @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
90
- # @return [Array<Twitter::Tweet>] The deleted Tweets.
91
- # @overload destroy_status(*tweets)
92
- # @param tweets [Enumerable<Integer, String, URI, Twitter::Tweet>] A collection of Tweet IDs, URIs, or objects.
93
- # @overload destroy_status(*tweets, options)
94
- # @param tweets [Enumerable<Integer, String, URI, Twitter::Tweet>] A collection of Tweet IDs, URIs, or objects.
95
- # @param options [Hash] A customizable set of options.
96
- # @option options [Boolean, String, Integer] :trim_user Each tweet returned in a timeline will include a user object with only the author's numerical ID when set to true, 't' or 1.
97
- def destroy_status(*args)
98
- parallel_tweets_from_response(:post, '/1.1/statuses/destroy', args)
99
- end
100
- alias_method :destroy_tweet, :destroy_status
101
- deprecate_alias :status_destroy, :destroy_status
102
- deprecate_alias :tweet_destroy, :destroy_status
103
-
104
- # Updates the authenticating user's status
105
- #
106
- # @see https://dev.twitter.com/docs/api/1.1/post/statuses/update
107
- # @note A status update with text identical to the authenticating user's current status will be ignored to prevent duplicates.
108
- # @rate_limited No
109
- # @authentication Requires user context
110
- # @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
111
- # @return [Twitter::Tweet] The created Tweet.
112
- # @param status [String] The text of your status update, up to 140 characters.
113
- # @param options [Hash] A customizable set of options.
114
- # @option options [Twitter::Tweet] :in_reply_to_status An existing status that the update is in reply to.
115
- # @option options [Integer] :in_reply_to_status_id The ID of an existing status that the update is in reply to.
116
- # @option options [Float] :lat The latitude of the location this tweet refers to. This option will be ignored unless it is inside the range -90.0 to +90.0 (North is positive) inclusive. It will also be ignored if there isn't a corresponding :long option.
117
- # @option options [Float] :long The longitude of the location this tweet refers to. The valid ranges for longitude is -180.0 to +180.0 (East is positive) inclusive. This option will be ignored if outside that range, if it is not a number, if geo_enabled is disabled, or if there not a corresponding :lat option.
118
- # @option options [Twitter::Place] :place A place in the world. These can be retrieved from {Twitter::REST::API::PlacesAndGeo#reverse_geocode}.
119
- # @option options [String] :place_id A place in the world. These IDs can be retrieved from {Twitter::REST::API::PlacesAndGeo#reverse_geocode}.
120
- # @option options [String] :display_coordinates Whether or not to put a pin on the exact coordinates a tweet has been sent from.
121
- # @option options [Boolean, String, Integer] :trim_user Each tweet returned in a timeline will include a user object with only the author's numerical ID when set to true, 't' or 1.
122
- def update(status, options = {})
123
- hash = options.dup
124
- hash[:in_reply_to_status_id] = hash.delete(:in_reply_to_status).id unless hash[:in_reply_to_status].nil?
125
- hash[:place_id] = hash.delete(:place).woeid unless hash[:place].nil?
126
- perform_with_object(:post, '/1.1/statuses/update.json', hash.merge(:status => status), Twitter::Tweet)
127
- rescue Twitter::Error::Forbidden => error
128
- handle_forbidden_error(Twitter::Error::AlreadyPosted, error)
129
- end
130
-
131
- # Retweets the specified Tweets as the authenticating user
132
- #
133
- # @see https://dev.twitter.com/docs/api/1.1/post/statuses/retweet/:id
134
- # @rate_limited Yes
135
- # @authentication Requires user context
136
- # @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
137
- # @return [Array<Twitter::Tweet>] The original tweets with retweet details embedded.
138
- # @overload retweet(*tweets)
139
- # @param tweets [Enumerable<Integer, String, URI, Twitter::Tweet>] A collection of Tweet IDs, URIs, or objects.
140
- # @overload retweet(*tweets, options)
141
- # @param tweets [Enumerable<Integer, String, URI, Twitter::Tweet>] A collection of Tweet IDs, URIs, or objects.
142
- # @param options [Hash] A customizable set of options.
143
- # @option options [Boolean, String, Integer] :trim_user Each tweet returned in a timeline will include a user object with only the author's numerical ID when set to true, 't' or 1.
144
- def retweet(*args)
145
- arguments = Twitter::Arguments.new(args)
146
- parallel_map(arguments) do |tweet|
147
- begin
148
- post_retweet(extract_id(tweet), arguments.options)
149
- rescue Twitter::Error::Forbidden => error
150
- raise unless error.message == Twitter::Error::AlreadyRetweeted::MESSAGE
151
- end
152
- end.compact
153
- end
154
-
155
- # Retweets the specified Tweets as the authenticating user and raises an error if one has already been retweeted
156
- #
157
- # @see https://dev.twitter.com/docs/api/1.1/post/statuses/retweet/:id
158
- # @rate_limited Yes
159
- # @authentication Requires user context
160
- # @raise [Twitter::Error::AlreadyRetweeted] Error raised when tweet has already been retweeted.
161
- # @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
162
- # @return [Array<Twitter::Tweet>] The original tweets with retweet details embedded.
163
- # @overload retweet!(*tweets)
164
- # @param tweets [Enumerable<Integer, String, URI, Twitter::Tweet>] A collection of Tweet IDs, URIs, or objects.
165
- # @overload retweet!(*tweets, options)
166
- # @param tweets [Enumerable<Integer, String, URI, Twitter::Tweet>] A collection of Tweet IDs, URIs, or objects.
167
- # @param options [Hash] A customizable set of options.
168
- # @option options [Boolean, String, Integer] :trim_user Each tweet returned in a timeline will include a user object with only the author's numerical ID when set to true, 't' or 1.
169
- def retweet!(*args)
170
- arguments = Twitter::Arguments.new(args)
171
- parallel_map(arguments) do |tweet|
172
- begin
173
- post_retweet(extract_id(tweet), arguments.options)
174
- rescue Twitter::Error::Forbidden => error
175
- handle_forbidden_error(Twitter::Error::AlreadyRetweeted, error)
176
- end
177
- end.compact
178
- end
179
-
180
- # Updates the authenticating user's status with media
181
- #
182
- # @see https://dev.twitter.com/docs/api/1.1/post/statuses/update_with_media
183
- # @note A status update with text/media identical to the authenticating user's current status will NOT be ignored
184
- # @rate_limited No
185
- # @authentication Requires user context
186
- # @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
187
- # @return [Twitter::Tweet] The created Tweet.
188
- # @param status [String] The text of your status update, up to 140 characters.
189
- # @param media [File, Hash] A File object with your picture (PNG, JPEG or GIF)
190
- # @param options [Hash] A customizable set of options.
191
- # @option options [Boolean, String, Integer] :possibly_sensitive Set to true for content which may not be suitable for every audience.
192
- # @option options [Twitter::Tweet] :in_reply_to_status An existing status that the update is in reply to.
193
- # @option options [Integer] :in_reply_to_status_id The ID of an existing Tweet that the update is in reply to.
194
- # @option options [Float] :lat The latitude of the location this tweet refers to. This option will be ignored unless it is inside the range -90.0 to +90.0 (North is positive) inclusive. It will also be ignored if there isn't a corresponding :long option.
195
- # @option options [Float] :long The longitude of the location this tweet refers to. The valid ranges for longitude is -180.0 to +180.0 (East is positive) inclusive. This option will be ignored if outside that range, if it is not a number, if geo_enabled is disabled, or if there not a corresponding :lat option.
196
- # @option options [Twitter::Place] :place A place in the world. These can be retrieved from {Twitter::REST::API::PlacesAndGeo#reverse_geocode}.
197
- # @option options [String] :place_id A place in the world. These IDs can be retrieved from {Twitter::REST::API::PlacesAndGeo#reverse_geocode}.
198
- # @option options [String] :display_coordinates Whether or not to put a pin on the exact coordinates a tweet has been sent from.
199
- # @option options [Boolean, String, Integer] :trim_user Each tweet returned in a timeline will include a user object with only the author's numerical ID when set to true, 't' or 1.
200
- def update_with_media(status, media, options = {})
201
- hash = options.dup
202
- hash[:in_reply_to_status_id] = hash.delete(:in_reply_to_status).id unless hash[:in_reply_to_status].nil?
203
- hash[:place_id] = hash.delete(:place).woeid unless hash[:place].nil?
204
- perform_with_object(:post, '/1.1/statuses/update_with_media.json', hash.merge('media[]' => media, 'status' => status), Twitter::Tweet)
205
- rescue Twitter::Error::Forbidden => error
206
- handle_forbidden_error(Twitter::Error::AlreadyPosted, error)
207
- end
208
-
209
- # Returns oEmbed for a Tweet
210
- #
211
- # @see https://dev.twitter.com/docs/api/1.1/get/statuses/oembed
212
- # @rate_limited Yes
213
- # @authentication Requires user context
214
- # @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
215
- # @return [Twitter::OEmbed] OEmbed for the requested Tweet.
216
- # @param tweet [Integer, String, URI, Twitter::Tweet] A Tweet ID, URI, or object.
217
- # @param options [Hash] A customizable set of options.
218
- # @option options [Integer] :maxwidth The maximum width in pixels that the embed should be rendered at. This value is constrained to be between 250 and 550 pixels.
219
- # @option options [Boolean, String, Integer] :hide_media Specifies whether the embedded Tweet should automatically expand images which were uploaded via {https://dev.twitter.com/docs/api/1.1/post/statuses/update_with_media POST statuses/update_with_media}. When set to either true, t or 1 images will not be expanded. Defaults to false.
220
- # @option options [Boolean, String, Integer] :hide_thread Specifies whether the embedded Tweet should automatically show the original message in the case that the embedded Tweet is a reply. When set to either true, t or 1 the original Tweet will not be shown. Defaults to false.
221
- # @option options [Boolean, String, Integer] :omit_script Specifies whether the embedded Tweet HTML should include a `<script>` element pointing to widgets.js. In cases where a page already includes widgets.js, setting this value to true will prevent a redundant script element from being included. When set to either true, t or 1 the `<script>` element will not be included in the embed HTML, meaning that pages must include a reference to widgets.js manually. Defaults to false.
222
- # @option options [String] :align Specifies whether the embedded Tweet should be left aligned, right aligned, or centered in the page. Valid values are left, right, center, and none. Defaults to none, meaning no alignment styles are specified for the Tweet.
223
- # @option options [String] :related A value for the TWT related parameter, as described in {https://dev.twitter.com/docs/intents Web Intents}. This value will be forwarded to all Web Intents calls.
224
- # @option options [String] :lang Language code for the rendered embed. This will affect the text and localization of the rendered HTML.
225
- def oembed(tweet, options = {})
226
- options[:id] = extract_id(tweet)
227
- perform_with_object(:get, '/1.1/statuses/oembed.json', options, Twitter::OEmbed)
228
- end
229
-
230
- # Returns oEmbeds for Tweets
231
- #
232
- # @see https://dev.twitter.com/docs/api/1.1/get/statuses/oembed
233
- # @rate_limited Yes
234
- # @authentication Requires user context
235
- # @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
236
- # @return [Array<Twitter::OEmbed>] OEmbeds for the requested Tweets.
237
- # @overload oembed(*tweets)
238
- # @param tweets [Enumerable<Integer, String, URI, Twitter::Tweet>] A collection of Tweet IDs, URIs, or objects.
239
- # @overload oembed(*tweets, options)
240
- # @param tweets [Enumerable<Integer, String, URI, Twitter::Tweet>] A collection of Tweet IDs, URIs, or objects.
241
- # @param options [Hash] A customizable set of options.
242
- # @option options [Integer] :maxwidth The maximum width in pixels that the embed should be rendered at. This value is constrained to be between 250 and 550 pixels.
243
- # @option options [Boolean, String, Integer] :hide_media Specifies whether the embedded Tweet should automatically expand images which were uploaded via {https://dev.twitter.com/docs/api/1.1/post/statuses/update_with_media POST statuses/update_with_media}. When set to either true, t or 1 images will not be expanded. Defaults to false.
244
- # @option options [Boolean, String, Integer] :hide_thread Specifies whether the embedded Tweet should automatically show the original message in the case that the embedded Tweet is a reply. When set to either true, t or 1 the original Tweet will not be shown. Defaults to false.
245
- # @option options [Boolean, String, Integer] :omit_script Specifies whether the embedded Tweet HTML should include a `<script>` element pointing to widgets.js. In cases where a page already includes widgets.js, setting this value to true will prevent a redundant script element from being included. When set to either true, t or 1 the `<script>` element will not be included in the embed HTML, meaning that pages must include a reference to widgets.js manually. Defaults to false.
246
- # @option options [String] :align Specifies whether the embedded Tweet should be left aligned, right aligned, or centered in the page. Valid values are left, right, center, and none. Defaults to none, meaning no alignment styles are specified for the Tweet.
247
- # @option options [String] :related A value for the TWT related parameter, as described in {https://dev.twitter.com/docs/intents Web Intents}. This value will be forwarded to all Web Intents calls.
248
- # @option options [String] :lang Language code for the rendered embed. This will affect the text and localization of the rendered HTML.
249
- def oembeds(*args)
250
- arguments = Twitter::Arguments.new(args)
251
- parallel_map(arguments) do |tweet|
252
- oembed(extract_id(tweet), arguments.options)
253
- end
254
- end
255
-
256
- # Returns a collection of up to 100 user IDs belonging to users who have retweeted the tweet specified by the id parameter.
257
- #
258
- # @see https://dev.twitter.com/docs/api/1.1/get/statuses/retweeters/ids
259
- # @rate_limited Yes
260
- # @authentication Required
261
- # @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
262
- # @return [Twitter::Cursor]
263
- # @overload retweeters_ids(options)
264
- # @param options [Hash] A customizable set of options.
265
- # @overload retweeters_ids(id, options = {})
266
- # @param tweet [Integer, String, URI, Twitter::Tweet] A Tweet ID, URI, or object.
267
- # @param options [Hash] A customizable set of options.
268
- def retweeters_ids(*args)
269
- arguments = Twitter::Arguments.new(args)
270
- arguments.options[:id] ||= extract_id(arguments.first)
271
- perform_with_cursor(:get, '/1.1/statuses/retweeters/ids.json', arguments.options, :ids)
272
- end
273
-
274
- private
275
-
276
- # @param request_method [Symbol]
277
- # @param path [String]
278
- # @param args [Array]
279
- # @return [Array<Twitter::Tweet>]
280
- def parallel_tweets_from_response(request_method, path, args)
281
- arguments = Twitter::Arguments.new(args)
282
- parallel_map(arguments) do |tweet|
283
- perform_with_object(request_method, path + "/#{extract_id(tweet)}.json", arguments.options, Twitter::Tweet)
284
- end
285
- end
286
-
287
- def post_retweet(tweet, options)
288
- response = post("/1.1/statuses/retweet/#{extract_id(tweet)}.json", options)
289
- retweeted_status = response.dup
290
- retweeted_status[:body] = response[:body].delete(:retweeted_status)
291
- retweeted_status[:body][:retweeted_status] = response[:body]
292
- Twitter::Tweet.from_response(retweeted_status)
293
- end
294
- end
295
- end
296
- end
297
- end
@@ -1,51 +0,0 @@
1
- require 'twitter/arguments'
2
- require 'twitter/cursor'
3
- require 'twitter/rest/api/utils'
4
- require 'twitter/tweet'
5
- require 'twitter/user'
6
-
7
- module Twitter
8
- module REST
9
- module API
10
- module Undocumented
11
- include Twitter::REST::API::Utils
12
-
13
- # @note Undocumented
14
- # @rate_limited Yes
15
- # @authentication Requires user context
16
- # @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
17
- #
18
- # @overload following_followers_of(options = {})
19
- # Returns users following followers of the specified user
20
- #
21
- # @param options [Hash] A customizable set of options.
22
- # @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.
23
- # @return [Twitter::Cursor]
24
- #
25
- # @overload following_followers_of(user, options = {})
26
- # Returns users following followers of the authenticated user
27
- #
28
- # @param user [Integer, String, Twitter::User] A Twitter user ID, screen name, URI, or object.
29
- # @param options [Hash] A customizable set of options.
30
- # @option options [Integer] :cursor (-1) Breaks the results into pages. Provide values as returned in the response objects's next_cursor and previous_cursor attributes to page back and forth in the list.
31
- # @return [Twitter::Cursor]
32
- def following_followers_of(*args)
33
- cursor_from_response_with_user(:users, Twitter::User, :get, '/users/following_followers_of.json', args)
34
- end
35
-
36
- # Returns Tweets count for a URI
37
- #
38
- # @note Undocumented
39
- # @rate_limited No
40
- # @authentication Not required
41
- # @return [Integer]
42
- # @param uri [String, URI] A URI.
43
- # @param options [Hash] A customizable set of options.
44
- def tweet_count(uri, options = {})
45
- connection = Faraday.new('https://cdn.api.twitter.com', connection_options.merge(:builder => middleware))
46
- connection.get('/1/urls/count.json', options.merge(:url => uri.to_s)).body[:count]
47
- end
48
- end
49
- end
50
- end
51
- end
@@ -1,383 +0,0 @@
1
- require 'twitter/arguments'
2
- require 'twitter/error/not_found'
3
- require 'twitter/profile_banner'
4
- require 'twitter/request'
5
- require 'twitter/rest/api/utils'
6
- require 'twitter/settings'
7
- require 'twitter/user'
8
- require 'twitter/utils'
9
-
10
- module Twitter
11
- module REST
12
- module API
13
- module Users
14
- include Twitter::REST::API::Utils
15
- include Twitter::Utils
16
- MAX_USERS_PER_REQUEST = 100
17
-
18
- # Updates the authenticating user's settings.
19
- # Or, if no options supplied, returns settings (including current trend, geo and sleep time information) for the authenticating user.
20
- #
21
- # @see https://dev.twitter.com/docs/api/1.1/post/account/settings
22
- # @see https://dev.twitter.com/docs/api/1.1/get/account/settings
23
- # @rate_limited Yes
24
- # @authentication Requires user context
25
- # @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
26
- # @return [Twitter::Settings]
27
- # @param options [Hash] A customizable set of options.
28
- # @option options [Integer] :trend_location_woeid The Yahoo! Where On Earth ID to use as the user's default trend location. Global information is available by using 1 as the WOEID. The woeid must be one of the locations returned by {https://dev.twitter.com/docs/api/1.1/get/trends/available GET trends/available}.
29
- # @option options [Boolean, String, Integer] :sleep_time_enabled When set to true, 't' or 1, will enable sleep time for the user. Sleep time is the time when push or SMS notifications should not be sent to the user.
30
- # @option options [Integer] :start_sleep_time The hour that sleep time should begin if it is enabled. The value for this parameter should be provided in {http://en.wikipedia.org/wiki/ISO_8601 ISO8601} format (i.e. 00-23). The time is considered to be in the same timezone as the user's time_zone setting.
31
- # @option options [Integer] :end_sleep_time The hour that sleep time should end if it is enabled. The value for this parameter should be provided in {http://en.wikipedia.org/wiki/ISO_8601 ISO8601} format (i.e. 00-23). The time is considered to be in the same timezone as the user's time_zone setting.
32
- # @option options [String] :time_zone The timezone dates and times should be displayed in for the user. The timezone must be one of the {http://api.rubyonrails.org/classes/ActiveSupport/TimeZone.html Rails TimeZone} names.
33
- # @option options [String] :lang The language which Twitter should render in for this user. The language must be specified by the appropriate two letter ISO 639-1 representation. Currently supported languages are provided by {https://dev.twitter.com/docs/api/1.1/get/help/languages GET help/languages}.
34
- def settings(options = {})
35
- request_method = options.size.zero? ? :get : :post
36
- response = send(request_method.to_sym, '/1.1/account/settings.json', options)
37
- # https://dev.twitter.com/issues/59
38
- response.update(:trend_location => Array(response[:trend_location]).first)
39
- Twitter::Settings.from_response(response)
40
- end
41
-
42
- # Returns the requesting user if authentication was successful, otherwise raises {Twitter::Error::Unauthorized}
43
- #
44
- # @see https://dev.twitter.com/docs/api/1.1/get/account/verify_credentials
45
- # @rate_limited Yes
46
- # @authentication Requires user context
47
- # @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
48
- # @return [Twitter::User] The authenticated user.
49
- # @param options [Hash] A customizable set of options.
50
- # @option options [Boolean, String, Integer] :skip_status Do not include user's Tweets when set to true, 't' or 1.
51
- def verify_credentials(options = {})
52
- perform_with_object(:get, '/1.1/account/verify_credentials.json', options, Twitter::User)
53
- end
54
- alias_method :current_user, :verify_credentials
55
-
56
- # Sets which device Twitter delivers updates to for the authenticating user
57
- #
58
- # @see https://dev.twitter.com/docs/api/1.1/post/account/update_delivery_device
59
- # @rate_limited No
60
- # @authentication Requires user context
61
- # @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
62
- # @return [Twitter::User] The authenticated user.
63
- # @param device [String] Must be one of: 'sms', 'none'.
64
- # @param options [Hash] A customizable set of options.
65
- def update_delivery_device(device, options = {})
66
- perform_with_object(:post, '/1.1/account/update_delivery_device.json', options.merge(:device => device), Twitter::User)
67
- end
68
-
69
- # Sets values that users are able to set under the "Account" tab of their settings page
70
- #
71
- # @see https://dev.twitter.com/docs/api/1.1/post/account/update_profile
72
- # @note Only the options specified will be updated.
73
- # @rate_limited No
74
- # @authentication Requires user context
75
- # @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
76
- # @return [Twitter::User] The authenticated user.
77
- # @param options [Hash] A customizable set of options.
78
- # @option options [String] :name Full name associated with the profile. Maximum of 20 characters.
79
- # @option options [String] :url URL associated with the profile. Will be prepended with "http://" if not present. Maximum of 100 characters.
80
- # @option options [String] :location The city or country describing where the user of the account is located. The contents are not normalized or geocoded in any way. Maximum of 30 characters.
81
- # @option options [String] :description A description of the user owning the account. Maximum of 160 characters.
82
- def update_profile(options = {})
83
- perform_with_object(:post, '/1.1/account/update_profile.json', options, Twitter::User)
84
- end
85
-
86
- # Updates the authenticating user's profile background image
87
- #
88
- # @see https://dev.twitter.com/docs/api/1.1/post/account/update_profile_background_image
89
- # @rate_limited No
90
- # @authentication Requires user context
91
- # @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
92
- # @return [Twitter::User] The authenticated user.
93
- # @param image [File] The background image for the profile, base64-encoded. Must be a valid GIF, JPG, or PNG image of less than 800 kilobytes in size. Images with width larger than 2048 pixels will be forcibly scaled down. The image must be provided as raw multipart data, not a URL.
94
- # @param options [Hash] A customizable set of options.
95
- # @option options [Boolean] :tile Whether or not to tile the background image. If set to true the background image will be displayed tiled. The image will not be tiled otherwise.
96
- def update_profile_background_image(image, options = {})
97
- perform_with_object(:post, '/1.1/account/update_profile_background_image.json', options.merge(:image => image), Twitter::User)
98
- end
99
-
100
- # Sets one or more hex values that control the color scheme of the authenticating user's profile
101
- #
102
- # @see https://dev.twitter.com/docs/api/1.1/post/account/update_profile_colors
103
- # @rate_limited No
104
- # @authentication Requires user context
105
- # @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
106
- # @return [Twitter::User] The authenticated user.
107
- # @param options [Hash] A customizable set of options.
108
- # @option options [String] :profile_background_color Profile background color.
109
- # @option options [String] :profile_text_color Profile text color.
110
- # @option options [String] :profile_link_color Profile link color.
111
- # @option options [String] :profile_sidebar_fill_color Profile sidebar's background color.
112
- # @option options [String] :profile_sidebar_border_color Profile sidebar's border color.
113
- def update_profile_colors(options = {})
114
- perform_with_object(:post, '/1.1/account/update_profile_colors.json', options, Twitter::User)
115
- end
116
-
117
- # Updates the authenticating user's profile image
118
- #
119
- # @see https://dev.twitter.com/docs/api/1.1/post/account/update_profile_image
120
- # @note Updates the authenticating user's profile image. Note that this method expects raw multipart data, not a URL to an image.
121
- # @note This method asynchronously processes the uploaded file before updating the user's profile image URL. You can either update your local cache the next time you request the user's information, or, at least 5 seconds after uploading the image, ask for the updated URL using GET users/show.
122
- # @rate_limited No
123
- # @authentication Requires user context
124
- # @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
125
- # @return [Twitter::User] The authenticated user.
126
- # @param image [File] The avatar image for the profile, base64-encoded. Must be a valid GIF, JPG, or PNG image of less than 700 kilobytes in size. Images with width larger than 500 pixels will be scaled down. Animated GIFs will be converted to a static GIF of the first frame, removing the animation.
127
- # @param options [Hash] A customizable set of options.
128
- def update_profile_image(image, options = {})
129
- perform_with_object(:post, '/1.1/account/update_profile_image.json', options.merge(:image => image), Twitter::User)
130
- end
131
-
132
- # Returns an array of user objects that the authenticating user is blocking
133
- #
134
- # @see https://dev.twitter.com/docs/api/1.1/get/blocks/list
135
- # @rate_limited Yes
136
- # @authentication Requires user context
137
- # @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
138
- # @return [Array<Twitter::User>] User objects that the authenticating user is blocking.
139
- # @param options [Hash] A customizable set of options.
140
- # @option options [Integer] :page Specifies the page of results to retrieve.
141
- def blocking(options = {})
142
- perform_with_cursor(:get, '/1.1/blocks/list.json', options, :users, Twitter::User)
143
- end
144
-
145
- # Returns an array of numeric user ids the authenticating user is blocking
146
- #
147
- # @see https://dev.twitter.com/docs/api/1.1/get/blocks/ids
148
- # @rate_limited Yes
149
- # @authentication Requires user context
150
- # @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
151
- # @return [Twitter::Cursor] Numeric user IDs the authenticating user is blocking.
152
- # @overload block(options = {})
153
- # @param options [Hash] A customizable set of options.
154
- def blocked_ids(*args)
155
- arguments = Twitter::Arguments.new(args)
156
- merge_user!(arguments.options, arguments.pop)
157
- perform_with_cursor(:get, '/1.1/blocks/ids.json', arguments.options, :ids)
158
- end
159
-
160
- # Returns true if the authenticating user is blocking a target user
161
- #
162
- # @see https://dev.twitter.com/docs/api/1.1/get/blocks/ids
163
- # @rate_limited Yes
164
- # @authentication Requires user context
165
- # @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
166
- # @return [Boolean] true if the authenticating user is blocking the target user, otherwise false.
167
- # @param user [Integer, String, URI, Twitter::User] A Twitter user ID, screen name, URI, or object.
168
- # @param options [Hash] A customizable set of options.
169
- def block?(user, options = {})
170
- user_id = case user
171
- when Integer
172
- user
173
- when String, URI, Addressable::URI
174
- user(user).id
175
- when Twitter::User
176
- user.id
177
- end
178
- blocked_ids(options).collect(&:to_i).include?(user_id)
179
- end
180
-
181
- # Blocks the users specified by the authenticating user
182
- #
183
- # @see https://dev.twitter.com/docs/api/1.1/post/blocks/create
184
- # @note Destroys a friendship to the blocked user if it exists.
185
- # @rate_limited Yes
186
- # @authentication Requires user context
187
- # @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
188
- # @return [Array<Twitter::User>] The blocked users.
189
- # @overload block(*users)
190
- # @param users [Enumerable<Integer, String, Twitter::User>] A collection of Twitter user IDs, screen names, or objects.
191
- # @overload block(*users, options)
192
- # @param users [Enumerable<Integer, String, Twitter::User>] A collection of Twitter user IDs, screen names, or objects.
193
- # @param options [Hash] A customizable set of options.
194
- def block(*args)
195
- parallel_user_objects_from_response(:post, '/1.1/blocks/create.json', args)
196
- end
197
-
198
- # Un-blocks the users specified by the authenticating user
199
- #
200
- # @see https://dev.twitter.com/docs/api/1.1/post/blocks/destroy
201
- # @rate_limited No
202
- # @authentication Requires user context
203
- # @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
204
- # @return [Array<Twitter::User>] The un-blocked users.
205
- # @overload unblock(*users)
206
- # @param users [Enumerable<Integer, String, Twitter::User>] A collection of Twitter user IDs, screen names, or objects.
207
- # @overload unblock(*users, options)
208
- # @param users [Enumerable<Integer, String, Twitter::User>] A collection of Twitter user IDs, screen names, or objects.
209
- # @param options [Hash] A customizable set of options.
210
- def unblock(*args)
211
- parallel_user_objects_from_response(:post, '/1.1/blocks/destroy.json', args)
212
- end
213
-
214
- # Returns extended information for up to 100 users
215
- #
216
- # @see https://dev.twitter.com/docs/api/1.1/get/users/lookup
217
- # @rate_limited Yes
218
- # @authentication Requires user context
219
- # @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
220
- # @return [Array<Twitter::User>] The requested users.
221
- # @overload users(*users)
222
- # @param users [Enumerable<Integer, String, Twitter::User>] A collection of Twitter user IDs, screen names, or objects.
223
- # @overload users(*users, options)
224
- # @param users [Enumerable<Integer, String, Twitter::User>] A collection of Twitter user IDs, screen names, or objects.
225
- # @param options [Hash] A customizable set of options.
226
- # @option options [Symbol, String] :method Requests users via a GET request instead of the standard POST request if set to ':get'.
227
- # @option options [Boolean] :include_entities The tweet entities node will be disincluded when set to false.
228
- def users(*args)
229
- arguments = Twitter::Arguments.new(args)
230
- request_method = arguments.options.delete(:method) || :post
231
- parallel_map(arguments.each_slice(MAX_USERS_PER_REQUEST)) do |users|
232
- perform_with_objects(request_method, '/1.1/users/lookup.json', merge_users(arguments.options, users), Twitter::User)
233
- end.flatten
234
- end
235
-
236
- # @see https://dev.twitter.com/docs/api/1.1/get/users/show
237
- # @rate_limited Yes
238
- # @authentication Requires user context
239
- # @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
240
- # @return [Twitter::User] The requested user.
241
- # @overload user(options = {})
242
- # Returns extended information for the authenticated user
243
- #
244
- # @param options [Hash] A customizable set of options.
245
- # @option options [Boolean] :include_entities The tweet entities node will be disincluded when set to false.
246
- # @option options [Boolean, String, Integer] :skip_status Do not include user's Tweets when set to true, 't' or 1.
247
- # @overload user(user, options = {})
248
- # Returns extended information for a given user
249
- #
250
- # @param user [Integer, String, Twitter::User] A Twitter user ID, screen name, URI, or object.
251
- # @param options [Hash] A customizable set of options.
252
- # @option options [Boolean] :include_entities The tweet entities node will be disincluded when set to false.
253
- # @option options [Boolean, String, Integer] :skip_status Do not include user's Tweets when set to true, 't' or 1.
254
- def user(*args)
255
- arguments = Twitter::Arguments.new(args)
256
- if arguments.last
257
- merge_user!(arguments.options, arguments.pop)
258
- perform_with_object(:get, '/1.1/users/show.json', arguments.options, Twitter::User)
259
- else
260
- verify_credentials(arguments.options)
261
- end
262
- end
263
-
264
- # Returns true if the specified user exists
265
- #
266
- # @rate_limited Yes
267
- # @authentication Requires user context
268
- # @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
269
- # @return [Boolean] true if the user exists, otherwise false.
270
- # @param user [Integer, String, Twitter::User] A Twitter user ID, screen name, URI, or object.
271
- def user?(user, options = {})
272
- merge_user!(options, user)
273
- get('/1.1/users/show.json', options)
274
- true
275
- rescue Twitter::Error::NotFound
276
- false
277
- end
278
-
279
- # Returns users that match the given query
280
- #
281
- # @see https://dev.twitter.com/docs/api/1.1/get/users/search
282
- # @rate_limited Yes
283
- # @authentication Requires user context
284
- # @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
285
- # @return [Array<Twitter::User>]
286
- # @param query [String] The search query to run against people search.
287
- # @param options [Hash] A customizable set of options.
288
- # @option options [Integer] :count The number of people to retrieve. Maxiumum of 20 allowed per page.
289
- # @option options [Integer] :page Specifies the page of results to retrieve.
290
- def user_search(query, options = {})
291
- perform_with_objects(:get, '/1.1/users/search.json', options.merge(:q => query), Twitter::User)
292
- end
293
-
294
- # Returns an array of users that the specified user can contribute to
295
- #
296
- # @see https://dev.twitter.com/docs/api/1.1/get/users/contributees
297
- # @rate_limited Yes
298
- # @authentication Requires user context
299
- # @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
300
- # @return [Array<Twitter::User>]
301
- # @overload contributees(options = {})
302
- # @param options [Hash] A customizable set of options.
303
- # @option options [Boolean, String, Integer] :skip_status Do not include contributee's Tweets when set to true, 't' or 1.
304
- # @overload contributees(user, options = {})
305
- # @param user [Integer, String, Twitter::User] A Twitter user ID, screen name, URI, or object.
306
- # @param options [Hash] A customizable set of options.
307
- # @option options [Boolean, String, Integer] :skip_status Do not include contributee's Tweets when set to true, 't' or 1.
308
- def contributees(*args)
309
- user_objects_from_response(:get, '/1.1/users/contributees.json', args)
310
- end
311
-
312
- # Returns an array of users who can contribute to the specified account
313
- #
314
- # @see https://dev.twitter.com/docs/api/1.1/get/users/contributors
315
- # @rate_limited Yes
316
- # @authentication Requires user context
317
- # @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
318
- # @return [Array<Twitter::User>]
319
- # @overload contributors(options = {})
320
- # @param options [Hash] A customizable set of options.
321
- # @option options [Boolean, String, Integer] :skip_status Do not include contributee's Tweets when set to true, 't' or 1.
322
- # @overload contributors(user, options = {})
323
- # @param user [Integer, String, Twitter::User] A Twitter user ID, screen name, URI, or object.
324
- # @param options [Hash] A customizable set of options.
325
- # @option options [Boolean, String, Integer] :skip_status Do not include contributee's Tweets when set to true, 't' or 1.
326
- def contributors(*args)
327
- user_objects_from_response(:get, '/1.1/users/contributors.json', args)
328
- end
329
-
330
- # Removes the authenticating user's profile banner image
331
- #
332
- # @see https://dev.twitter.com/docs/api/1.1/post/account/remove_profile_banner
333
- # @rate_limited No
334
- # @authentication Requires user context
335
- # @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
336
- # @return [nil]
337
- # @param options [Hash] A customizable set of options.
338
- def remove_profile_banner(options = {})
339
- post('/1.1/account/remove_profile_banner.json', options)[:body]
340
- end
341
- deprecate_alias :profile_banner_remove, :remove_profile_banner
342
-
343
- # Updates the authenticating user's profile banner image
344
- #
345
- # @see https://dev.twitter.com/docs/api/1.1/post/account/update_profile_banner
346
- # @note Uploads a profile banner on behalf of the authenticating user. For best results, upload an <5MB image that is exactly 1252px by 626px. Images will be resized for a number of display options. Users with an uploaded profile banner will have a profile_banner_url node in their Users objects. More information about sizing variations can be found in User Profile Images and Banners.
347
- # @note Profile banner images are processed asynchronously. The profile_banner_url and its variant sizes will not necessary be available directly after upload.
348
- # @rate_limited No
349
- # @authentication Requires user context
350
- # @raise [Twitter::Error::BadRequest] Error raised when either an image was not provided or the image data could not be processed.
351
- # @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
352
- # @raise [Twitter::Error::UnprocessableEntity] Error raised when the image could not be resized or is too large.
353
- # @return [nil]
354
- # @param banner [File] The Base64-encoded or raw image data being uploaded as the user's new profile banner.
355
- # @param options [Hash] A customizable set of options.
356
- # @option options [Integer] :width The width of the preferred section of the image being uploaded in pixels. Use with height, offset_left, and offset_top to select the desired region of the image to use.
357
- # @option options [Integer] :height The height of the preferred section of the image being uploaded in pixels. Use with width, offset_left, and offset_top to select the desired region of the image to use.
358
- # @option options [Integer] :offset_left The number of pixels by which to offset the uploaded image from the left. Use with height, width, and offset_top to select the desired region of the image to use.
359
- # @option options [Integer] :offset_top The number of pixels by which to offset the uploaded image from the top. Use with height, width, and offset_left to select the desired region of the image to use.
360
- def update_profile_banner(banner, options = {})
361
- post('/1.1/account/update_profile_banner.json', options.merge(:banner => banner))[:body]
362
- end
363
-
364
- # Returns the available size variations of the specified user's profile banner.
365
- #
366
- # @see https://dev.twitter.com/docs/api/1.1/get/users/profile_banner
367
- # @note If the user has not uploaded a profile banner, a HTTP 404 will be served instead.
368
- # @rate_limited Yes
369
- # @authentication Requires user context
370
- # @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
371
- # @return [Twitter::ProfileBanner]
372
- # @overload profile_banner(options = {})
373
- # @overload profile_banner(user, options = {})
374
- # @param user [Integer, String, Twitter::User] A Twitter user ID, screen name, URI, or object.
375
- def profile_banner(*args)
376
- arguments = Twitter::Arguments.new(args)
377
- merge_user!(arguments.options, arguments.pop || screen_name) unless arguments.options[:user_id] || arguments.options[:screen_name]
378
- perform_with_object(:get, '/1.1/users/profile_banner.json', arguments.options, Twitter::ProfileBanner)
379
- end
380
- end
381
- end
382
- end
383
- end