Class: ApiAiRuby::RequestQuery
- Inherits:
-
Object
- Object
- ApiAiRuby::RequestQuery
- Defined in:
- lib/api-ai-ruby/request_query.rb
Direct Known Subclasses
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::TextRequest
12 13 14 15 16 17 18 19 20 21 |
# File 'lib/api-ai-ruby/request_query.rb', line 12 def initialize(client, = {}) @client = client @uri = client.api_base_url + 'query?v=' + client.api_version @request_method = :post [:lang] = client.api_lang = @headers = { Authorization: 'Bearer ' + client.client_access_token, } end |
Instance Attribute Details
#client ⇒ Object
Returns the value of attribute client.
6 7 8 |
# File 'lib/api-ai-ruby/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_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_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_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_query.rb', line 6 def uri @uri end |
Instance Method Details
#perform ⇒ Array, Hash
24 25 26 27 28 29 30 |
# File 'lib/api-ai-ruby/request_query.rb', line 24 def perform = .has_key?(:voiceData) ? :form : :json response = HTTP.with(@headers).public_send(@request_method, @uri.to_s, => ) response_body = symbolize_keys!(response.parse) response_headers = response.headers fail_or_return_response_body(response.code, response_body) end |