Class: ApiAiRuby::Client
- Inherits:
-
Object
- Object
- ApiAiRuby::Client
- Defined in:
- lib/api-ai-ruby/client.rb
Instance Attribute Summary collapse
- #api_base_url ⇒ Object
- #api_lang ⇒ Object
- #api_version ⇒ Object
-
#client_access_token ⇒ Object
Returns the value of attribute client_access_token.
-
#subscription_key ⇒ Object
Returns the value of attribute subscription_key.
- #user_agent ⇒ String
Instance Method Summary collapse
- #credentials ⇒ Hash
- #credentials? ⇒ Boolean
-
#initialize(options = {}) {|_self| ... } ⇒ Twitter::Client
constructor
Initializes a new Client object.
- #text_request(query = '', options = {}) ⇒ Object
- #voice_request(file_stream, options = {}) ⇒ Object
Constructor Details
#initialize(options = {}) {|_self| ... } ⇒ Twitter::Client
Initializes a new Client object
10 11 12 13 14 15 |
# File 'lib/api-ai-ruby/client.rb', line 10 def initialize( = {}) .each do |key, value| instance_variable_set("@#{key}", value) end yield(self) if block_given? end |
Instance Attribute Details
#api_base_url ⇒ Object
22 23 24 |
# File 'lib/api-ai-ruby/client.rb', line 22 def api_base_url @api_base_url ||= ApiAiRuby::Constants::DEFAULT_BASE_URL end |
#api_lang ⇒ Object
26 27 28 |
# File 'lib/api-ai-ruby/client.rb', line 26 def api_lang @api_lang ||= ApiAiRuby::Constants::DEFAULT_CLIENT_LANG end |
#api_version ⇒ Object
30 31 32 |
# File 'lib/api-ai-ruby/client.rb', line 30 def api_version @api_version ||= ApiAiRuby::Constants::DEFAULT_API_VERSION end |
#client_access_token ⇒ Object
Returns the value of attribute client_access_token.
3 4 5 |
# File 'lib/api-ai-ruby/client.rb', line 3 def client_access_token @client_access_token end |
#subscription_key ⇒ Object
Returns the value of attribute subscription_key.
3 4 5 |
# File 'lib/api-ai-ruby/client.rb', line 3 def subscription_key @subscription_key end |
#user_agent ⇒ String
18 19 20 |
# File 'lib/api-ai-ruby/client.rb', line 18 def user_agent @user_agent ||= "ApiAiRubyGem/#{ApiAiRuby::Constants::VERSION}" end |
Instance Method Details
#credentials ⇒ Hash
35 36 37 38 39 |
# File 'lib/api-ai-ruby/client.rb', line 35 def credentials { client_access_token: client_access_token, } end |
#credentials? ⇒ Boolean
42 43 44 |
# File 'lib/api-ai-ruby/client.rb', line 42 def credentials? credentials.values.all? end |
#text_request(query = '', options = {}) ⇒ Object
46 47 48 49 50 |
# File 'lib/api-ai-ruby/client.rb', line 46 def text_request (query = '', = {}) raise ApiAiRuby::ClientError.new('Credentials missing') if !credentials? [:query] = query ApiAiRuby::TextRequest.new(self, ).perform end |
#voice_request(file_stream, options = {}) ⇒ Object
52 53 54 55 56 |
# File 'lib/api-ai-ruby/client.rb', line 52 def voice_request(file_stream, = {}) raise ApiAiRuby::ClientError.new('Credentials missing') if !credentials? [:file] = file_stream ApiAiRuby::VoiceRequest.new(self, ).perform end |