Class: Enveloop::TemplateResponse
- Inherits:
-
Object
- Object
- Enveloop::TemplateResponse
- Defined in:
- lib/enveloop/template_response.rb
Instance Attribute Summary collapse
-
#error ⇒ Object
readonly
Returns the value of attribute error.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
-
#template ⇒ Object
readonly
Returns the value of attribute template.
Instance Method Summary collapse
-
#initialize(status: 200, body: nil) ⇒ TemplateResponse
constructor
A new instance of TemplateResponse.
- #success? ⇒ Boolean
Constructor Details
#initialize(status: 200, body: nil) ⇒ TemplateResponse
Returns a new instance of TemplateResponse.
5 6 7 8 9 10 11 12 13 14 15 |
# File 'lib/enveloop/template_response.rb', line 5 def initialize(status: 200, body: nil) @status = status if status == 200 @template = JSON.parse(body) elsif status == 500 @error = JSON.parse(body)['error'] else @error = 'Unknown error' end end |
Instance Attribute Details
#error ⇒ Object (readonly)
Returns the value of attribute error.
3 4 5 |
# File 'lib/enveloop/template_response.rb', line 3 def error @error end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
3 4 5 |
# File 'lib/enveloop/template_response.rb', line 3 def status @status end |
#template ⇒ Object (readonly)
Returns the value of attribute template.
3 4 5 |
# File 'lib/enveloop/template_response.rb', line 3 def template @template end |
Instance Method Details
#success? ⇒ Boolean
17 18 19 |
# File 'lib/enveloop/template_response.rb', line 17 def success? @status == 200 end |