Skip to content

Commit

Permalink
[+] Readme update
Browse files Browse the repository at this point in the history
  • Loading branch information
Gugic committed Sep 5, 2016
1 parent 4b71655 commit 4bbdaa1
Showing 1 changed file with 48 additions and 48 deletions.
96 changes: 48 additions & 48 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,61 +84,61 @@ Another possibility is to send and retrieve [custom entities](https://docs.api.a

You can do it along with **query** request
```ruby
client.text_request 'call Mozart', entities: [
{
name: 'contacts',
entries: [
ApiAiRuby::Entry.new('Mozart', %w(Mozart Wolfgang)),
ApiAiRuby::Entry.new('Salieri', %w(Salieri Antonio))
]
}
]
# the same without ApiAiRuby::Entry wrapper
client.text_request 'call Mozart', entities: [
{
name: 'contacts',
entries: [
{value: 'Mozart', synonyms: %w(Mozart Wolfgang))},
{value: 'Salieri', synonyms: %w(Salieri Antonio))},
]
}
]
client.text_request 'call Mozart', entities: [
{
name: 'contacts',
entries: [
ApiAiRuby::Entry.new('Mozart', %w(Mozart Wolfgang)),
ApiAiRuby::Entry.new('Salieri', %w(Salieri Antonio))
]
}
]

# the same without ApiAiRuby::Entry wrapper

client.text_request 'call Mozart', entities: [
{
name: 'contacts',
entries: [
{value: 'Mozart', synonyms: %w(Mozart Wolfgang))},
{value: 'Salieri', synonyms: %w(Salieri Antonio))},
]
}
]

```

Or with separate **user_entities_request** object with full CRUD support:

```ruby

# preparations
entries_composers = [
ApiAiRuby::Entry.new('Mozart', %w(Mozart Wolfgang)),
ApiAiRuby::Entry.new('Salieri', %w(Salieri Antonio))
]
entries_unknown = [
ApiAiRuby::Entry.new('John Doe', %w(John Unknown)),
ApiAiRuby::Entry.new('Jane Doe', %w(Jane))
]
entity_contacts = ApiAiRuby::Entity.new('contacts', [entries_composers])
# let's go
uer = client.user_entities_request
uer.create(contacts) # or uer.create([entity1, entity2...])
client.text_request 'call Mozart' # will work
uer.update('contacts', entries_unknown)
client.text_request 'call Mozart' # will NOT work
client.text_request 'call John' # will work
uer.retrieve('contacts') # will return current state of user entity
uer.delete('contacts') # will remove user entities for given session
# preparations
entries_composers = [
ApiAiRuby::Entry.new('Mozart', %w(Mozart Wolfgang)),
ApiAiRuby::Entry.new('Salieri', %w(Salieri Antonio))
]

entries_unknown = [
ApiAiRuby::Entry.new('John Doe', %w(John Unknown)),
ApiAiRuby::Entry.new('Jane Doe', %w(Jane))
]

entity_contacts = ApiAiRuby::Entity.new('contacts', [entries_composers])

# let's go
uer = client.user_entities_request
uer.create(contacts) # or uer.create([entity1, entity2...])

client.text_request 'call Mozart' # will work

uer.update('contacts', entries_unknown)

client.text_request 'call Mozart' # will NOT work
client.text_request 'call John' # will work

uer.retrieve('contacts') # will return current state of user entity
uer.delete('contacts') # will remove user entities for given session

```


Expand Down

0 comments on commit 4bbdaa1

Please sign in to comment.