twitter 4.8.1 → 5.0.0.rc.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (197) hide show
  1. data.tar.gz.sig +0 -0
  2. data/CHANGELOG.md +30 -0
  3. data/LICENSE.md +1 -1
  4. data/README.md +386 -266
  5. data/lib/twitter.rb +4 -39
  6. data/lib/twitter/arguments.rb +11 -0
  7. data/lib/twitter/base.rb +89 -68
  8. data/lib/twitter/client.rb +69 -110
  9. data/lib/twitter/configuration.rb +7 -3
  10. data/lib/twitter/creatable.rb +2 -4
  11. data/lib/twitter/cursor.rb +50 -42
  12. data/lib/twitter/direct_message.rb +2 -11
  13. data/lib/twitter/entity/uri.rb +13 -0
  14. data/lib/twitter/enumerable.rb +15 -0
  15. data/lib/twitter/error.rb +55 -7
  16. data/lib/twitter/error/already_favorited.rb +1 -1
  17. data/lib/twitter/error/already_posted.rb +10 -0
  18. data/lib/twitter/error/already_retweeted.rb +1 -1
  19. data/lib/twitter/error/bad_gateway.rb +2 -3
  20. data/lib/twitter/error/bad_request.rb +2 -2
  21. data/lib/twitter/error/forbidden.rb +2 -2
  22. data/lib/twitter/error/gateway_timeout.rb +2 -3
  23. data/lib/twitter/error/internal_server_error.rb +2 -3
  24. data/lib/twitter/error/not_acceptable.rb +2 -2
  25. data/lib/twitter/error/not_found.rb +2 -2
  26. data/lib/twitter/error/service_unavailable.rb +2 -3
  27. data/lib/twitter/error/too_many_requests.rb +2 -2
  28. data/lib/twitter/error/unauthorized.rb +2 -2
  29. data/lib/twitter/error/unprocessable_entity.rb +2 -2
  30. data/lib/twitter/factory.rb +2 -8
  31. data/lib/twitter/geo_factory.rb +2 -2
  32. data/lib/twitter/geo_results.rb +36 -0
  33. data/lib/twitter/identity.rb +0 -22
  34. data/lib/twitter/list.rb +18 -4
  35. data/lib/twitter/media/photo.rb +3 -3
  36. data/lib/twitter/media_factory.rb +2 -2
  37. data/lib/twitter/null_object.rb +24 -0
  38. data/lib/twitter/oembed.rb +3 -2
  39. data/lib/twitter/place.rb +15 -9
  40. data/lib/twitter/profile_banner.rb +5 -3
  41. data/lib/twitter/rate_limit.rb +1 -17
  42. data/lib/twitter/relationship.rb +2 -10
  43. data/lib/twitter/rest/api/direct_messages.rb +135 -0
  44. data/lib/twitter/rest/api/favorites.rb +120 -0
  45. data/lib/twitter/rest/api/friends_and_followers.rb +290 -0
  46. data/lib/twitter/rest/api/help.rb +58 -0
  47. data/lib/twitter/rest/api/lists.rb +491 -0
  48. data/lib/twitter/rest/api/oauth.rb +45 -0
  49. data/lib/twitter/rest/api/places_and_geo.rb +104 -0
  50. data/lib/twitter/rest/api/saved_searches.rb +91 -0
  51. data/lib/twitter/rest/api/search.rb +37 -0
  52. data/lib/twitter/rest/api/spam_reporting.rb +29 -0
  53. data/lib/twitter/rest/api/suggested_users.rb +51 -0
  54. data/lib/twitter/rest/api/timelines.rb +202 -0
  55. data/lib/twitter/rest/api/trends.rb +58 -0
  56. data/lib/twitter/rest/api/tweets.rb +293 -0
  57. data/lib/twitter/rest/api/undocumented.rb +52 -0
  58. data/lib/twitter/rest/api/users.rb +383 -0
  59. data/lib/twitter/rest/api/utils.rb +219 -0
  60. data/lib/twitter/rest/client.rb +193 -0
  61. data/lib/twitter/rest/request/multipart_with_file.rb +36 -0
  62. data/lib/twitter/rest/response/parse_json.rb +27 -0
  63. data/lib/twitter/{response → rest/response}/raise_error.rb +8 -11
  64. data/lib/twitter/search_results.rb +33 -21
  65. data/lib/twitter/settings.rb +1 -6
  66. data/lib/twitter/size.rb +1 -1
  67. data/lib/twitter/streaming/client.rb +77 -0
  68. data/lib/twitter/streaming/connection.rb +22 -0
  69. data/lib/twitter/streaming/response.rb +30 -0
  70. data/lib/twitter/suggestion.rb +4 -2
  71. data/lib/twitter/token.rb +8 -0
  72. data/lib/twitter/trend.rb +2 -1
  73. data/lib/twitter/trend_results.rb +59 -0
  74. data/lib/twitter/tweet.rb +41 -85
  75. data/lib/twitter/user.rb +51 -41
  76. data/lib/twitter/version.rb +4 -4
  77. data/spec/fixtures/already_posted.json +1 -0
  78. data/spec/fixtures/ids_list.json +1 -1
  79. data/spec/fixtures/ids_list2.json +1 -1
  80. data/spec/fixtures/search.json +1 -1
  81. data/spec/fixtures/search_malformed.json +1 -1
  82. data/spec/fixtures/track_streaming.json +3 -0
  83. data/spec/helper.rb +8 -13
  84. data/spec/twitter/base_spec.rb +25 -99
  85. data/spec/twitter/configuration_spec.rb +1 -1
  86. data/spec/twitter/cursor_spec.rb +13 -31
  87. data/spec/twitter/direct_message_spec.rb +41 -8
  88. data/spec/twitter/entity/uri_spec.rb +74 -0
  89. data/spec/twitter/error_spec.rb +59 -11
  90. data/spec/twitter/geo/point_spec.rb +1 -1
  91. data/spec/twitter/geo_factory_spec.rb +3 -3
  92. data/spec/twitter/geo_results_spec.rb +35 -0
  93. data/spec/twitter/identifiable_spec.rb +0 -21
  94. data/spec/twitter/list_spec.rb +51 -8
  95. data/spec/twitter/media/photo_spec.rb +118 -3
  96. data/spec/twitter/media_factory_spec.rb +2 -2
  97. data/spec/twitter/null_object_spec.rb +26 -0
  98. data/spec/twitter/oembed_spec.rb +69 -45
  99. data/spec/twitter/place_spec.rb +68 -12
  100. data/spec/twitter/profile_banner_spec.rb +1 -1
  101. data/spec/twitter/rate_limit_spec.rb +12 -12
  102. data/spec/twitter/relationship_spec.rb +31 -9
  103. data/spec/twitter/{api → rest/api}/direct_messages_spec.rb +22 -9
  104. data/spec/twitter/{api → rest/api}/favorites_spec.rb +80 -7
  105. data/spec/twitter/{api → rest/api}/friends_and_followers_spec.rb +104 -65
  106. data/spec/twitter/{api → rest/api}/geo_spec.rb +10 -10
  107. data/spec/twitter/{api → rest/api}/help_spec.rb +6 -6
  108. data/spec/twitter/{api → rest/api}/lists_spec.rb +77 -56
  109. data/spec/twitter/{api → rest/api}/oauth_spec.rb +6 -6
  110. data/spec/twitter/{api → rest/api}/saved_searches_spec.rb +7 -7
  111. data/spec/twitter/{api → rest/api}/search_spec.rb +8 -9
  112. data/spec/twitter/{api → rest/api}/spam_reporting_spec.rb +3 -3
  113. data/spec/twitter/{api → rest/api}/suggested_users_spec.rb +5 -5
  114. data/spec/twitter/{api → rest/api}/timelines_spec.rb +9 -9
  115. data/spec/twitter/{api → rest/api}/trends_spec.rb +6 -6
  116. data/spec/twitter/rest/api/tweets_spec.rb +503 -0
  117. data/spec/twitter/{api → rest/api}/undocumented_spec.rb +19 -45
  118. data/spec/twitter/{api → rest/api}/users_spec.rb +60 -35
  119. data/spec/twitter/rest/client_spec.rb +193 -0
  120. data/spec/twitter/saved_search_spec.rb +11 -0
  121. data/spec/twitter/search_results_spec.rb +29 -42
  122. data/spec/twitter/settings_spec.rb +17 -6
  123. data/spec/twitter/streaming/client_spec.rb +75 -0
  124. data/spec/twitter/token_spec.rb +16 -0
  125. data/spec/twitter/trend_results_spec.rb +89 -0
  126. data/spec/twitter/trend_spec.rb +23 -0
  127. data/spec/twitter/tweet_spec.rb +122 -115
  128. data/spec/twitter/user_spec.rb +136 -77
  129. data/spec/twitter_spec.rb +0 -119
  130. data/twitter.gemspec +8 -5
  131. metadata +148 -141
  132. metadata.gz.sig +0 -0
  133. data/lib/twitter/action/favorite.rb +0 -19
  134. data/lib/twitter/action/follow.rb +0 -30
  135. data/lib/twitter/action/list_member_added.rb +0 -39
  136. data/lib/twitter/action/mention.rb +0 -46
  137. data/lib/twitter/action/reply.rb +0 -27
  138. data/lib/twitter/action/retweet.rb +0 -27
  139. data/lib/twitter/action/tweet.rb +0 -20
  140. data/lib/twitter/action_factory.rb +0 -22
  141. data/lib/twitter/api/arguments.rb +0 -13
  142. data/lib/twitter/api/direct_messages.rb +0 -148
  143. data/lib/twitter/api/favorites.rb +0 -126
  144. data/lib/twitter/api/friends_and_followers.rb +0 -334
  145. data/lib/twitter/api/help.rb +0 -64
  146. data/lib/twitter/api/lists.rb +0 -618
  147. data/lib/twitter/api/oauth.rb +0 -44
  148. data/lib/twitter/api/places_and_geo.rb +0 -121
  149. data/lib/twitter/api/saved_searches.rb +0 -99
  150. data/lib/twitter/api/search.rb +0 -37
  151. data/lib/twitter/api/spam_reporting.rb +0 -30
  152. data/lib/twitter/api/suggested_users.rb +0 -55
  153. data/lib/twitter/api/timelines.rb +0 -214
  154. data/lib/twitter/api/trends.rb +0 -63
  155. data/lib/twitter/api/tweets.rb +0 -304
  156. data/lib/twitter/api/undocumented.rb +0 -97
  157. data/lib/twitter/api/users.rb +0 -439
  158. data/lib/twitter/api/utils.rb +0 -187
  159. data/lib/twitter/configurable.rb +0 -96
  160. data/lib/twitter/default.rb +0 -102
  161. data/lib/twitter/entity/url.rb +0 -9
  162. data/lib/twitter/error/client_error.rb +0 -35
  163. data/lib/twitter/error/decode_error.rb +0 -9
  164. data/lib/twitter/error/identity_map_key_error.rb +0 -9
  165. data/lib/twitter/error/server_error.rb +0 -28
  166. data/lib/twitter/exceptable.rb +0 -36
  167. data/lib/twitter/identity_map.rb +0 -22
  168. data/lib/twitter/request/multipart_with_file.rb +0 -34
  169. data/lib/twitter/response/parse_json.rb +0 -25
  170. data/spec/fixtures/about_me.json +0 -1
  171. data/spec/fixtures/activity_summary.json +0 -1
  172. data/spec/fixtures/bad_gateway.json +0 -1
  173. data/spec/fixtures/bad_request.json +0 -1
  174. data/spec/fixtures/by_friends.json +0 -1
  175. data/spec/fixtures/end_session.json +0 -1
  176. data/spec/fixtures/forbidden.json +0 -1
  177. data/spec/fixtures/internal_server_error.json +0 -1
  178. data/spec/fixtures/not_acceptable.json +0 -1
  179. data/spec/fixtures/phoenix_search.phoenix +0 -1
  180. data/spec/fixtures/resolve.json +0 -1
  181. data/spec/fixtures/service_unavailable.json +0 -1
  182. data/spec/fixtures/totals.json +0 -1
  183. data/spec/fixtures/trends.json +0 -1
  184. data/spec/fixtures/unauthorized.json +0 -1
  185. data/spec/fixtures/video_facets.json +0 -1
  186. data/spec/twitter/action/favorite_spec.rb +0 -29
  187. data/spec/twitter/action/follow_spec.rb +0 -29
  188. data/spec/twitter/action/list_member_added_spec.rb +0 -41
  189. data/spec/twitter/action/mention_spec.rb +0 -52
  190. data/spec/twitter/action/reply_spec.rb +0 -41
  191. data/spec/twitter/action/retweet_spec.rb +0 -41
  192. data/spec/twitter/action_factory_spec.rb +0 -35
  193. data/spec/twitter/action_spec.rb +0 -16
  194. data/spec/twitter/api/tweets_spec.rb +0 -285
  195. data/spec/twitter/client_spec.rb +0 -223
  196. data/spec/twitter/error/client_error_spec.rb +0 -23
  197. data/spec/twitter/error/server_error_spec.rb +0 -20
@@ -4,14 +4,18 @@ module Twitter
4
4
  class Configuration < Twitter::Base
5
5
  attr_reader :characters_reserved_per_media, :max_media_per_upload,
6
6
  :non_username_paths, :photo_size_limit, :short_url_length, :short_url_length_https
7
+ alias short_uri_length short_url_length
8
+ alias short_uri_length_https short_url_length_https
7
9
 
8
10
  # Returns an array of photo sizes
9
11
  #
10
12
  # @return [Array<Twitter::Size>]
11
13
  def photo_sizes
12
- @photo_sizes ||= Array(@attrs[:photo_sizes]).inject({}) do |object, (key, value)|
13
- object[key] = Twitter::Size.fetch_or_new(value)
14
- object
14
+ memoize(:photo_sizes) do
15
+ Array(@attrs[:photo_sizes]).inject({}) do |object, (key, value)|
16
+ object[key] = Twitter::Size.new(value)
17
+ object
18
+ end
15
19
  end
16
20
  end
17
21
 
@@ -7,13 +7,11 @@ module Twitter
7
7
  #
8
8
  # @return [Time]
9
9
  def created_at
10
- @created_at ||= Time.parse(@attrs[:created_at]) if created?
10
+ @created_at ||= Time.parse(@attrs[:created_at]) if @attrs[:created_at]
11
11
  end
12
12
 
13
- private
14
-
15
13
  def created?
16
- !@attrs[:created_at].nil?
14
+ !!@attrs[:created_at]
17
15
  end
18
16
 
19
17
  end
@@ -3,62 +3,58 @@ require 'twitter/core_ext/kernel'
3
3
  module Twitter
4
4
  class Cursor
5
5
  include Enumerable
6
- attr_reader :attrs, :collection
6
+ attr_reader :attrs
7
+ alias to_h attrs
7
8
  alias to_hash attrs
9
+ alias to_hsh attrs
8
10
 
9
- # Initializes a new Cursor object
11
+ # Construct a new Cursor object from a response hash
10
12
  #
11
13
  # @param response [Hash]
12
- # @param collection_name [String, Symbol] The name of the method to return the collection
13
- # @param klass [Class] The class to instantiate object in the collection
14
- # @param client [Twitter::Client]
15
- # @param method_name [String, Symbol]
16
- # @param method_options [Hash]
14
+ # @param key [String, Symbol] The key to fetch the data from the response
15
+ # @param klass [Class] The class to instantiate objects in the response
16
+ # @param client [Twitter::REST::Client]
17
+ # @param request_method [String, Symbol]
18
+ # @param path [String]
19
+ # @param options [Hash]
17
20
  # @return [Twitter::Cursor]
18
- def self.from_response(response, collection_name, klass, client, method_name, method_options)
19
- new(response[:body], collection_name, klass, client, method_name, method_options)
21
+ def self.from_response(response, key, klass, client, request_method, path, options)
22
+ new(response[:body], key, klass, client, request_method, path, options)
20
23
  end
21
24
 
22
25
  # Initializes a new Cursor
23
26
  #
24
27
  # @param attrs [Hash]
25
- # @param collection_name [String, Symbol] The name of the method to return the collection
26
- # @param klass [Class] The class to instantiate object in the collection
27
- # @param client [Twitter::Client]
28
- # @param method_name [String, Symbol]
29
- # @param method_options [Hash]
28
+ # @param key [String, Symbol] The key to fetch the data from the response
29
+ # @param klass [Class] The class to instantiate objects in the response
30
+ # @param client [Twitter::REST::Client]
31
+ # @param request_method [String, Symbol]
32
+ # @param path [String]
33
+ # @param options [Hash]
30
34
  # @return [Twitter::Cursor]
31
- def initialize(attrs, collection_name, klass, client, method_name, method_options)
32
- @attrs = attrs
35
+ def initialize(attrs, key, klass, client, request_method, path, options)
36
+ @key = key.to_sym
37
+ @klass = klass
33
38
  @client = client
34
- @method_name = method_name
35
- @method_options = method_options
36
- @collection = Array(attrs[collection_name.to_sym]).map do |item|
37
- if klass
38
- klass.fetch_or_new(item)
39
- else
40
- item
41
- end
42
- end
43
- singleton_class.class_eval do
44
- alias_method(collection_name.to_sym, :collection)
45
- end
39
+ @request_method = request_method.to_sym
40
+ @path = path
41
+ @options = options
42
+ @collection = []
43
+ set_attrs(attrs)
46
44
  end
47
45
 
48
- # @param collection [Array]
49
- # @param cursor [Integer]
50
- # @return [Array]
51
- def all(collection=collection, cursor=next_cursor)
52
- cursor = @client.send(@method_name.to_sym, @method_options.merge(:cursor => cursor))
53
- collection += cursor.collection
54
- cursor.last? ? collection.flatten : all(collection, cursor.next_cursor)
55
- end
56
-
57
- # @return [Enumerable]
58
- def each
59
- all(collection, next_cursor).each do |element|
46
+ # @return [Enumerator]
47
+ def each(start = 0, &block)
48
+ return to_enum(:each) unless block_given?
49
+ Array(@collection[start..-1]).each do |element|
60
50
  yield element
61
51
  end
52
+ unless last?
53
+ start = [@collection.size, start].max
54
+ fetch_next_page
55
+ each(start, &block)
56
+ end
57
+ self
62
58
  end
63
59
 
64
60
  def next_cursor
@@ -75,13 +71,25 @@ module Twitter
75
71
  def first?
76
72
  previous_cursor.zero?
77
73
  end
78
- alias first first?
79
74
 
80
75
  # @return [Boolean]
81
76
  def last?
82
77
  next_cursor.zero?
83
78
  end
84
- alias last last?
79
+
80
+ private
81
+
82
+ def fetch_next_page
83
+ response = @client.send(@request_method, @path, @options.merge(:cursor => next_cursor))
84
+ set_attrs(response[:body])
85
+ end
86
+
87
+ def set_attrs(attrs)
88
+ @attrs = attrs
89
+ Array(attrs[@key]).each do |element|
90
+ @collection << (@klass ? @klass.new(element) : element)
91
+ end
92
+ end
85
93
 
86
94
  end
87
95
  end
@@ -6,16 +6,7 @@ module Twitter
6
6
  include Twitter::Creatable
7
7
  attr_reader :text
8
8
  alias full_text text
9
-
10
- # @return [Twitter::User]
11
- def recipient
12
- @recipient ||= Twitter::User.fetch_or_new(@attrs[:recipient])
13
- end
14
-
15
- # @return [Twitter::User]
16
- def sender
17
- @sender ||= Twitter::User.fetch_or_new(@attrs[:sender])
18
- end
19
-
9
+ object_attr_reader :User, :recipient
10
+ object_attr_reader :User, :sender
20
11
  end
21
12
  end
@@ -0,0 +1,13 @@
1
+ require 'twitter/entity'
2
+
3
+ module Twitter
4
+ class Entity
5
+ class URI < Twitter::Entity
6
+ uri_attr_reader :display_uri, :expanded_uri, :uri
7
+ end
8
+
9
+ Uri = URI
10
+ URL = URI
11
+ Url = URI
12
+ end
13
+ end
@@ -0,0 +1,15 @@
1
+ module Twitter
2
+ module Enumerable
3
+ include ::Enumerable
4
+
5
+ # @return [Enumerator]
6
+ def each(start = 0, &block)
7
+ return to_enum(:each) unless block_given?
8
+ Array(@collection[start..-1]).each do |element|
9
+ yield element
10
+ end
11
+ self
12
+ end
13
+
14
+ end
15
+ end
@@ -3,31 +3,79 @@ require 'twitter/rate_limit'
3
3
  module Twitter
4
4
  # Custom error class for rescuing from all Twitter errors
5
5
  class Error < StandardError
6
- attr_reader :rate_limit, :wrapped_exception
6
+ attr_reader :rate_limit, :wrapped_exception, :code
7
+
8
+ # If error code is missing see https://dev.twitter.com/docs/error-codes-responses
9
+ module Codes
10
+ AUTHENTICATION_PROBLEM = 32
11
+ RESOURCE_NOT_FOUND = 34
12
+ SUSPENDED_ACCOUNT = 64
13
+ DEPRECATED_CALL = 68
14
+ RATE_LIMIT_EXCEEDED = 88
15
+ INVALID_OR_EXPIRED_TOKEN = 89
16
+ OVER_CAPACITY = 130
17
+ INTERNAL_ERROR = 131
18
+ OAUTH_TIMESTAMP_OUT_OF_RANGE = 135
19
+ DUPLICATE_STATUS = 187
20
+ BAD_AUTHENTICATION_DATA = 215
21
+ LOGIN_VERIFICATION_NEEDED = 231
22
+ end
23
+
24
+ # Create a new error from an HTTP response
25
+ #
26
+ # @param response [Hash]
27
+ # @return [Twitter::Error]
28
+ def self.from_response(response={})
29
+ error, code = parse_error(response[:body])
30
+ new(error, response[:response_headers], code)
31
+ end
7
32
 
8
33
  # @return [Hash]
9
34
  def self.errors
10
- @errors ||= Hash[descendants.map{|klass| [klass.const_get(:HTTP_STATUS_CODE), klass]}]
35
+ @errors ||= descendants.inject({}) do |hash, klass|
36
+ hash[klass::HTTP_STATUS_CODE] = klass
37
+ hash
38
+ end
11
39
  end
12
40
 
13
41
  # @return [Array]
14
42
  def self.descendants
15
- ObjectSpace.each_object(::Class).select{|klass| klass < self}
43
+ @descendants ||= []
44
+ end
45
+
46
+ # @return [Array]
47
+ def self.inherited(descendant)
48
+ descendants << descendant
16
49
  end
17
50
 
18
51
  # Initializes a new Error object
19
52
  #
20
53
  # @param exception [Exception, String]
21
54
  # @param response_headers [Hash]
55
+ # @param code [Integer]
22
56
  # @return [Twitter::Error]
23
- def initialize(exception=$!, response_headers={})
57
+ def initialize(exception=$!, response_headers={}, code=nil)
24
58
  @rate_limit = Twitter::RateLimit.new(response_headers)
25
59
  @wrapped_exception = exception
26
- exception.respond_to?(:backtrace) ? super(exception.message) : super(exception.to_s)
60
+ @code = code
61
+ exception.respond_to?(:message) ? super(exception.message) : super(exception.to_s)
27
62
  end
28
63
 
29
- def backtrace
30
- @wrapped_exception.respond_to?(:backtrace) ? @wrapped_exception.backtrace : super
64
+ private
65
+
66
+ def self.parse_error(body)
67
+ if body.nil?
68
+ ['', nil]
69
+ elsif body[:error]
70
+ [body[:error], nil]
71
+ elsif body[:errors]
72
+ first = Array(body[:errors]).first
73
+ if first.is_a?(Hash)
74
+ [first[:message].chomp, first[:code]]
75
+ else
76
+ [first.chomp, nil]
77
+ end
78
+ end
31
79
  end
32
80
 
33
81
  end
@@ -3,7 +3,7 @@ require 'twitter/error/forbidden'
3
3
  module Twitter
4
4
  class Error
5
5
  # Raised when a Tweet has already been favorited
6
- class AlreadyFavorited < Twitter::Error
6
+ class AlreadyFavorited < Twitter::Error::Forbidden
7
7
  MESSAGE = "You have already favorited this status"
8
8
  end
9
9
  end
@@ -0,0 +1,10 @@
1
+ require 'twitter/error/forbidden'
2
+
3
+ module Twitter
4
+ class Error
5
+ # Raised when a Tweet has already been posted
6
+ class AlreadyPosted < Twitter::Error::Forbidden
7
+ MESSAGE = "Status is a duplicate"
8
+ end
9
+ end
10
+ end
@@ -3,7 +3,7 @@ require 'twitter/error/forbidden'
3
3
  module Twitter
4
4
  class Error
5
5
  # Raised when a Tweet has already been retweeted
6
- class AlreadyRetweeted < Twitter::Error
6
+ class AlreadyRetweeted < Twitter::Error::Forbidden
7
7
  MESSAGE = "sharing is not permissible for this status (Share validations failed)"
8
8
  end
9
9
  end
@@ -1,11 +1,10 @@
1
- require 'twitter/error/server_error'
1
+ require 'twitter/error'
2
2
 
3
3
  module Twitter
4
4
  class Error
5
5
  # Raised when Twitter returns the HTTP status code 502
6
- class BadGateway < Twitter::Error::ServerError
6
+ class BadGateway < Twitter::Error
7
7
  HTTP_STATUS_CODE = 502
8
- MESSAGE = "Twitter is down or being upgraded."
9
8
  end
10
9
  end
11
10
  end
@@ -1,9 +1,9 @@
1
- require 'twitter/error/client_error'
1
+ require 'twitter/error'
2
2
 
3
3
  module Twitter
4
4
  class Error
5
5
  # Raised when Twitter returns the HTTP status code 400
6
- class BadRequest < Twitter::Error::ClientError
6
+ class BadRequest < Twitter::Error
7
7
  HTTP_STATUS_CODE = 400
8
8
  end
9
9
  end
@@ -1,9 +1,9 @@
1
- require 'twitter/error/client_error'
1
+ require 'twitter/error'
2
2
 
3
3
  module Twitter
4
4
  class Error
5
5
  # Raised when Twitter returns the HTTP status code 403
6
- class Forbidden < Twitter::Error::ClientError
6
+ class Forbidden < Twitter::Error
7
7
  HTTP_STATUS_CODE = 403
8
8
  end
9
9
  end
@@ -1,11 +1,10 @@
1
- require 'twitter/error/server_error'
1
+ require 'twitter/error'
2
2
 
3
3
  module Twitter
4
4
  class Error
5
5
  # Raised when Twitter returns the HTTP status code 504
6
- class GatewayTimeout < Twitter::Error::ServerError
6
+ class GatewayTimeout < Twitter::Error
7
7
  HTTP_STATUS_CODE = 504
8
- MESSAGE = "The Twitter servers are up, but the request couldn't be serviced due to some failure within our stack. Try again later."
9
8
  end
10
9
  end
11
10
  end
@@ -1,11 +1,10 @@
1
- require 'twitter/error/server_error'
1
+ require 'twitter/error'
2
2
 
3
3
  module Twitter
4
4
  class Error
5
5
  # Raised when Twitter returns the HTTP status code 500
6
- class InternalServerError < Twitter::Error::ServerError
6
+ class InternalServerError < Twitter::Error
7
7
  HTTP_STATUS_CODE = 500
8
- MESSAGE = "Something is technically wrong."
9
8
  end
10
9
  end
11
10
  end
@@ -1,9 +1,9 @@
1
- require 'twitter/error/client_error'
1
+ require 'twitter/error'
2
2
 
3
3
  module Twitter
4
4
  class Error
5
5
  # Raised when Twitter returns the HTTP status code 406
6
- class NotAcceptable < Twitter::Error::ClientError
6
+ class NotAcceptable < Twitter::Error
7
7
  HTTP_STATUS_CODE = 406
8
8
  end
9
9
  end
@@ -1,9 +1,9 @@
1
- require 'twitter/error/client_error'
1
+ require 'twitter/error'
2
2
 
3
3
  module Twitter
4
4
  class Error
5
5
  # Raised when Twitter returns the HTTP status code 404
6
- class NotFound < Twitter::Error::ClientError
6
+ class NotFound < Twitter::Error
7
7
  HTTP_STATUS_CODE = 404
8
8
  end
9
9
  end
@@ -1,11 +1,10 @@
1
- require 'twitter/error/server_error'
1
+ require 'twitter/error'
2
2
 
3
3
  module Twitter
4
4
  class Error
5
5
  # Raised when Twitter returns the HTTP status code 503
6
- class ServiceUnavailable < Twitter::Error::ServerError
6
+ class ServiceUnavailable < Twitter::Error
7
7
  HTTP_STATUS_CODE = 503
8
- MESSAGE = "(__-){ Twitter is over capacity."
9
8
  end
10
9
  end
11
10
  end
@@ -1,9 +1,9 @@
1
- require 'twitter/error/client_error'
1
+ require 'twitter/error'
2
2
 
3
3
  module Twitter
4
4
  class Error
5
5
  # Raised when Twitter returns the HTTP status code 429
6
- class TooManyRequests < Twitter::Error::ClientError
6
+ class TooManyRequests < Twitter::Error
7
7
  HTTP_STATUS_CODE = 429
8
8
  end
9
9
  EnhanceYourCalm = TooManyRequests