Marketplace methods (#51)
This commit is contained in:
parent
c6c5f737bd
commit
440c7fcd8c
@ -46,6 +46,7 @@ class ApiVersion5 extends AbstractLoader
|
||||
use V5\Customers;
|
||||
use V5\CustomFields;
|
||||
use V5\Delivery;
|
||||
use V5\Module;
|
||||
use V5\Orders;
|
||||
use V5\Packs;
|
||||
use V5\References;
|
||||
|
@ -30,4 +30,20 @@ use RetailCrm\Methods\V4\Delivery as Previous;
|
||||
trait Delivery
|
||||
{
|
||||
use Previous;
|
||||
|
||||
/**
|
||||
* Get delivery settings
|
||||
*
|
||||
* @param string $code
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
* @throws \RetailCrm\Exception\CurlException
|
||||
* @throws \RetailCrm\Exception\InvalidJsonException
|
||||
*
|
||||
* @return \RetailCrm\Response\ApiResponse
|
||||
*/
|
||||
public function deliverySettingsGet($code)
|
||||
{
|
||||
throw new \InvalidArgumentException('This method is not available');
|
||||
}
|
||||
}
|
||||
|
80
lib/RetailCrm/Methods/V5/Module.php
Normal file
80
lib/RetailCrm/Methods/V5/Module.php
Normal file
@ -0,0 +1,80 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* PHP version 5.4
|
||||
*
|
||||
* Marketplace
|
||||
*
|
||||
* @category RetailCrm
|
||||
* @package RetailCrm
|
||||
* @author RetailCrm <integration@retailcrm.ru>
|
||||
* @license https://opensource.org/licenses/MIT MIT License
|
||||
* @link http://www.retailcrm.ru/docs/Developers/ApiVersion5
|
||||
*/
|
||||
|
||||
namespace RetailCrm\Methods\V5;
|
||||
|
||||
/**
|
||||
* PHP version 5.4
|
||||
*
|
||||
* Module class
|
||||
*
|
||||
* @category RetailCrm
|
||||
* @package RetailCrm
|
||||
* @author RetailCrm <integration@retailcrm.ru>
|
||||
* @license https://opensource.org/licenses/MIT MIT License
|
||||
* @link http://www.retailcrm.ru/docs/Developers/ApiVersion5
|
||||
*/
|
||||
trait Module
|
||||
{
|
||||
/**
|
||||
* Get module configuration
|
||||
*
|
||||
* @param string $code
|
||||
*
|
||||
* @throws \RetailCrm\Exception\InvalidJsonException
|
||||
* @throws \RetailCrm\Exception\CurlException
|
||||
* @throws \InvalidArgumentException
|
||||
*
|
||||
* @return \RetailCrm\Response\ApiResponse
|
||||
*/
|
||||
public function integrationModulesGet($code)
|
||||
{
|
||||
if (empty($code)) {
|
||||
throw new \InvalidArgumentException(
|
||||
'Parameter `code` must be set'
|
||||
);
|
||||
}
|
||||
|
||||
return $this->client->makeRequest(
|
||||
sprintf('/integration-modules/%s', $code),
|
||||
"GET"
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Edit module configuration
|
||||
*
|
||||
* @param array $configuration
|
||||
*
|
||||
* @throws \RetailCrm\Exception\InvalidJsonException
|
||||
* @throws \RetailCrm\Exception\CurlException
|
||||
* @throws \InvalidArgumentException
|
||||
*
|
||||
* @return \RetailCrm\Response\ApiResponse
|
||||
*/
|
||||
public function integrationModulesEdit(array $configuration)
|
||||
{
|
||||
if (!count($configuration) || empty($configuration['code'])) {
|
||||
throw new \InvalidArgumentException(
|
||||
'Parameter `configuration` must contains a data & configuration `code` must be set'
|
||||
);
|
||||
}
|
||||
|
||||
return $this->client->makeRequest(
|
||||
sprintf('/integration-modules/%s/edit', $configuration['code']),
|
||||
"POST",
|
||||
['integrationModule' => json_encode($configuration)]
|
||||
);
|
||||
}
|
||||
}
|
@ -31,6 +31,23 @@ trait Stores
|
||||
{
|
||||
use Previous;
|
||||
|
||||
/**
|
||||
* Get store settings
|
||||
*
|
||||
* @param string $code get settings code
|
||||
*
|
||||
* @return \RetailCrm\Response\ApiResponse
|
||||
* @throws \RetailCrm\Exception\InvalidJsonException
|
||||
* @throws \RetailCrm\Exception\CurlException
|
||||
* @throws \InvalidArgumentException
|
||||
*
|
||||
* @return \RetailCrm\Response\ApiResponse
|
||||
*/
|
||||
public function storeSettingsGet($code)
|
||||
{
|
||||
throw new \InvalidArgumentException('This method is not available');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get products groups
|
||||
*
|
||||
|
@ -30,4 +30,9 @@ use RetailCrm\Methods\V4\Telephony as Previous;
|
||||
trait Telephony
|
||||
{
|
||||
use Previous;
|
||||
|
||||
public function telephonySettingsGet($code)
|
||||
{
|
||||
throw new \InvalidArgumentException('This method is not available');
|
||||
}
|
||||
}
|
||||
|
@ -23,27 +23,30 @@ use RetailCrm\Test\TestCase;
|
||||
*/
|
||||
class ApiClientMarketplaceTest extends TestCase
|
||||
{
|
||||
const SNAME = 'Marketplace integration v5';
|
||||
const SCODE = 'integration_v5';
|
||||
const SERVICE_NAME = 'Marketplace integration v5';
|
||||
const SERVICE_CODE = 'integration_v5';
|
||||
|
||||
/**
|
||||
* @group marketplace_v5
|
||||
*/
|
||||
public function testConfigurationEdit()
|
||||
{
|
||||
$client = static::getApiClient(null, null, "v5");
|
||||
$client = static::getApiClient();
|
||||
|
||||
$response = $client->request->marketplaceSettingsEdit(
|
||||
$response = $client->request->integrationModulesEdit(
|
||||
[
|
||||
'name' => self::SNAME,
|
||||
'code' => self::SCODE,
|
||||
'name' => self::SERVICE_NAME,
|
||||
'code' => self::SERVICE_CODE,
|
||||
'clientId' => uniqid(),
|
||||
'logo' => 'http://download.retailcrm.pro/logos/setup.svg',
|
||||
'active' => 'true'
|
||||
]
|
||||
);
|
||||
|
||||
static::assertInstanceOf('RetailCrm\Response\ApiResponse', $response);
|
||||
static::assertTrue(in_array($response->getStatusCode(), [200, 201]));
|
||||
static::assertEquals($response->getStatusCode(), 200);
|
||||
static::assertTrue($response->isSuccessful());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -31,7 +31,7 @@ class ApiClientStoreTest extends TestCase
|
||||
const SCODE = 'test-store-v5';
|
||||
|
||||
/**
|
||||
* @group store_v4
|
||||
* @group store_v5
|
||||
*/
|
||||
public function testStoreCreate()
|
||||
{
|
||||
@ -45,7 +45,7 @@ class ApiClientStoreTest extends TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* @group store_v4
|
||||
* @group store_v5
|
||||
*/
|
||||
public function testStoreInventories()
|
||||
{
|
||||
@ -63,7 +63,7 @@ class ApiClientStoreTest extends TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* @group store_v4
|
||||
* @group store_v5
|
||||
* @expectedException \InvalidArgumentException
|
||||
*/
|
||||
public function testInventoriesException()
|
||||
@ -74,7 +74,7 @@ class ApiClientStoreTest extends TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* @group store_v4
|
||||
* @group store_v5
|
||||
*/
|
||||
public function testInventoriesUpload()
|
||||
{
|
||||
@ -109,7 +109,7 @@ class ApiClientStoreTest extends TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* @group integration
|
||||
* @group store_v5
|
||||
*/
|
||||
public function testInventoriesFailed()
|
||||
{
|
||||
@ -137,7 +137,7 @@ class ApiClientStoreTest extends TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* @group store_v4
|
||||
* @group store_v5
|
||||
*/
|
||||
public function testStoreProducts()
|
||||
{
|
||||
@ -151,7 +151,7 @@ class ApiClientStoreTest extends TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* @group store_v4
|
||||
* @group store_v5
|
||||
*/
|
||||
public function testStoreProductsGroups()
|
||||
{
|
||||
@ -163,4 +163,14 @@ class ApiClientStoreTest extends TestCase
|
||||
static::assertEquals(200, $response->getStatusCode());
|
||||
static::assertTrue($response->isSuccessful());
|
||||
}
|
||||
|
||||
/**
|
||||
* @group store_v5
|
||||
* @expectedException \InvalidArgumentException
|
||||
*/
|
||||
public function testStoreSettingsGet()
|
||||
{
|
||||
$client = static::getApiClient();
|
||||
$client->request->storeSettingsGet(self::SCODE);
|
||||
}
|
||||
}
|
||||
|
@ -31,22 +31,6 @@ class ApiClientTelephonyTest extends TestCase
|
||||
const TEL_CLIENT = '456';
|
||||
const TEL_IMAGE = 'http://www.mec.ph/horizon/wp-content/uploads/2011/11/telephony.svg';
|
||||
|
||||
/**
|
||||
* Settings Get test
|
||||
*
|
||||
* @group telephony
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testTelephonySettingsGet()
|
||||
{
|
||||
$client = static::getApiClient();
|
||||
$response = $client->request->telephonySettingsGet(self::TEL_CODE);
|
||||
static::assertInstanceOf('RetailCrm\Response\ApiResponse', $response);
|
||||
static::assertEquals(200, $response->getStatusCode());
|
||||
static::assertTrue($response->isSuccessful());
|
||||
}
|
||||
|
||||
/**
|
||||
* Event test
|
||||
*
|
||||
@ -125,4 +109,14 @@ class ApiClientTelephonyTest extends TestCase
|
||||
static::assertEquals(200, $response->getStatusCode());
|
||||
static::assertTrue($response->isSuccessful());
|
||||
}
|
||||
|
||||
/**
|
||||
* @group telephony_v5
|
||||
* @expectedException \InvalidArgumentException
|
||||
*/
|
||||
public function testTelephonySettingsGet()
|
||||
{
|
||||
$client = static::getApiClient();
|
||||
$client->request->telephonySettingsGet(self::TEL_CODE);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user