diff --git a/src/Model/Entity/Integration/EmbedJs/EmbedJsConfiguration.php b/src/Model/Entity/Integration/EmbedJs/EmbedJsConfiguration.php index 8050b3a5..321fab3b 100644 --- a/src/Model/Entity/Integration/EmbedJs/EmbedJsConfiguration.php +++ b/src/Model/Entity/Integration/EmbedJs/EmbedJsConfiguration.php @@ -50,4 +50,12 @@ class EmbedJsConfiguration * @JMS\SerializedName("runner") */ public $runner; + + /** + * @var \RetailCrm\Api\Model\Entity\Integration\EmbedJs\EmbedJsPage[] + * + * @JMS\Type("array") + * @JMS\SerializedName("pages") + */ + public $pages; } diff --git a/src/Model/Entity/Integration/EmbedJs/EmbedJsPage.php b/src/Model/Entity/Integration/EmbedJs/EmbedJsPage.php new file mode 100644 index 00000000..9476d4db --- /dev/null +++ b/src/Model/Entity/Integration/EmbedJs/EmbedJsPage.php @@ -0,0 +1,69 @@ +en = 'Orders'; + $menuItemTitle->es = 'Pedidos'; + $menuItemTitle->ru = 'Заказы'; + + $pageHelpLink = new EmbedJsTranslation(); + $pageHelpLink->en = 'https://example.com/help/en'; + $pageHelpLink->es = 'https://example.com/help/es'; + $pageHelpLink->ru = 'https://example.com/help/ru'; + + $page = new EmbedJsPage(); + $page->code = 'orders-page'; + $page->menu = 'orders'; + $page->parentMenuItemCode = 'orders'; + $page->menuItemOrdering = 100; + $page->menuItemTitle = $menuItemTitle; + $page->pageHelpLink = $pageHelpLink; + + $module = new IntegrationModule(); + $module->integrations = new Integrations(); + $module->integrations->embedJs = new EmbedJsConfiguration(); + + $module->code = 'test-embedjs-integration'; + $module->clientId = 'test-embedjs-integration'; + $module->integrationCode = 'test-embedjs-integration'; + $module->active = true; + $module->freeze = false; + $module->name = 'Test EmbedJs Integration'; + $module->logo = 'https://example.com/logo.svg'; + $module->native = true; + $module->baseUrl = 'https://example.com'; + $module->actions = ['activity' => '/activity']; + $module->availableCountries = ['RU', 'US']; + $module->accountUrl = 'https://example.com/account'; + $module->integrations->embedJs->entrypoint = 'https://example.com/embed.js'; + $module->integrations->embedJs->stylesheet = 'https://example.com/embed.css'; + $module->integrations->embedJs->targets = ['order_card', 'customer_card']; + $module->integrations->embedJs->runner = 'worker'; + $module->integrations->embedJs->pages = [$page]; + + $request = new IntegrationModulesEditRequest($module); + + $body = static::encodeFormArray($request); + $integrationModule = json_decode($body['integrationModule'], true, 512, JSON_THROW_ON_ERROR); + + self::assertSame([ + 'entrypoint' => 'https://example.com/embed.js', + 'stylesheet' => 'https://example.com/embed.css', + 'targets' => ['order_card', 'customer_card'], + 'runner' => 'worker', + 'pages' => [ + [ + 'code' => 'orders-page', + 'menu' => 'orders', + 'parentMenuItemCode' => 'orders', + 'menuItemOrdering' => 100, + 'menuItemTitle' => [ + 'en' => 'Orders', + 'es' => 'Pedidos', + 'ru' => 'Заказы', + ], + 'pageHelpLink' => [ + 'en' => 'https://example.com/help/en', + 'es' => 'https://example.com/help/es', + 'ru' => 'https://example.com/help/ru', + ], + ], + ], + ], $integrationModule['integrations']['embedJs']); + + $mock = static::createApiMockBuilder('integration-modules/test-embedjs-integration/edit'); + $mock->matchMethod(RequestMethod::POST) + ->matchBody(static::encodeForm($request)) + ->reply(200) + ->withBody($json); + + $client = TestClientFactory::createClient($mock->getClient()); + $response = $client->integration->edit('test-embedjs-integration', $request); + + self::assertModelEqualsToResponse($json, $response); + } + public function testDeliveryEdit(): void { $json = <<<'EOF'