-
Notifications
You must be signed in to change notification settings - Fork 96
ChatAPI functionality #23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
3d878e5
Created the messages and channels endpoint implementation for Chat API
d01f7a2
added Chat Channels and chat channel examples
feb2fe5
added Chat platforms, some changes on chat messages
4c7d2af
fixed Client.php to do proper assignment of httpClients for both chat…
5f35d27
added unit tests for ChatAPI (platforms/channels/messages)
f6ee6b8
Added ChatAPI contact object
5846687
fixed Update (PUT request) for channels
bd6ce36
added channel update unit test
52cc8b8
added _links attribute (HATEOAS links related to the objects)
ef3816f
added getter for id at ChatMessage
3421376
Merge pull request #1 from sotoz/chat_api_integration
sotoz 672a188
Changed namespace for chat-api related objects/resources
445f58c
Merge pull request #2 from sotoz/chat_api_integration
sotoz 8e68414
Fixed examples
c862e28
Merge pull request #3 from sotoz/chat_api_integration
sotoz cb51812
Removed tab character from dummy access key
e98e014
Merge pull request #4 from sotoz/chat_api_integration
sotoz b599d14
Fixed contactId and typo.
3516285
Merge pull request #5 from sotoz/chat_api_integration
sotoz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php | ||
|
||
require_once(__DIR__ . '/../autoload.php'); | ||
|
||
$MessageBird = new \MessageBird\Client('YOUR_ACCESS_KEY'); // Set your own API access key here. | ||
|
||
$ChatChannel = new \MessageBird\Objects\Chat\Channel(); | ||
|
||
//Example for telegram channel | ||
|
||
$ChatChannel->name = 'Test Channel Telegram'; | ||
$ChatChannel->platformId = 'e82d332c5649a5f911e569n69040697'; | ||
|
||
// Channel details is a hash with name-value pairs indicating which channel details (and their respective data types) | ||
// are required when creating a channel for this platform. | ||
|
||
$ChatChannel->channelDetails = | ||
array( | ||
'botName' => 'testBot', | ||
'token' => '1234566778:A34JT44Yr4amk234352et5hvRnHeAEHA' | ||
); | ||
|
||
try { | ||
$ChatChannelResult = $MessageBird->chatchannels->create($ChatChannel); | ||
var_dump($ChatChannelResult); | ||
|
||
} catch (\MessageBird\Exceptions\AuthenticateException $e) { | ||
// That means that your accessKey is unknown | ||
echo 'wrong login'; | ||
|
||
} catch (\Exception $e) { | ||
echo $e->getMessage(); | ||
} |
This file contains hidden or 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 |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?php | ||
|
||
require_once(__DIR__ . '/../autoload.php'); | ||
|
||
$MessageBird = new \MessageBird\Client('YOUR_ACCESS_KEY'); // Set your own API access key here. | ||
|
||
try { | ||
|
||
$deleted = $MessageBird->chatchannels->delete('4affac2c577fb22e373921n52675409'); // Set a message id here | ||
var_dump('Deleted: ' . $deleted); | ||
|
||
} catch (\MessageBird\Exceptions\AuthenticateException $e) { | ||
// That means that your accessKey is unknown | ||
echo 'wrong login'; | ||
|
||
} catch (\Exception $e) { | ||
echo $e->getMessage(); | ||
} |
This file contains hidden or 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 |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?php | ||
|
||
require_once(__DIR__ . '/../autoload.php'); | ||
|
||
$MessageBird = new \MessageBird\Client('YOUR_ACCESS_KEY'); // Set your own API access key here. | ||
|
||
try { | ||
$ChatChannelResult = $MessageBird->chatchannels->getList(); | ||
var_dump($ChatChannelResult); | ||
|
||
} catch (\MessageBird\Exceptions\AuthenticateException $e) { | ||
// That means that your accessKey is unknown | ||
echo 'wrong login'; | ||
|
||
} catch (\Exception $e) { | ||
echo $e->getMessage(); | ||
} |
This file contains hidden or 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 |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?php | ||
|
||
require_once(__DIR__ . '/../autoload.php'); | ||
|
||
$MessageBird = new \MessageBird\Client('YOUR_ACCESS_KEY'); // Set your own API access key here. | ||
|
||
$ChatChannel = new \MessageBird\Objects\Chat\Channel(); | ||
$ChatChannel->name = 'New name'; | ||
$ChatChannel->callbackUrl = 'http://newurl.dev'; | ||
|
||
|
||
try { | ||
|
||
$ChatChannelResult = $MessageBird->chatchannels->update($ChatChannel, '331af4c577e3asbbc3631455680736'); | ||
var_dump($ChatChannelResult); | ||
|
||
} catch (\MessageBird\Exceptions\AuthenticateException $e) { | ||
// That means that your accessKey is unknown | ||
echo 'wrong login'; | ||
|
||
} catch (\Exception $e) { | ||
echo $e->getMessage(); | ||
} |
This file contains hidden or 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 |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?php | ||
|
||
require_once(__DIR__ . '/../autoload.php'); | ||
|
||
$MessageBird = new \MessageBird\Client('YOUR_ACCESS_KEY'); // Set your own API access key here. | ||
|
||
try { | ||
$ChatChannelResult = $MessageBird->chatchannels->read('0051af4c577e3eebbc3631n95680736'); // Set a channel id here | ||
var_dump($ChatChannelResult); | ||
|
||
} catch (\MessageBird\Exceptions\AuthenticateException $e) { | ||
// That means that your accessKey is unknown | ||
echo 'wrong login'; | ||
|
||
} catch (\Exception $e) { | ||
echo $e->getMessage(); | ||
} |
This file contains hidden or 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 |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?php | ||
|
||
require_once(__DIR__ . '/../autoload.php'); | ||
|
||
$MessageBird = new \MessageBird\Client('YOUR_ACCESS_KEY'); // Set your own API access key here. | ||
|
||
try { | ||
|
||
$deleted = $MessageBird->chatcontacts->delete('4affa2345d7fb22e373921n524df5409'); // Set a contact id | ||
var_dump('Deleted : ' . $deleted); | ||
|
||
} catch (\MessageBird\Exceptions\AuthenticateException $e) { | ||
// That means that your accessKey is unknown | ||
echo 'wrong login'; | ||
|
||
} catch (\Exception $e) { | ||
echo $e->getMessage(); | ||
} |
This file contains hidden or 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 |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?php | ||
|
||
require_once(__DIR__ . '/../autoload.php'); | ||
|
||
$MessageBird = new \MessageBird\Client('YOUR_ACCESS_KEY'); // Set your own API access key here. | ||
|
||
try { | ||
|
||
$ChatContactResult = $MessageBird->chatcontacts->getList(); | ||
var_dump($ChatContactResult); | ||
|
||
} catch (\MessageBird\Exceptions\AuthenticateException $e) { | ||
// That means that your accessKey is unknown | ||
echo 'wrong login'; | ||
|
||
} catch (\Exception $e) { | ||
echo $e->getMessage(); | ||
} |
This file contains hidden or 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 |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?php | ||
|
||
require_once(__DIR__ . '/../autoload.php'); | ||
|
||
$MessageBird = new \MessageBird\Client('YOUR_ACCESS_KEY'); // Set your own API access key here. | ||
|
||
try { | ||
|
||
$ChatContactResult = $MessageBird->chatcontacts->read('0051af4c577e3eebbc3631n95680736'); // Set a contact id here | ||
var_dump($ChatContactResult); | ||
|
||
} catch (\MessageBird\Exceptions\AuthenticateException $e) { | ||
// That means that your accessKey is unknown | ||
echo 'wrong login'; | ||
|
||
} catch (\Exception $e) { | ||
echo $e->getMessage(); | ||
} |
This file contains hidden or 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 |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<?php | ||
|
||
require_once(__DIR__ . '/../autoload.php'); | ||
|
||
$MessageBird = new \MessageBird\Client('YOUR_ACCESS_KEY'); // Set your own API access key here. | ||
|
||
$ChatMessage = new \MessageBird\Objects\Chat\Message(); | ||
$ChatMessage->contactId = '9d754dac577e3ff103cdf4n29856560'; | ||
$ChatMessage->payload = 'This is a test message to test the Chat API'; | ||
$ChatMessage->type = 'text'; | ||
|
||
|
||
try { | ||
$ChatMessageResult = $MessageBird->chatmessages->create($ChatMessage); | ||
var_dump($ChatMessageResult); | ||
|
||
} catch (\MessageBird\Exceptions\AuthenticateException $e) { | ||
// That means that your accessKey is unknown | ||
echo 'wrong login'; | ||
|
||
} catch (\MessageBird\Exceptions\BalanceException $e) { | ||
// That means that you are out of credits, so do something about it. | ||
echo 'no balance'; | ||
|
||
} catch (\Exception $e) { | ||
echo $e->getMessage(); | ||
} |
This file contains hidden or 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 |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?php | ||
|
||
require_once(__DIR__ . '/../autoload.php'); | ||
|
||
$MessageBird = new \MessageBird\Client('YOUR_ACCESS_KEY'); // Set your own API access key here. | ||
|
||
$ChatMessage = new \MessageBird\Objects\Chat\Message(); | ||
|
||
|
||
try { | ||
$ChatMessageResult = $MessageBird->chatmessages->getList(); | ||
var_dump($ChatMessageResult); | ||
|
||
} catch (\MessageBird\Exceptions\AuthenticateException $e) { | ||
// That means that your accessKey is unknown | ||
echo 'wrong login'; | ||
|
||
} catch (\Exception $e) { | ||
echo $e->getMessage(); | ||
} |
This file contains hidden or 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 |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?php | ||
|
||
require_once(__DIR__ . '/../autoload.php'); | ||
|
||
$MessageBird = new \MessageBird\Client('YOUR_ACCESS_KEY'); // Set your own API access key here. | ||
|
||
$ChatMessage = new \MessageBird\Objects\Chat\Message(); | ||
|
||
try { | ||
|
||
$MessageResult = $MessageBird->chatmessages->read('d6508edc578ca7641e3919n79796670'); // Set a message id here | ||
var_dump($MessageResult); | ||
|
||
} catch (\MessageBird\Exceptions\AuthenticateException $e) { | ||
// That means that your accessKey is unknown | ||
echo 'wrong login'; | ||
|
||
} catch (\Exception $e) { | ||
echo $e->getMessage(); | ||
} |
This file contains hidden or 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 |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?php | ||
|
||
require_once(__DIR__ . '/../autoload.php'); | ||
|
||
$MessageBird = new \MessageBird\Client('YOUR_ACCESS_KEY'); // Set your own API access key here. | ||
|
||
$ChatPlatform = new \MessageBird\Objects\Chat\Channel(); | ||
|
||
try { | ||
|
||
$ChatPlatformResult = $MessageBird->chatplatforms->getList(); | ||
var_dump($ChatPlatformResult); | ||
|
||
} catch (\MessageBird\Exceptions\AuthenticateException $e) { | ||
// That means that your accessKey is unknown | ||
echo 'wrong login'; | ||
|
||
} catch (\Exception $e) { | ||
echo $e->getMessage(); | ||
} |
This file contains hidden or 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
This file contains hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should this be updated during release somehow?