Class: NftmakerApi::Response
- Inherits:
-
Object
- Object
- NftmakerApi::Response
- Defined in:
- lib/nftmaker_api/response.rb
Instance Attribute Summary collapse
-
#original_response ⇒ Object
(also: #original)
readonly
Returns the value of attribute original_response.
Instance Method Summary collapse
- #error ⇒ Object
- #error? ⇒ Boolean
-
#initialize(response) ⇒ Response
constructor
A new instance of Response.
- #parsed ⇒ Object (also: #to_h)
- #success? ⇒ Boolean
Constructor Details
#initialize(response) ⇒ Response
Returns a new instance of Response.
8 9 10 |
# File 'lib/nftmaker_api/response.rb', line 8 def initialize(response) @original_response = response end |
Instance Attribute Details
#original_response ⇒ Object (readonly) Also known as: original
Returns the value of attribute original_response.
5 6 7 |
# File 'lib/nftmaker_api/response.rb', line 5 def original_response @original_response end |
Instance Method Details
#error ⇒ Object
25 26 27 |
# File 'lib/nftmaker_api/response.rb', line 25 def error @error ||= success? ? nil : Error.new(self) end |
#error? ⇒ Boolean
21 22 23 |
# File 'lib/nftmaker_api/response.rb', line 21 def error? !success? end |
#parsed ⇒ Object Also known as: to_h
12 13 14 |
# File 'lib/nftmaker_api/response.rb', line 12 def parsed @parsed = Oj.load(@original_response.body) || {} end |
#success? ⇒ Boolean
17 18 19 |
# File 'lib/nftmaker_api/response.rb', line 17 def success? @original_response.status == 200 end |