Class: VoxableApiAiRuby::Request
- Inherits:
-
Object
- Object
- VoxableApiAiRuby::Request
- Defined in:
- lib/voxable-api-ai-ruby/request.rb
Direct Known Subclasses
GetEntityRequest, GetIntentRequest, TextRequest, UpdateEntitiesRequest, UpdateIntentRequest, VoiceRequest
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
- #initialize(client, options = {}) ⇒ VoxableApiAiRuby::TextRequest constructor
- #perform ⇒ Array, Hash
Constructor Details
#initialize(client, options = {}) ⇒ VoxableApiAiRuby::TextRequest
15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/voxable-api-ai-ruby/request.rb', line 15 def initialize(client, = {}) @client = client @uri = client.api_base_url + @path + '?v=' + client.api_version @request_method = :post [:params] ||= {} [:params] = [:params].merge({ lang: client.api_lang }) @options = @headers = { 'Authorization': ('Bearer ' + client.client_access_token), 'Content-Type': 'application/json; charset=utf-8' } end |
Instance Attribute Details
#client ⇒ Object
Returns the value of attribute client.
8 9 10 |
# File 'lib/voxable-api-ai-ruby/request.rb', line 8 def client @client end |
#headers ⇒ Object
Returns the value of attribute headers.
8 9 10 |
# File 'lib/voxable-api-ai-ruby/request.rb', line 8 def headers @headers end |
#options ⇒ Object
Returns the value of attribute options.
8 9 10 |
# File 'lib/voxable-api-ai-ruby/request.rb', line 8 def @options end |
#request_method ⇒ Object
Returns the value of attribute request_method.
8 9 10 |
# File 'lib/voxable-api-ai-ruby/request.rb', line 8 def request_method @request_method end |
#uri ⇒ Object
Returns the value of attribute uri.
8 9 10 |
# File 'lib/voxable-api-ai-ruby/request.rb', line 8 def uri @uri end |
Instance Method Details
#perform ⇒ Array, Hash
29 30 31 32 33 34 35 |
# File 'lib/voxable-api-ai-ruby/request.rb', line 29 def perform response = HTTP.with(@headers).public_send(@request_method, @uri.to_s, @options) response_body = symbolize_keys!(response.parse) response_headers = response.headers fail_or_return_response_body(response.code, response_body) end |