Permalink
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...
1 parent c3a19dc commit e60b9cac2b14d11dcc703c87b9a74328c173f35a @sferik committed Oct 3, 2011
Showing with 3,197 additions and 31,525 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
  97. +295 −299 spec/twitter/client/list_subscribers_spec.rb
  98. +6 −6 spec/twitter/client/local_trends_spec.rb
  99. +44 −48 spec/twitter/client/notification_spec.rb
  100. +83 −87 spec/twitter/client/saved_searches_spec.rb
  101. +55 −59 spec/twitter/client/search_spec.rb
  102. +18 −22 spec/twitter/client/spam_reporting_spec.rb
  103. +184 −188 spec/twitter/client/timeline_spec.rb
  104. +8 −8 spec/twitter/client/trends_spec.rb
  105. +149 −153 spec/twitter/client/tweets_spec.rb
  106. +21 −23 spec/twitter/client/urls_spec.rb
  107. +416 −420 spec/twitter/client/user_spec.rb
  108. +2 −2 spec/twitter/client_spec.rb
  109. +0 −1 spec/twitter/search_spec.rb
  110. +2 −15 spec/twitter_spec.rb
  111. +0 −2 twitter.gemspec
View
@@ -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
@@ -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
@@ -7,17 +7,14 @@ 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.
# @raise [Twitter::Unauthorized] Error raised when supplied user credentials are not valid.
# @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,58 +24,47 @@ 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
#
# @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
#
# @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.
# @return [Hashie::Mash] The authenticated user.
# @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
#
# @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,26 +85,21 @@ 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.
# @return [Hashie::Mash] The authenticated user.
# @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
#
# @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,24 +127,20 @@ 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.
#
# @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
@@ -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,15 +15,14 @@ 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
#
# @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
@@ -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,17 +18,14 @@ 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
#
# @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,33 +79,27 @@ 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.
# @return [Array] User objects that the authenticating user is blocking.
# @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
#
# @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
Oops, something went wrong.

0 comments on commit e60b9ca

Please sign in to comment.