Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/Model/Entity/Integration/EmbedJs/EmbedJsConfiguration.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,12 @@ class EmbedJsConfiguration
* @JMS\SerializedName("runner")
*/
public $runner;

/**
* @var \RetailCrm\Api\Model\Entity\Integration\EmbedJs\EmbedJsPage[]
*
* @JMS\Type("array<RetailCrm\Api\Model\Entity\Integration\EmbedJs\EmbedJsPage>")
* @JMS\SerializedName("pages")
*/
public $pages;
}
69 changes: 69 additions & 0 deletions src/Model/Entity/Integration/EmbedJs/EmbedJsPage.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
<?php

/**
* PHP version 7.3
*
* @category EmbedJsPage
* @package RetailCrm\Api\Model\Entity\Integration\EmbedJs
*/

namespace RetailCrm\Api\Model\Entity\Integration\EmbedJs;

use RetailCrm\Api\Component\Serializer\Annotation as JMS;

/**
* Class EmbedJsPage
*
* @category EmbedJsPage
* @package RetailCrm\Api\Model\Entity\Integration\EmbedJs
*/
class EmbedJsPage
{
/**
* @var string
*
* @JMS\Type("string")
* @JMS\SerializedName("code")
*/
public $code;

/**
* @var string|null
*
* @JMS\Type("string")
* @JMS\SerializedName("menu")
*/
public $menu;

/**
* @var string|null
*
* @JMS\Type("string")
* @JMS\SerializedName("parentMenuItemCode")
*/
public $parentMenuItemCode;

/**
* @var int|null
*
* @JMS\Type("int")
* @JMS\SerializedName("menuItemOrdering")
*/
public $menuItemOrdering;

/**
* @var \RetailCrm\Api\Model\Entity\Integration\EmbedJs\EmbedJsTranslation|null
*
* @JMS\Type("RetailCrm\Api\Model\Entity\Integration\EmbedJs\EmbedJsTranslation")
* @JMS\SerializedName("menuItemTitle")
*/
public $menuItemTitle;

/**
* @var \RetailCrm\Api\Model\Entity\Integration\EmbedJs\EmbedJsTranslation|null
*
* @JMS\Type("RetailCrm\Api\Model\Entity\Integration\EmbedJs\EmbedJsTranslation")
* @JMS\SerializedName("pageHelpLink")
*/
public $pageHelpLink;
}
45 changes: 45 additions & 0 deletions src/Model/Entity/Integration/EmbedJs/EmbedJsTranslation.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?php

/**
* PHP version 7.3
*
* @category EmbedJsTranslation
* @package RetailCrm\Api\Model\Entity\Integration\EmbedJs
*/

namespace RetailCrm\Api\Model\Entity\Integration\EmbedJs;

use RetailCrm\Api\Component\Serializer\Annotation as JMS;

/**
* Class EmbedJsTranslation
*
* @category EmbedJsTranslation
* @package RetailCrm\Api\Model\Entity\Integration\EmbedJs
*/
class EmbedJsTranslation
{
/**
* @var string|null
*
* @JMS\Type("string")
* @JMS\SerializedName("en")
*/
public $en;

/**
* @var string|null
*
* @JMS\Type("string")
* @JMS\SerializedName("es")
*/
public $es;

/**
* @var string|null
*
* @JMS\Type("string")
* @JMS\SerializedName("ru")
*/
public $ru;
}
93 changes: 93 additions & 0 deletions tests/src/ResourceGroup/IntegrationTests.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
use RetailCrm\Api\Model\Entity\Integration\Delivery\DeliveryConfiguration;
use RetailCrm\Api\Model\Entity\Integration\Delivery\Plate;
use RetailCrm\Api\Model\Entity\Integration\Delivery\Status;
use RetailCrm\Api\Model\Entity\Integration\EmbedJs\EmbedJsConfiguration;
use RetailCrm\Api\Model\Entity\Integration\EmbedJs\EmbedJsPage;
use RetailCrm\Api\Model\Entity\Integration\EmbedJs\EmbedJsTranslation;
use RetailCrm\Api\Model\Entity\Integration\IntegrationModule;
use RetailCrm\Api\Model\Entity\Integration\Integrations;
use RetailCrm\Api\Model\Entity\Integration\Payment\Actions;
Expand Down Expand Up @@ -160,6 +163,96 @@ public function testPaymentEdit(): void
self::assertModelEqualsToResponse($json, $response);
}

public function testEmbedJsEdit(): void
{
$json = <<<'EOF'
{
"success": true,
"info": []
}
EOF;
$menuItemTitle = new EmbedJsTranslation();
$menuItemTitle->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'
Expand Down
Loading