Class: ApiAiWrapper::Trainers::EntityTrainer
- Inherits:
-
Components::TrainerComponent
- Object
- Components::Component
- Components::TrainerComponent
- ApiAiWrapper::Trainers::EntityTrainer
- Defined in:
- lib/api_ai_wrapper/trainers/entity_trainer.rb
Overview
Instance Attribute Summary
Attributes inherited from Components::Component
Instance Method Summary collapse
-
#delete_entity(eid) ⇒ Object
api.ai/docs/reference/agent/entities#delete_entitieseid Delete an entity eid can either be the ID or the entity NAME.
-
#delete_entity_entries(eid, entries) ⇒ Object
api.ai/docs/reference/agent/entities#delete_entitieseidentries Delete an entity’s entries eid can either be the ID or the entity NAME entries is an array of reference values (e.g. [“blue”, “red”] for entity “color”).
-
#get_entities ⇒ Object
api.ai/docs/reference/agent/entities#get_entities Retrieves all entities for a given token.
-
#get_entity(eid) ⇒ Object
api.ai/docs/reference/agent/entities#get_entitieseid Retrieves entity info eid can either be the ID or the entity NAME.
-
#post_entity(name, entries) ⇒ Object
docs.api.ai/docs/entities#post-entities Creates an entity with the corresponding entries.
-
#post_entity_entries(eid, entries) ⇒ Object
api.ai/docs/reference/agent/entities#post_entitieseidentries Allows to add entries to en existing entity eid can either be the ID or the entity NAME.
-
#put_entity(eid, options = {}) ⇒ Object
api.ai/docs/reference/agent/entities#put_entitieseid Update an entity.
-
#put_entity_entries(eid, entries) ⇒ Object
api.ai/docs/reference/agent/entities#put_entitieseid Update an entity’s entries.
Methods inherited from Components::TrainerComponent
#raise_if_unauthorized, #set_headers
Instance Method Details
#delete_entity(eid) ⇒ Object
api.ai/docs/reference/agent/entities#delete_entitieseid Delete an entity eid can either be the ID or the entity NAME
65 66 67 68 69 |
# File 'lib/api_ai_wrapper/trainers/entity_trainer.rb', line 65 def delete_entity(eid) endpoint_url = URI.join(self.engine.base_url, "entities/#{eid}?v=#{self.engine.version}") self.delete(endpoint_url, {}) end |
#delete_entity_entries(eid, entries) ⇒ Object
api.ai/docs/reference/agent/entities#delete_entitieseidentries Delete an entity’s entries eid can either be the ID or the entity NAME entries is an array of reference values (e.g. [“blue”, “red”] for entity “color”)
75 76 77 78 79 80 |
# File 'lib/api_ai_wrapper/trainers/entity_trainer.rb', line 75 def delete_entity_entries(eid, entries) body = { entries: entries } endpoint_url = URI.join(self.engine.base_url, "entities/#{eid}/entries?v=#{self.engine.version}") self.delete(endpoint_url, body.to_json) end |
#get_entities ⇒ Object
api.ai/docs/reference/agent/entities#get_entities Retrieves all entities for a given token
9 10 11 12 13 |
# File 'lib/api_ai_wrapper/trainers/entity_trainer.rb', line 9 def get_entities endpoint_url = URI.join(self.engine.base_url, "entities?v=#{self.engine.version}") self.get(endpoint_url, {}) end |
#get_entity(eid) ⇒ Object
api.ai/docs/reference/agent/entities#get_entitieseid Retrieves entity info eid can either be the ID or the entity NAME
18 19 20 21 22 |
# File 'lib/api_ai_wrapper/trainers/entity_trainer.rb', line 18 def get_entity(eid) endpoint_url = URI.join(self.engine.base_url, "entities/#{eid}?v=#{self.engine.version}") self.get(endpoint_url, {}) end |
#post_entity(name, entries) ⇒ Object
docs.api.ai/docs/entities#post-entities Creates an entity with the corresponding entries
26 27 28 29 30 31 32 33 34 |
# File 'lib/api_ai_wrapper/trainers/entity_trainer.rb', line 26 def post_entity(name, entries) body = { name: name, entries: entries } endpoint_url = URI.join(self.engine.base_url, "entities?v=#{self.engine.version}") self.post(endpoint_url, body.to_json) end |
#post_entity_entries(eid, entries) ⇒ Object
api.ai/docs/reference/agent/entities#post_entitieseidentries Allows to add entries to en existing entity eid can either be the ID or the entity NAME
39 40 41 42 43 |
# File 'lib/api_ai_wrapper/trainers/entity_trainer.rb', line 39 def post_entity_entries(eid, entries) endpoint_url = URI.join(self.engine.base_url, "entities/#{eid}/entries?v=#{self.engine.version}") self.post(endpoint_url, entries.to_json) end |
#put_entity(eid, options = {}) ⇒ Object
api.ai/docs/reference/agent/entities#put_entitieseid Update an entity
47 48 49 50 51 |
# File 'lib/api_ai_wrapper/trainers/entity_trainer.rb', line 47 def put_entity(eid, = {}) endpoint_url = URI.join(self.engine.base_url, "entities/#{eid}?v=#{self.engine.version}") self.put(endpoint_url, .to_json) end |
#put_entity_entries(eid, entries) ⇒ Object
api.ai/docs/reference/agent/entities#put_entitieseid Update an entity’s entries
55 56 57 58 59 60 |
# File 'lib/api_ai_wrapper/trainers/entity_trainer.rb', line 55 def put_entity_entries(eid, entries) body = { entries: entries } endpoint_url = URI.join(self.engine.base_url, "entities/#{eid}/entries?v=#{self.engine.version}") self.put(endpoint_url, entries.to_json) end |