|
14 | 14 | use RetailCrm\Api\Model\Entity\Integration\Delivery\DeliveryConfiguration; |
15 | 15 | use RetailCrm\Api\Model\Entity\Integration\Delivery\Plate; |
16 | 16 | use RetailCrm\Api\Model\Entity\Integration\Delivery\Status; |
| 17 | +use RetailCrm\Api\Model\Entity\Integration\EmbedJs\EmbedJsConfiguration; |
| 18 | +use RetailCrm\Api\Model\Entity\Integration\EmbedJs\EmbedJsPage; |
| 19 | +use RetailCrm\Api\Model\Entity\Integration\EmbedJs\EmbedJsTranslation; |
17 | 20 | use RetailCrm\Api\Model\Entity\Integration\IntegrationModule; |
18 | 21 | use RetailCrm\Api\Model\Entity\Integration\Integrations; |
19 | 22 | use RetailCrm\Api\Model\Entity\Integration\Payment\Actions; |
@@ -160,6 +163,96 @@ public function testPaymentEdit(): void |
160 | 163 | self::assertModelEqualsToResponse($json, $response); |
161 | 164 | } |
162 | 165 |
|
| 166 | + public function testEmbedJsEdit(): void |
| 167 | + { |
| 168 | + $json = <<<'EOF' |
| 169 | +{ |
| 170 | + "success": true, |
| 171 | + "info": [] |
| 172 | +} |
| 173 | +EOF; |
| 174 | + $menuItemTitle = new EmbedJsTranslation(); |
| 175 | + $menuItemTitle->en = 'Orders'; |
| 176 | + $menuItemTitle->es = 'Pedidos'; |
| 177 | + $menuItemTitle->ru = 'Заказы'; |
| 178 | + |
| 179 | + $pageHelpLink = new EmbedJsTranslation(); |
| 180 | + $pageHelpLink->en = 'https://example.com/help/en'; |
| 181 | + $pageHelpLink->es = 'https://example.com/help/es'; |
| 182 | + $pageHelpLink->ru = 'https://example.com/help/ru'; |
| 183 | + |
| 184 | + $page = new EmbedJsPage(); |
| 185 | + $page->code = 'orders-page'; |
| 186 | + $page->menu = 'orders'; |
| 187 | + $page->parentMenuItemCode = 'orders'; |
| 188 | + $page->menuItemOrdering = 100; |
| 189 | + $page->menuItemTitle = $menuItemTitle; |
| 190 | + $page->pageHelpLink = $pageHelpLink; |
| 191 | + |
| 192 | + $module = new IntegrationModule(); |
| 193 | + $module->integrations = new Integrations(); |
| 194 | + $module->integrations->embedJs = new EmbedJsConfiguration(); |
| 195 | + |
| 196 | + $module->code = 'test-embedjs-integration'; |
| 197 | + $module->clientId = 'test-embedjs-integration'; |
| 198 | + $module->integrationCode = 'test-embedjs-integration'; |
| 199 | + $module->active = true; |
| 200 | + $module->freeze = false; |
| 201 | + $module->name = 'Test EmbedJs Integration'; |
| 202 | + $module->logo = 'https://example.com/logo.svg'; |
| 203 | + $module->native = true; |
| 204 | + $module->baseUrl = 'https://example.com'; |
| 205 | + $module->actions = ['activity' => '/activity']; |
| 206 | + $module->availableCountries = ['RU', 'US']; |
| 207 | + $module->accountUrl = 'https://example.com/account'; |
| 208 | + $module->integrations->embedJs->entrypoint = 'https://example.com/embed.js'; |
| 209 | + $module->integrations->embedJs->stylesheet = 'https://example.com/embed.css'; |
| 210 | + $module->integrations->embedJs->targets = ['order_card', 'customer_card']; |
| 211 | + $module->integrations->embedJs->runner = 'worker'; |
| 212 | + $module->integrations->embedJs->pages = [$page]; |
| 213 | + |
| 214 | + $request = new IntegrationModulesEditRequest($module); |
| 215 | + |
| 216 | + $body = static::encodeFormArray($request); |
| 217 | + $integrationModule = json_decode($body['integrationModule'], true, 512, JSON_THROW_ON_ERROR); |
| 218 | + |
| 219 | + self::assertSame([ |
| 220 | + 'entrypoint' => 'https://example.com/embed.js', |
| 221 | + 'stylesheet' => 'https://example.com/embed.css', |
| 222 | + 'targets' => ['order_card', 'customer_card'], |
| 223 | + 'runner' => 'worker', |
| 224 | + 'pages' => [ |
| 225 | + [ |
| 226 | + 'code' => 'orders-page', |
| 227 | + 'menu' => 'orders', |
| 228 | + 'parentMenuItemCode' => 'orders', |
| 229 | + 'menuItemOrdering' => 100, |
| 230 | + 'menuItemTitle' => [ |
| 231 | + 'en' => 'Orders', |
| 232 | + 'es' => 'Pedidos', |
| 233 | + 'ru' => 'Заказы', |
| 234 | + ], |
| 235 | + 'pageHelpLink' => [ |
| 236 | + 'en' => 'https://example.com/help/en', |
| 237 | + 'es' => 'https://example.com/help/es', |
| 238 | + 'ru' => 'https://example.com/help/ru', |
| 239 | + ], |
| 240 | + ], |
| 241 | + ], |
| 242 | + ], $integrationModule['integrations']['embedJs']); |
| 243 | + |
| 244 | + $mock = static::createApiMockBuilder('integration-modules/test-embedjs-integration/edit'); |
| 245 | + $mock->matchMethod(RequestMethod::POST) |
| 246 | + ->matchBody(static::encodeForm($request)) |
| 247 | + ->reply(200) |
| 248 | + ->withBody($json); |
| 249 | + |
| 250 | + $client = TestClientFactory::createClient($mock->getClient()); |
| 251 | + $response = $client->integration->edit('test-embedjs-integration', $request); |
| 252 | + |
| 253 | + self::assertModelEqualsToResponse($json, $response); |
| 254 | + } |
| 255 | + |
163 | 256 | public function testDeliveryEdit(): void |
164 | 257 | { |
165 | 258 | $json = <<<'EOF' |
|
0 commit comments