Class: Enveloop::TemplateResponse

Inherits:
Object
  • Object
show all
Defined in:
lib/enveloop/template_response.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#errorObject (readonly)

Returns the value of attribute error.



3
4
5
# File 'lib/enveloop/template_response.rb', line 3

def error
  @error
end

#statusObject (readonly)

Returns the value of attribute status.



3
4
5
# File 'lib/enveloop/template_response.rb', line 3

def status
  @status
end

#templateObject (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

Returns:

  • (Boolean)


17
18
19
# File 'lib/enveloop/template_response.rb', line 17

def success?
  @status == 200
end