ChatAPIHttpClient = new Common\HttpClient(self::CHATAPI_ENDPOINT); $this->HttpClient = new Common\HttpClient(self::ENDPOINT); } else { $this->ChatAPIHttpClient = $httpClient; $this->HttpClient = $httpClient; } $this->HttpClient->addUserAgentString('MessageBird/ApiClient/' . self::CLIENT_VERSION); $this->HttpClient->addUserAgentString($this->getPhpVersion()); $this->ChatAPIHttpClient->addUserAgentString('MessageBird/ApiClient/' . self::CLIENT_VERSION); $this->ChatAPIHttpClient->addUserAgentString($this->getPhpVersion()); if ($accessKey !== null) { $this->setAccessKey($accessKey); } $this->messages = new Resources\Messages($this->HttpClient); $this->hlr = new Resources\Hlr($this->HttpClient); $this->verify = new Resources\Verify($this->HttpClient); $this->balance = new Resources\Balance($this->HttpClient); $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); } /** * @param $accessKey */ public function setAccessKey ($accessKey) { $Authentication = new Common\Authentication($accessKey); $this->ChatAPIHttpClient->setAuthentication($Authentication); $this->HttpClient->setAuthentication($Authentication); } /** * @return string */ private function getPhpVersion() { if (!defined('PHP_VERSION_ID')) { $version = explode('.', PHP_VERSION); define('PHP_VERSION_ID', $version[0] * 10000 + $version[1] * 100 + $version[2]); } return 'PHP/' . PHP_VERSION_ID; } }