Skip to content
This repository has been archived by the owner on Jul 23, 2021. It is now read-only.

Commit

Permalink
Update README with more detailled instructions
Browse files Browse the repository at this point in the history
  • Loading branch information
Olivier Dolbeau committed Jun 12, 2019
1 parent 6b32cf1 commit ea58e48
Showing 1 changed file with 43 additions and 1 deletion.
44 changes: 43 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit ea58e48

Please sign in to comment.