2016-04-10 00:46:08 +03:00
|
|
|
<?php
|
|
|
|
|
2016-07-22 01:01:47 +03:00
|
|
|
/**
|
|
|
|
* PHP version 5.3
|
|
|
|
*
|
|
|
|
* API client telephony test class
|
|
|
|
*
|
|
|
|
* @category RetailCrm
|
|
|
|
* @package RetailCrm
|
|
|
|
* @author RetailCrm <integration@retailcrm.ru>
|
|
|
|
* @license https://opensource.org/licenses/MIT MIT License
|
2017-06-12 23:58:56 +03:00
|
|
|
* @link http://www.retailcrm.ru/docs/Developers/ApiVersion5
|
2016-07-22 01:01:47 +03:00
|
|
|
*/
|
|
|
|
|
2016-04-10 00:46:08 +03:00
|
|
|
namespace RetailCrm\Tests;
|
|
|
|
|
|
|
|
use RetailCrm\Test\TestCase;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Class ApiClientTelephonyTest
|
|
|
|
* @category RetailCrm
|
|
|
|
* @package RetailCrm\Tests
|
|
|
|
* @author RetailCrm <integration@retailcrm.ru>
|
|
|
|
* @license https://opensource.org/licenses/MIT MIT License
|
2017-06-12 23:58:56 +03:00
|
|
|
* @link http://www.retailcrm.ru/docs/Developers/ApiVersion5
|
2016-04-10 00:46:08 +03:00
|
|
|
*/
|
|
|
|
class ApiClientTelephonyTest extends TestCase
|
|
|
|
{
|
2016-07-22 01:01:47 +03:00
|
|
|
|
|
|
|
const TEL_CODE = 'telephony-code';
|
|
|
|
const TEL_CLIENT = '123';
|
|
|
|
const TEL_IMAGE = 'http://www.mec.ph/horizon/wp-content/uploads/2011/11/telephony.svg';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Settings Edit test
|
|
|
|
*
|
|
|
|
* @group telephony
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function testTelephonySettingsEdit()
|
|
|
|
{
|
|
|
|
$client = static::getApiClient();
|
|
|
|
|
|
|
|
$response = $client->telephonySettingsEdit(
|
|
|
|
self::TEL_CODE,
|
|
|
|
self::TEL_CLIENT,
|
|
|
|
true,
|
|
|
|
'TestTelephony',
|
|
|
|
false,
|
|
|
|
self::TEL_IMAGE,
|
|
|
|
array(array('userId' => $_SERVER['CRM_USER_ID'], 'code' => '101')),
|
|
|
|
array(array('siteCode' => 'api-client-php', 'externalPhone' => '+74950000000'))
|
|
|
|
);
|
|
|
|
|
2017-06-12 23:58:56 +03:00
|
|
|
static::assertInstanceOf('RetailCrm\Response\ApiResponse', $response);
|
|
|
|
static::assertTrue(in_array($response->getStatusCode(), array(200, 201)));
|
|
|
|
static::assertTrue($response->isSuccessful());
|
2016-07-22 01:01:47 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Settings Get test
|
|
|
|
*
|
|
|
|
* @group telephony
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function testTelephonySettingsGet()
|
|
|
|
{
|
|
|
|
$client = static::getApiClient();
|
|
|
|
|
|
|
|
$response = $client->telephonySettingsGet(self::TEL_CODE);
|
2017-06-12 23:58:56 +03:00
|
|
|
static::assertInstanceOf('RetailCrm\Response\ApiResponse', $response);
|
|
|
|
static::assertEquals(200, $response->getStatusCode());
|
|
|
|
static::assertTrue($response->isSuccessful());
|
2016-07-22 01:01:47 +03:00
|
|
|
}
|
|
|
|
|
2016-04-10 00:46:08 +03:00
|
|
|
/**
|
2016-07-22 01:01:47 +03:00
|
|
|
* Event test
|
2016-04-10 00:46:08 +03:00
|
|
|
*
|
2016-07-22 01:01:47 +03:00
|
|
|
* @group telephony
|
2016-04-10 00:46:08 +03:00
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
2016-07-22 01:01:47 +03:00
|
|
|
public function testTelephonyEvent()
|
2016-04-10 00:46:08 +03:00
|
|
|
{
|
|
|
|
$client = static::getApiClient();
|
|
|
|
|
2016-07-22 01:01:47 +03:00
|
|
|
$response = $client->telephonyCallEvent(
|
|
|
|
'+79999999999',
|
|
|
|
'in',
|
|
|
|
array('101'),
|
|
|
|
'failed',
|
|
|
|
'+74950000000'
|
|
|
|
|
|
|
|
);
|
|
|
|
|
2017-06-12 23:58:56 +03:00
|
|
|
static::assertInstanceOf('RetailCrm\Response\ApiResponse', $response);
|
|
|
|
static::assertEquals(200, $response->getStatusCode());
|
|
|
|
static::assertTrue($response->isSuccessful());
|
2016-07-22 01:01:47 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Upload test
|
|
|
|
*
|
|
|
|
* @group telephony
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function testTelephonyUpload()
|
|
|
|
{
|
|
|
|
$client = static::getApiClient();
|
2016-04-10 00:46:08 +03:00
|
|
|
|
2016-07-22 01:01:47 +03:00
|
|
|
$response = $client->telephonyCallsUpload(
|
|
|
|
array(
|
|
|
|
array(
|
|
|
|
'date' => '2016-07-22 00:18:00',
|
|
|
|
'type' => 'in',
|
|
|
|
'phone' => '+79999999999',
|
|
|
|
'code' => '101',
|
|
|
|
'result' => 'answered',
|
2017-06-12 23:58:56 +03:00
|
|
|
'externalId' => rand(10, 100),
|
|
|
|
'recordUrl' => 'http://download.retailcrm.pro/api-client-files/beep1.mp3'
|
2016-07-22 01:01:47 +03:00
|
|
|
),
|
|
|
|
array(
|
|
|
|
'date' => '2016-07-22 00:24:00',
|
|
|
|
'type' => 'in',
|
|
|
|
'phone' => '+79999999999',
|
|
|
|
'code' => '101',
|
|
|
|
'result' => 'answered',
|
2017-06-12 23:58:56 +03:00
|
|
|
'externalId' => rand(10, 100),
|
|
|
|
'recordUrl' => 'http://download.retailcrm.pro/api-client-files/beep2.mp3'
|
2016-07-22 01:01:47 +03:00
|
|
|
)
|
|
|
|
)
|
2016-04-10 00:46:08 +03:00
|
|
|
);
|
|
|
|
|
2017-06-12 23:58:56 +03:00
|
|
|
static::assertInstanceOf('RetailCrm\Response\ApiResponse', $response);
|
|
|
|
static::assertEquals(200, $response->getStatusCode());
|
|
|
|
static::assertTrue($response->isSuccessful());
|
2016-07-22 01:01:47 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Manager test
|
|
|
|
*
|
|
|
|
* @group telephony
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function testTelephonyManager()
|
|
|
|
{
|
|
|
|
$client = static::getApiClient();
|
|
|
|
|
|
|
|
$response = $client->telephonyCallManager('+79999999999', 1);
|
|
|
|
|
2017-06-12 23:58:56 +03:00
|
|
|
static::assertInstanceOf('RetailCrm\Response\ApiResponse', $response);
|
|
|
|
static::assertEquals(200, $response->getStatusCode());
|
|
|
|
static::assertTrue($response->isSuccessful());
|
2016-04-10 00:46:08 +03:00
|
|
|
}
|
|
|
|
}
|