Class: Knowtify::Response
- Inherits:
-
Object
- Object
- Knowtify::Response
- Defined in:
- lib/knowtify/response.rb
Constant Summary collapse
- ERROR_HTTP_CODES =
[500,501,502,503,504,505,429,0].freeze
Instance Attribute Summary collapse
-
#body ⇒ Object
String - body from HTTP request.
-
#count ⇒ Object
String - body from HTTP request.
-
#http_code ⇒ Object
String - body from HTTP request.
-
#raw_response ⇒ Object
String - body from HTTP request.
Instance Method Summary collapse
- #authentication_error? ⇒ Boolean
-
#initialize(count = 0) ⇒ Response
constructor
A new instance of Response.
- #retried? ⇒ Boolean
- #retry? ⇒ Boolean
- #successful? ⇒ Boolean
Constructor Details
#initialize(count = 0) ⇒ Response
Returns a new instance of Response.
10 11 12 |
# File 'lib/knowtify/response.rb', line 10 def initialize(count=0) @count = count || 0 end |
Instance Attribute Details
#body ⇒ Object
String - body from HTTP request
3 4 5 |
# File 'lib/knowtify/response.rb', line 3 def body @body end |
#count ⇒ Object
String - body from HTTP request
3 4 5 |
# File 'lib/knowtify/response.rb', line 3 def count @count end |
#http_code ⇒ Object
String - body from HTTP request
3 4 5 |
# File 'lib/knowtify/response.rb', line 3 def http_code @http_code end |
#raw_response ⇒ Object
String - body from HTTP request
3 4 5 |
# File 'lib/knowtify/response.rb', line 3 def raw_response @raw_response end |
Instance Method Details
#authentication_error? ⇒ Boolean
26 27 28 |
# File 'lib/knowtify/response.rb', line 26 def authentication_error? http_code == 401 end |
#retried? ⇒ Boolean
18 19 20 |
# File 'lib/knowtify/response.rb', line 18 def retried? count != 0 end |
#retry? ⇒ Boolean
14 15 16 |
# File 'lib/knowtify/response.rb', line 14 def retry? (((count + 1) <= Knowtify.config.max_retries) && ERROR_HTTP_CODES.include?(http_code)) end |
#successful? ⇒ Boolean
22 23 24 |
# File 'lib/knowtify/response.rb', line 22 def successful? http_code == 200 end |