Skip to content

Commit c3fd192

Browse files
committed
Add EmbedJs pages models
1 parent 315cdd8 commit c3fd192

4 files changed

Lines changed: 215 additions & 0 deletions

File tree

src/Model/Entity/Integration/EmbedJs/EmbedJsConfiguration.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,4 +50,12 @@ class EmbedJsConfiguration
5050
* @JMS\SerializedName("runner")
5151
*/
5252
public $runner;
53+
54+
/**
55+
* @var \RetailCrm\Api\Model\Entity\Integration\EmbedJs\EmbedJsPage[]
56+
*
57+
* @JMS\Type("array<RetailCrm\Api\Model\Entity\Integration\EmbedJs\EmbedJsPage>")
58+
* @JMS\SerializedName("pages")
59+
*/
60+
public $pages;
5361
}
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
<?php
2+
3+
/**
4+
* PHP version 7.3
5+
*
6+
* @category EmbedJsPage
7+
* @package RetailCrm\Api\Model\Entity\Integration\EmbedJs
8+
*/
9+
10+
namespace RetailCrm\Api\Model\Entity\Integration\EmbedJs;
11+
12+
use RetailCrm\Api\Component\Serializer\Annotation as JMS;
13+
14+
/**
15+
* Class EmbedJsPage
16+
*
17+
* @category EmbedJsPage
18+
* @package RetailCrm\Api\Model\Entity\Integration\EmbedJs
19+
*/
20+
class EmbedJsPage
21+
{
22+
/**
23+
* @var string
24+
*
25+
* @JMS\Type("string")
26+
* @JMS\SerializedName("code")
27+
*/
28+
public $code;
29+
30+
/**
31+
* @var string|null
32+
*
33+
* @JMS\Type("string")
34+
* @JMS\SerializedName("menu")
35+
*/
36+
public $menu;
37+
38+
/**
39+
* @var string|null
40+
*
41+
* @JMS\Type("string")
42+
* @JMS\SerializedName("parentMenuItemCode")
43+
*/
44+
public $parentMenuItemCode;
45+
46+
/**
47+
* @var int|null
48+
*
49+
* @JMS\Type("int")
50+
* @JMS\SerializedName("menuItemOrdering")
51+
*/
52+
public $menuItemOrdering;
53+
54+
/**
55+
* @var \RetailCrm\Api\Model\Entity\Integration\EmbedJs\EmbedJsTranslation|null
56+
*
57+
* @JMS\Type("RetailCrm\Api\Model\Entity\Integration\EmbedJs\EmbedJsTranslation")
58+
* @JMS\SerializedName("menuItemTitle")
59+
*/
60+
public $menuItemTitle;
61+
62+
/**
63+
* @var \RetailCrm\Api\Model\Entity\Integration\EmbedJs\EmbedJsTranslation|null
64+
*
65+
* @JMS\Type("RetailCrm\Api\Model\Entity\Integration\EmbedJs\EmbedJsTranslation")
66+
* @JMS\SerializedName("pageHelpLink")
67+
*/
68+
public $pageHelpLink;
69+
}
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
<?php
2+
3+
/**
4+
* PHP version 7.3
5+
*
6+
* @category EmbedJsTranslation
7+
* @package RetailCrm\Api\Model\Entity\Integration\EmbedJs
8+
*/
9+
10+
namespace RetailCrm\Api\Model\Entity\Integration\EmbedJs;
11+
12+
use RetailCrm\Api\Component\Serializer\Annotation as JMS;
13+
14+
/**
15+
* Class EmbedJsTranslation
16+
*
17+
* @category EmbedJsTranslation
18+
* @package RetailCrm\Api\Model\Entity\Integration\EmbedJs
19+
*/
20+
class EmbedJsTranslation
21+
{
22+
/**
23+
* @var string|null
24+
*
25+
* @JMS\Type("string")
26+
* @JMS\SerializedName("en")
27+
*/
28+
public $en;
29+
30+
/**
31+
* @var string|null
32+
*
33+
* @JMS\Type("string")
34+
* @JMS\SerializedName("es")
35+
*/
36+
public $es;
37+
38+
/**
39+
* @var string|null
40+
*
41+
* @JMS\Type("string")
42+
* @JMS\SerializedName("ru")
43+
*/
44+
public $ru;
45+
}

tests/src/ResourceGroup/IntegrationTests.php

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@
1414
use RetailCrm\Api\Model\Entity\Integration\Delivery\DeliveryConfiguration;
1515
use RetailCrm\Api\Model\Entity\Integration\Delivery\Plate;
1616
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;
1720
use RetailCrm\Api\Model\Entity\Integration\IntegrationModule;
1821
use RetailCrm\Api\Model\Entity\Integration\Integrations;
1922
use RetailCrm\Api\Model\Entity\Integration\Payment\Actions;
@@ -160,6 +163,96 @@ public function testPaymentEdit(): void
160163
self::assertModelEqualsToResponse($json, $response);
161164
}
162165

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+
163256
public function testDeliveryEdit(): void
164257
{
165258
$json = <<<'EOF'

0 commit comments

Comments
 (0)