Class: ApiAiRuby::RequestQuery
- Inherits:
-
Object
- Object
- ApiAiRuby::RequestQuery
- Defined in:
- lib/api-ai-ruby/request/request_query.rb
Direct Known Subclasses
ContextsRequest, EventRequest, TextRequest, UserEntitiesRequest
Instance Attribute Summary collapse
-
#client ⇒ Object
Returns the value of attribute client.
-
#headers ⇒ Object
Returns the value of attribute headers.
-
#options ⇒ Object
Returns the value of attribute options.
-
#request_method ⇒ Object
Returns the value of attribute request_method.
-
#uri ⇒ Object
Returns the value of attribute uri.
Instance Method Summary collapse
Constructor Details
#initialize(client, options = {}) ⇒ ApiAiRuby::RequestQuery
12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/api-ai-ruby/request/request_query.rb', line 12 def initialize(client, = {}) @client = client @uri = client.api_base_url + 'query?v=' + client.api_version @request_method = :post [:sessionId] = client.api_session_id = @headers = { Authorization: 'Bearer ' + client.client_access_token, } = client. || [:timeout_options] end |
Instance Attribute Details
#client ⇒ Object
Returns the value of attribute client.
6 7 8 |
# File 'lib/api-ai-ruby/request/request_query.rb', line 6 def client @client end |
#headers ⇒ Object
Returns the value of attribute headers.
6 7 8 |
# File 'lib/api-ai-ruby/request/request_query.rb', line 6 def headers @headers end |
#options ⇒ Object
Returns the value of attribute options.
6 7 8 |
# File 'lib/api-ai-ruby/request/request_query.rb', line 6 def end |
#request_method ⇒ Object
Returns the value of attribute request_method.
6 7 8 |
# File 'lib/api-ai-ruby/request/request_query.rb', line 6 def request_method @request_method end |
#uri ⇒ Object
Returns the value of attribute uri.
6 7 8 |
# File 'lib/api-ai-ruby/request/request_query.rb', line 6 def uri @uri end |
Instance Method Details
#perform ⇒ Hash
25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/api-ai-ruby/request/request_query.rb', line 25 def perform if && .is_a?(Hash) && .has_key?(:voiceData) = :form else = (@request_method === :get) ? :params : :json end request = HTTP.headers(@headers) request = request.timeout(*) if response = request.public_send(@request_method, @uri.to_s, => ) if response = request.public_send(@request_method, @uri.to_s) if == nil response_body = symbolize_keys!(response.parse) fail_or_return_response_body(response.code, response_body) end |