twitter 4.2.0 → 4.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (49) hide show
  1. data/CHANGELOG.md +4 -0
  2. data/lib/twitter/api/direct_messages.rb +150 -0
  3. data/lib/twitter/api/favorites.rb +132 -0
  4. data/lib/twitter/api/friends_and_followers.rb +259 -0
  5. data/lib/twitter/api/help.rb +64 -0
  6. data/lib/twitter/api/lists.rb +570 -0
  7. data/lib/twitter/api/places_and_geo.rb +121 -0
  8. data/lib/twitter/api/saved_searches.rb +98 -0
  9. data/lib/twitter/api/search.rb +37 -0
  10. data/lib/twitter/api/spam_reporting.rb +30 -0
  11. data/lib/twitter/api/suggested_users.rb +54 -0
  12. data/lib/twitter/api/timelines.rb +213 -0
  13. data/lib/twitter/api/trends.rb +63 -0
  14. data/lib/twitter/api/tweets.rb +284 -0
  15. data/lib/twitter/api/undocumented.rb +116 -0
  16. data/lib/twitter/api/users.rb +427 -0
  17. data/lib/twitter/api/utils.rb +111 -0
  18. data/lib/twitter/client.rb +41 -13
  19. data/lib/twitter/core_ext/enumerable.rb +1 -1
  20. data/lib/twitter/default.rb +16 -18
  21. data/lib/twitter/error/already_favorited.rb +1 -1
  22. data/lib/twitter/error/already_retweeted.rb +1 -1
  23. data/lib/twitter/profile_banner.rb +18 -0
  24. data/lib/twitter/version.rb +1 -1
  25. data/spec/fixtures/profile_banner.json +1 -0
  26. data/spec/twitter/api/direct_messages_spec.rb +32 -32
  27. data/spec/twitter/api/favorites_spec.rb +114 -0
  28. data/spec/twitter/api/{friendships_spec.rb → friends_and_followers_spec.rb} +146 -146
  29. data/spec/twitter/api/geo_spec.rb +28 -28
  30. data/spec/twitter/api/help_spec.rb +1 -1
  31. data/spec/twitter/api/lists_spec.rb +82 -82
  32. data/spec/twitter/api/saved_searches_spec.rb +1 -1
  33. data/spec/twitter/api/search_spec.rb +1 -17
  34. data/spec/twitter/api/{report_spam_spec.rb → spam_reporting_spec.rb} +1 -1
  35. data/spec/twitter/api/suggested_users_spec.rb +94 -0
  36. data/spec/twitter/api/timelines_spec.rb +138 -0
  37. data/spec/twitter/api/trends_spec.rb +1 -1
  38. data/spec/twitter/api/tweets_spec.rb +249 -0
  39. data/spec/twitter/api/undocumented_spec.rb +103 -0
  40. data/spec/twitter/api/users_spec.rb +308 -17
  41. data/spec/twitter/client_spec.rb +1 -1
  42. data/spec/twitter/profile_banner_spec.rb +13 -0
  43. data/twitter.gemspec +3 -2
  44. metadata +44 -21
  45. data/lib/twitter/api.rb +0 -2558
  46. data/spec/twitter/api/account_spec.rb +0 -152
  47. data/spec/twitter/api/activity_spec.rb +0 -37
  48. data/spec/twitter/api/blocks_spec.rb +0 -122
  49. data/spec/twitter/api/statuses_spec.rb +0 -541
@@ -0,0 +1,63 @@
1
+ require 'twitter/api/utils'
2
+ require 'twitter/place'
3
+ require 'twitter/trend'
4
+
5
+ module Twitter
6
+ module API
7
+ module Trends
8
+ include Twitter::API::Utils
9
+
10
+ # Returns the top 10 trending topics for a specific WOEID
11
+ #
12
+ # @see https://dev.twitter.com/docs/api/1.1/get/trends/place
13
+ # @rate_limited Yes
14
+ # @authentication_required Requires user context
15
+ # @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
16
+ # @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::API::Trends#trend_locations}. Global information is available by using 1 as the WOEID.
17
+ # @param options [Hash] A customizable set of options.
18
+ # @option options [String] :exclude Setting this equal to 'hashtags' will remove all hashtags from the trends list.
19
+ # @return [Array<Twitter::Trend>]
20
+ # @example Return the top 10 trending topics for San Francisco
21
+ # Twitter.trends(2487956)
22
+ def trends(id=1, options={})
23
+ options[:id] = id
24
+ response = get("/1.1/trends/place.json", options)
25
+ collection_from_array(Twitter::Trend, response[:body].first[:trends])
26
+ end
27
+ alias local_trends trends
28
+ alias trends_place trends
29
+
30
+ # Returns the locations that Twitter has trending topic information for
31
+ #
32
+ # @see https://dev.twitter.com/docs/api/1.1/get/trends/available
33
+ # @rate_limited Yes
34
+ # @authentication_required Requires user context
35
+ # @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
36
+ # @param options [Hash] A customizable set of options.
37
+ # @return [Array<Twitter::Place>]
38
+ # @example Return the locations that Twitter has trending topic information for
39
+ # Twitter.trends_available
40
+ def trends_available(options={})
41
+ collection_from_response(Twitter::Place, :get, "/1.1/trends/available.json", options)
42
+ end
43
+ alias trend_locations trends_available
44
+
45
+ # Returns the locations that Twitter has trending topic information for, closest to a specified location.
46
+ #
47
+ # @see https://dev.twitter.com/docs/api/1.1/get/trends/closest
48
+ # @rate_limited Yes
49
+ # @authentication_required Requires user context
50
+ # @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
51
+ # @param options [Hash] A customizable set of options.
52
+ # @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.
53
+ # @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.
54
+ # @return [Array<Twitter::Place>]
55
+ # @example Return the locations that Twitter has trending topic information for
56
+ # Twitter.trends_closest
57
+ def trends_closest(options={})
58
+ collection_from_response(Twitter::Place, :get, "/1.1/trends/closest.json", options)
59
+ end
60
+
61
+ end
62
+ end
63
+ end
@@ -0,0 +1,284 @@
1
+ require 'twitter/api/utils'
2
+ require 'twitter/error/already_retweeted'
3
+ require 'twitter/error/forbidden'
4
+ require 'twitter/oembed'
5
+ require 'twitter/tweet'
6
+
7
+ module Twitter
8
+ module API
9
+ module Tweets
10
+ include Twitter::API::Utils
11
+
12
+ # Returns up to 100 of the first retweets of a given tweet
13
+ #
14
+ # @see https://dev.twitter.com/docs/api/1.1/get/statuses/retweets/:id
15
+ # @rate_limited Yes
16
+ # @authentication_required Requires user context
17
+ # @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
18
+ # @return [Array<Twitter::Tweet>]
19
+ # @param id [Integer] The numerical ID of the desired Tweet.
20
+ # @param options [Hash] A customizable set of options.
21
+ # @option options [Integer] :count Specifies the number of records to retrieve. Must be less than or equal to 100.
22
+ # @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.
23
+ # @example Return up to 100 of the first retweets of the Tweet with the ID 28561922516
24
+ # Twitter.retweets(28561922516)
25
+ def retweets(id, options={})
26
+ collection_from_response(Twitter::Tweet, :get, "/1.1/statuses/retweets/#{id}.json", options)
27
+ end
28
+
29
+ # Show up to 100 users who retweeted the Tweet
30
+ #
31
+ # @see https://dev.twitter.com/docs/api/1.1/get/statuses/retweets/:id
32
+ # @rate_limited Yes
33
+ # @authentication_required Requires user context
34
+ # @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
35
+ # @return [Array]
36
+ # @param id [Integer] The numerical ID of the desired Tweet.
37
+ # @param options [Hash] A customizable set of options.
38
+ # @option options [Integer] :count Specifies the number of records to retrieve. Must be less than or equal to 100.
39
+ # @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.
40
+ # @option options [Boolean] :ids_only ('false') Only return user ids instead of full user objects.
41
+ # @example Show up to 100 users who retweeted the Tweet with the ID 28561922516
42
+ # Twitter.retweeters_of(28561922516)
43
+ def retweeters_of(id, options={})
44
+ ids_only = !!options.delete(:ids_only)
45
+ retweeters = retweets(id, options).map(&:user)
46
+ if ids_only
47
+ retweeters.map(&:id)
48
+ else
49
+ retweeters
50
+ end
51
+ end
52
+
53
+ # Returns a Tweet
54
+ #
55
+ # @see https://dev.twitter.com/docs/api/1.1/get/statuses/show/:id
56
+ # @rate_limited Yes
57
+ # @authentication_required Requires user context
58
+ # @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
59
+ # @return [Twitter::Tweet] The requested Tweet.
60
+ # @param id [Integer] A Tweet ID.
61
+ # @param options [Hash] A customizable set of options.
62
+ # @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.
63
+ # @example Return the Tweet with the ID 25938088801
64
+ # Twitter.status(25938088801)
65
+ def status(id, options={})
66
+ object_from_response(Twitter::Tweet, :get, "/1.1/statuses/show/#{id}.json", options)
67
+ end
68
+
69
+ # Returns Tweets
70
+ #
71
+ # @see https://dev.twitter.com/docs/api/1.1/get/statuses/show/:id
72
+ # @rate_limited Yes
73
+ # @authentication_required Requires user context
74
+ # @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
75
+ # @return [Array<Twitter::Tweet>] The requested Tweets.
76
+ # @overload statuses(*ids)
77
+ # @param ids [Array<Integer>, Set<Integer>] An array of Tweet IDs.
78
+ # @example Return the Tweet with the ID 25938088801
79
+ # Twitter.statuses(25938088801)
80
+ # @overload statuses(*ids, options)
81
+ # @param ids [Array<Integer>, Set<Integer>] An array of Tweet IDs.
82
+ # @param options [Hash] A customizable set of options.
83
+ # @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.
84
+ def statuses(*args)
85
+ threaded_tweets_from_response(:get, "/1.1/statuses/show", args)
86
+ end
87
+
88
+ # Destroys the specified Tweets
89
+ #
90
+ # @see https://dev.twitter.com/docs/api/1.1/post/statuses/destroy/:id
91
+ # @note The authenticating user must be the author of the specified Tweets.
92
+ # @rate_limited No
93
+ # @authentication_required Requires user context
94
+ # @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
95
+ # @return [Array<Twitter::Tweet>] The deleted Tweets.
96
+ # @overload status_destroy(*ids)
97
+ # @param ids [Array<Integer>, Set<Integer>] An array of Tweet IDs.
98
+ # @example Destroy the Tweet with the ID 25938088801
99
+ # Twitter.status_destroy(25938088801)
100
+ # @overload status_destroy(*ids, options)
101
+ # @param ids [Array<Integer>, Set<Integer>] An array of Tweet IDs.
102
+ # @param options [Hash] A customizable set of options.
103
+ # @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.
104
+ def status_destroy(*args)
105
+ threaded_tweets_from_response(:post, "/1.1/statuses/destroy", args)
106
+ end
107
+ alias tweet_destroy status_destroy
108
+
109
+ # Updates the authenticating user's status
110
+ #
111
+ # @see https://dev.twitter.com/docs/api/1.1/post/statuses/update
112
+ # @note A status update with text identical to the authenticating user's current status will be ignored to prevent duplicates.
113
+ # @rate_limited No
114
+ # @authentication_required Requires user context
115
+ # @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
116
+ # @return [Twitter::Tweet] The created Tweet.
117
+ # @param status [String] The text of your status update, up to 140 characters.
118
+ # @param options [Hash] A customizable set of options.
119
+ # @option options [Integer] :in_reply_to_status_id The ID of an existing status that the update is in reply to.
120
+ # @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.
121
+ # @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.
122
+ # @option options [String] :place_id A place in the world. These IDs can be retrieved from {Twitter::API::Geo#reverse_geocode}.
123
+ # @option options [String] :display_coordinates Whether or not to put a pin on the exact coordinates a tweet has been sent from.
124
+ # @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.
125
+ # @example Update the authenticating user's status
126
+ # Twitter.update("I'm tweeting with @gem!")
127
+ def update(status, options={})
128
+ object_from_response(Twitter::Tweet, :post, "/1.1/statuses/update.json", options.merge(:status => status))
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_required 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(*ids)
139
+ # @param ids [Array<Integer>, Set<Integer>] An array of Tweet IDs.
140
+ # @example Retweet the Tweet with the ID 28561922516
141
+ # Twitter.retweet(28561922516)
142
+ # @overload retweet(*ids, options)
143
+ # @param ids [Array<Integer>, Set<Integer>] An array of Tweet IDs.
144
+ # @param options [Hash] A customizable set of options.
145
+ # @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.
146
+ def retweet(*args)
147
+ options = args.extract_options!
148
+ args.flatten.threaded_map do |id|
149
+ begin
150
+ post_retweet(id, options)
151
+ rescue Twitter::Error::Forbidden => error
152
+ raise unless error.message == Twitter::Error::AlreadyRetweeted::MESSAGE
153
+ end
154
+ end.compact
155
+ end
156
+
157
+ # Retweets the specified Tweets as the authenticating user and raises an error if one has already been retweeted
158
+ #
159
+ # @see https://dev.twitter.com/docs/api/1.1/post/statuses/retweet/:id
160
+ # @rate_limited Yes
161
+ # @authentication_required Requires user context
162
+ # @raise [Twitter::Error::AlreadyRetweeted] Error raised when tweet has already been retweeted.
163
+ # @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
164
+ # @return [Array<Twitter::Tweet>] The original tweets with retweet details embedded.
165
+ # @overload retweet(*ids)
166
+ # @param ids [Array<Integer>, Set<Integer>] An array of Tweet IDs.
167
+ # @example Retweet the Tweet with the ID 28561922516
168
+ # Twitter.retweet(28561922516)
169
+ # @overload retweet(*ids, options)
170
+ # @param ids [Array<Integer>, Set<Integer>] An array of Tweet IDs.
171
+ # @param options [Hash] A customizable set of options.
172
+ # @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.
173
+ def retweet!(*args)
174
+ options = args.extract_options!
175
+ args.flatten.threaded_map do |id|
176
+ begin
177
+ post_retweet(id, options)
178
+ rescue Twitter::Error::Forbidden => error
179
+ if error.message == "sharing is not permissible for this status (Share validations failed)"
180
+ raise Twitter::Error::AlreadyRetweeted.new("Tweet with the ID #{id} has already been retweeted by the authenticated user.")
181
+ else
182
+ raise
183
+ end
184
+ end
185
+ end.compact
186
+ end
187
+
188
+ # Updates the authenticating user's status with media
189
+ #
190
+ # @see https://dev.twitter.com/docs/api/1.1/post/statuses/update_with_media
191
+ # @note A status update with text/media identical to the authenticating user's current status will NOT be ignored
192
+ # @rate_limited No
193
+ # @authentication_required Requires user context
194
+ # @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
195
+ # @return [Twitter::Tweet] The created Tweet.
196
+ # @param status [String] The text of your status update, up to 140 characters.
197
+ # @param media [File, Hash] A File object with your picture (PNG, JPEG or GIF)
198
+ # @param options [Hash] A customizable set of options.
199
+ # @option options [Integer] :in_reply_to_status_id The ID of an existing Tweet that the update is in reply to.
200
+ # @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.
201
+ # @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.
202
+ # @option options [String] :place_id A place in the world. These IDs can be retrieved from {Twitter::API::Geo#reverse_geocode}.
203
+ # @option options [String] :display_coordinates Whether or not to put a pin on the exact coordinates a tweet has been sent from.
204
+ # @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.
205
+ # @example Update the authenticating user's status
206
+ # Twitter.update_with_media("I'm tweeting with @gem!", File.new('my_awesome_pic.jpeg'))
207
+ def update_with_media(status, media, options={})
208
+ object_from_response(Twitter::Tweet, :post, "/1.1/statuses/update_with_media.json", options.merge('media[]' => media, 'status' => status))
209
+ end
210
+
211
+ # Returns oEmbed for a Tweet
212
+ #
213
+ # @see https://dev.twitter.com/docs/api/1.1/get/statuses/oembed
214
+ # @rate_limited Yes
215
+ # @authentication_required Requires user context
216
+ # @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
217
+ # @return [Twitter::OEmbed] OEmbed for the requested Tweet.
218
+ # @param id [Integer, String] A Tweet ID.
219
+ # @param options [Hash] A customizable set of options.
220
+ # @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.
221
+ # @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.
222
+ # @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.
223
+ # @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.
224
+ # @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.
225
+ # @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.
226
+ # @option options [String] :lang Language code for the rendered embed. This will affect the text and localization of the rendered HTML.
227
+ # @example Return oEmbeds for Tweet with the ID 25938088801
228
+ # Twitter.status_with_activity(25938088801)
229
+ def oembed(id, options={})
230
+ object_from_response(Twitter::OEmbed, :get, "/1.1/statuses/oembed.json?id=#{id}", options)
231
+ end
232
+
233
+ # Returns oEmbeds for Tweets
234
+ #
235
+ # @see https://dev.twitter.com/docs/api/1.1/get/statuses/oembed
236
+ # @rate_limited Yes
237
+ # @authentication_required Requires user context
238
+ # @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
239
+ # @return [Array<Twitter::OEmbed>] OEmbeds for the requested Tweets.
240
+ # @overload oembed(*ids_or_urls)
241
+ # @param ids_or_urls [Array<Integer, String>, Set<Integer, String>] An array of Tweet IDs or URLs.
242
+ # @example Return oEmbeds for Tweets with the ID 25938088801
243
+ # Twitter.status_with_activity(25938088801)
244
+ # @overload oembed(*ids_or_urls, options)
245
+ # @param ids_or_urls [Array<Integer, String>, Set<Integer, String>] An array of Tweet IDs or URLs.
246
+ # @param options [Hash] A customizable set of options.
247
+ # @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.
248
+ # @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.
249
+ # @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.
250
+ # @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.
251
+ # @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.
252
+ # @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.
253
+ # @option options [String] :lang Language code for the rendered embed. This will affect the text and localization of the rendered HTML.
254
+ def oembeds(*args)
255
+ options = args.extract_options!
256
+ args.flatten.threaded_map do |id|
257
+ object_from_response(Twitter::OEmbed, :get, "/1.1/statuses/oembed.json?id=#{id}", options)
258
+ end
259
+ end
260
+
261
+ private
262
+
263
+ # @param request_method [Symbol]
264
+ # @param url [String]
265
+ # @param args [Array]
266
+ # @return [Array<Twitter::Tweet>]
267
+ def threaded_tweets_from_response(request_method, url, args)
268
+ options = args.extract_options!
269
+ args.flatten.threaded_map do |id|
270
+ object_from_response(Twitter::Tweet, request_method, url + "/#{id}.json", options)
271
+ end
272
+ end
273
+
274
+ def post_retweet(id, options)
275
+ response = post("/1.1/statuses/retweet/#{id}.json", options)
276
+ retweeted_status = response.dup
277
+ retweeted_status[:body] = response[:body].delete(:retweeted_status)
278
+ retweeted_status[:body][:retweeted_status] = response[:body]
279
+ Twitter::Tweet.from_response(retweeted_status)
280
+ end
281
+
282
+ end
283
+ end
284
+ end
@@ -0,0 +1,116 @@
1
+ require 'twitter/action_factory'
2
+ require 'twitter/api/utils'
3
+ require 'twitter/cursor'
4
+ require 'twitter/tweet'
5
+ require 'twitter/user'
6
+
7
+ module Twitter
8
+ module API
9
+ module Undocumented
10
+ include Twitter::API::Utils
11
+
12
+ # Returns activity about me
13
+ #
14
+ # @note Undocumented
15
+ # @rate_limited Yes
16
+ # @authentication_required Requires user context
17
+ # @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
18
+ # @return [Array] An array of actions
19
+ # @param options [Hash] A customizable set of options.
20
+ # @option options [Integer] :count Specifies the number of records to retrieve. Must be less than or equal to 100.
21
+ # @option options [Integer] :since_id Returns results with an ID greater than (that is, more recent than) the specified ID.
22
+ # @example Return activity about me
23
+ # Twitter.activity_about_me
24
+ def activity_about_me(options={})
25
+ collection_from_response(Twitter::ActionFactory, :get, "/i/activity/about_me.json", options)
26
+ end
27
+
28
+ # Returns activity by friends
29
+ #
30
+ # @note Undocumented
31
+ # @rate_limited Yes
32
+ # @authentication_required Requires user context
33
+ # @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid./
34
+ # @return [Array] An array of actions
35
+ # @param options [Hash] A customizable set of options.
36
+ # @option options [Integer] :count Specifies the number of records to retrieve. Must be less than or equal to 100.
37
+ # @option options [Integer] :since_id Returns results with an ID greater than (that is, more recent than) the specified ID.
38
+ # @example Return activity by friends
39
+ # Twitter.activity_by_friends
40
+ def activity_by_friends(options={})
41
+ collection_from_response(Twitter::ActionFactory, :get, "/i/activity/by_friends.json", options)
42
+ end
43
+
44
+ # @note Undocumented
45
+ # @rate_limited Yes
46
+ # @authentication_required Requires user context
47
+ # @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
48
+ #
49
+ # @overload following_followers_of(options={})
50
+ # Returns users following followers of the specified user
51
+ #
52
+ # @param options [Hash] A customizable set of options.
53
+ # @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.
54
+ # @return [Twitter::Cursor]
55
+ # @example Return users follow followers of @sferik
56
+ # Twitter.following_followers_of
57
+ #
58
+ # @overload following_followers_of(user, options={})
59
+ # Returns users following followers of the authenticated user
60
+ #
61
+ # @param user [Integer, String, Twitter::User] A Twitter user ID, screen name, or object.
62
+ # @param options [Hash] A customizable set of options.
63
+ # @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.
64
+ # @return [Twitter::Cursor]
65
+ # @example Return users follow followers of @sferik
66
+ # Twitter.following_followers_of('sferik')
67
+ # Twitter.following_followers_of(7505382) # Same as above
68
+ def following_followers_of(*args)
69
+ options = args.extract_options!
70
+ merge_default_cursor!(options)
71
+ options.merge_user!(args.pop || screen_name)
72
+ cursor_from_response(:users, Twitter::User, :get, "/users/following_followers_of.json", options)
73
+ end
74
+
75
+ # Returns activity summary for a Tweet
76
+ #
77
+ # @note Undocumented
78
+ # @rate_limited Yes
79
+ # @authentication_required Requires user context
80
+ # @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
81
+ # @return [Twitter::Tweet] The requested Tweet.
82
+ # @param id [Integer] A Tweet ID.
83
+ # @param options [Hash] A customizable set of options.
84
+ # @example Return activity summary for the Tweet with the ID 25938088801
85
+ # Twitter.status_activity(25938088801)
86
+ def status_activity(id, options={})
87
+ response = get("/i/statuses/#{id}/activity/summary.json", options)
88
+ response[:body].merge!(:id => id) if response[:body]
89
+ Twitter::Tweet.from_response(response)
90
+ end
91
+ alias tweet_activity status_activity
92
+
93
+ # Returns activity summary for Tweets
94
+ #
95
+ # @note Undocumented
96
+ # @rate_limited Yes
97
+ # @authentication_required Requires user context
98
+ # @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
99
+ # @return [Array<Twitter::Tweet>] The requested Tweets.
100
+ # @overload statuses_activity(*ids)
101
+ # @param ids [Array<Integer>, Set<Integer>] An array of Tweet IDs.
102
+ # @example Return activity summary for the Tweet with the ID 25938088801
103
+ # Twitter.statuses_activity(25938088801)
104
+ # @overload statuses_activity(*ids, options)
105
+ # @param ids [Array<Integer>, Set<Integer>] An array of Tweet IDs.
106
+ # @param options [Hash] A customizable set of options.
107
+ def statuses_activity(*args)
108
+ options = args.extract_options!
109
+ args.flatten.threaded_map do |id|
110
+ status_activity(id, options)
111
+ end
112
+ end
113
+
114
+ end
115
+ end
116
+ end