diff --git a/lib/RetailCrm/Client/ApiVersion5.php b/lib/RetailCrm/Client/ApiVersion5.php index b8a6f3e..e0a992b 100644 --- a/lib/RetailCrm/Client/ApiVersion5.php +++ b/lib/RetailCrm/Client/ApiVersion5.php @@ -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; diff --git a/lib/RetailCrm/Methods/V5/Delivery.php b/lib/RetailCrm/Methods/V5/Delivery.php index 0469177..de43c1c 100644 --- a/lib/RetailCrm/Methods/V5/Delivery.php +++ b/lib/RetailCrm/Methods/V5/Delivery.php @@ -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'); + } } diff --git a/lib/RetailCrm/Methods/V5/Module.php b/lib/RetailCrm/Methods/V5/Module.php new file mode 100644 index 0000000..5c5f4b8 --- /dev/null +++ b/lib/RetailCrm/Methods/V5/Module.php @@ -0,0 +1,80 @@ + + * @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 + * @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)] + ); + } +} diff --git a/lib/RetailCrm/Methods/V5/Stores.php b/lib/RetailCrm/Methods/V5/Stores.php index 93a7c7f..262e30a 100644 --- a/lib/RetailCrm/Methods/V5/Stores.php +++ b/lib/RetailCrm/Methods/V5/Stores.php @@ -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 * diff --git a/lib/RetailCrm/Methods/V5/Telephony.php b/lib/RetailCrm/Methods/V5/Telephony.php index 03ed217..e392968 100644 --- a/lib/RetailCrm/Methods/V5/Telephony.php +++ b/lib/RetailCrm/Methods/V5/Telephony.php @@ -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'); + } } diff --git a/tests/RetailCrm/Tests/Methods/Version5/ApiClientMarketplaceTest.php b/tests/RetailCrm/Tests/Methods/Version5/ApiClientMarketplaceTest.php index 5eb176f..95a14e0 100644 --- a/tests/RetailCrm/Tests/Methods/Version5/ApiClientMarketplaceTest.php +++ b/tests/RetailCrm/Tests/Methods/Version5/ApiClientMarketplaceTest.php @@ -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()); } + + } diff --git a/tests/RetailCrm/Tests/Methods/Version5/ApiClientStoreTest.php b/tests/RetailCrm/Tests/Methods/Version5/ApiClientStoreTest.php index 1948cbe..68c5f9d 100644 --- a/tests/RetailCrm/Tests/Methods/Version5/ApiClientStoreTest.php +++ b/tests/RetailCrm/Tests/Methods/Version5/ApiClientStoreTest.php @@ -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); + } } diff --git a/tests/RetailCrm/Tests/Methods/Version5/ApiClientTelephonyTest.php b/tests/RetailCrm/Tests/Methods/Version5/ApiClientTelephonyTest.php index 9520474..3658253 100644 --- a/tests/RetailCrm/Tests/Methods/Version5/ApiClientTelephonyTest.php +++ b/tests/RetailCrm/Tests/Methods/Version5/ApiClientTelephonyTest.php @@ -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); + } }