Skip to content

Commit c95a6ca

Browse files
author
Alexandru Bucur
committed
wip
1 parent 93a7731 commit c95a6ca

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

81 files changed

+566
-1608
lines changed

examples/chatchannels-create.php

Lines changed: 0 additions & 31 deletions
This file was deleted.

examples/chatchannels-delete.php

Lines changed: 0 additions & 15 deletions
This file was deleted.

examples/chatchannels-list.php

Lines changed: 0 additions & 15 deletions
This file was deleted.

examples/chatchannels-update.php

Lines changed: 0 additions & 19 deletions
This file was deleted.

examples/chatchannels-view.php

Lines changed: 0 additions & 15 deletions
This file was deleted.

examples/chatcontacts-delete.php

Lines changed: 0 additions & 15 deletions
This file was deleted.

examples/chatcontacts-list.php

Lines changed: 0 additions & 15 deletions
This file was deleted.

examples/chatcontacts-view.php

Lines changed: 0 additions & 15 deletions
This file was deleted.

examples/chatmessages-create.php

Lines changed: 0 additions & 23 deletions
This file was deleted.

examples/chatmessages-list.php

Lines changed: 0 additions & 17 deletions
This file was deleted.

examples/chatmessages-view.php

Lines changed: 0 additions & 17 deletions
This file was deleted.

examples/chatplatforms-list.php

Lines changed: 0 additions & 17 deletions
This file was deleted.

src/MessageBird/Client.php

Lines changed: 9 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
class Client
1313
{
1414
public const ENDPOINT = 'https://rest.messagebird.com';
15-
public const CHATAPI_ENDPOINT = 'https://chat.messagebird.com/1';
1615
public const CONVERSATIONSAPI_ENDPOINT = 'https://conversations.messagebird.com/v1';
1716
public const VOICEAPI_ENDPOINT = 'https://voice.messagebird.com';
1817
public const PARTNER_ACCOUNT_ENDPOINT = 'https://partner-accounts.messagebird.com';
@@ -67,22 +66,6 @@ class Client
6766
* @var Resources\MmsMessages
6867
*/
6968
public $mmsMessages;
70-
/**
71-
* @var Resources\Chat\Message
72-
*/
73-
public $chatMessages;
74-
/**
75-
* @var Resources\Chat\Channel
76-
*/
77-
public $chatChannels;
78-
/**
79-
* @var Resources\Chat\Platform
80-
*/
81-
public $chatPlatforms;
82-
/**
83-
* @var Resources\Chat\Contact
84-
*/
85-
public $chatContacts;
8669
/**
8770
* @var Resources\Voice\Calls
8871
*/
@@ -144,11 +127,6 @@ class Client
144127
*/
145128
protected $httpClient;
146129

147-
/**
148-
* @var Common\HttpClient
149-
*/
150-
protected $chatAPIHttpClient;
151-
152130
/**
153131
* @var Common\HttpClient
154132
*/
@@ -169,25 +147,23 @@ class Client
169147
*/
170148
protected $numbersAPIClient;
171149

172-
/**
173-
* @param string $accessKey
174-
*/
175-
public function __construct($accessKey = null, Common\HttpClient $httpClient = null, array $config = [])
150+
public function __construct(?string $accessKey = null, Common\HttpClient $httpClient = null, array $config = [])
176151
{
177152
if ($httpClient === null) {
178-
$this->chatAPIHttpClient = new Common\HttpClient(self::CHATAPI_ENDPOINT);
179-
$this->conversationsAPIHttpClient = new Common\HttpClient(\in_array(
180-
self::ENABLE_CONVERSATIONSAPI_WHATSAPP_SANDBOX,
181-
$config
182-
) ? self::CONVERSATIONSAPI_WHATSAPP_SANDBOX_ENDPOINT : self::CONVERSATIONSAPI_ENDPOINT);
153+
$this->conversationsAPIHttpClient = new Common\HttpClient(
154+
\in_array(
155+
self::ENABLE_CONVERSATIONSAPI_WHATSAPP_SANDBOX,
156+
$config,
157+
true
158+
) ? self::CONVERSATIONSAPI_WHATSAPP_SANDBOX_ENDPOINT : self::CONVERSATIONSAPI_ENDPOINT
159+
);
183160
$this->httpClient = new Common\HttpClient(self::ENDPOINT);
184161
$this->voiceAPIHttpClient = new Common\HttpClient(self::VOICEAPI_ENDPOINT, 10, 2, [
185162
'X-MessageBird-Version' => '20170314',
186163
]);
187164
$this->partnerAccountClient = new Common\HttpClient(self::PARTNER_ACCOUNT_ENDPOINT);
188165
$this->numbersAPIClient = new Common\HttpClient(self::NUMBERSAPI_ENDPOINT);
189166
} else {
190-
$this->chatAPIHttpClient = $httpClient;
191167
$this->conversationsAPIHttpClient = $httpClient;
192168
$this->httpClient = $httpClient;
193169
$this->voiceAPIHttpClient = $httpClient;
@@ -198,9 +174,6 @@ public function __construct($accessKey = null, Common\HttpClient $httpClient = n
198174
$this->httpClient->addUserAgentString('MessageBird/ApiClient/' . self::CLIENT_VERSION);
199175
$this->httpClient->addUserAgentString($this->getPhpVersion());
200176

201-
$this->chatAPIHttpClient->addUserAgentString('MessageBird/ApiClient/' . self::CLIENT_VERSION);
202-
$this->chatAPIHttpClient->addUserAgentString($this->getPhpVersion());
203-
204177
$this->conversationsAPIHttpClient->addUserAgentString('MessageBird/ApiClient/' . self::CLIENT_VERSION);
205178
$this->conversationsAPIHttpClient->addUserAgentString($this->getPhpVersion());
206179

@@ -225,10 +198,6 @@ public function __construct($accessKey = null, Common\HttpClient $httpClient = n
225198
$this->voicemessages = new Resources\VoiceMessage($this->httpClient);
226199
$this->lookup = new Resources\Lookup($this->httpClient);
227200
$this->lookupHlr = new Resources\LookupHlr($this->httpClient);
228-
$this->chatMessages = new Resources\Chat\Message($this->chatAPIHttpClient);
229-
$this->chatChannels = new Resources\Chat\Channel($this->chatAPIHttpClient);
230-
$this->chatPlatforms = new Resources\Chat\Platform($this->chatAPIHttpClient);
231-
$this->chatContacts = new Resources\Chat\Contact($this->chatAPIHttpClient);
232201
$this->voiceCallFlows = new Resources\Voice\CallFlows($this->voiceAPIHttpClient);
233202
$this->voiceCalls = new Resources\Voice\Calls($this->voiceAPIHttpClient);
234203
$this->voiceLegs = new Resources\Voice\Legs($this->voiceAPIHttpClient);
@@ -247,10 +216,7 @@ public function __construct($accessKey = null, Common\HttpClient $httpClient = n
247216
$this->availablePhoneNumbers = new Resources\AvailablePhoneNumbers($this->numbersAPIClient);
248217
}
249218

250-
/**
251-
* @return string
252-
*/
253-
private function getPhpVersion()
219+
private function getPhpVersion(): string
254220
{
255221
if (!\defined('PHP_VERSION_ID')) {
256222
$version = array_map('intval', explode('.', \PHP_VERSION));
@@ -267,7 +233,6 @@ public function setAccessKey($accessKey): void
267233
{
268234
$authentication = new Common\Authentication($accessKey);
269235

270-
$this->chatAPIHttpClient->setAuthentication($authentication);
271236
$this->conversationsAPIHttpClient->setAuthentication($authentication);
272237
$this->httpClient->setAuthentication($authentication);
273238
$this->voiceAPIHttpClient->setAuthentication($authentication);

0 commit comments

Comments
 (0)