Telephony
extends AbstractApiResourceGroup
in package
Class Telephony
Tags
Table of Contents
Methods
- callEvent() : CallEventResponse
- Makes POST "/api/v5/telephony/call/event" request.
- callsUpload() : CallsUploadResponse
- Makes POST "/api/v5/telephony/calls/upload" request.
- manager() : ManagerResponse
- Makes GET "/api/v5/telephony/manager" request.
Methods
callEvent()
Makes POST "/api/v5/telephony/call/event" request.
public
callEvent(TelephonyCallEventRequest $request) : CallEventResponse
Example:
use RetailCrm\Api\Enum\Telephony\CallEventType;
use RetailCrm\Api\Factory\SimpleClientFactory;
use RetailCrm\Api\Interfaces\ApiExceptionInterface;
use RetailCrm\Api\Model\Entity\Telephony\CallEvent;
use RetailCrm\Api\Model\Request\Telephony\TelephonyCallEventRequest;
$client = SimpleClientFactory::createClient('https://test.retailcrm.pro', 'apiKey');
$event = new CallEvent();
$event->site = 'aliexpress';
$event->type = CallEventType::IN;
$event->phone = '88005553125';
$event->userIds = [27];
try {
$response = $client->telephony->callEvent(new TelephonyCallEventRequest($event));
} catch (ApiExceptionInterface $exception) {
echo sprintf(
'Error from RetailCRM API (status code: %d): %s',
$exception->getStatusCode(),
$exception->getMessage()
);
if (count($exception->getErrorResponse()->errors) > 0) {
echo PHP_EOL . 'Errors: ' . implode(', ', $exception->getErrorResponse()->errors);
}
return;
}
echo 'Response: ' . print_r($response, true);
Parameters
- $request : TelephonyCallEventRequest
Tags
Return values
CallEventResponsecallsUpload()
Makes POST "/api/v5/telephony/calls/upload" request.
public
callsUpload(TelephonyCallsUploadRequest $request) : CallsUploadResponse
Example:
use RetailCrm\Api\Enum\Telephony\CallEventType;
use RetailCrm\Api\Enum\Telephony\CallResult;
use RetailCrm\Api\Factory\SimpleClientFactory;
use RetailCrm\Api\Interfaces\ApiExceptionInterface;
use RetailCrm\Api\Model\Entity\Telephony\Call;
use RetailCrm\Api\Model\Request\Telephony\TelephonyCallsUploadRequest;
$client = SimpleClientFactory::createClient('https://test.retailcrm.pro', 'apiKey');
$call = new Call();
$call->externalId = 'test_call_external_id';
$call->date = new DateTime();
$call->type = CallEventType::IN;
$call->phone = '88005553125';
$call->userId = 27;
$call->result = CallResult::ANSWERED;
$call->duration = 60;
$call->durationWaiting = 10;
$call->recordUrl = 'https://examle.com/test.mp3';
$call->site = 'aliexpress';
try {
$response = $client->telephony->callsUpload(new TelephonyCallsUploadRequest([$call]));
} catch (ApiExceptionInterface $exception) {
echo sprintf(
'Error from RetailCRM API (status code: %d): %s',
$exception->getStatusCode(),
$exception->getMessage()
);
if (count($exception->getErrorResponse()->errors) > 0) {
echo PHP_EOL . 'Errors: ' . implode(', ', $exception->getErrorResponse()->errors);
}
return;
}
echo 'Response: ' . print_r($response, true);
Parameters
- $request : TelephonyCallsUploadRequest
Tags
Return values
CallsUploadResponsemanager()
Makes GET "/api/v5/telephony/manager" request.
public
manager(TelephonyManagerRequest $request) : ManagerResponse
Example:
use RetailCrm\Api\Enum\NumericBoolean;
use RetailCrm\Api\Factory\SimpleClientFactory;
use RetailCrm\Api\Interfaces\ApiExceptionInterface;
use RetailCrm\Api\Model\Request\Telephony\TelephonyManagerRequest;
$client = SimpleClientFactory::createClient('https://test.retailcrm.pro', 'apiKey');
$request = new TelephonyManagerRequest();
$request->phone = '88005553125';
$request->details = NumericBoolean::TRUE;
$request->ignoreStatus = NumericBoolean::TRUE;
try {
$response = $client->telephony->manager($request);
} catch (ApiExceptionInterface $exception) {
echo sprintf(
'Error from RetailCRM API (status code: %d): %s',
$exception->getStatusCode(),
$exception->getMessage()
);
if (count($exception->getErrorResponse()->errors) > 0) {
echo PHP_EOL . 'Errors: ' . implode(', ', $exception->getErrorResponse()->errors);
}
return;
}
echo 'Manager: ' . print_r($response->manager, true);
Parameters
- $request : TelephonyManagerRequest