@@ -11,6 +11,7 @@ class Client
11
11
{
12
12
13
13
const ENDPOINT = 'https://rest.messagebird.com ' ;
14
+ const CHATAPI_ENDPOINT = 'https://chat.messagebird.com/1 ' ;
14
15
15
16
const CLIENT_VERSION = '1.4.1 ' ;
16
17
@@ -59,20 +60,31 @@ class Client
59
60
*/
60
61
protected $ HttpClient ;
61
62
63
+ /**
64
+ * @var Common\HttpClient
65
+ */
66
+ protected $ ChatAPIHttpClient ;
67
+
62
68
/**
63
69
* @param string $accessKey
64
70
* @param Common\HttpClient $httpClient
65
71
*/
66
72
public function __construct ($ accessKey = null , Common \HttpClient $ httpClient = null )
67
73
{
68
74
if ($ httpClient == null ) {
75
+ $ this ->ChatAPIHttpClient = new Common \HttpClient (self ::CHATAPI_ENDPOINT );
69
76
$ this ->HttpClient = new Common \HttpClient (self ::ENDPOINT );
70
77
} else {
78
+ $ this ->ChatAPIHttpClient = $ httpClient ;
71
79
$ this ->HttpClient = $ httpClient ;
72
80
}
81
+
73
82
$ this ->HttpClient ->addUserAgentString ('MessageBird/ApiClient/ ' . self ::CLIENT_VERSION );
74
83
$ this ->HttpClient ->addUserAgentString ($ this ->getPhpVersion ());
75
84
85
+ $ this ->ChatAPIHttpClient ->addUserAgentString ('MessageBird/ApiClient/ ' . self ::CLIENT_VERSION );
86
+ $ this ->ChatAPIHttpClient ->addUserAgentString ($ this ->getPhpVersion ());
87
+
76
88
if ($ accessKey !== null ) {
77
89
$ this ->setAccessKey ($ accessKey );
78
90
}
@@ -84,6 +96,11 @@ public function __construct($accessKey = null, Common\HttpClient $httpClient = n
84
96
$ this ->voicemessages = new Resources \VoiceMessage ($ this ->HttpClient );
85
97
$ this ->lookup = new Resources \Lookup ($ this ->HttpClient );
86
98
$ this ->lookupHlr = new Resources \LookupHlr ($ this ->HttpClient );
99
+ $ this ->chatmessages = new Resources \Chat \Message ($ this ->ChatAPIHttpClient );
100
+ $ this ->chatchannels = new Resources \Chat \Channel ($ this ->ChatAPIHttpClient );
101
+ $ this ->chatplatforms = new Resources \Chat \Platform ($ this ->ChatAPIHttpClient );
102
+ $ this ->chatcontacts = new Resources \Chat \Contact ($ this ->ChatAPIHttpClient );
103
+
87
104
}
88
105
89
106
/**
@@ -92,6 +109,8 @@ public function __construct($accessKey = null, Common\HttpClient $httpClient = n
92
109
public function setAccessKey ($ accessKey )
93
110
{
94
111
$ Authentication = new Common \Authentication ($ accessKey );
112
+
113
+ $ this ->ChatAPIHttpClient ->setAuthentication ($ Authentication );
95
114
$ this ->HttpClient ->setAuthentication ($ Authentication );
96
115
}
97
116
0 commit comments