Class: Xdelivery::API::Response::Base
- Inherits:
-
Object
- Object
- Xdelivery::API::Response::Base
- Defined in:
- lib/xdelivery/api/response/base.rb
Instance Attribute Summary collapse
-
#data ⇒ Object
Returns the value of attribute data.
-
#response ⇒ Object
Returns the value of attribute response.
Instance Method Summary collapse
- #auth? ⇒ Boolean
- #code ⇒ Object
-
#initialize(response) ⇒ Base
constructor
A new instance of Base.
- #status? ⇒ Boolean
Constructor Details
#initialize(response) ⇒ Base
Returns a new instance of Base.
7 8 9 10 11 12 13 14 15 16 |
# File 'lib/xdelivery/api/response/base.rb', line 7 def initialize(response) self.response = response handle_error! self.data = begin JSON.parse(response.body) rescue JSON::ParserError raise Client::UnknownResponse, "#{code}, Response is not json." end end |
Instance Attribute Details
#data ⇒ Object
Returns the value of attribute data.
5 6 7 |
# File 'lib/xdelivery/api/response/base.rb', line 5 def data @data end |
#response ⇒ Object
Returns the value of attribute response.
5 6 7 |
# File 'lib/xdelivery/api/response/base.rb', line 5 def response @response end |
Instance Method Details
#auth? ⇒ Boolean
22 23 24 |
# File 'lib/xdelivery/api/response/base.rb', line 22 def auth? code == 200 end |
#code ⇒ Object
18 19 20 |
# File 'lib/xdelivery/api/response/base.rb', line 18 def code response.code end |
#status? ⇒ Boolean
26 27 28 |
# File 'lib/xdelivery/api/response/base.rb', line 26 def status? data['status'] == true end |