1
0
mirror of synced 2024-11-22 05:16:07 +03:00

deliveryType and billingInfo for IntegrationModuleEditInfo (#130)

This commit is contained in:
Сергей Чазов 2021-12-13 10:44:39 +03:00 committed by GitHub
parent 75fd10d40e
commit 8c05f269fa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 236 additions and 0 deletions

View File

@ -0,0 +1,22 @@
<?php
/**
* PHP version 7.3
*
* @category BillingInfo
* @package RetailCrm\Api\Model\Callback\Entity\Integration
*/
namespace RetailCrm\Api\Model\Callback\Entity\Integration;
use RetailCrm\Api\Model\Entity\Integration\BillingInfo as BaseBillingInfo;
/**
* Class BillingInfo
*
* @category IntegrationModule
* @package RetailCrm\Api\Model\Callback\Entity\Integration
*/
class BillingInfo extends BaseBillingInfo
{
}

View File

@ -0,0 +1,45 @@
<?php
/**
* PHP version 7.3
*
* @category BillingInfo
* @package RetailCrm\Api\Model\Entity\Integration
*/
namespace RetailCrm\Api\Model\Entity\Integration;
use RetailCrm\Api\Component\Serializer\Annotation as JMS;
/**
* Class BillingInfo
*
* @category IntegrationModuleEditInfo
* @package RetailCrm\Api\Model\Entity\Integration
*/
class BillingInfo
{
/**
* @var float
*
* @JMS\Type("float")
* @JMS\SerializedName("price")
*/
public $price;
/**
* @var \RetailCrm\Api\Model\Entity\Integration\Currency
*
* @JMS\Type("RetailCrm\Api\Model\Entity\Integration\Currency")
* @JMS\SerializedName("currency")
*/
public $currency;
/**
* @var string
*
* @JMS\Type("string")
* @JMS\SerializedName("billingType")
*/
public $billingType;
}

View File

@ -0,0 +1,45 @@
<?php
/**
* PHP version 7.3
*
* @category Currency
* @package RetailCrm\Api\Model\Entity\Integration
*/
namespace RetailCrm\Api\Model\Entity\Integration;
use RetailCrm\Api\Component\Serializer\Annotation as JMS;
/**
* Class Currency
*
* @category IntegrationModuleEditInfo
* @package RetailCrm\Api\Model\Entity\Integration
*/
class Currency
{
/**
* @var string
*
* @JMS\Type("string")
* @JMS\SerializedName("name")
*/
public $name;
/**
* @var string
*
* @JMS\Type("string")
* @JMS\SerializedName("shortName")
*/
public $shortName;
/**
* @var string
*
* @JMS\Type("string")
* @JMS\SerializedName("code")
*/
public $code;
}

View File

@ -50,4 +50,20 @@ class IntegrationModuleEditInfo
* @JMS\SerializedName("notExistSiteCodes") * @JMS\SerializedName("notExistSiteCodes")
*/ */
public $notExistSiteCodes; public $notExistSiteCodes;
/**
* @var \RetailCrm\Api\Model\Entity\References\DeliveryType
*
* @JMS\Type("RetailCrm\Api\Model\Entity\References\DeliveryType")
* @JMS\SerializedName("deliveryType")
*/
public $deliveryType;
/**
* @var \RetailCrm\Api\Model\Entity\Integration\BillingInfo
*
* @JMS\Type("RetailCrm\Api\Model\Entity\Integration\BillingInfo")
* @JMS\SerializedName("billingInfo")
*/
public $billingInfo;
} }

View File

@ -21,6 +21,14 @@ use RetailCrm\Api\Component\Serializer\Annotation as JMS;
*/ */
class DeliveryType class DeliveryType
{ {
/**
* @var int
*
* @JMS\Type("int")
* @JMS\SerializedName("id")
*/
public $id;
/** /**
* @var bool * @var bool
* *

View File

@ -11,6 +11,8 @@ namespace RetailCrm\Tests\ResourceGroup;
use RetailCrm\Api\Enum\Currency; use RetailCrm\Api\Enum\Currency;
use RetailCrm\Api\Enum\RequestMethod; use RetailCrm\Api\Enum\RequestMethod;
use RetailCrm\Api\Model\Entity\Integration\Delivery\DeliveryConfiguration;
use RetailCrm\Api\Model\Entity\Integration\Delivery\Plate;
use RetailCrm\Api\Model\Entity\Integration\IntegrationModule; use RetailCrm\Api\Model\Entity\Integration\IntegrationModule;
use RetailCrm\Api\Model\Entity\Integration\Integrations; use RetailCrm\Api\Model\Entity\Integration\Integrations;
use RetailCrm\Api\Model\Entity\Integration\Payment\Actions; use RetailCrm\Api\Model\Entity\Integration\Payment\Actions;
@ -154,4 +156,102 @@ EOF;
self::assertModelEqualsToResponse($json, $response); self::assertModelEqualsToResponse($json, $response);
} }
public function testDeliveryEdit(): void
{
$json = <<<'EOF'
{
"success": true,
"info": {
"billingInfo": {
"price": 0,
"currency": {
"name": "Рубль",
"shortName": "руб.",
"code": "RUB"
},
"billingType": "fixed"
},
"deliveryType": {
"id": 1,
"code": "ozon-integration-10"
}
}
}
EOF;
$module = new IntegrationModule();
$module->clientId = '34fa3509-92f3-4faf-87d5-2efbd88cb4cb';
$module->name = 'Ozon seller';
$module->code = 'ozon-integration-10';
$module->integrationCode = 'ozon-integration';
$module->logo = 'https://localhost/images/logo.svg';
$module->accountUrl = 'https://localhost/login';
$module->baseUrl = 'https://localhost';
$module->active = true;
$module->actions = [
'activity' => '/api/callback/v1/activity'
];
$module->availableCountries = ['RU'];
$deliveryConfiguration = new DeliveryConfiguration();
$deliveryConfiguration->actions = [
'get' => '/api/callback/v1/get',
'print' => '/api/callback/v1/print'
];
$deliveryConfiguration->payerType = ['receiver'];
$deliveryConfiguration->platePrintLimit = 20;
$deliveryConfiguration->rateDeliveryCost = true;
$deliveryConfiguration->allowPackages = false;
$deliveryConfiguration->codAvailable = false;
$deliveryConfiguration->plateList = $this->createPlateList();
$integrations = new Integrations();
$integrations->delivery = $deliveryConfiguration;
$module->integrations = $integrations;
$request = new IntegrationModulesEditRequest($module);
$mock = static::createApiMockBuilder('integration-modules/ozon-integration-10/edit');
$mock->matchMethod(RequestMethod::POST)
->matchBody(static::encodeForm($request))
->reply(200)
->withBody($json);
$client = TestClientFactory::createClient($mock->getClient());
$response = $client->integration->edit('ozon-integration-10', $request);
self::assertModelEqualsToResponse($json, $response);
}
/**
* @return Plate[]
*/
private function createPlateList(): array
{
$plateList = [];
$plates = [
[
'type' => 'order',
'code' => 'sticker',
'label' => 'Наклейка OZON',
],
[
'type' => 'order',
'code' => 'act',
'label' => 'Акт OZON',
],
];
foreach ($plates as $plate) {
$plateModel = new Plate();
$plateModel->code = $plate['code'];
$plateModel->type = $plate['type'];
$plateModel->label = $plate['label'];
$plateList[] = $plateModel;
}
return $plateList;
}
} }