Class: Paperdrive::Response
- Inherits:
-
Object
- Object
- Paperdrive::Response
- Defined in:
- lib/paperdrive/response.rb
Overview
Wrapper class of the Faraday::Response.
Instance Attribute Summary collapse
-
#body ⇒ Object
Returns the value of attribute body.
-
#header ⇒ Object
Returns the value of attribute header.
-
#ratelimit ⇒ Object
Returns the value of attribute ratelimit.
-
#status_code ⇒ Object
Returns the value of attribute status_code.
-
#status_phrase ⇒ Object
Returns the value of attribute status_phrase.
Instance Method Summary collapse
-
#initialize(response) ⇒ Response
constructor
build instance from Faraday::Response.
-
#success? ⇒ Boolean
return whether the request was successfully processed or not.
Constructor Details
#initialize(response) ⇒ Response
build instance from Faraday::Response
13 14 15 16 17 18 19 20 |
# File 'lib/paperdrive/response.rb', line 13 def initialize(response) Paperdrive::Error.raise_from(response) @header = response.headers.to_h @ratelimit = build_ratelimit(@header) @body = JSON.parse(response.body) @status_code = response.status @status_phrase = response.reason_phrase end |
Instance Attribute Details
#body ⇒ Object
Returns the value of attribute body.
8 9 10 |
# File 'lib/paperdrive/response.rb', line 8 def body @body end |
#header ⇒ Object
Returns the value of attribute header.
8 9 10 |
# File 'lib/paperdrive/response.rb', line 8 def header @header end |
#ratelimit ⇒ Object
Returns the value of attribute ratelimit.
8 9 10 |
# File 'lib/paperdrive/response.rb', line 8 def ratelimit @ratelimit end |
#status_code ⇒ Object
Returns the value of attribute status_code.
8 9 10 |
# File 'lib/paperdrive/response.rb', line 8 def status_code @status_code end |
#status_phrase ⇒ Object
Returns the value of attribute status_phrase.
8 9 10 |
# File 'lib/paperdrive/response.rb', line 8 def status_phrase @status_phrase end |
Instance Method Details
#success? ⇒ Boolean
return whether the request was successfully processed or not
25 26 27 |
# File 'lib/paperdrive/response.rb', line 25 def success? !!@body['success'] end |