This repository has been archived by the owner on Jul 23, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update README with more detailled instructions
- Loading branch information
Olivier Dolbeau
committed
Jun 12, 2019
1 parent
6b32cf1
commit ea58e48
Showing
1 changed file
with
43 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,12 +17,54 @@ $ composer require shapintv/talkjs | |
|
||
## Usage | ||
|
||
### Create a `TalkJSClient` | ||
|
||
Using the static `create` method: | ||
|
||
``` php | ||
$client = TalkJSClient::create($secretKey, $appId); | ||
// Create a customer | ||
``` | ||
|
||
Using your own `HttpClient`: | ||
|
||
```php | ||
$client = new TalkJSClient($myHttpClient); | ||
``` | ||
|
||
Learn how to create your own client on [PHP-HTTP documentation](http://docs.php-http.org/en/latest/). | ||
If you use your own client, be sure to configure it properly. See [HttpClientConfigurator](src/HttpClientConfigurator.php) to see what's needed. | ||
|
||
### Deal with users | ||
|
||
```php | ||
// Create or update a user | ||
$client->users()->createOrUpdate('my_custom_id', [ | ||
'email' => '[email protected]', | ||
]); | ||
|
||
// Retrieve a user | ||
$user = $client->users()->get('my_custom_id'); | ||
``` | ||
|
||
### Deal with conversations | ||
|
||
```php | ||
// Create or update a user | ||
$client->conversations()->createOrUpdate('my_custom_id', [ | ||
'subject' => 'My new conversation', | ||
]); | ||
|
||
// Retrive a conversation | ||
$conversation = $client->conversations()->get('my_custom_id'); | ||
|
||
// Find conversations | ||
$conversations = $client->conversations()->find(); | ||
|
||
// Join a conversation | ||
$client->conversation()->join('my_conversation_id', 'my_user_id'); | ||
|
||
// Leave a conversation | ||
$client->conversation()->leave('my_conversation_id', 'my_user_id'); | ||
``` | ||
|
||
## License | ||
|