module ApiAi
Copyright © 2015 Gustavo Bazan MIT License
Copyright © 2015 Gustavo Bazan MIT License
Copyright © 2015 Gustavo Bazan MIT License
Copyright © 2015 Gustavo Bazan MIT License
Copyright © 2015 Gustavo Bazan MIT License
Copyright © 2015 Gustavo Bazan MIT License
Constants
- API_SERVER
api.ai api path
- API_VERSION
- VERSION
- WEB_SERVER
api.ai url
Public Class Methods
parse_response(response, raw = false)
click to toggle source
Parse response. You probably shouldn’t be calling this directly. This takes responses from the server and parses them. It also checks for errors and raises exceptions with the appropriate messages.
@param [Net::HTTPResponse] response @param [Boolean] raw if return raw data @raise [ApiAi::Error] @raise [ApiAi::AuthError]
# File lib/api-ai.rb, line 29 def self.parse_response(response, raw = false) if response.is_a?(Net::HTTPServerError) fail ApiAi::Error.new("api.ai Server Error: #{response} - #{response.body}", response) end return response.body if raw begin return JSON.parse(response.body) rescue JSON::ParserError raise ApiAi::Error.new("Unable to parse JSON response: #{response.body}", response) end end