* @license https://opensource.org/licenses/MIT MIT License * @link http://www.retailcrm.ru/docs/Developers/ApiVersion5 */ namespace RetailCrm\Methods\V3; /** * PHP version 5.4 * * Telephony class * * @category RetailCrm * @package RetailCrm * @author RetailCrm * @license https://opensource.org/licenses/MIT MIT License * @link http://www.retailcrm.ru/docs/Developers/ApiVersion5 */ trait Telephony { /** * Get telephony settings * * @param string $code * * @throws \RetailCrm\Exception\InvalidJsonException * @throws \RetailCrm\Exception\CurlException * @throws \InvalidArgumentException * * @return \RetailCrm\Response\ApiResponse */ public function telephonySettingsGet($code) { if (empty($code)) { throw new \InvalidArgumentException('Parameter `code` must be set'); } /* @noinspection PhpUndefinedMethodInspection */ return $this->client->makeRequest( "/telephony/setting/$code", "GET" ); } /** * Call event * * @param string $phone phone number * @param string $type call type * @param array $codes * @param string $hangupStatus * @param string $externalPhone * @param array $webAnalyticsData * * @return \RetailCrm\Response\ApiResponse * @internal param string $code additional phone code * @internal param string $status call status * */ public function telephonyCallEvent( $phone, $type, $codes, $hangupStatus = null, $externalPhone = null, $webAnalyticsData = [] ) { if (!isset($phone)) { throw new \InvalidArgumentException('Phone number must be set'); } if (!isset($type)) { throw new \InvalidArgumentException('Type must be set (in|out|hangup)'); } if (empty($codes)) { throw new \InvalidArgumentException('Codes array must be set'); } $parameters['phone'] = $phone; $parameters['type'] = $type; $parameters['codes'] = $codes; $parameters['hangupStatus'] = $hangupStatus; $parameters['callExternalId'] = $externalPhone; $parameters['webAnalyticsData'] = $webAnalyticsData; /* @noinspection PhpUndefinedMethodInspection */ return $this->client->makeRequest( '/telephony/call/event', "POST", ['event' => json_encode($parameters)] ); } /** * Upload calls * * @param array $calls calls data * * @throws \InvalidArgumentException * @throws \RetailCrm\Exception\CurlException * @throws \RetailCrm\Exception\InvalidJsonException * * @return \RetailCrm\Response\ApiResponse */ public function telephonyCallsUpload(array $calls) { if (!count($calls)) { throw new \InvalidArgumentException( 'Parameter `calls` must contains array of the calls' ); } /* @noinspection PhpUndefinedMethodInspection */ return $this->client->makeRequest( '/telephony/calls/upload', "POST", ['calls' => json_encode($calls)] ); } /** * Get call manager * * @param string $phone phone number * @param bool $details detailed information * * @throws \InvalidArgumentException * @throws \RetailCrm\Exception\CurlException * @throws \RetailCrm\Exception\InvalidJsonException * * @return \RetailCrm\Response\ApiResponse */ public function telephonyCallManager($phone, $details) { if (!isset($phone)) { throw new \InvalidArgumentException('Phone number must be set'); } $parameters['phone'] = $phone; $parameters['details'] = isset($details) ? $details : 0; /* @noinspection PhpUndefinedMethodInspection */ return $this->client->makeRequest( '/telephony/manager', "GET", $parameters ); } }