1
0
mirror of synced 2024-11-21 21:06:07 +03:00

Marketplace methods (#51)

This commit is contained in:
Alex Lushpai 2017-11-17 15:02:54 +03:00 committed by GitHub
parent c6c5f737bd
commit 440c7fcd8c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 156 additions and 30 deletions

View File

@ -46,6 +46,7 @@ class ApiVersion5 extends AbstractLoader
use V5\Customers; use V5\Customers;
use V5\CustomFields; use V5\CustomFields;
use V5\Delivery; use V5\Delivery;
use V5\Module;
use V5\Orders; use V5\Orders;
use V5\Packs; use V5\Packs;
use V5\References; use V5\References;

View File

@ -30,4 +30,20 @@ use RetailCrm\Methods\V4\Delivery as Previous;
trait Delivery trait Delivery
{ {
use Previous; 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');
}
} }

View 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)]
);
}
}

View File

@ -31,6 +31,23 @@ trait Stores
{ {
use Previous; 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 * Get products groups
* *

View File

@ -30,4 +30,9 @@ use RetailCrm\Methods\V4\Telephony as Previous;
trait Telephony trait Telephony
{ {
use Previous; use Previous;
public function telephonySettingsGet($code)
{
throw new \InvalidArgumentException('This method is not available');
}
} }

View File

@ -23,27 +23,30 @@ use RetailCrm\Test\TestCase;
*/ */
class ApiClientMarketplaceTest extends TestCase class ApiClientMarketplaceTest extends TestCase
{ {
const SNAME = 'Marketplace integration v5'; const SERVICE_NAME = 'Marketplace integration v5';
const SCODE = 'integration_v5'; const SERVICE_CODE = 'integration_v5';
/** /**
* @group marketplace_v5 * @group marketplace_v5
*/ */
public function testConfigurationEdit() public function testConfigurationEdit()
{ {
$client = static::getApiClient(null, null, "v5"); $client = static::getApiClient();
$response = $client->request->marketplaceSettingsEdit( $response = $client->request->integrationModulesEdit(
[ [
'name' => self::SNAME, 'name' => self::SERVICE_NAME,
'code' => self::SCODE, 'code' => self::SERVICE_CODE,
'clientId' => uniqid(),
'logo' => 'http://download.retailcrm.pro/logos/setup.svg', 'logo' => 'http://download.retailcrm.pro/logos/setup.svg',
'active' => 'true' 'active' => 'true'
] ]
); );
static::assertInstanceOf('RetailCrm\Response\ApiResponse', $response); static::assertInstanceOf('RetailCrm\Response\ApiResponse', $response);
static::assertTrue(in_array($response->getStatusCode(), [200, 201])); static::assertEquals($response->getStatusCode(), 200);
static::assertTrue($response->isSuccessful()); static::assertTrue($response->isSuccessful());
} }
} }

View File

@ -31,7 +31,7 @@ class ApiClientStoreTest extends TestCase
const SCODE = 'test-store-v5'; const SCODE = 'test-store-v5';
/** /**
* @group store_v4 * @group store_v5
*/ */
public function testStoreCreate() public function testStoreCreate()
{ {
@ -45,7 +45,7 @@ class ApiClientStoreTest extends TestCase
} }
/** /**
* @group store_v4 * @group store_v5
*/ */
public function testStoreInventories() public function testStoreInventories()
{ {
@ -63,7 +63,7 @@ class ApiClientStoreTest extends TestCase
} }
/** /**
* @group store_v4 * @group store_v5
* @expectedException \InvalidArgumentException * @expectedException \InvalidArgumentException
*/ */
public function testInventoriesException() public function testInventoriesException()
@ -74,7 +74,7 @@ class ApiClientStoreTest extends TestCase
} }
/** /**
* @group store_v4 * @group store_v5
*/ */
public function testInventoriesUpload() public function testInventoriesUpload()
{ {
@ -109,7 +109,7 @@ class ApiClientStoreTest extends TestCase
} }
/** /**
* @group integration * @group store_v5
*/ */
public function testInventoriesFailed() public function testInventoriesFailed()
{ {
@ -137,7 +137,7 @@ class ApiClientStoreTest extends TestCase
} }
/** /**
* @group store_v4 * @group store_v5
*/ */
public function testStoreProducts() public function testStoreProducts()
{ {
@ -151,7 +151,7 @@ class ApiClientStoreTest extends TestCase
} }
/** /**
* @group store_v4 * @group store_v5
*/ */
public function testStoreProductsGroups() public function testStoreProductsGroups()
{ {
@ -163,4 +163,14 @@ class ApiClientStoreTest extends TestCase
static::assertEquals(200, $response->getStatusCode()); static::assertEquals(200, $response->getStatusCode());
static::assertTrue($response->isSuccessful()); static::assertTrue($response->isSuccessful());
} }
/**
* @group store_v5
* @expectedException \InvalidArgumentException
*/
public function testStoreSettingsGet()
{
$client = static::getApiClient();
$client->request->storeSettingsGet(self::SCODE);
}
} }

View File

@ -31,22 +31,6 @@ class ApiClientTelephonyTest extends TestCase
const TEL_CLIENT = '456'; const TEL_CLIENT = '456';
const TEL_IMAGE = 'http://www.mec.ph/horizon/wp-content/uploads/2011/11/telephony.svg'; 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 * Event test
* *
@ -125,4 +109,14 @@ class ApiClientTelephonyTest extends TestCase
static::assertEquals(200, $response->getStatusCode()); static::assertEquals(200, $response->getStatusCode());
static::assertTrue($response->isSuccessful()); static::assertTrue($response->isSuccessful());
} }
/**
* @group telephony_v5
* @expectedException \InvalidArgumentException
*/
public function testTelephonySettingsGet()
{
$client = static::getApiClient();
$client->request->telephonySettingsGet(self::TEL_CODE);
}
} }