diff --git a/composer.json b/composer.json index 7f0e6c7f..cf79c302 100644 --- a/composer.json +++ b/composer.json @@ -1,7 +1,6 @@ { "name": "messagebird/php-rest-api", "description": "MessageBird REST API client for PHP", - "version": "1.4.1", "type": "library", "homepage": "https://github.com/messagebird/php-rest-api", "license": "BSD-2-Clause", diff --git a/examples/chatchannels-create.php b/examples/chatchannels-create.php index 9d825b92..f5359379 100644 --- a/examples/chatchannels-create.php +++ b/examples/chatchannels-create.php @@ -21,7 +21,7 @@ ); try { - $ChatChannelResult = $MessageBird->chatchannels->create($ChatChannel); + $ChatChannelResult = $MessageBird->chatChannels->create($ChatChannel); var_dump($ChatChannelResult); } catch (\MessageBird\Exceptions\AuthenticateException $e) { diff --git a/examples/chatchannels-delete.php b/examples/chatchannels-delete.php index b26ee67e..5fe89f12 100644 --- a/examples/chatchannels-delete.php +++ b/examples/chatchannels-delete.php @@ -5,8 +5,7 @@ $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 + $deleted = $MessageBird->chatChannels->delete('4affac2c577fb22e373921n52675409'); // Set a message id here var_dump('Deleted: ' . $deleted); } catch (\MessageBird\Exceptions\AuthenticateException $e) { diff --git a/examples/chatchannels-list.php b/examples/chatchannels-list.php index 766b462a..b36bd214 100644 --- a/examples/chatchannels-list.php +++ b/examples/chatchannels-list.php @@ -5,7 +5,7 @@ $MessageBird = new \MessageBird\Client('YOUR_ACCESS_KEY'); // Set your own API access key here. try { - $ChatChannelResult = $MessageBird->chatchannels->getList(); + $ChatChannelResult = $MessageBird->chatChannels->getList(); var_dump($ChatChannelResult); } catch (\MessageBird\Exceptions\AuthenticateException $e) { diff --git a/examples/chatchannels-update.php b/examples/chatchannels-update.php index 5f2c9d01..58492e9f 100644 --- a/examples/chatchannels-update.php +++ b/examples/chatchannels-update.php @@ -8,10 +8,8 @@ $ChatChannel->name = 'New name'; $ChatChannel->callbackUrl = 'http://newurl.dev'; - try { - - $ChatChannelResult = $MessageBird->chatchannels->update($ChatChannel, '331af4c577e3asbbc3631455680736'); + $ChatChannelResult = $MessageBird->chatChannels->update($ChatChannel, '331af4c577e3asbbc3631455680736'); var_dump($ChatChannelResult); } catch (\MessageBird\Exceptions\AuthenticateException $e) { diff --git a/examples/chatchannels-view.php b/examples/chatchannels-view.php index aefd99aa..71609a55 100644 --- a/examples/chatchannels-view.php +++ b/examples/chatchannels-view.php @@ -5,7 +5,7 @@ $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 + $ChatChannelResult = $MessageBird->chatChannels->read('0051af4c577e3eebbc3631n95680736'); // Set a channel id here var_dump($ChatChannelResult); } catch (\MessageBird\Exceptions\AuthenticateException $e) { diff --git a/examples/chatcontacts-delete.php b/examples/chatcontacts-delete.php index acedb94c..5598705e 100644 --- a/examples/chatcontacts-delete.php +++ b/examples/chatcontacts-delete.php @@ -5,8 +5,7 @@ $MessageBird = new \MessageBird\Client('YOUR_ACCESS_KEY'); // Set your own API access key here. try { - - $deleted = $MessageBird->chatcontacts->delete('4affa2345d7fb22e373921n524df5409'); // Set a contact id + $deleted = $MessageBird->chatContacts->delete('4affa2345d7fb22e373921n524df5409'); // Set a contact id var_dump('Deleted : ' . $deleted); } catch (\MessageBird\Exceptions\AuthenticateException $e) { diff --git a/examples/chatcontacts-list.php b/examples/chatcontacts-list.php index b44ee6fd..9abfa3de 100644 --- a/examples/chatcontacts-list.php +++ b/examples/chatcontacts-list.php @@ -5,8 +5,7 @@ $MessageBird = new \MessageBird\Client('YOUR_ACCESS_KEY'); // Set your own API access key here. try { - - $ChatContactResult = $MessageBird->chatcontacts->getList(); + $ChatContactResult = $MessageBird->chatContacts->getList(); var_dump($ChatContactResult); } catch (\MessageBird\Exceptions\AuthenticateException $e) { diff --git a/examples/chatcontacts-view.php b/examples/chatcontacts-view.php index 4f62ac3d..7366c6ce 100644 --- a/examples/chatcontacts-view.php +++ b/examples/chatcontacts-view.php @@ -5,8 +5,7 @@ $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 + $ChatContactResult = $MessageBird->chatContacts->read('0051af4c577e3eebbc3631n95680736'); // Set a contact id here var_dump($ChatContactResult); } catch (\MessageBird\Exceptions\AuthenticateException $e) { diff --git a/examples/chatmessages-create.php b/examples/chatmessages-create.php index 55b98061..c5995a3a 100644 --- a/examples/chatmessages-create.php +++ b/examples/chatmessages-create.php @@ -9,9 +9,8 @@ $ChatMessage->payload = 'This is a test message to test the Chat API'; $ChatMessage->type = 'text'; - try { - $ChatMessageResult = $MessageBird->chatmessages->create($ChatMessage); + $ChatMessageResult = $MessageBird->chatMessages->create($ChatMessage); var_dump($ChatMessageResult); } catch (\MessageBird\Exceptions\AuthenticateException $e) { diff --git a/examples/chatmessages-list.php b/examples/chatmessages-list.php index fd193b2f..c6e6235b 100644 --- a/examples/chatmessages-list.php +++ b/examples/chatmessages-list.php @@ -6,9 +6,8 @@ $ChatMessage = new \MessageBird\Objects\Chat\Message(); - try { - $ChatMessageResult = $MessageBird->chatmessages->getList(); + $ChatMessageResult = $MessageBird->chatMessages->getList(); var_dump($ChatMessageResult); } catch (\MessageBird\Exceptions\AuthenticateException $e) { diff --git a/examples/chatmessages-view.php b/examples/chatmessages-view.php index 2356d0c7..1bd00fa5 100644 --- a/examples/chatmessages-view.php +++ b/examples/chatmessages-view.php @@ -7,8 +7,7 @@ $ChatMessage = new \MessageBird\Objects\Chat\Message(); try { - - $MessageResult = $MessageBird->chatmessages->read('d6508edc578ca7641e3919n79796670'); // Set a message id here + $MessageResult = $MessageBird->chatMessages->read('d6508edc578ca7641e3919n79796670'); // Set a message id here var_dump($MessageResult); } catch (\MessageBird\Exceptions\AuthenticateException $e) { diff --git a/examples/chatplatforms-list.php b/examples/chatplatforms-list.php index 828f5965..85e76d54 100644 --- a/examples/chatplatforms-list.php +++ b/examples/chatplatforms-list.php @@ -7,8 +7,7 @@ $ChatPlatform = new \MessageBird\Objects\Chat\Channel(); try { - - $ChatPlatformResult = $MessageBird->chatplatforms->getList(); + $ChatPlatformResult = $MessageBird->chatPlatforms->getList(); var_dump($ChatPlatformResult); } catch (\MessageBird\Exceptions\AuthenticateException $e) { diff --git a/src/MessageBird/Client.php b/src/MessageBird/Client.php index 2d8d10b0..b239c861 100644 --- a/src/MessageBird/Client.php +++ b/src/MessageBird/Client.php @@ -13,7 +13,7 @@ class Client const ENDPOINT = 'https://rest.messagebird.com'; const CHATAPI_ENDPOINT = 'https://chat.messagebird.com/1'; - const CLIENT_VERSION = '1.4.1'; + const CLIENT_VERSION = '1.5.0'; /** * @var string @@ -55,6 +55,23 @@ class Client */ public $lookupHlr; + /** + * @var Resources\Chat\Message + */ + public $chatMessages; + /** + * @var Resources\Chat\Channel + */ + public $chatChannels; + /** + * @var Resources\Chat\Platform + */ + public $chatPlatforms; + /** + * @var Resources\Chat\Contact + */ + public $chatContacts; + /** * @var Common\HttpClient */ @@ -96,10 +113,10 @@ public function __construct($accessKey = null, Common\HttpClient $httpClient = n $this->voicemessages = new Resources\VoiceMessage($this->HttpClient); $this->lookup = new Resources\Lookup($this->HttpClient); $this->lookupHlr = new Resources\LookupHlr($this->HttpClient); - $this->chatmessages = new Resources\Chat\Message($this->ChatAPIHttpClient); - $this->chatchannels = new Resources\Chat\Channel($this->ChatAPIHttpClient); - $this->chatplatforms = new Resources\Chat\Platform($this->ChatAPIHttpClient); - $this->chatcontacts = new Resources\Chat\Contact($this->ChatAPIHttpClient); + $this->chatMessages = new Resources\Chat\Message($this->ChatAPIHttpClient); + $this->chatChannels = new Resources\Chat\Channel($this->ChatAPIHttpClient); + $this->chatPlatforms = new Resources\Chat\Platform($this->ChatAPIHttpClient); + $this->chatContacts = new Resources\Chat\Contact($this->ChatAPIHttpClient); } diff --git a/src/MessageBird/Objects/Chat/Channel.php b/src/MessageBird/Objects/Chat/Channel.php index 378635c5..f2f9f517 100644 --- a/src/MessageBird/Objects/Chat/Channel.php +++ b/src/MessageBird/Objects/Chat/Channel.php @@ -40,13 +40,6 @@ class Channel extends Base */ public $callbackUrl; - /** - * The endpoint of the action (platforms, messages, channels, contacts) - * - * @var string - */ - public $endpoint; - /** * A unique random ID which is created on the MessageBird platform and is returned upon creation of the object. * @@ -87,16 +80,4 @@ class Channel extends Base */ protected $_links = array(); - /** - * @param $object - * - * @return $this|void - */ - public function loadFromArray ($object) - { - parent::loadFromArray($object); - - return $this; - } - } \ No newline at end of file diff --git a/src/MessageBird/Objects/Chat/Contact.php b/src/MessageBird/Objects/Chat/Contact.php index 13399ef5..675901d9 100644 --- a/src/MessageBird/Objects/Chat/Contact.php +++ b/src/MessageBird/Objects/Chat/Contact.php @@ -68,16 +68,4 @@ class Contact extends Base */ protected $updatedAt; - /** - * @param $object - * - * @return $this|void - */ - public function loadFromArray ($object) - { - parent::loadFromArray($object); - - return $this; - } - } \ No newline at end of file diff --git a/src/MessageBird/Objects/Chat/Message.php b/src/MessageBird/Objects/Chat/Message.php index f0912967..f77fde23 100644 --- a/src/MessageBird/Objects/Chat/Message.php +++ b/src/MessageBird/Objects/Chat/Message.php @@ -34,13 +34,6 @@ class Message extends Base */ public $contactId; - /** - * The endpoint of the action (platforms, messages, channels, contacts) - * - * @var string - */ - public $endpoint; - /** * A unique random ID which is created on the MessageBird platform and is returned upon creation of the object. * @@ -82,17 +75,6 @@ class Message extends Base */ protected $_links = array(); - /** - * @param $object - * - * @return $this|void - */ - public function loadFromArray ($object) - { - parent::loadFromArray($object); - - return $this; - } public function getId() { diff --git a/src/MessageBird/Objects/Chat/Platform.php b/src/MessageBird/Objects/Chat/Platform.php index bd0ea120..3713cc49 100644 --- a/src/MessageBird/Objects/Chat/Platform.php +++ b/src/MessageBird/Objects/Chat/Platform.php @@ -74,16 +74,4 @@ class Platform extends Base */ protected $_links; - /** - * @param $object - * - * @return $this|void - */ - public function loadFromArray($object) - { - parent::loadFromArray($object); - - return $this; - } - } \ No newline at end of file diff --git a/tests/integration/BaseTest.php b/tests/integration/BaseTest.php index b944a193..1280a0f9 100644 --- a/tests/integration/BaseTest.php +++ b/tests/integration/BaseTest.php @@ -14,10 +14,10 @@ public function testClientConstructor() $this->assertInstanceOf('MessageBird\Resources\Messages', $MessageBird->messages); $this->assertInstanceOf('MessageBird\Resources\VoiceMessage', $MessageBird->voicemessages); $this->assertInstanceOf('MessageBird\Resources\Verify', $MessageBird->verify); - $this->assertInstanceOf('MessageBird\Resources\Chat\Message', $MessageBird->chatmessages); - $this->assertInstanceOf('MessageBird\Resources\Chat\Platform', $MessageBird->chatplatforms); - $this->assertInstanceOf('MessageBird\Resources\Chat\Channel', $MessageBird->chatchannels); - $this->assertInstanceOf('MessageBird\Resources\Chat\Contact', $MessageBird->chatcontacts); + $this->assertInstanceOf('MessageBird\Resources\Chat\Message', $MessageBird->chatMessages); + $this->assertInstanceOf('MessageBird\Resources\Chat\Platform', $MessageBird->chatPlatforms); + $this->assertInstanceOf('MessageBird\Resources\Chat\Channel', $MessageBird->chatChannels); + $this->assertInstanceOf('MessageBird\Resources\Chat\Contact', $MessageBird->chatContacts); } diff --git a/tests/integration/chat/ChatTest.php b/tests/integration/chat/ChatTest.php index c8b90bcf..50c3ca71 100644 --- a/tests/integration/chat/ChatTest.php +++ b/tests/integration/chat/ChatTest.php @@ -9,32 +9,32 @@ public function setUp() public function testCreateChatMessage() { - $ChatMessage = new \MessageBird\Objects\Chat\Message(); + $ChatMessage = new \MessageBird\Objects\Chat\Message(); $ChatMessage->contactId = '9d754dac577e3ff103cdf4n29856560'; $ChatMessage->payload = 'This is a test message to test the Chat API'; $ChatMessage->type = 'text'; - $this->mockClient->expects($this->atLeastOnce())->method('performHttpRequest')->willReturn(array(200, '', '{"type":"text","payload":"This is a test message to test the Chat API","contactId":"9d754dac577e3ff103cdf4n29856560","endpoint":null}')); - $this->mockClient->expects($this->once())->method('performHttpRequest')->with("POST", 'messages', null, '{"type":"text","payload":"This is a test message to test the Chat API","contactId":"9d754dac577e3ff103cdf4n29856560","endpoint":null}'); - $this->client->chatmessages->create($ChatMessage); + $this->mockClient->expects($this->atLeastOnce())->method('performHttpRequest')->willReturn(array(200, '', '{"type":"text","payload":"This is a test message to test the Chat API","contactId":"9d754dac577e3ff103cdf4n29856560"}')); + $this->mockClient->expects($this->once())->method('performHttpRequest')->with("POST", 'messages', null, '{"type":"text","payload":"This is a test message to test the Chat API","contactId":"9d754dac577e3ff103cdf4n29856560"}'); + $this->client->chatMessages->create($ChatMessage); } /** - * @expectedException MessageBird\Exceptions\ServerException + * @expectedException MessageBird\Exceptions\ServerException */ public function testListChatMessage() { $this->mockClient->expects($this->once())->method('performHttpRequest')->with("GET", 'messages', array ('offset' => 100, 'limit' => 30), null); - $ChatMessageList = $this->client->chatmessages->getList(array ('offset' => 100, 'limit' => 30)); + $ChatMessageList = $this->client->chatMessages->getList(array ('offset' => 100, 'limit' => 30)); } /** - * @expectedException MessageBird\Exceptions\ServerException + * @expectedException MessageBird\Exceptions\ServerException */ public function testReadChatMessage() { $this->mockClient->expects($this->once())->method('performHttpRequest')->with("GET", 'messages/id', null, null); - $ChatMessageList = $this->client->chatmessages->read("id"); + $ChatMessageList = $this->client->chatMessages->read("id"); } @@ -50,91 +50,91 @@ public function testCreateChatChannel() 'token' => '1234566778:A34JT44Yr4amk234352et5hvRnHeAEHA' ); - $this->mockClient->expects($this->atLeastOnce())->method('performHttpRequest')->willReturn(array(200, '', '{"name":"Test Channel Telegram","platformId":"e84f332c5649a5f911e569n69330697","channelDetails":{"botName":"testBot","token":"1234566778:A34JT44Yr4amk234352et5hvRnHeAEHA"},"callbackUrl":null,"endpoint":null}')); - $this->mockClient->expects($this->once())->method('performHttpRequest')->with("POST", 'channels', null, '{"name":"Test Channel Telegram","platformId":"e84f332c5649a5f911e569n69330697","channelDetails":{"botName":"testBot","token":"1234566778:A34JT44Yr4amk234352et5hvRnHeAEHA"},"callbackUrl":null,"endpoint":null}'); - $this->client->chatchannels->create($ChatChannel); + $this->mockClient->expects($this->atLeastOnce())->method('performHttpRequest')->willReturn(array(200, '', '{"name":"Test Channel Telegram","platformId":"e84f332c5649a5f911e569n69330697","channelDetails":{"botName":"testBot","token":"1234566778:A34JT44Yr4amk234352et5hvRnHeAEHA"},"callbackUrl":null}')); + $this->mockClient->expects($this->once())->method('performHttpRequest')->with("POST", 'channels', null, '{"name":"Test Channel Telegram","platformId":"e84f332c5649a5f911e569n69330697","channelDetails":{"botName":"testBot","token":"1234566778:A34JT44Yr4amk234352et5hvRnHeAEHA"},"callbackUrl":null}'); + $this->client->chatChannels->create($ChatChannel); } /** - * @expectedException MessageBird\Exceptions\ServerException + * @expectedException MessageBird\Exceptions\ServerException */ public function testListChatChannels() { $this->mockClient->expects($this->once())->method('performHttpRequest')->with("GET", 'channels', array ('offset' => 100, 'limit' => 30), null); - $ChannelList = $this->client->chatchannels->getList(array ('offset' => 100, 'limit' => 30)); + $ChannelList = $this->client->chatChannels->getList(array ('offset' => 100, 'limit' => 30)); } /** - * @expectedException MessageBird\Exceptions\ServerException + * @expectedException MessageBird\Exceptions\ServerException */ public function testReadChatChannel() { $this->mockClient->expects($this->once())->method('performHttpRequest')->with("GET", 'channels/id', null, null); - $Channel = $this->client->chatchannels->read("id"); + $Channel = $this->client->chatChannels->read("id"); } /** - * @expectedException MessageBird\Exceptions\ServerException + * @expectedException MessageBird\Exceptions\ServerException */ public function testDeleteChannel() { $this->mockClient->expects($this->once())->method('performHttpRequest')->with("DELETE", 'channels/id', null, null); - $Channel = $this->client->chatchannels->delete("id"); + $Channel = $this->client->chatChannels->delete("id"); } public function testUpdateChatChannel() { - $ChatChannel = new \MessageBird\Objects\Chat\Channel(); + $ChatChannel = new \MessageBird\Objects\Chat\Channel(); $ChatChannel->name = '9d2345ac577e4f103cd3d4529856560'; $ChatChannel->callbackUrl = 'http://testurl.dev'; $this->mockClient->expects($this->atLeastOnce())->method('performHttpRequest')->willReturn(array(200, '', '{"name":"9d2345ac577e4f103cd3d4529856560","callbackUrl":"http:\/\/testurl.dev"}')); $this->mockClient->expects($this->once())->method('performHttpRequest')->with("PUT", 'channels/234agfgADFH2974gaADFH3hudf9h', null, '{"name":"9d2345ac577e4f103cd3d4529856560","callbackUrl":"http:\/\/testurl.dev"}'); - $this->client->chatchannels->update($ChatChannel,'234agfgADFH2974gaADFH3hudf9h'); + $this->client->chatChannels->update($ChatChannel,'234agfgADFH2974gaADFH3hudf9h'); } /** - * @expectedException MessageBird\Exceptions\ServerException + * @expectedException MessageBird\Exceptions\ServerException */ public function testListChatPlatforms() { $this->mockClient->expects($this->once())->method('performHttpRequest')->with("GET", 'platforms', array ('offset' => 100, 'limit' => 30), null); - $ChannelList = $this->client->chatplatforms->getList(array ('offset' => 100, 'limit' => 30)); + $ChannelList = $this->client->chatPlatforms->getList(array ('offset' => 100, 'limit' => 30)); } /** - * @expectedException MessageBird\Exceptions\ServerException + * @expectedException MessageBird\Exceptions\ServerException */ public function testReadChatPlatform() { $this->mockClient->expects($this->once())->method('performHttpRequest')->with("GET", 'platforms/id', null, null); - $Channel = $this->client->chatplatforms->read("id"); + $Channel = $this->client->chatPlatforms->read("id"); } /** - * @expectedException MessageBird\Exceptions\ServerException + * @expectedException MessageBird\Exceptions\ServerException */ public function testListChatContacts() { $this->mockClient->expects($this->once())->method('performHttpRequest')->with("GET", 'contacts', array ('offset' => 100, 'limit' => 30), null); - $ContactList = $this->client->chatcontacts->getList(array ('offset' => 100, 'limit' => 30)); + $ContactList = $this->client->chatContacts->getList(array ('offset' => 100, 'limit' => 30)); } /** - * @expectedException MessageBird\Exceptions\ServerException + * @expectedException MessageBird\Exceptions\ServerException */ public function testReadChatContact() { $this->mockClient->expects($this->once())->method('performHttpRequest')->with("GET", 'contacts/id', null, null); - $Contact = $this->client->chatcontacts->read("id"); + $Contact = $this->client->chatContacts->read("id"); } /** - * @expectedException MessageBird\Exceptions\ServerException + * @expectedException MessageBird\Exceptions\ServerException */ public function testDeleteContact() { $this->mockClient->expects($this->once())->method('performHttpRequest')->with("DELETE", 'contacts/id', null, null); - $contact = $this->client->chatcontacts->delete("id"); + $contact = $this->client->chatContacts->delete("id"); } }