Method: Watsbot::Response::Parser#parse

Defined in:
lib/watsbot/response/parser.rb

#parseObject



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/watsbot/response/parser.rb', line 10

def parse
  if @response.code >= 400
    response = Error.new @response.code
    response.message = parse_error_message
    response
  else
    response = Success.new @response.code
    response.intents = @response_body["intents"]
    response.entities = parse_entities
    response.input = @response_body["input"]
    response.output = @response_body["output"]
    response.context = @response_body["context"]
    response
  end
end