Class: HaveAPI::SpecMethods::ApiResponse
- Inherits:
-
Object
- Object
- HaveAPI::SpecMethods::ApiResponse
- Defined in:
- lib/haveapi/spec/helpers.rb
Overview
This class wraps raw reply from the API and provides more friendly interface.
Instance Method Summary collapse
- #[](k) ⇒ Object
- #errors ⇒ Object
- #failed? ⇒ Boolean
-
#initialize(body) ⇒ ApiResponse
constructor
A new instance of ApiResponse.
- #message ⇒ Object
- #ok? ⇒ Boolean
- #response ⇒ Object
- #status ⇒ Object
Constructor Details
#initialize(body) ⇒ ApiResponse
Returns a new instance of ApiResponse.
40 41 42 |
# File 'lib/haveapi/spec/helpers.rb', line 40 def initialize(body) @data = JSON.parse(body, symbolize_names: true) end |
Instance Method Details
#[](k) ⇒ Object
68 69 70 |
# File 'lib/haveapi/spec/helpers.rb', line 68 def [](k) @data[:response][k] end |
#errors ⇒ Object
64 65 66 |
# File 'lib/haveapi/spec/helpers.rb', line 64 def errors @data[:errors] end |
#message ⇒ Object
60 61 62 |
# File 'lib/haveapi/spec/helpers.rb', line 60 def @data[:message] end |
#response ⇒ Object
56 57 58 |
# File 'lib/haveapi/spec/helpers.rb', line 56 def response @data[:response] end |
#status ⇒ Object
44 45 46 |
# File 'lib/haveapi/spec/helpers.rb', line 44 def status @data[:status] end |