Class: Emarsys::Response
- Inherits:
-
Object
- Object
- Emarsys::Response
- Defined in:
- lib/emarsys/response.rb
Instance Attribute Summary collapse
-
#code ⇒ Object
Returns the value of attribute code.
-
#data ⇒ Object
Returns the value of attribute data.
-
#status ⇒ Object
Returns the value of attribute status.
-
#text ⇒ Object
Returns the value of attribute text.
Instance Method Summary collapse
-
#initialize(response) ⇒ Response
constructor
A new instance of Response.
- #result ⇒ Object
Constructor Details
#initialize(response) ⇒ Response
5 6 7 8 9 10 11 |
# File 'lib/emarsys/response.rb', line 5 def initialize(response) json = JSON.parse(response) self.code = json['replyCode'] self.text = json['replyText'] self.data = json['data'] self.status = response.code if response.respond_to?(:code) end |
Instance Attribute Details
#code ⇒ Object
Returns the value of attribute code.
3 4 5 |
# File 'lib/emarsys/response.rb', line 3 def code @code end |
#data ⇒ Object
Returns the value of attribute data.
3 4 5 |
# File 'lib/emarsys/response.rb', line 3 def data @data end |
#status ⇒ Object
Returns the value of attribute status.
3 4 5 |
# File 'lib/emarsys/response.rb', line 3 def status @status end |
#text ⇒ Object
Returns the value of attribute text.
3 4 5 |
# File 'lib/emarsys/response.rb', line 3 def text @text end |
Instance Method Details
#result ⇒ Object
13 14 15 16 17 18 19 20 21 |
# File 'lib/emarsys/response.rb', line 13 def result if code == 0 data elsif !status.nil? && status == 401 raise Emarsys::.new(code, text, status) else raise Emarsys::BadRequest.new(code, text, status) end end |