12
12
class Client
13
13
{
14
14
public const ENDPOINT = 'https://rest.messagebird.com ' ;
15
- public const CHATAPI_ENDPOINT = 'https://chat.messagebird.com/1 ' ;
16
15
public const CONVERSATIONSAPI_ENDPOINT = 'https://conversations.messagebird.com/v1 ' ;
17
16
public const VOICEAPI_ENDPOINT = 'https://voice.messagebird.com ' ;
18
17
public const PARTNER_ACCOUNT_ENDPOINT = 'https://partner-accounts.messagebird.com ' ;
@@ -67,22 +66,6 @@ class Client
67
66
* @var Resources\MmsMessages
68
67
*/
69
68
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 ;
86
69
/**
87
70
* @var Resources\Voice\Calls
88
71
*/
@@ -144,11 +127,6 @@ class Client
144
127
*/
145
128
protected $ httpClient ;
146
129
147
- /**
148
- * @var Common\HttpClient
149
- */
150
- protected $ chatAPIHttpClient ;
151
-
152
130
/**
153
131
* @var Common\HttpClient
154
132
*/
@@ -169,25 +147,23 @@ class Client
169
147
*/
170
148
protected $ numbersAPIClient ;
171
149
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 = [])
176
151
{
177
152
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
+ );
183
160
$ this ->httpClient = new Common \HttpClient (self ::ENDPOINT );
184
161
$ this ->voiceAPIHttpClient = new Common \HttpClient (self ::VOICEAPI_ENDPOINT , 10 , 2 , [
185
162
'X-MessageBird-Version ' => '20170314 ' ,
186
163
]);
187
164
$ this ->partnerAccountClient = new Common \HttpClient (self ::PARTNER_ACCOUNT_ENDPOINT );
188
165
$ this ->numbersAPIClient = new Common \HttpClient (self ::NUMBERSAPI_ENDPOINT );
189
166
} else {
190
- $ this ->chatAPIHttpClient = $ httpClient ;
191
167
$ this ->conversationsAPIHttpClient = $ httpClient ;
192
168
$ this ->httpClient = $ httpClient ;
193
169
$ this ->voiceAPIHttpClient = $ httpClient ;
@@ -198,9 +174,6 @@ public function __construct($accessKey = null, Common\HttpClient $httpClient = n
198
174
$ this ->httpClient ->addUserAgentString ('MessageBird/ApiClient/ ' . self ::CLIENT_VERSION );
199
175
$ this ->httpClient ->addUserAgentString ($ this ->getPhpVersion ());
200
176
201
- $ this ->chatAPIHttpClient ->addUserAgentString ('MessageBird/ApiClient/ ' . self ::CLIENT_VERSION );
202
- $ this ->chatAPIHttpClient ->addUserAgentString ($ this ->getPhpVersion ());
203
-
204
177
$ this ->conversationsAPIHttpClient ->addUserAgentString ('MessageBird/ApiClient/ ' . self ::CLIENT_VERSION );
205
178
$ this ->conversationsAPIHttpClient ->addUserAgentString ($ this ->getPhpVersion ());
206
179
@@ -225,10 +198,6 @@ public function __construct($accessKey = null, Common\HttpClient $httpClient = n
225
198
$ this ->voicemessages = new Resources \VoiceMessage ($ this ->httpClient );
226
199
$ this ->lookup = new Resources \Lookup ($ this ->httpClient );
227
200
$ 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 );
232
201
$ this ->voiceCallFlows = new Resources \Voice \CallFlows ($ this ->voiceAPIHttpClient );
233
202
$ this ->voiceCalls = new Resources \Voice \Calls ($ this ->voiceAPIHttpClient );
234
203
$ this ->voiceLegs = new Resources \Voice \Legs ($ this ->voiceAPIHttpClient );
@@ -247,10 +216,7 @@ public function __construct($accessKey = null, Common\HttpClient $httpClient = n
247
216
$ this ->availablePhoneNumbers = new Resources \AvailablePhoneNumbers ($ this ->numbersAPIClient );
248
217
}
249
218
250
- /**
251
- * @return string
252
- */
253
- private function getPhpVersion ()
219
+ private function getPhpVersion (): string
254
220
{
255
221
if (!\defined ('PHP_VERSION_ID ' )) {
256
222
$ version = array_map ('intval ' , explode ('. ' , \PHP_VERSION ));
@@ -267,7 +233,6 @@ public function setAccessKey($accessKey): void
267
233
{
268
234
$ authentication = new Common \Authentication ($ accessKey );
269
235
270
- $ this ->chatAPIHttpClient ->setAuthentication ($ authentication );
271
236
$ this ->conversationsAPIHttpClient ->setAuthentication ($ authentication );
272
237
$ this ->httpClient ->setAuthentication ($ authentication );
273
238
$ this ->voiceAPIHttpClient ->setAuthentication ($ authentication );
0 commit comments