Class: Peach::App::Response

Inherits:
Object
  • Object
show all
Defined in:
lib/peach/app/response.rb

Overview

:nodoc:

Constant Summary collapse

SUPPORTED_ACTIONS =
%w[navigate send_prompt end].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(**args) ⇒ Response

Returns a new instance of Response.



11
12
13
14
15
# File 'lib/peach/app/response.rb', line 11

def initialize(**args)
  args = set_defaults_for args
  validate_arguments args
  instantiate_instance_variables_from args
end

Instance Attribute Details

#actionObject

Returns the value of attribute action.



9
10
11
# File 'lib/peach/app/response.rb', line 9

def action
  @action
end

#contextObject

Returns the value of attribute context.



9
10
11
# File 'lib/peach/app/response.rb', line 9

def context
  @context
end

#dataObject

Returns the value of attribute data.



9
10
11
# File 'lib/peach/app/response.rb', line 9

def data
  @data
end

#screenObject

Returns the value of attribute screen.



9
10
11
# File 'lib/peach/app/response.rb', line 9

def screen
  @screen
end

Instance Method Details

#bodyObject



17
18
19
20
21
22
23
24
25
# File 'lib/peach/app/response.rb', line 17

def body
  body = { action: @action,
           screen: @screen,
           data: @data,
           context: @context }
  validate_arguments body
  body.delete(:screen) if @action == 'end'
  JSON.generate body
end