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.
-
#developer_access_token ⇒ Object
Returns the value of attribute developer_access_token.
- #user_agent ⇒ String
Instance Method Summary collapse
-
#client_credentials? ⇒ Boolean
True if the client credentials are present.
- #credentials ⇒ Hash
-
#developer_credentials? ⇒ Boolean
True if the developer credentials are present.
- #get_entities_request(options = {}) ⇒ Object
- #get_entity_request(eid, options = {}) ⇒ Object
- #get_intent_request(iid, options = {}) ⇒ Object
- #get_intents_request(options = {}) ⇒ Object
-
#initialize(options = {}) {|_self| ... } ⇒ Twitter::Client
constructor
Initializes a new Client object.
- #text_request(query = '', options = {}) ⇒ Object
- #update_entities_request(entities, options = {}) ⇒ Object
- #update_intent_request(intent, 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 |
#developer_access_token ⇒ Object
Returns the value of attribute developer_access_token.
3 4 5 |
# File 'lib/api-ai-ruby/client.rb', line 3 def developer_access_token @developer_access_token end |
Instance Method Details
#client_credentials? ⇒ Boolean
Returns true if the client credentials are present.
43 44 45 |
# File 'lib/api-ai-ruby/client.rb', line 43 def client_credentials? credentials[:client_access_token] end |
#credentials ⇒ Hash
35 36 37 38 39 40 |
# File 'lib/api-ai-ruby/client.rb', line 35 def credentials { client_access_token: client_access_token, developer_access_token: developer_access_token } end |
#developer_credentials? ⇒ Boolean
Returns true if the developer credentials are present.
48 49 50 |
# File 'lib/api-ai-ruby/client.rb', line 48 def developer_credentials? credentials[:developer_access_token] end |
#get_entities_request(options = {}) ⇒ Object
95 96 97 98 |
# File 'lib/api-ai-ruby/client.rb', line 95 def get_entities_request( = {}) raise ApiAiRuby::ClientError.new('Credentials missing') if !developer_credentials? ApiAiRuby::GetEntityRequest.new(self, ).perform end |
#get_entity_request(eid, options = {}) ⇒ Object
89 90 91 92 93 |
# File 'lib/api-ai-ruby/client.rb', line 89 def get_entity_request(eid, = {}) raise ApiAiRuby::ClientError.new('Credentials missing') if !developer_credentials? [:eid] = eid ApiAiRuby::GetEntityRequest.new(self, ).perform end |
#get_intent_request(iid, options = {}) ⇒ Object
78 79 80 81 82 |
# File 'lib/api-ai-ruby/client.rb', line 78 def get_intent_request(iid, = {}) raise ApiAiRuby::ClientError.new('Credentials missing') if !developer_credentials? [:iid] = iid ApiAiRuby::GetIntentRequest.new(self, ).perform end |
#get_intents_request(options = {}) ⇒ Object
84 85 86 87 |
# File 'lib/api-ai-ruby/client.rb', line 84 def get_intents_request( = {}) raise ApiAiRuby::ClientError.new('Credentials missing') if !developer_credentials? ApiAiRuby::GetIntentRequest.new(self, ).perform end |
#text_request(query = '', options = {}) ⇒ Object
52 53 54 55 56 57 |
# File 'lib/api-ai-ruby/client.rb', line 52 def text_request (query = '', = {}) raise ApiAiRuby::ClientError.new('Credentials missing') if !client_credentials? [:params] ||= {} [:params] = [:params].merge({ query: query }) ApiAiRuby::TextRequest.new(self, ).perform end |
#update_entities_request(entities, options = {}) ⇒ Object
66 67 68 69 70 |
# File 'lib/api-ai-ruby/client.rb', line 66 def update_entities_request(entities, = {}) raise ApiAiRuby::ClientError.new('Credentials missing') if !developer_credentials? [:json] = entities ApiAiRuby::UpdateEntitiesRequest.new(self, ).perform end |
#update_intent_request(intent, options = {}) ⇒ Object
72 73 74 75 76 |
# File 'lib/api-ai-ruby/client.rb', line 72 def update_intent_request(intent, = {}) raise ApiAiRuby::ClientError.new('Credentials missing') if !developer_credentials? [:json] = intent ApiAiRuby::UpdateIntentRequest.new(self, ).perform end |
#voice_request(file_stream, options = {}) ⇒ Object
59 60 61 62 63 64 |
# File 'lib/api-ai-ruby/client.rb', line 59 def voice_request(file_stream, = {}) raise ApiAiRuby::ClientError.new('Credentials missing') if !client_credentials? [:form] ||= {} [:form] = [:form].merge({ file: file_stream }) ApiAiRuby::VoiceRequest.new(self, ).perform end |