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
38 changes: 38 additions & 0 deletions src/Model/Entity/Settings/BooleanValue.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?php

/**
* PHP version 7.3
*
* @category BooleanValue
* @package RetailCrm\Api\Model\Entity\Settings
*/

namespace RetailCrm\Api\Model\Entity\Settings;

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

/**
* Class BooleanValue
*
* @category BooleanValue
* @package RetailCrm\Api\Model\Entity\Settings
*/
class BooleanValue
{
/**
* @var bool
*
* @JMS\Type("bool")
* @JMS\SerializedName("value")
*/
public $value;

/**
* @var DateTime
*
* @JMS\Type("DateTime<'Y-m-d H:i:s'>")
* @JMS\SerializedName("updated_at")
*/
public $updatedAt;
}
29 changes: 29 additions & 0 deletions src/Model/Entity/Settings/OrderSettings.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php

/**
* PHP version 7.3
*
* @category OrderSettings
* @package RetailCrm\Api\Model\Entity\Settings
*/

namespace RetailCrm\Api\Model\Entity\Settings;

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

/**
* Class OrderSettings
*
* @category OrderSettings
* @package RetailCrm\Api\Model\Entity\Settings
*/
class OrderSettings
{
/**
* @var \RetailCrm\Api\Model\Entity\Settings\BooleanValue
*
* @JMS\Type("RetailCrm\Api\Model\Entity\Settings\BooleanValue")
* @JMS\SerializedName("allow_duplicate_order_product")
*/
public $allowDuplicateOrderProduct;

Check warning on line 28 in src/Model/Entity/Settings/OrderSettings.php

View workflow job for this annotation

GitHub Actions / PHP MessDetector

[PHPMD] reported by reviewdog 🐶 LongVariable Avoid excessively long variable names like $allowDuplicateOrderProduct. Keep variable name length under 20. Raw Output: /github/workspace/src/Model/Entity/Settings/OrderSettings.php:28:LongVariable Avoid excessively long variable names like $allowDuplicateOrderProduct. Keep variable name length under 20.
}
8 changes: 8 additions & 0 deletions src/Model/Entity/Settings/Settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,12 @@ class Settings
* @JMS\SerializedName("mg")
*/
public $mgSettings;

/**
* @var \RetailCrm\Api\Model\Entity\Settings\OrderSettings
*
* @JMS\Type("RetailCrm\Api\Model\Entity\Settings\OrderSettings")
* @JMS\SerializedName("order")
*/
public $order;
}
41 changes: 41 additions & 0 deletions tests/src/ResourceGroup/SettingsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,5 +89,46 @@ public function testGet(): void
$response = $client->settings->get();

self::assertModelEqualsToResponse($json, $response);
self::assertNull($response->settings->order);
}

/**
* @dataProvider orderValues
*/
public function testOrder(bool $enabled): void
{
$json = json_encode([
'success' => true,
'settings' => [
'order' => [
'allow_duplicate_order_product' => [
'value' => $enabled,
'updated_at' => '2026-05-27 13:31:02',
],
],
],
], JSON_THROW_ON_ERROR);

$mock = static::createApiMockBuilder('settings');
$mock->matchMethod(RequestMethod::GET)
->reply(200)
->withBody($json);

$client = TestClientFactory::createClient($mock->getClient());
$response = $client->settings->get();
$setting = $response->settings->order->allowDuplicateOrderProduct;

self::assertSame($enabled, $setting->value);
self::assertInstanceOf(\DateTime::class, $setting->updatedAt);
self::assertSame('2026-05-27 13:31:02', $setting->updatedAt->format('Y-m-d H:i:s'));
self::assertModelEqualsToResponse($json, $response);
}

public function orderValues(): array
{
return [
'enabled' => [true],
'disabled' => [false],
];
}
}
Loading