Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for MG settings #195

Merged
merged 1 commit into from
Jul 9, 2024
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
45 changes: 45 additions & 0 deletions src/Model/Entity/Settings/ChannelSetting.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?php

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

namespace RetailCrm\Api\Model\Entity\Settings;

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

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

/**
* @var string
*
* @JMS\Type("string")
* @JMS\SerializedName("order_type")
*/
public $orderType;

/**
* @var string
*
* @JMS\Type("string")
* @JMS\SerializedName("order_method")
*/
public $orderMethod;
}
37 changes: 37 additions & 0 deletions src/Model/Entity/Settings/MgOrderCreationSettings.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?php

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

namespace RetailCrm\Api\Model\Entity\Settings;

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

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

/**
* @var array<int, \RetailCrm\Api\Model\Entity\Settings\ChannelSetting>
*
* @JMS\Type("array<int, RetailCrm\Api\Model\Entity\Settings\ChannelSetting>")
* @JMS\SerializedName("channels")
*/
public $channels;
}
29 changes: 29 additions & 0 deletions src/Model/Entity/Settings/MgSettings.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php

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

namespace RetailCrm\Api\Model\Entity\Settings;

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

/**
* Class MgSettings
*
* @category MgSettings
* @package RetailCrm\Api\Model\Entity\Settings
*/
class MgSettings
{
/**
* @var \RetailCrm\Api\Model\Entity\Settings\MgOrderCreationSettings
*
* @JMS\Type("RetailCrm\Api\Model\Entity\Settings\MgOrderCreationSettings")
* @JMS\SerializedName("order_creation")
*/
public $orderCreation;
}
8 changes: 8 additions & 0 deletions src/Model/Entity/Settings/Settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,12 @@ class Settings
* @JMS\SerializedName("non_working_days")
*/
public $nonWorkingDays;

/**
* @var \RetailCrm\Api\Model\Entity\Settings\MgSettings
*
* @JMS\Type("RetailCrm\Api\Model\Entity\Settings\MgSettings")
* @JMS\SerializedName("mg")
*/
public $mgSettings;
}
23 changes: 23 additions & 0 deletions tests/src/Model/Callback/Entity/Integration/SettingsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

use PHPUnit\Framework\TestCase;
use RetailCrm\Api\Factory\SerializerFactory;
use RetailCrm\Api\Model\Entity\Settings\MgSettings;
use RetailCrm\Api\Model\Entity\Settings\NonWorkingDay;
use RetailCrm\Api\Model\Entity\Settings\Settings as SystemSettings;
use RetailCrm\Api\Model\Callback\Entity\Integration\Settings;
Expand Down Expand Up @@ -50,6 +51,27 @@ public function testDeserialize(): void
'start_date' => '05.29',
'end_date' => '06.29'
]
],
'mg' => [
'order_creation' => [
'default' => [
'site' => 'site',
'order_type' => 'type',
'order_method' => 'method',
],
'channels' => [
1111 => [
'site' => 'site_1',
'order_type' => 'type_1',
'order_method' => 'method_1',
],
2222 => [
'site' => 'site_2',
'order_type' => 'type_2',
'order_method' => 'method_2',
],
]
]
]
],
],
Expand All @@ -61,5 +83,6 @@ public function testDeserialize(): void
self::assertInstanceOf(Value::class, $settings->settings->defaultCurrency);
self::assertInstanceOf(WorkTime::class, $settings->settings->workTimes[0]);
self::assertInstanceOf(NonWorkingDay::class, $settings->settings->nonWorkingDays[0]);
self::assertInstanceOf(MgSettings::class, $settings->settings->mgSettings);
}
}
23 changes: 22 additions & 1 deletion tests/src/ResourceGroup/SettingsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,28 @@ public function testGet(): void
"lunch_start_time": "12:30",
"lunch_end_time": "13:00"
}
]
],
"mg": {
"order_creation": {
"default": {
"site": "site",
"order_type": "type",
"order_method": "method"
},
"channels": {
"1111": {
"site": "site_1",
"order_type": "type_1",
"order_method": "method_1"
},
"2222": {
"site": "site_2",
"order_type": "type_2",
"order_method": "method_2"
}
}
}
}
}
}
EOF;
Expand Down
Loading