Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Remove support for XML response format

Twitter stopped providing XML responses for all resources and there's no
benefit in supporting XML, especially now that JSON parsing is provided
by the Ruby standard library.
  • Loading branch information...
commit e60b9cac2b14d11dcc703c87b9a74328c173f35a 1 parent c3a19dc
@sferik authored
Showing with 1,914 additions and 30,192 deletions.
  1. +0 −1  .yardopts
  2. +2 −3 Rakefile
  3. +13 −43 lib/twitter/client/account.rb
  4. +2 −4 lib/twitter/client/activity.rb
  5. +5 −17 lib/twitter/client/block.rb
  6. +4 −16 lib/twitter/client/direct_messages.rb
  7. +7 −13 lib/twitter/client/favorites.rb
  8. +2 −8 lib/twitter/client/friends_and_followers.rb
  9. +6 −25 lib/twitter/client/friendship.rb
  10. +5 −10 lib/twitter/client/geo.rb
  11. +2 −8 lib/twitter/client/help.rb
  12. +2 −6 lib/twitter/client/legal.rb
  13. +11 −35 lib/twitter/client/list.rb
  14. +5 −17 lib/twitter/client/list_members.rb
  15. +4 −17 lib/twitter/client/list_subscribers.rb
  16. +2 −4 lib/twitter/client/local_trends.rb
  17. +2 −8 lib/twitter/client/notification.rb
  18. +4 −16 lib/twitter/client/saved_searches.rb
  19. +3 −11 lib/twitter/client/search.rb
  20. +1 −4 lib/twitter/client/spam_reporting.rb
  21. +8 −34 lib/twitter/client/timeline.rb
  22. +2 −6 lib/twitter/client/trends.rb
  23. +7 −28 lib/twitter/client/tweets.rb
  24. +1 −2  lib/twitter/client/urls.rb
  25. +20 −52 lib/twitter/client/user.rb
  26. +3 −10 lib/twitter/configuration.rb
  27. +5 −11 lib/twitter/connection.rb
  28. +9 −17 lib/twitter/request.rb
  29. +2 −2 lib/twitter/search.rb
  30. +3 −3 spec/faraday/response_spec.rb
  31. +0 −5 spec/fixtures/bad_gateway.xml
  32. +0 −5 spec/fixtures/bad_request.xml
  33. +0 −1,919 spec/fixtures/category.xml
  34. +0 −116 spec/fixtures/configuration.xml
  35. +0 −348 spec/fixtures/contributees.xml
  36. +0 −807 spec/fixtures/contributors.xml
  37. +0 −78 spec/fixtures/direct_message.xml
  38. +0 −1,543 spec/fixtures/direct_messages.xml
  39. +0 −5 spec/fixtures/end_session.xml
  40. +0 −1  spec/fixtures/false.xml
  41. +0 −1,040 spec/fixtures/favorites.xml
  42. +0 −5,238 spec/fixtures/followers.xml
  43. +0 −5 spec/fixtures/forbidden.xml
  44. +0 −4,642 spec/fixtures/friends.xml
  45. +0 −31 spec/fixtures/id_list.xml
  46. +0 −91 spec/fixtures/ids.xml
  47. +0 −2,081 spec/fixtures/image_facets.xml
  48. +0 −5 spec/fixtures/internal_server_error.xml
  49. +0 −63 spec/fixtures/languages.xml
  50. +0 −47 spec/fixtures/list.xml
  51. +0 −99 spec/fixtures/lists.xml
  52. +0 −164 spec/fixtures/locations.xml
  53. +0 −21 spec/fixtures/matching_trends.xml
  54. +0 −1,046 spec/fixtures/media_timeline.xml
  55. +0 −1,165 spec/fixtures/members.xml
  56. +0 −5 spec/fixtures/not_found.xml
  57. +0 −53 spec/fixtures/pengwynn.xml
  58. +0 −62 spec/fixtures/privacy.xml
  59. +0 −7 spec/fixtures/rate_limit_status.xml
  60. +0 −843 spec/fixtures/recommendations.xml
  61. +0 −22 spec/fixtures/relationship.xml
  62. +0 −104 spec/fixtures/retweet.xml
  63. +0 −770 spec/fixtures/retweeters_of.xml
  64. +0 −1,844 spec/fixtures/retweets.xml
  65. +0 −8 spec/fixtures/saved_search.xml
  66. +0 −10 spec/fixtures/saved_searches.xml
  67. +0 −5 spec/fixtures/service_unavailable.xml
  68. +0 −25 spec/fixtures/settings.xml
  69. +0 −70 spec/fixtures/sferik.xml
  70. +0 −63 spec/fixtures/status.xml
  71. +0 −97 spec/fixtures/status_with_media.xml
  72. +0 −1,002 spec/fixtures/statuses.xml
  73. +0 −103 spec/fixtures/suggestions.xml
  74. +0 −108 spec/fixtures/tos.xml
  75. +0 −7 spec/fixtures/totals.xml
  76. +0 −1  spec/fixtures/true.xml
  77. +0 −5 spec/fixtures/unauthorized.xml
  78. +0 −71 spec/fixtures/user_search.xml
  79. +0 −870 spec/fixtures/user_timeline.xml
  80. +0 −122 spec/fixtures/users.xml
  81. +0 −1,017 spec/fixtures/users_list.xml
  82. +0 −84 spec/fixtures/video_facets.xml
  83. +0 −1  spec/twitter/api_spec.rb
  84. +2 −2 spec/twitter/base_spec.rb
  85. +204 −208 spec/twitter/client/account_spec.rb
  86. +34 −35 spec/twitter/client/activity_spec.rb
  87. +115 −119 spec/twitter/client/block_spec.rb
  88. +84 −88 spec/twitter/client/direct_messages_spec.rb
  89. +65 −69 spec/twitter/client/favorites_spec.rb
  90. +82 −86 spec/twitter/client/friends_and_followers_spec.rb
  91. +153 −157 spec/twitter/client/friendship_spec.rb
  92. +111 −115 spec/twitter/client/geo_spec.rb
  93. +40 −44 spec/twitter/client/help_spec.rb
  94. +40 −44 spec/twitter/client/legal_spec.rb
  95. +376 −380 spec/twitter/client/list_members_spec.rb
  96. +466 −470 spec/twitter/client/list_spec.rb
Sorry, we could not display the entire diff because it was too big.
View
1  .yardopts
@@ -2,7 +2,6 @@
--protected
--tag rate_limited:"Rate Limited?"
--tag requires_authentication:"Requires Authentication?"
---tag response_format:"Response Formats"
--markup markdown
-
HISTORY.md
View
5 Rakefile
@@ -16,9 +16,8 @@ namespace :doc do
task.options = [
'--protected',
'--output-dir', 'doc/yard',
- '--tag', 'format:Supported formats',
- '--tag', 'authenticated:Requires Authentication',
- '--tag', 'rate_limited:Rate Limited',
+ '--tag', 'requires_authentication:Requires Authentication?',
+ '--tag', 'rate_limited:Rate Limited?',
'--markup', 'markdown',
]
end
View
56 lib/twitter/client/account.rb
@@ -7,8 +7,6 @@ module Account
# @see https://dev.twitter.com/docs/api/1/get/account/verify_credentials
# @rate_limited Yes
# @requires_authentication Yes
- # @response_format `json`
- # @response_format `xml`
# @param options [Hash] A customizable set of options.
# @option options [Boolean, String, Integer] :include_entities Include {https://dev.twitter.com/docs/tweet-entities Tweet Entities} when set to true, 't' or 1.
# @return [Hashie::Mash] The authenticated user.
@@ -16,8 +14,7 @@ module Account
# @example Return the requesting user if authentication was successful
# Twitter.verify_credentials
def verify_credentials(options={})
- response = get('1/account/verify_credentials', options)
- format.to_s.downcase == 'xml' ? response['user'] : response
+ get("/1/account/verify_credentials.json", options)
end
# Returns the remaining number of API requests available to the requesting user
@@ -27,15 +24,12 @@ def verify_credentials(options={})
# @requires_authentication No
#
# This will return the requesting IP's rate limit status. If you want the authenticating user's rate limit status you must authenticate.
- # @response_format `json`
- # @response_format `xml`
# @param options [Hash] A customizable set of options.
# @return [Hashie::Mash]
# @example Return the remaining number of API requests available to the requesting user
# Twitter.rate_limit_status
def rate_limit_status(options={})
- response = get('1/account/rate_limit_status', options)
- format.to_s.downcase == 'xml' ? response['hash'] : response
+ get("/1/account/rate_limit_status.json", options)
end
# Ends the session of the authenticating user
@@ -43,15 +37,12 @@ def rate_limit_status(options={})
# @see https://dev.twitter.com/docs/api/1/post/account/end_session
# @rate_limited No
# @requires_authentication Yes
- # @response_format `json`
- # @response_format `xml`
# @param options [Hash] A customizable set of options.
# @return [Hashie::Mash]
# @example End the session of the authenticating user
# Twitter.end_session
def end_session(options={})
- response = post('1/account/end_session', options)
- format.to_s.downcase == 'xml' ? response['hash'] : response
+ post("/1/account/end_session.json", options)
end
# Sets which device Twitter delivers updates to for the authenticating user
@@ -59,8 +50,6 @@ def end_session(options={})
# @see https://dev.twitter.com/docs/api/1/post/account/update_delivery_device
# @rate_limited No
# @requires_authentication Yes
- # @response_format `json`
- # @response_format `xml`
# @param device [String] Must be one of: 'sms', 'none'.
# @param options [Hash] A customizable set of options.
# @option options [Boolean, String, Integer] :include_entities Include {https://dev.twitter.com/docs/tweet-entities Tweet Entities} when set to true, 't' or 1.
@@ -68,8 +57,7 @@ def end_session(options={})
# @example Turn SMS updates on for the authenticating user
# Twitter.update_delivery_device('sms')
def update_delivery_device(device, options={})
- response = post('1/account/update_delivery_device', options.merge(:device => device))
- format.to_s.downcase == 'xml' ? response['user'] : response
+ post("/1/account/update_delivery_device.json", options.merge(:device => device))
end
# Sets one or more hex values that control the color scheme of the authenticating user's profile
@@ -77,8 +65,6 @@ def update_delivery_device(device, options={})
# @see https://dev.twitter.com/docs/api/1/post/account/update_profile_colors
# @rate_limited No
# @requires_authentication Yes
- # @response_format `json`
- # @response_format `xml`
# @param options [Hash] A customizable set of options.
# @option options [String] :profile_background_color Profile background color.
# @option options [String] :profile_text_color Profile text color.
@@ -90,8 +76,7 @@ def update_delivery_device(device, options={})
# @example Set authenticating user's profile background to black
# Twitter.update_profile_colors(:profile_background_color => '000000')
def update_profile_colors(options={})
- response = post('1/account/update_profile_colors', options)
- format.to_s.downcase == 'xml' ? response['user'] : response
+ post("/1/account/update_profile_colors.json", options)
end
# Updates the authenticating user's profile image
@@ -100,8 +85,6 @@ def update_profile_colors(options={})
# @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 {Twitter::Client::User#profile_image}.
# @rate_limited No
# @requires_authentication Yes
- # @response_format `json`
- # @response_format `xml`
# @param image [String] The avatar image for the profile. 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.
# @param options [Hash] A customizable set of options.
# @option options [Boolean, String, Integer] :include_entities Include {https://dev.twitter.com/docs/tweet-entities Tweet Entities} when set to true, 't' or 1.
@@ -109,8 +92,7 @@ def update_profile_colors(options={})
# @example Update the authenticating user's profile image
# Twitter.update_profile_image(File.new("me.jpeg"))
def update_profile_image(image, options={})
- response = post('1/account/update_profile_image', options.merge(:image => image))
- format.to_s.downcase == 'xml' ? response['user'] : response
+ post("/1/account/update_profile_image.json", options.merge(:image => image))
end
# Updates the authenticating user's profile background image
@@ -118,8 +100,6 @@ def update_profile_image(image, options={})
# @see https://dev.twitter.com/docs/api/1/post/account/update_profile_background_image
# @rate_limited No
# @requires_authentication Yes
- # @response_format `json`
- # @response_format `xml`
# @param image [String] The background image for the profile. 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 scaled down.
# @param options [Hash] A customizable set of options.
# @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.
@@ -128,8 +108,7 @@ def update_profile_image(image, options={})
# @example Update the authenticating user's profile background image
# Twitter.update_profile_background_image(File.new("we_concept_bg2.png"))
def update_profile_background_image(image, options={})
- response = post('1/account/update_profile_background_image', options.merge(:image => image))
- format.to_s.downcase == 'xml' ? response['user'] : response
+ post("/1/account/update_profile_background_image.json", options.merge(:image => image))
end
# Sets values that users are able to set under the "Account" tab of their settings page
@@ -138,8 +117,6 @@ def update_profile_background_image(image, options={})
# @note Only the options specified will be updated.
# @rate_limited No
# @requires_authentication Yes
- # @response_format `json`
- # @response_format `xml`
# @param options [Hash] A customizable set of options.
# @option options [String] :name Full name associated with the profile. Maximum of 20 characters.
# @option options [String] :url URL associated with the profile. Will be prepended with "http://" if not present. Maximum of 100 characters.
@@ -150,8 +127,7 @@ def update_profile_background_image(image, options={})
# @example Set authenticating user's name to Erik Michaels-Ober
# Twitter.update_profile(:name => "Erik Michaels-Ober")
def update_profile(options={})
- response = post('1/account/update_profile', options)
- format.to_s.downcase == 'xml' ? response['user'] : response
+ post("/1/account/update_profile.json", options)
end
# Returns the current count of friends, followers, updates (statuses) and favorites of the authenticating user.
@@ -159,15 +135,12 @@ def update_profile(options={})
# @see https://dev.twitter.com/docs/api/1/get/account/totals
# @rate_limited Yes
# @requires_authentication Yes
- # @response_format `json`
- # @response_format `xml`
# @return [Hashie::Mash] the current count of friends, followers, updates, and favorites of the authenticating user.
# @raise [Twitter::Unauthorized] Error raised when supplied user credentials are not valid.
# @example Return the totals for the authenticating user.
# Twitter.totals
- def totals()
- response = get('1/account/totals')
- format.to_s.downcase == 'xml' ? response['hash'] : response
+ def totals(options={})
+ get("/1/account/totals.json", options)
end
# Updates the authenticating user's settings.
@@ -177,8 +150,6 @@ def totals()
# @see https://dev.twitter.com/docs/api/1/get/account/settings
# @rate_limited Yes
# @requires_authentication Yes
- # @response_format `json`
- # @response_format `xml`
# @param options [Hash] A customizable set of options.
# @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/get/trends/available GET trends/available}.
# @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.
@@ -190,14 +161,13 @@ def totals()
# @raise [Twitter::Unauthorized] Error raised when supplied user credentials are not valid.
# @example Return the settings for the authenticating user.
# Twitter.settings
- def settings(options = {})
+ def settings(options={})
case options.length
when 0
- response = get('1/account/settings')
+ get("/1/account/settings.json", options)
else
- response = post('1/account/settings', options)
+ post("/1/account/settings.json", options)
end
- format.to_s.downcase == 'xml' ? response['hash'] : response
end
end
View
6 lib/twitter/client/activity.rb
@@ -7,7 +7,6 @@ module Activity
# @note Undocumented
# @rate_limited Yes
# @requires_authentication Yes
- # @response_format `json`
# @param options [Hash] A customizable set of options.
# @option options [Integer] :count Specifies the number of records to retrieve. Must be less than or equal to 100.
# @option options [Boolean, String, Integer] :include_entities Include {http://dev.twitter.com/pages/tweet_entities Tweet Entities} when set to true, 't' or 1.
@@ -16,7 +15,7 @@ module Activity
# @example Return activity about me
# Twitter.about_me
def about_me(options={})
- get("i/activity/about_me", options, :format => :json, :phoenix => true)
+ get("/i/activity/about_me.json", options, :phoenix => true)
end
# Returns activity by friends
@@ -24,7 +23,6 @@ def about_me(options={})
# @note Undocumented
# @rate_limited Yes
# @requires_authentication Yes
- # @response_format `json`
# @param options [Hash] A customizable set of options.
# @option options [Integer] :count Specifies the number of records to retrieve. Must be less than or equal to 100.
# @option options [Boolean, String, Integer] :include_entities Include {http://dev.twitter.com/pages/tweet_entities Tweet Entities} when set to true, 't' or 1.
@@ -33,7 +31,7 @@ def about_me(options={})
# @example Return activity by friends
# Twitter.by_friends
def by_friends(options={})
- get("i/activity/by_friends", options, :format => :json, :phoenix => true)
+ get("/i/activity/by_friends.json", options, :phoenix => true)
end
end
end
View
22 lib/twitter/client/block.rb
@@ -9,8 +9,6 @@ module Block
# @note Destroys a friendship to the blocked user if it exists.
# @rate_limited Yes
# @requires_authentication Yes
- # @response_format `json`
- # @response_format `xml`
# @param user [Integer, String] A Twitter user ID or screen name.
# @param options [Hash] A customizable set of options.
# @option options [Boolean, String, Integer] :include_entities Include {https://dev.twitter.com/docs/tweet-entities Tweet Entities} when set to true, 't' or 1.
@@ -20,8 +18,7 @@ module Block
# Twitter.block(7505382) # Same as above
def block(user, options={})
merge_user_into_options!(user, options)
- response = post('1/blocks/create', options)
- format.to_s.downcase == 'xml' ? response['user'] : response
+ post("/1/blocks/create.json", options)
end
# Un-blocks the user specified by the authenticating user
@@ -29,8 +26,6 @@ def block(user, options={})
# @see https://dev.twitter.com/docs/api/1/post/blocks/destroy
# @rate_limited No
# @requires_authentication Yes
- # @response_format `json`
- # @response_format `xml`
# @param user [Integer, String] A Twitter user ID or screen name.
# @param options [Hash] A customizable set of options.
# @option options [Boolean, String, Integer] :include_entities Include {https://dev.twitter.com/docs/tweet-entities Tweet Entities} when set to true, 't' or 1.
@@ -40,8 +35,7 @@ def block(user, options={})
# Twitter.unblock(7505382) # Same as above
def unblock(user, options={})
merge_user_into_options!(user, options)
- response = delete('1/blocks/destroy', options)
- format.to_s.downcase == 'xml' ? response['user'] : response
+ delete("/1/blocks/destroy.json", options)
end
# Returns true if the authenticating user is blocking a target user
@@ -57,7 +51,7 @@ def unblock(user, options={})
# Twitter.block?(7505382) # Same as above
def block?(user, options={})
merge_user_into_options!(user, options)
- get('1/blocks/exists', options, :format => :json, :raw => true)
+ get("/1/blocks/exists.json", options, :raw => true)
true
rescue Twitter::NotFound
false
@@ -85,8 +79,6 @@ def block_exists?(user, options={})
# @see https://dev.twitter.com/docs/api/1/get/blocks/blocking
# @rate_limited Yes
# @requires_authentication Yes
- # @response_format `json`
- # @response_format `xml`
# @param options [Hash] A customizable set of options.
# @option options [Integer] :page Specifies the page of results to retrieve.
# @option options [Boolean, String, Integer] :include_entities Include {https://dev.twitter.com/docs/tweet-entities Tweet Entities} when set to true, 't' or 1.
@@ -94,8 +86,7 @@ def block_exists?(user, options={})
# @example Return an array of user objects that the authenticating user is blocking
# Twitter.blocking
def blocking(options={})
- response = get('1/blocks/blocking', options)
- format.to_s.downcase == 'xml' ? response['users'] : response
+ get("/1/blocks/blocking.json", options)
end
# Returns an array of numeric user ids the authenticating user is blocking
@@ -103,15 +94,12 @@ def blocking(options={})
# @see https://dev.twitter.com/docs/api/1/get/blocks/blocking/ids
# @rate_limited Yes
# @requires_authentication Yes
- # @response_format `json`
- # @response_format `xml`
# @param options [Hash] A customizable set of options.
# @return [Array] Numeric user ids the authenticating user is blocking.
# @example Return an array of numeric user ids the authenticating user is blocking
# Twitter.blocking_ids
def blocked_ids(options={})
- response = get('1/blocks/blocking/ids', options)
- format.to_s.downcase == 'xml' ? response['ids']['id'].map{|id| id.to_i} : response
+ get("/1/blocks/blocking/ids.json", options)
end
end
end
View
20 lib/twitter/client/direct_messages.rb
@@ -7,8 +7,6 @@ module DirectMessages
# @see https://dev.twitter.com/docs/api/1/get/direct_messages
# @rate_limited Yes
# @requires_authentication Yes
- # @response_format `json`
- # @response_format `xml`
# @param options [Hash] A customizable set of options.
# @option options [Integer] :since_id Returns results with an ID greater than (that is, more recent than) the specified ID.
# @option options [Integer] :max_id Returns results with an ID less than (that is, older than) or equal to the specified ID.
@@ -19,8 +17,7 @@ module DirectMessages
# @example Return the 20 most recent direct messages sent to the authenticating user
# Twitter.direct_messages
def direct_messages(options={})
- response = get('1/direct_messages', options)
- format.to_s.downcase == 'xml' ? response['direct_messages'] : response
+ get("/1/direct_messages.json", options)
end
# Returns the 20 most recent direct messages sent by the authenticating user
@@ -28,8 +25,6 @@ def direct_messages(options={})
# @see https://dev.twitter.com/docs/api/1/get/direct_messages/sent
# @rate_limited Yes
# @requires_authentication Yes
- # @response_format `json`
- # @response_format `xml`
# @param options [Hash] A customizable set of options.
# @option options [Integer] :since_id Returns results with an ID greater than (that is, more recent than) the specified ID.
# @option options [Integer] :max_id Returns results with an ID less than (that is, older than) or equal to the specified ID.
@@ -40,8 +35,7 @@ def direct_messages(options={})
# @example Return the 20 most recent direct messages sent by the authenticating user
# Twitter.direct_messages_sent
def direct_messages_sent(options={})
- response = get('1/direct_messages/sent', options)
- format.to_s.downcase == 'xml' ? response['direct_messages'] : response
+ get("/1/direct_messages/sent.json", options)
end
# Sends a new direct message to the specified user from the authenticating user
@@ -49,8 +43,6 @@ def direct_messages_sent(options={})
# @see https://dev.twitter.com/docs/api/1/post/direct_messages/new
# @rate_limited No
# @requires_authentication Yes
- # @response_format `json`
- # @response_format `xml`
# @param user [Integer, String] A Twitter user ID or screen name.
# @param text [String] The text of your direct message, up to 140 characters.
# @param options [Hash] A customizable set of options.
@@ -61,8 +53,7 @@ def direct_messages_sent(options={})
# Twitter.direct_message_create(7505382, "I'm sending you this message via the Twitter Ruby Gem!") # Same as above
def direct_message_create(user, text, options={})
merge_user_into_options!(user, options)
- response = post('1/direct_messages/new', options.merge(:text => text))
- format.to_s.downcase == 'xml' ? response['direct_message'] : response
+ post("/1/direct_messages/new.json", options.merge(:text => text))
end
# Destroys a direct message
@@ -71,8 +62,6 @@ def direct_message_create(user, text, options={})
# @note The authenticating user must be the recipient of the specified direct message.
# @rate_limited No
# @requires_authentication Yes
- # @response_format `json`
- # @response_format `xml`
# @param id [Integer] The ID of the direct message to delete.
# @param options [Hash] A customizable set of options.
# @option options [Boolean, String, Integer] :include_entities Include {https://dev.twitter.com/docs/tweet-entities Tweet Entities} when set to true, 't' or 1.
@@ -80,8 +69,7 @@ def direct_message_create(user, text, options={})
# @example Destroys the direct message with the ID 1825785544
# Twitter.direct_message_destroy(1825785544)
def direct_message_destroy(id, options={})
- response = delete("1/direct_messages/destroy/#{id}", options)
- format.to_s.downcase == 'xml' ? response['direct_message'] : response
+ delete("/1/direct_messages/destroy/#{id}.json", options)
end
end
end
View
20 lib/twitter/client/favorites.rb
@@ -5,8 +5,6 @@ module Favorites
# @see https://dev.twitter.com/docs/api/1/get/favorites
# @rate_limited Yes
# @requires_authentication No
- # @response_format `json`
- # @response_format `xml`
# @overload favorites(options={})
# Returns the 20 most recent favorite statuses for the authenticating user
#
@@ -27,9 +25,11 @@ module Favorites
# Twitter.favorites("sferik")
def favorites(*args)
options = args.last.is_a?(Hash) ? args.pop : {}
- user = args.first
- response = get([1, 'favorites', user].compact.join('/'), options)
- format.to_s.downcase == 'xml' ? response['statuses'] : response
+ if user = args.first
+ get("/1/favorites/#{user}.json", options)
+ else
+ get("/1/favorites.json", options)
+ end
end
# Favorites the specified status as the authenticating user
@@ -37,8 +37,6 @@ def favorites(*args)
# @see https://dev.twitter.com/docs/api/1/post/favorites/create/:id
# @rate_limited No
# @requires_authentication Yes
- # @response_format `json`
- # @response_format `xml`
# @param id [Integer] The numerical ID of the desired status.
# @param options [Hash] A customizable set of options.
# @option options [Boolean, String, Integer] :include_entities Include {https://dev.twitter.com/docs/tweet-entities Tweet Entities} when set to true, 't' or 1.
@@ -46,8 +44,7 @@ def favorites(*args)
# @example Favorite the status with the ID 25938088801
# Twitter.favorite_create(25938088801)
def favorite_create(id, options={})
- response = post("1/favorites/create/#{id}", options)
- format.to_s.downcase == 'xml' ? response['status'] : response
+ post("/1/favorites/create/#{id}.json", options)
end
# Un-favorites the specified status as the authenticating user
@@ -55,8 +52,6 @@ def favorite_create(id, options={})
# @see https://dev.twitter.com/docs/api/1/post/favorites/destroy/:id
# @rate_limited No
# @requires_authentication Yes
- # @response_format `json`
- # @response_format `xml`
# @param id [Integer] The numerical ID of the desired status.
# @param options [Hash] A customizable set of options.
# @option options [Boolean, String, Integer] :include_entities Include {https://dev.twitter.com/docs/tweet-entities Tweet Entities} when set to true, 't' or 1.
@@ -64,8 +59,7 @@ def favorite_create(id, options={})
# @example Un-favorite the status with the ID 25938088801
# Twitter.favorite_destroy(25938088801)
def favorite_destroy(id, options={})
- response = delete("1/favorites/destroy/#{id}", options)
- format.to_s.downcase == 'xml' ? response['status'] : response
+ delete("/1/favorites/destroy/#{id}.json", options)
end
end
end
View
10 lib/twitter/client/friends_and_followers.rb
@@ -7,8 +7,6 @@ module FriendsAndFollowers
# @requires_authentication No unless requesting it from a protected user
#
# If getting this data of a protected user, you must authenticate (and be allowed to see that user).
- # @response_format `json`
- # @response_format `xml`
# @overload friend_ids(options={})
# Returns an array of numeric IDs for every user the authenticated user is following
#
@@ -32,8 +30,7 @@ def friend_ids(*args)
options.merge!(args.last.is_a?(Hash) ? args.pop : {})
user = args.first
merge_user_into_options!(user, options)
- response = get('1/friends/ids', options)
- format.to_s.downcase == 'xml' ? Hashie::Mash.new(:ids => response['id_list']['ids']['id'].map{|id| id.to_i}) : response
+ get("/1/friends/ids.json", options)
end
# @see https://dev.twitter.com/docs/api/1/get/followers/ids
@@ -41,8 +38,6 @@ def friend_ids(*args)
# @requires_authentication No unless requesting it from a protected user
#
# If getting this data of a protected user, you must authenticate (and be allowed to see that user).
- # @response_format `json`
- # @response_format `xml`
# @overload follower_ids(options={})
# Returns an array of numeric IDs for every user following the authenticated user
#
@@ -66,8 +61,7 @@ def follower_ids(*args)
options.merge!(args.last.is_a?(Hash) ? args.pop : {})
user = args.first
merge_user_into_options!(user, options)
- response = get('1/followers/ids', options)
- format.to_s.downcase == 'xml' ? Hashie::Mash.new(:ids => response['id_list']['ids']['id'].map{|id| id.to_i}) : response
+ get("/1/followers/ids.json", options)
end
end
end
View
31 lib/twitter/client/friendship.rb
@@ -7,8 +7,6 @@ module Friendship
# @see https://dev.twitter.com/docs/api/1/post/friendships/create
# @rate_limited No
# @requires_authentication Yes
- # @response_format `json`
- # @response_format `xml`
# @param user [Integer, String] A Twitter user ID or screen name.
# @param options [Hash] A customizable set of options.
# @option options [Boolean] :follow (false) Enable notifications for the target user.
@@ -21,8 +19,7 @@ def follow(user, options={})
# Twitter always turns on notifications if the "follow" option is present, even if it's set to false
# so only send follow if it's true
options.merge!(:follow => true) if options.delete(:follow)
- response = post('1/friendships/create', options)
- format.to_s.downcase == 'xml' ? response['user'] : response
+ post("/1/friendships/create.json", options)
end
alias :friendship_create :follow
@@ -31,8 +28,6 @@ def follow(user, options={})
# @see https://dev.twitter.com/docs/api/1/post/friendships/destroy
# @rate_limited No
# @requires_authentication Yes
- # @response_format `json`
- # @response_format `xml`
# @param user [Integer, String] A Twitter user ID or screen name.
# @param options [Hash] A customizable set of options.
# @option options [Boolean, String, Integer] :include_entities Include {https://dev.twitter.com/docs/tweet-entities Tweet Entities} when set to true, 't' or 1.
@@ -41,8 +36,7 @@ def follow(user, options={})
# Twitter.unfollow("sferik")
def unfollow(user, options={})
merge_user_into_options!(user, options)
- response = delete('1/friendships/destroy', options)
- format.to_s.downcase == 'xml' ? response['user'] : response
+ delete("/1/friendships/destroy.json", options)
end
alias :friendship_destroy :unfollow
@@ -52,8 +46,6 @@ def unfollow(user, options={})
# @note Consider using {Twitter::Client::Friendship#friendship} instead of this method.
# @rate_limited Yes
# @requires_authentication No unless user_a or user_b is protected
- # @response_format `json`
- # @response_format `xml`
# @param user_a [Integer, String] The ID or screen_name of the subject user.
# @param user_b [Integer, String] The ID or screen_name of the user to test for following.
# @param options [Hash] A customizable set of options.
@@ -61,8 +53,7 @@ def unfollow(user, options={})
# @example Return true if @sferik follows @pengwynn
# Twitter.friendship?("sferik", "pengwynn")
def friendship?(user_a, user_b, options={})
- response = get('1/friendships/exists', options.merge(:user_a => user_a, :user_b => user_b))
- format.to_s.downcase == 'xml' ? !%w(0 false).include?(response['friends']) : response
+ get("/1/friendships/exists.json", options.merge(:user_a => user_a, :user_b => user_b))
end
# Test for the existence of friendship between two users
@@ -71,8 +62,6 @@ def friendship?(user_a, user_b, options={})
# @deprecated {Twitter::Client::Friendship#friendship_exists?} is deprecated and will be removed in the next major version. Please use {Twitter::Client::Friendship#friendship?} instead.
# @rate_limited Yes
# @requires_authentication No unless user_a or user_b is protected
- # @response_format `json`
- # @response_format `xml`
# @param user_a [Integer, String] The ID or screen_name of the subject user.
# @param user_b [Integer, String] The ID or screen_name of the user to test for following.
# @param options [Hash] A customizable set of options.
@@ -89,8 +78,6 @@ def friendship_exists?(user_a, user_b, options={})
# @see https://dev.twitter.com/docs/api/1/get/friendships/show
# @rate_limited Yes
# @requires_authentication No
- # @response_format `json`
- # @response_format `xml`
# @param options [Hash] A customizable set of options.
# @option options [Integer] :source_id The ID of the subject user.
# @option options [String] :source_screen_name The screen_name of the subject user.
@@ -101,7 +88,7 @@ def friendship_exists?(user_a, user_b, options={})
# Twitter.friendship(:source_screen_name => "sferik", :target_screen_name => "pengwynn")
# Twitter.friendship(:source_id => 7505382, :target_id => 14100886)
def friendship(options={})
- get('1/friendships/show', options)['relationship']
+ get("/1/friendships/show.json", options)['relationship']
end
alias :friendship_show :friendship
@@ -110,8 +97,6 @@ def friendship(options={})
# @see https://dev.twitter.com/docs/api/1/get/friendships/incoming
# @rate_limited Yes
# @requires_authentication Yes
- # @response_format `json`
- # @response_format `xml`
# @param options [Hash] A customizable set of options.
# @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.
# @return [Hashie::Mash]
@@ -119,8 +104,7 @@ def friendship(options={})
# Twitter.friendships_incoming
def friendships_incoming(options={})
options = {:cursor => -1}.merge(options)
- response = get('1/friendships/incoming', options)
- format.to_s.downcase == 'xml' ? Hashie::Mash.new(:ids => response['id_list']['ids']['id'].map{|id| id.to_i}) : response
+ get("/1/friendships/incoming.json", options)
end
# Returns an array of numeric IDs for every protected user for whom the authenticating user has a pending follow request
@@ -128,8 +112,6 @@ def friendships_incoming(options={})
# @see https://dev.twitter.com/docs/api/1/get/friendships/outgoing
# @rate_limited Yes
# @requires_authentication Yes
- # @response_format `json`
- # @response_format `xml`
# @param options [Hash] A customizable set of options.
# @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.
# @return [Hashie::Mash]
@@ -137,8 +119,7 @@ def friendships_incoming(options={})
# Twitter.friendships_outgoing
def friendships_outgoing(options={})
options = {:cursor => -1}.merge(options)
- response = get('1/friendships/outgoing', options)
- format.to_s.downcase == 'xml' ? Hashie::Mash.new(:ids => response['id_list']['ids']['id'].map{|id| id.to_i}) : response
+ get("/1/friendships/outgoing.json", options)
end
end
end
View
15 lib/twitter/client/geo.rb
@@ -8,7 +8,6 @@ module Geo
# @see https://dev.twitter.com/docs/api/1/get/geo/search
# @rate_limited Yes
# @requires_authentication No
- # @response_format `json`
# @param options [Hash] A customizable set of options.
# @option options [Float] :lat The latitude to search around. 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.
# @option options [Float] :long The longitude to search around. The valid range 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.
@@ -23,7 +22,7 @@ module Geo
# @example Return an array of places near the IP address 74.125.19.104
# Twitter.places_nearby(:ip => "74.125.19.104")
def places_nearby(options={})
- get('1/geo/search', options, :format => :json)['result']['places']
+ get("/1/geo/search.json", options)['result']['places']
end
alias :geo_search :places_nearby
@@ -33,7 +32,6 @@ def places_nearby(options={})
# @note Conceptually, you would use this method to get a list of known places to choose from first. Then, if the desired place doesn't exist, make a request to {Twitter::Client::Geo#place} to create a new one. The token contained in the response is the token necessary to create a new place.
# @rate_limited Yes
# @requires_authentication No
- # @response_format `json`
# @param options [Hash] A customizable set of options.
# @option options [Float] :lat The latitude to search around. 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.
# @option options [Float] :long The longitude to search around. The valid range 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.
@@ -44,7 +42,7 @@ def places_nearby(options={})
# @example Return an array of places similar to Twitter HQ
# Twitter.places_similar(:lat => "37.7821120598956", :long => "-122.400612831116", :name => "Twitter HQ")
def places_similar(options={})
- get('1/geo/similar_places', options, :format => :json)['result']
+ get("/1/geo/similar_places.json", options)['result']
end
# Searches for up to 20 places that can be used as a place_id
@@ -53,7 +51,6 @@ def places_similar(options={})
# @note This request is an informative call and will deliver generalized results about geography.
# @rate_limited Yes
# @requires_authentication No
- # @response_format `json`
# @param options [Hash] A customizable set of options.
# @option options [Float] :lat The latitude to search around. 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.
# @option options [Float] :long The longitude to search around. The valid range 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.
@@ -64,7 +61,7 @@ def places_similar(options={})
# @example Return an array of places within the specified region
# Twitter.reverse_geocode(:lat => "37.7821120598956", :long => "-122.400612831116")
def reverse_geocode(options={})
- get('1/geo/reverse_geocode', options, :format => :json)['result']['places']
+ get("/1/geo/reverse_geocode.json", options)['result']['places']
end
# Returns all the information about a known place
@@ -72,14 +69,13 @@ def reverse_geocode(options={})
# @see https://dev.twitter.com/docs/api/1/get/geo/id/:place_id
# @rate_limited Yes
# @requires_authentication No
- # @response_format `json`
# @param place_id [String] A place in the world. These IDs can be retrieved from {Twitter::Client::Geo#reverse_geocode}.
# @param options [Hash] A customizable set of options.
# @return [Hashie::Mash] The requested place.
# @example Return all the information about Twitter HQ
# Twitter.place("247f43d441defc03")
def place(place_id, options={})
- get("1/geo/id/#{place_id}", options, :format => :json)
+ get("/1/geo/id/#{place_id}.json", options)
end
# Creates a new place at the given latitude and longitude
@@ -87,7 +83,6 @@ def place(place_id, options={})
# @see https://dev.twitter.com/docs/api/1/post/geo/place
# @rate_limited Yes
# @requires_authentication No
- # @response_format `json`
# @param options [Hash] A customizable set of options.
# @option options [String] :name The name a place is known as.
# @option options [String] :contained_within This is the place_id which you would like to restrict the search results to. Setting this value means only places within the given place_id will be found.
@@ -99,7 +94,7 @@ def place(place_id, options={})
# @example Create a new place
# Twitter.place_create(:name => "@sferik's Apartment", :token => "22ff5b1f7159032cf69218c4d8bb78bc", :contained_within => "41bcb736f84a799e", :lat => "37.783699", :long => "-122.393581")
def place_create(options={})
- post('1/geo/place', options, :format => :json)
+ post("/1/geo/place.json", options)
end
end
end
View
10 lib/twitter/client/help.rb
@@ -7,14 +7,11 @@ module Help
# @see https://dev.twitter.com/docs/api/1/get/help/configuration
# @rate_limited Yes
# @requires_authentication No
- # @response_format `json`
- # @response_format `xml`
# @return [Hashie::Mash] Twitter's configuration.
# @example Return the current configuration used by Twitter
# Twitter.configuration
def configuration(options={})
- response = get('1/help/configuration', options)
- format.to_s.downcase == 'xml' ? response['configuration'] : response
+ get("/1/help/configuration.json", options)
end
# Returns the list of languages supported by Twitter
@@ -22,14 +19,11 @@ def configuration(options={})
# @see https://dev.twitter.com/docs/api/1/get/help/languages
# @rate_limited Yes
# @requires_authentication No
- # @response_format `json`
- # @response_format `xml`
# @return [Array]
# @example Return the list of languages Twitter supports
# Twitter.languages
def languages(options={})
- response = get('1/help/languages', options)
- format.to_s.downcase == 'xml' ? response['languages']['language'] : response
+ get("/1/help/languages.json", options)
end
end
end
View
8 lib/twitter/client/legal.rb
@@ -7,13 +7,11 @@ module Legal
# @see https://dev.twitter.com/docs/api/1/get/legal/tos
# @rate_limited Yes
# @requires_authentication No
- # @response_format `json`
- # @response_format `xml`
# @return [String]
# @example Return {https://twitter.com/tos Twitter's Terms of Service}
# Twitter.tos
def tos(options={})
- get('1/legal/tos', options)['tos']
+ get("/1/legal/tos.json", options)['tos']
end
# Returns {https://twitter.com/privacy Twitter's Privacy Policy}
@@ -21,13 +19,11 @@ def tos(options={})
# @see https://dev.twitter.com/docs/api/1/get/legal/privacy
# @rate_limited Yes
# @requires_authentication No
- # @response_format `json`
- # @response_format `xml`
# @return [String]
# @example Return {https://twitter.com/privacy Twitter's Privacy Policy}
# Twitter.privacy
def privacy(options={})
- get('1/legal/privacy', options)['privacy']
+ get("/1/legal/privacy.json", options)['privacy']
end
end
end
View
46 lib/twitter/client/list.rb
@@ -10,8 +10,6 @@ module List
# @note Accounts are limited to 20 lists.
# @rate_limited No
# @requires_authentication Yes
- # @response_format `json`
- # @response_format `xml`
# @overload list_create(screen_name, name, options={})
# @deprecated Calling {Twitter::Client::List#list_create} with a screen_name is deprecated and will be removed in the next major version. Please omit the screen_name argument.
# @param screen_name [String] A Twitter user name.
@@ -35,8 +33,7 @@ def list_create(*args)
if screen_name = args.pop
warn "#{caller.first}: [DEPRECATION] Calling #list_create with a screen_name is deprecated and will be removed in the next major version. Please omit the screen_name argument."
end
- response = post("1/lists/create", options.merge(:name => name))
- format.to_s.downcase == 'xml' ? response['list'] : response
+ post("/1/lists/create.json", options.merge(:name => name))
end
# Updates the specified list
@@ -44,8 +41,6 @@ def list_create(*args)
# @see https://dev.twitter.com/docs/api/1/post/lists/update
# @rate_limited No
# @requires_authentication Yes
- # @response_format `json`
- # @response_format `xml`
# @overload list_update(list, options={})
# @param list [Integer, String] The list_id or slug for the list.
# @param options [Hash] A customizable set of options.
@@ -74,8 +69,7 @@ def list_update(*args)
user = args.pop || get_screen_name
merge_list_into_options!(list, options)
merge_owner_into_options!(user, options)
- response = post("1/lists/update", options)
- format.to_s.downcase == 'xml' ? response['list'] : response
+ post("/1/lists/update.json", options)
end
# List the lists of the specified user
@@ -84,8 +78,6 @@ def list_update(*args)
# @note Private lists will be included if the authenticated user is the same as the user whose lists are being returned.
# @rate_limited Yes
# @requires_authentication Yes
- # @response_format `json`
- # @response_format `xml`
# @overload lists(options={})
# @param options [Hash] A customizable set of options.
# @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.
@@ -105,8 +97,7 @@ def lists(*args)
options = {:cursor => -1}.merge(args.last.is_a?(Hash) ? args.pop : {})
user = args.first
merge_user_into_options!(user, options) if user
- response = get("1/lists", options)
- format.to_s.downcase == 'xml' ? response['lists_list'] : response
+ get("/1/lists.json", options)
end
# Show the specified list
@@ -115,8 +106,6 @@ def lists(*args)
# @note Private lists will only be shown if the authenticated user owns the specified list.
# @rate_limited Yes
# @requires_authentication Yes
- # @response_format `json`
- # @response_format `xml`
# @overload list(list, options={})
# @param list [Integer, String] The list_id or slug of the list.
# @param options [Hash] A customizable set of options.
@@ -141,8 +130,7 @@ def list(*args)
user = args.pop || get_screen_name
merge_list_into_options!(list, options)
merge_owner_into_options!(user, options)
- response = get("1/lists/show", options)
- format.to_s.downcase == 'xml' ? response['list'] : response
+ get("/1/lists/show.json", options)
end
# Deletes the specified list
@@ -151,14 +139,12 @@ def list(*args)
# @note Must be owned by the authenticated user.
# @rate_limited No
# @requires_authentication Yes
- # @response_format `json`
- # @response_format `xml`
# @overload list_delete(list, options={})
# @param list [Integer, String] The list_id or slug of the list.
# @param options [Hash] A customizable set of options.
# @return [Hashie::Mash] The deleted list.
# @example Delete the authenticated user's "presidents" list
- # Twitter.list_delete("presidents")
+ # Twitter.list_delete("/presidents")
# Twitter.list_delete(8863586)
# @overload list_delete(user, list, options={})
# @param user [Integer, String] A Twitter user ID or screen name.
@@ -166,8 +152,8 @@ def list(*args)
# @param options [Hash] A customizable set of options.
# @return [Hashie::Mash] The deleted list.
# @example Delete @sferik's "presidents" list
- # Twitter.list_delete("sferik", "presidents")
- # Twitter.list_delete("sferik", 8863586)
+ # Twitter.list_delete("/sferik", "presidents")
+ # Twitter.list_delete("/sferik", 8863586)
# Twitter.list_delete(7505382, "presidents")
# Twitter.list_delete(7505382, 8863586)
# @return [Hashie::Mash] The deleted list.
@@ -177,8 +163,7 @@ def list_delete(*args)
user = args.pop || get_screen_name
merge_list_into_options!(list, options)
merge_owner_into_options!(user, options)
- response = delete("1/lists/destroy", options)
- format.to_s.downcase == 'xml' ? response['list'] : response
+ delete("/1/lists/destroy.json", options)
end
# Show tweet timeline for members of the specified list
@@ -186,8 +171,6 @@ def list_delete(*args)
# @see https://dev.twitter.com/docs/api/1/get/lists/statuses
# @rate_limited Yes
# @requires_authentication No
- # @response_format `json`
- # @response_format `xml`
# @overload list_timeline(list, options={})
# @param list [Integer, String] The list_id or slug of the list.
# @param options [Hash] A customizable set of options.
@@ -222,8 +205,7 @@ def list_timeline(*args)
user = args.pop || get_screen_name
merge_list_into_options!(list, options)
merge_owner_into_options!(user, options)
- response = get("1/lists/statuses", options)
- format.to_s.downcase == 'xml' ? response['statuses'] : response
+ get("/1/lists/statuses.json", options)
end
# List the lists the specified user has been added to
@@ -231,8 +213,6 @@ def list_timeline(*args)
# @see https://dev.twitter.com/docs/api/1/get/lists/memberships
# @rate_limited Yes
# @requires_authentication Yes
- # @response_format `json`
- # @response_format `xml`
# @overload memberships(options={})
# @param options [Hash] A customizable set of options.
# @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.
@@ -252,8 +232,7 @@ def memberships(*args)
options = {:cursor => -1}.merge(args.last.is_a?(Hash) ? args.pop : {})
user = args.pop || get_screen_name
merge_user_into_options!(user, options)
- response = get("1/lists/memberships", options)
- format.to_s.downcase == 'xml' ? response['lists_list'] : response
+ get("/1/lists/memberships.json", options)
end
# List the lists the specified user follows
@@ -261,8 +240,6 @@ def memberships(*args)
# @see https://dev.twitter.com/docs/api/1/get/lists/subscriptions
# @rate_limited Yes
# @requires_authentication Yes
- # @response_format `json`
- # @response_format `xml`
# @overload subscriptions(options={})
# @param options [Hash] A customizable set of options.
# @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.
@@ -282,8 +259,7 @@ def subscriptions(*args)
options = {:cursor => -1}.merge(args.last.is_a?(Hash) ? args.pop : {})
user = args.pop || get_screen_name
merge_user_into_options!(user, options)
- response = get("1/lists/subscriptions", options)
- format.to_s.downcase == 'xml' ? response['lists_list'] : response
+ get("/1/lists/subscriptions.json", options)
end
end
end
View
22 lib/twitter/client/list_members.rb
@@ -9,8 +9,6 @@ module ListMembers
# @see https://dev.twitter.com/docs/api/1/get/lists/members
# @rate_limited Yes
# @requires_authentication Yes
- # @response_format `json`
- # @response_format `xml`
# @overload list_members(list, options={})
# @param list [Integer, String] The list_id or slug of the list.
# @param options [Hash] A customizable set of options.
@@ -39,8 +37,7 @@ def list_members(*args)
user = args.pop || get_screen_name
merge_list_into_options!(list, options)
merge_owner_into_options!(user, options)
- response = get("1/lists/members", options)
- format.to_s.downcase == 'xml' ? response['users_list'] : response
+ get("/1/lists/members.json", options)
end
# Add a member to a list
@@ -49,8 +46,6 @@ def list_members(*args)
# @note Lists are limited to having 500 members.
# @rate_limited No
# @requires_authentication Yes
- # @response_format `json`
- # @response_format `xml`
# @overload list_add_member(list, user_to_add, options={})
# @param list [Integer, String] The list_id or slug of the list.
# @param user_to_add [Integer, String] The user id or screen name to add to the list.
@@ -78,8 +73,7 @@ def list_add_member(*args)
merge_list_into_options!(list, options)
merge_owner_into_options!(user, options)
merge_user_into_options!(user_to_add, options)
- response = post("1/lists/members/create", options)
- format.to_s.downcase == 'xml' ? response['list'] : response
+ post("/1/lists/members/create.json", options)
end
# Adds multiple members to a list
@@ -88,8 +82,6 @@ def list_add_member(*args)
# @note Lists are limited to having 500 members, and you are limited to adding up to 100 members to a list at a time with this method.
# @rate_limited No
# @requires_authentication Yes
- # @response_format `json`
- # @response_format `xml`
# @overload list_add_members(list, users_to_add, options={})
# @param list [Integer, String] The list_id or slug of the list.
# @param users_to_add [Array] The user IDs and/or screen names to add.
@@ -119,8 +111,7 @@ def list_add_members(*args)
merge_list_into_options!(list, options)
merge_owner_into_options!(user, options)
merge_users_into_options!(Array(users_to_add), options)
- response = post("1/lists/members/create_all", options)
- format.to_s.downcase == 'xml' ? response['list'] : response
+ post("/1/lists/members/create_all.json", options)
end
# Removes the specified member from the list
@@ -128,8 +119,6 @@ def list_add_members(*args)
# @see https://dev.twitter.com/docs/api/1/post/lists/members/destroy
# @rate_limited No
# @requires_authentication Yes
- # @response_format `json`
- # @response_format `xml`
# @overload list_remove_member(list, user_to_remove, options={})
# @param list [Integer, String] The list_id or slug of the list.
# @param user_to_remove [Integer, String] The user id or screen name of the list member to remove.
@@ -158,8 +147,7 @@ def list_remove_member(*args)
merge_list_into_options!(list, options)
merge_owner_into_options!(user, options)
merge_user_into_options!(user_to_remove, options)
- response = post("1/lists/members/destroy", options)
- format.to_s.downcase == 'xml' ? response['list'] : response
+ post("/1/lists/members/destroy.json", options)
end
# Check if a user is a member of the specified list
@@ -193,7 +181,7 @@ def list_member?(*args)
merge_list_into_options!(list, options)
merge_owner_into_options!(user, options)
merge_user_into_options!(user_to_check, options)
- get("1/lists/members/show", options, :format => :json, :raw => true)
+ get("/1/lists/members/show.json", options, :raw => true)
true
rescue Twitter::NotFound, Twitter::Forbidden
false
View
21 lib/twitter/client/list_subscribers.rb
@@ -9,8 +9,6 @@ module ListSubscribers
# @see https://dev.twitter.com/docs/api/1/get/lists/subscriptions
# @rate_limited Yes
# @requires_authentication Yes
- # @response_format `json`
- # @response_format `xml`
# @overload list_subscribers(list, options={})
# @param list [Integer, String] The list_id or slug of the list.
# @param options [Hash] A customizable set of options.
@@ -38,8 +36,7 @@ def list_subscribers(*args)
user = args.pop || get_screen_name
merge_list_into_options!(list, options)
merge_owner_into_options!(user, options)
- response = get("1/lists/subscribers", options)
- format.to_s.downcase == 'xml' ? response['users_list'] : response
+ get("/1/lists/subscribers.json", options)
end
# Make the authenticated user follow the specified list
@@ -47,8 +44,6 @@ def list_subscribers(*args)
# @see https://dev.twitter.com/docs/api/1/post/lists/subscribers/create
# @rate_limited No
# @requires_authentication Yes
- # @response_format `json`
- # @response_format `xml`
# @overload list_subscribe(list, options={})
# @param list [Integer, String] The list_id or slug of the list.
# @param options [Hash] A customizable set of options.
@@ -72,8 +67,7 @@ def list_subscribe(*args)
user = args.pop || get_screen_name
merge_list_into_options!(list, options)
merge_owner_into_options!(user, options)
- response = post("1/lists/subscribers/create", options)
- format.to_s.downcase == 'xml' ? response['list'] : response
+ post("/1/lists/subscribers/create.json", options)
end
# Unsubscribes the authenticated user form the specified list
@@ -81,8 +75,6 @@ def list_subscribe(*args)
# @see https://dev.twitter.com/docs/api/1/post/lists/subscribers/destroy
# @rate_limited No
# @requires_authentication Yes
- # @response_format `json`
- # @response_format `xml`
# @overload list_unsubscribe(list, options={})
# @param list [Integer, String] The list_id or slug of the list.
# @param options [Hash] A customizable set of options.
@@ -106,8 +98,7 @@ def list_unsubscribe(*args)
user = args.pop || get_screen_name
merge_list_into_options!(list, options)
merge_owner_into_options!(user, options)
- response = post("1/lists/subscribers/destroy", options)
- format.to_s.downcase == 'xml' ? response['list'] : response
+ post("/1/lists/subscribers/destroy.json", options)
end
# Check if a user is a subscriber of the specified list
@@ -115,8 +106,6 @@ def list_unsubscribe(*args)
# @see https://dev.twitter.com/docs/api/1/get/lists/subscribers/show
# @rate_limited Yes
# @requires_authentication Yes
- # @response_format `json`
- # @response_format `xml`
# @overload list_subscriber?(list, user_to_check, options={})
# @param list [Integer, String] The list_id or slug of the list.
# @param user_to_check [Integer, String] The user ID or screen_name of the list member.
@@ -145,7 +134,7 @@ def list_subscriber?(*args)
merge_list_into_options!(list, options)
merge_owner_into_options!(user, options)
merge_user_into_options!(user_to_check, options)
- get("1/lists/subscribers/show", options, :format => :json, :raw => true)
+ get("/1/lists/subscribers/show.json", options, :raw => true)
true
rescue Twitter::NotFound, Twitter::Forbidden
false
@@ -157,8 +146,6 @@ def list_subscriber?(*args)
# @deprecated {Twitter::Client::ListSubscribers#is_subscriber?} is deprecated and will be removed in the next major version. Please use {Twitter::Client::ListSubscribers#list_subscriber?} instead.
# @rate_limited Yes
# @requires_authentication Yes
- # @response_format `json`
- # @response_format `xml`
# @overload is_subscriber?(list, user_to_check, options={})
# @param list [Integer, String] The list_id or slug of the list.
# @param user_to_check [Integer, String] The user ID or screen_name of the list member.
View
6 lib/twitter/client/local_trends.rb
@@ -8,7 +8,6 @@ module LocalTrends
# @see https://dev.twitter.com/docs/api/1/get/trends/available
# @rate_limited Yes
# @requires_authentication No
- # @response_format `json`
# @param options [Hash] A customizable set of options.
# @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.
# @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.
@@ -16,7 +15,7 @@ module LocalTrends
# @example Return the locations that Twitter has trending topic information for
# Twitter.trend_locations
def trend_locations(options={})
- get('1/trends/available', options, :format => :json)
+ get("/1/trends/available.json", options)
end
# Returns the top 10 trending topics for a specific WOEID
@@ -24,7 +23,6 @@ def trend_locations(options={})
# @see https://dev.twitter.com/docs/api/1/get/trends/:woeid
# @rate_limited Yes
# @requires_authentication No
- # @response_format `json`
# @param woeid [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::Client::LocalTrends#trend_locations}. Global information is available by using 1 as the WOEID.
# @param options [Hash] A customizable set of options.
# @option options [String] :exclude Setting this equal to 'hashtags' will remove all hashtags from the trends list.
@@ -32,7 +30,7 @@ def trend_locations(options={})
# @example Return the top 10 trending topics for San Francisco
# Twitter.local_trends(2487956)
def local_trends(woeid=1, options={})
- response = get("1/trends/#{woeid}", options, :format => :json)
+ response = get("/1/trends/#{woeid}.json", options)
response.first.trends.map{|trend| trend.name}
end
end
View
10 lib/twitter/client/notification.rb
@@ -7,8 +7,6 @@ module Notification
# @see https://dev.twitter.com/docs/api/1/post/notifications/follow
# @rate_limited No
# @requires_authentication Yes
- # @response_format `json`
- # @response_format `xml`
# @param user [Integer, String] A Twitter user ID or screen name.
# @param options [Hash] A customizable set of options.
# @option options [Boolean, String, Integer] :include_entities Include {https://dev.twitter.com/docs/tweet-entities Tweet Entities} when set to true, 't' or 1.
@@ -18,8 +16,7 @@ module Notification
# Twitter.enable_notifications(7505382) # Same as above
def enable_notifications(user, options={})
merge_user_into_options!(user, options)
- response = post('1/notifications/follow', options)
- format.to_s.downcase == 'xml' ? response['user'] : response
+ post("/1/notifications/follow.json", options)
end
# Disables notifications for updates from the specified user to the authenticating user
@@ -27,8 +24,6 @@ def enable_notifications(user, options={})
# @see https://dev.twitter.com/docs/api/1/post/notifications/leave
# @rate_limited No
# @requires_authentication Yes
- # @response_format `json`
- # @response_format `xml`
# @param user [Integer, String] A Twitter user ID or screen name.
# @param options [Hash] A customizable set of options.
# @option options [Boolean, String, Integer] :include_entities Include {https://dev.twitter.com/docs/tweet-entities Tweet Entities} when set to true, 't' or 1.
@@ -38,8 +33,7 @@ def enable_notifications(user, options={})
# Twitter.disable_notifications(7505382) # Same as above
def disable_notifications(user, options={})
merge_user_into_options!(user, options)
- response = post('1/notifications/leave', options)
- format.to_s.downcase == 'xml' ? response['user'] : response
+ post("/1/notifications/leave.json", options)
end
end
end
View
20 lib/twitter/client/saved_searches.rb
@@ -7,15 +7,12 @@ module SavedSearches
# @see https://dev.twitter.com/docs/api/1/get/saved_searches
# @rate_limited Yes
# @requires_authentication Yes
- # @response_format `json`
- # @response_format `xml`
# @param options [Hash] A customizable set of options.
# @return [Array] Saved search queries.
# @example Return the authenticated user's saved search queries
# Twitter.saved_searches
def saved_searches(options={})
- response = get('1/saved_searches', options)
- format.to_s.downcase == 'xml' ? response['saved_searches'] : response
+ get("/1/saved_searches.json", options)
end
# Retrieve the data for a saved search owned by the authenticating user specified by the given ID
@@ -23,16 +20,13 @@ def saved_searches(options={})
# @see https://dev.twitter.com/docs/api/1/get/saved_searches/show/:id
# @rate_limited Yes
# @requires_authentication Yes
- # @response_format `json`
- # @response_format `xml`
# @param id [Integer] The ID of the saved search.
# @param options [Hash] A customizable set of options.
# @return [Hashie::Mash] The saved search.
# @example Retrieve the data for a saved search owned by the authenticating user with the ID 16129012
# Twitter.saved_search(16129012)
def saved_search(id, options={})
- response = get("1/saved_searches/show/#{id}", options)
- format.to_s.downcase == 'xml' ? response['saved_search'] : response
+ get("/1/saved_searches/show/#{id}.json", options)
end
# Creates a saved search for the authenticated user
@@ -40,16 +34,13 @@ def saved_search(id, options={})
# @see https://dev.twitter.com/docs/api/1/post/saved_searches/create
# @rate_limited No
# @requires_authentication Yes
- # @response_format `json`
- # @response_format `xml`
# @param query [String] The query of the search the user would like to save.
# @param options [Hash] A customizable set of options.
# @return [Hashie::Mash] The created saved search.
# @example Create a saved search for the authenticated user with the query "twitter"
# Twitter.saved_search_create("twitter")
def saved_search_create(query, options={})
- response = post('1/saved_searches/create', options.merge(:query => query))
- format.to_s.downcase == 'xml' ? response['saved_search'] : response
+ post("/1/saved_searches/create.json", options.merge(:query => query))
end
# Destroys a saved search for the authenticated user
@@ -58,16 +49,13 @@ def saved_search_create(query, options={})
# @note The search specified by ID must be owned by the authenticating user.
# @rate_limited No
# @requires_authentication Yes
- # @response_format `json`
- # @response_format `xml`
# @param id [Integer] The ID of the saved search.
# @param options [Hash] A customizable set of options.
# @return [Hashie::Mash] The deleted saved search.
# @example Destroys a saved search for the authenticated user with the ID 16129012
# Twitter.saved_search_destroy(16129012)
def saved_search_destroy(id, options={})
- response = delete("1/saved_searches/destroy/#{id}", options)
- format.to_s.downcase == 'xml' ? response['saved_search'] : response
+ delete("/1/saved_searches/destroy/#{id}.json", options)
end
end
end
View
14 lib/twitter/client/search.rb
@@ -7,8 +7,6 @@ module Search
# @note Undocumented
# @rate_limited Yes
# @requires_authentication No
- # @response_format `json`
- # @response_format `xml`
# @param q [String] A search term.
# @param options [Hash] A customizable set of options.
# @option options [Integer] :count Specifies the number of records to retrieve. Must be less than or equal to 100.
@@ -17,8 +15,7 @@ module Search
# @example Return recent statuses that contain images related to a query
# Twitter.images('twitter')
def images(q, options={})
- response = get('i/search/image_facets', options.merge(:q => q), :phoenix => true)
- format.to_s.downcase == 'xml' ? response['statuses'] : response
+ get("/i/search/image_facets.json", options.merge(:q => q), :phoenix => true)
end
# Returns recent statuses that contain videos related to a query
@@ -26,8 +23,6 @@ def images(q, options={})
# @note Undocumented
# @rate_limited Yes
# @requires_authentication No
- # @response_format `json`
- # @response_format `xml`
# @param q [String] A search term.
# @param options [Hash] A customizable set of options.
# @option options [Integer] :count Specifies the number of records to retrieve. Must be less than or equal to 100.
@@ -36,8 +31,7 @@ def images(q, options={})
# @example Return recent statuses that contain videos related to a query
# Twitter.videos('twitter')
def videos(q, options={})
- response = get('i/search/video_facets', options.merge(:q => q), :phoenix => true)
- format.to_s.downcase == 'xml' ? response['statuses'] : response
+ get("/i/search/video_facets.json", options.merge(:q => q), :phoenix => true)
end
# Returns recent statuses related to a query with images and videos embedded
@@ -45,8 +39,6 @@ def videos(q, options={})
# @note Undocumented
# @rate_limited Yes
# @requires_authentication No
- # @response_format `json`
- # @response_format `xml`
# @param q [String] A search term.
# @param options [Hash] A customizable set of options.
# @option options [Integer] :count Specifies the number of records to retrieve. Must be less than or equal to 100.
@@ -56,7 +48,7 @@ def videos(q, options={})
# @example Return recent statuses related to twitter with images and videos embedded
# Twitter.search('twitter')
def search(q, options={})
- response = get('phoenix_search', options.merge(:q => q), :format => :phoenix, :phoenix => true)['statuses']
+ get("/phoenix_search.phoenix", options.merge(:q => q), :phoenix => true)['statuses']
end
end
end
View
5 lib/twitter/client/spam_reporting.rb
@@ -8,8 +8,6 @@ module SpamReporting
# @see https://dev.twitter.com/docs/api/1/post/report_spam
# @rate_limited Yes
# @requires_authentication No
- # @response_format `json`
- # @response_format `xml`
# @param user [Integer, String] A Twitter user ID or screen name.
# @param options [Hash] A customizable set of options.
# @option options [Boolean, String, Integer] :include_entities Include {https://dev.twitter.com/docs/tweet-entities Tweet Entities} when set to true, 't' or 1.
@@ -19,8 +17,7 @@ module SpamReporting
# Twitter.report_spam(14589771) # Same as above
def report_spam(user, options={})
merge_user_into_options!(user, options)
- response = post('1/report_spam', options)
- format.to_s.downcase == 'xml' ? response['user'] : response
+ post("/1/report_spam.json", options)
end
end
end
View
42 lib/twitter/client/timeline.rb
@@ -8,8 +8,6 @@ module Timeline
# @note The public timeline is cached for 60 seconds. Requesting more frequently than that will not return any more data, and will count against your rate limit usage.
# @rate_limited Yes
# @requires_authentication No
- # @response_format `json`
- # @response_format `xml`
# @param options [Hash] A customizable set of options.
# @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.
# @option options [Boolean, String, Integer] :include_entities Include {https://dev.twitter.com/docs/tweet-entities Tweet Entities} when set to true, 't' or 1.
@@ -17,8 +15,7 @@ module Timeline
# @example Return the 20 most recent statuses, including retweets if they exist, from non-protected users
# Twitter.public_timeline
def public_timeline(options={})
- response = get('1/statuses/public_timeline', options)
- format.to_s.downcase == 'xml' ? response['statuses'] : response
+ get("/1/statuses/public_timeline.json", options)
end
# Returns the 20 most recent statuses, including retweets if they exist, posted by the authenticating user and the users they follow
@@ -28,8 +25,6 @@ def public_timeline(options={})
# @note This method can only return up to 800 statuses, including retweets.
# @rate_limited Yes
# @requires_authentication Yes
- # @response_format `json`
- # @response_format `xml`
# @param options [Hash] A customizable set of options.
# @option options [Integer] :since_id Returns results with an ID greater than (that is, more recent than) the specified ID.
# @option options [Integer] :max_id Returns results with an ID less than (that is, older than) or equal to the specified ID.
@@ -41,8 +36,7 @@ def public_timeline(options={})
# @example Return the 20 most recent statuses, including retweets if they exist, posted by the authenticating user and the users they follow
# Twitter.home_timeline
def home_timeline(options={})
- response = get('1/statuses/home_timeline', options)
- format.to_s.downcase == 'xml' ? response['statuses'] : response
+ get("/1/statuses/home_timeline.json", options)
end
# Returns the 20 most recent statuses posted by the authenticating user and the users they follow
@@ -53,8 +47,6 @@ def home_timeline(options={})
# @note This method can only return up to 800 statuses. If the :include_rts option is set, only 800 statuses, including retweets if they exist, can be returned.
# @rate_limited Yes
# @requires_authentication Yes
- # @response_format `json`
- # @response_format `xml`
# @param options [Hash] A customizable set of options.
# @option options [Integer] :since_id Returns results with an ID greater than (that is, more recent than) the specified ID.
# @option options [Integer] :max_id Returns results with an ID less than (that is, older than) or equal to the specified ID.
@@ -77,8 +69,6 @@ def friends_timeline(options={})
# @note This method can only return up to 3200 statuses. If the :include_rts option is set, only 3200 statuses, including retweets if they exist, can be returned.
# @rate_limited Yes
# @requires_authentication No unless the user whose timeline you're trying to view is protected
- # @response_format `json`
- # @response_format `xml`
# @overload user_timeline(user, options={})
# @param user [Integer, String] A Twitter user ID or screen name.
# @param options [Hash] A customizable set of options.
@@ -96,8 +86,7 @@ def user_timeline(*args)
options = args.last.is_a?(Hash) ? args.pop : {}
user = args.first || get_screen_name
merge_user_into_options!(user, options)
- response = get('1/statuses/user_timeline', options)
- format.to_s.downcase == 'xml' ? response['statuses'] : response
+ get("/1/statuses/user_timeline.json", options)
end
# Returns the 20 most recent mentions (statuses containing @username) for the authenticating user
@@ -106,8 +95,6 @@ def user_timeline(*args)
# @note This method can only return up to 800 statuses. If the :include_rts option is set, only 800 statuses, including retweets if they exist, can be returned.
# @rate_limited Yes
# @requires_authentication Yes
- # @response_format `json`
- # @response_format `xml`
# @param options [Hash] A customizable set of options.
# @option options [Integer] :since_id Returns results with an ID greater than (that is, more recent than) the specified ID.
# @option options [Integer] :max_id Returns results with an ID less than (that is, older than) or equal to the specified ID.
@@ -120,8 +107,7 @@ def user_timeline(*args)
# @example Return the 20 most recent mentions (statuses containing @username) for the authenticating user
# Twitter.mentions
def mentions(options={})
- response = get('1/statuses/mentions', options)
- format.to_s.downcase == 'xml' ? response['statuses'] : response
+ get("/1/statuses/mentions.json", options)
end
# Returns the 20 most recent retweets posted by the authenticating user
@@ -129,8 +115,6 @@ def mentions(options={})
# @see https://dev.twitter.com/docs/api/1/get/statuses/retweeted_by_me
# @rate_limited Yes
# @requires_authentication Yes
- # @response_format `json`
- # @response_format `xml`
# @param options [Hash] A customizable set of options.
# @option options [Integer] :since_id Returns results with an ID greater than (that is, more recent than) the specified ID.
# @option options [Integer] :max_id Returns results with an ID less than (that is, older than) or equal to the specified ID.
@@ -142,8 +126,7 @@ def mentions(options={})
# @example Return the 20 most recent retweets posted by the authenticating user
# Twitter.retweeted_by_me
def retweeted_by_me(options={})
- response = get('1/statuses/retweeted_by_me', options)
- format.to_s.downcase == 'xml' ? response['statuses'] : response
+ get("/1/statuses/retweeted_by_me.json", options)
end
# Returns the 20 most recent retweets posted by users followed by the authenticating user
@@ -151,8 +134,6 @@ def retweeted_by_me(options={})
# @see https://dev.twitter.com/docs/api/1/get/statuses/retweeted_to_me
# @rate_limited Yes
# @requires_authentication Yes
- # @response_format `json`
- # @response_format `xml`
# @param options [Hash] A customizable set of options.
# @option options [Integer] :since_id Returns results with an ID greater than (that is, more recent than) the specified ID.
# @option options [Integer] :max_id Returns results with an ID less than (that is, older than) or equal to the specified ID.
@@ -164,8 +145,7 @@ def retweeted_by_me(options={})
# @example Return the 20 most recent retweets posted by users followed by the authenticating user
# Twitter.retweeted_to_me
def retweeted_to_me(options={})
- response = get('1/statuses/retweeted_to_me', options)
- format.to_s.downcase == 'xml' ? response['statuses'] : response
+ get("/1/statuses/retweeted_to_me.json", options)
end
# Returns the 20 most recent tweets of the authenticated user that have been retweeted by others
@@ -173,8 +153,6 @@ def retweeted_to_me(options={})
# @see https://dev.twitter.com/docs/api/1/get/statuses/retweets_of_me
# @rate_limited Yes
# @requires_authentication Yes
- # @response_format `json`
- # @response_format `xml`
# @param options [Hash] A customizable set of options.
# @option options [Integer] :since_id Returns results with an ID greater than (that is, more recent than) the specified ID.
# @option options [Integer] :max_id Returns results with an ID less than (that is, older than) or equal to the specified ID.
@@ -186,8 +164,7 @@ def retweeted_to_me(options={})
# @example Return the 20 most recent tweets of the authenticated user that have been retweeted by others
# Twitter.retweets_of_me
def retweets_of_me(options={})
- response = get('1/statuses/retweets_of_me', options)
- format.to_s.downcase == 'xml' ? response['statuses'] : response
+ get("/1/statuses/retweets_of_me.json", options)
end
# Returns the 20 most recent images posted by the specified user
@@ -197,8 +174,6 @@ def retweets_of_me(options={})
# @note Images will not be returned from tweets posted before January 1, 2010.
# @rate_limited Yes
# @requires_authentication No unless the user whose timeline you're trying to view is protected
- # @response_format `json`
- # @response_format `xml`
# @overload media_timeline(user, options={})
# @param user [Integer, String] A Twitter user ID or screen name.
# @param options [Hash] A customizable set of options.
@@ -213,8 +188,7 @@ def media_timeline(*args)
options = args.last.is_a?(Hash) ? args.pop : {}
user = args.first || get_screen_name
merge_user_into_options!(user, options)
- response = get('1/statuses/media_timeline', options)
- format.to_s.downcase == 'xml' ? response['statuses'] : response
+ get("/1/statuses/media_timeline.json", options)
end
end
end
View
8 lib/twitter/client/trends.rb
@@ -8,7 +8,6 @@ module Trends
# @see https://dev.twitter.com/docs/api/1/get/trends/:woeid
# @rate_limited Yes
# @requires_authentication No
- # @response_format `json`
# @param options [Hash] A customizable set of options.
# @option options [String] :exclude Setting this equal to 'hashtags' will remove all hashtags from the trends list.
# @return [Array]
@@ -24,7 +23,6 @@ def trends(options={})
# @deprecated {Twitter::Client::Trends#trends_current} is deprecated and will be removed in the next major version. Please use {Twitter::Client::Trends#trends} instead.
# @rate_limited Yes
# @requires_authentication No
- # @response_format `json`
# @param options [Hash] A customizable set of options.
# @option options [String] :exclude Setting this equal to 'hashtags' will remove all hashtags from the trends list.
# @return [Array]
@@ -40,7 +38,6 @@ def trends_current(options={})
# @see https://dev.twitter.com/docs/api/1/get/trends/daily
# @rate_limited Yes
# @requires_authentication No
- # @response_format `json`
# @param date [Date] The start date for the report. A 404 error will be thrown if the date is older than the available search index (7-10 days). Dates in the future will be forced to the current date.
# @param options [Hash] A customizable set of options.
# @option options [String] :exclude Setting this equal to 'hashtags' will remove all hashtags from the trends list.
@@ -48,7 +45,7 @@ def trends_current(options={})
# @example Return the top 20 trending topics for each hour of October 24, 2010
# Twitter.trends_daily(Date.parse("2010-10-24"))
def trends_daily(date=Date.today, options={})
- get('1/trends/daily', options.merge(:date => date.strftime('%Y-%m-%d')), :format => :json)['trends']
+ get("/1/trends/daily.json", options.merge(:date => date.strftime('%Y-%m-%d')))['trends']
end
# Returns the top 30 trending topics for each day in a given week
@@ -56,7 +53,6 @@ def trends_daily(date=Date.today, options={})
# @see https://dev.twitter.com/docs/api/1/get/trends/weekly
# @rate_limited Yes
# @requires_authentication No
- # @response_format `json`
# @param date [Date] The start date for the report. A 404 error will be thrown if the date is older than the available search index (7-10 days). Dates in the future will be forced to the current date.
# @param options [Hash] A customizable set of options.
# @option options [String] :exclude Setting this equal to 'hashtags' will remove all hashtags from the trends list.
@@ -64,7 +60,7 @@ def trends_daily(date=Date.today, options={})
# @example Return the top ten topics that are currently trending on Twitter
# Twitter.trends_weekly(Date.parse("2010-10-24"))
def trends_weekly(date=Date.today, options={})
- get('1/trends/weekly', options.merge(:date => date.strftime('%Y-%m-%d')), :format => :json)['trends']
+ get("/1/trends/weekly.json", options.merge(:date => date.strftime('%Y-%m-%d')))['trends']
end
end
end
View
35 lib/twitter/client/tweets.rb
@@ -7,8 +7,6 @@ module Tweets
# @see https://dev.twitter.com/docs/api/1/get/statuses/show/:id
# @rate_limited Yes
# @requires_authentication No unless the author of the status is protected
- # @response_format `json`
- # @response_format `xml`
# @param id [Integer] The numerical ID of the desired status.
# @param options [Hash] A customizable set of options.
# @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.
@@ -17,8 +15,7 @@ module Tweets
# @example Return the status with the ID 25938088801
# Twitter.status(25938088801)
def status(id, options={})
- response = get("1/statuses/show/#{id}", options)
- format.to_s.downcase == 'xml' ? response['status'] : response
+ get("/1/statuses/show/#{id}.json", options)
end
# Updates the authenticating user's status
@@ -27,8 +24,6 @@ def status(id, options={})
# @note A status update with text identical to the authenticating user's current status will be ignored to prevent duplicates.
# @rate_limited No
# @requires_authentication Yes
- # @response_format `json`
- # @response_format `xml`
# @param status [String] The text of your status update, up to 140 characters.
# @param options [Hash] A customizable set of options.
# @option options [Integer] :in_reply_to_status_id The ID of an existing status that the update is in reply to.
@@ -42,8 +37,7 @@ def status(id, options={})
# @example Update the authenticating user's status
# Twitter.update("I just posted a status update via the Twitter Ruby Gem!")
def update(status, options={})
- response = post('1/statuses/update', options.merge(:status => status))
- format.to_s.downcase == 'xml' ? response['status'] : response
+ post("/1/statuses/update.json", options.merge(:status => status))
end
# Updates with media the authenticating user's status
@@ -51,8 +45,6 @@ def update(status, options={})
# @note A status update with text/media identical to the authenticating user's current status will NOT be ignored
# @requires_authentication Yes
# @rate_limited No
- # @response_format `json`
- # @response_format `xml`
# @param status [String] The text of your status update, up to 140 characters.
# @param media [File] A File object with your picture (PNG, JPEG or GIF)
# @param options [Hash] A customizable set of options.
@@ -72,8 +64,7 @@ def update(status, options={})
# download the pic and put the response in a StringIO object
# Twitter.update_with_media("I just posted a status update with a pic via the Twitter Ruby Gem!", {'io' => StringIO.new(pic), 'type' => 'jpg'})
def update_with_media(status, image, options={})
- response = post('1/statuses/update_with_media', options.merge('media[]' => image, 'status' => status), :endpoint => media_endpoint)
- format.to_s.downcase == 'xml' ? response['status'] : response
+ post("/1/statuses/update_with_media.json", options.merge('media[]' => image, 'status' => status), :endpoint => media_endpoint)
end
# Destroys the specified status
@@ -82,8 +73,6 @@ def update_with_media(status, image, options={})
# @note The authenticating user must be the author of the specified status.
# @rate_limited No
# @requires_authentication Yes
- # @response_format `json`
- # @response_format `xml`
# @param id [Integer] The numerical ID of the desired status.
# @param options [Hash] A customizable set of options.
# @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.
@@ -92,8 +81,7 @@ def update_with_media(status, image, options={})
# @example Destroy the status with the ID 25938088801
# Twitter.status_destroy(25938088801)
def status_destroy(id, options={})
- response = delete("1/statuses/destroy/#{id}", options)
- format.to_s.downcase == 'xml' ? response['status'] : response
+ delete("/1/statuses/destroy/#{id}.json", options)
end
# Retweets a tweet
@@ -102,8 +90,6 @@ def status_destroy(id, options={})
# @note The authenticating user must be the author of the specified status.
# @rate_limited Yes
# @requires_authentication Yes
- # @response_format `json`
- # @response_format `xml`
# @param id [Integer] The numerical ID of the desired status.
# @param options [Hash] A customizable set of options.
# @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.
@@ -112,8 +98,7 @@ def status_destroy(id, options={})
# @example Retweet the status with the ID 28561922516
# Twitter.retweet(28561922516)
def retweet(id, options={})
- response = post("1/statuses/retweet/#{id}", options)
- format.to_s.downcase == 'xml' ? response['status'] : response
+ post("/1/statuses/retweet/#{id}.json", options)
end
# Returns up to 100 of the first retweets of a given tweet
@@ -121,8 +106,6 @@ def retweet(id, options={})
# @see https://dev.twitter.com/docs/api/1/get/statuses/retweets/:id
# @rate_limited Yes
# @requires_authentication Yes
- # @response_format `json`
- # @response_format `xml`
# @param id [Integer] The numerical ID of the desired status.
# @param options [Hash] A customizable set of options.
# @option options [Integer] :count Specifies the number of records to retrieve. Must be less than or equal to 100.
@@ -132,8 +115,7 @@ def retweet(id, options={})
# @example Return up to 100 of the first retweets of the status with the ID 28561922516
# Twitter.retweets(28561922516)
def retweets(id, options={})
- response = get("1/statuses/retweets/#{id}", options)
- format.to_s.downcase == 'xml' ? response['statuses'] : response
+ get("/1/statuses/retweets/#{id}.json", options)
end
# Show up to 100 users who retweeted the status
@@ -142,8 +124,6 @@ def retweets(id, options={})
# @see https://dev.twitter.com/docs/api/1/get/statuses/:id/retweeted_by/ids
# @rate_limited Yes
# @requires_authentication Yes
- # @response_format `json`
- # @response_format `xml`
# @param id [Integer] The numerical ID of the desired status.
# @param options [Hash] A customizable set of options.
# @option options [Integer] :count Specifies the number of records to retrieve. Must be less than or equal to 100.
@@ -156,8 +136,7 @@ def retweets(id, options={})
# Twitter.retweeters_of(28561922516)
def retweeters_of(id, options={})
ids_only = !!options.delete(:ids_only)
- response = get("1/statuses/#{id}/retweeted_by#{'/ids' if ids_only}", options)
- format.to_s.downcase == 'xml' ? response['users'] : response
+ get("/1/statuses/#{id}/retweeted_by#{'/ids' if ids_only}.json", options)
end
end
end
View
3  lib/twitter/client/urls.rb
@@ -7,7 +7,6 @@ module Urls
# @note Undocumented
# @rate_limited Yes
# @requires_authentication Yes
- # @response_format `json`
# @overload resolve(urls, options={})
# @param urls [String] A list of shortened URLs.
# @param options [Hash] A customizable set of options.
@@ -17,7 +16,7 @@ module Urls
# Twitter.resolve(['http://t.co/uw5bn1w', 'http://t.co/dXvMz9i']) # Same as above
def resolve(*args)
options = args.last.is_a?(Hash) ? args.pop : {}
- get("1/urls/resolve", options.merge("urls[]" => args), :format => :json, :phoenix => true)
+ get("/1/urls/resolve.json", options.merge("urls[]" => args), :phoenix => true)
end
end