From 8c05f269fa7804c30471936a3dfa504222ccadfd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A1=D0=B5=D1=80=D0=B3=D0=B5=D0=B9=20=D0=A7=D0=B0=D0=B7?= =?UTF-8?q?=D0=BE=D0=B2?= <45812598+Chazovs@users.noreply.github.com> Date: Mon, 13 Dec 2021 10:44:39 +0300 Subject: [PATCH] deliveryType and billingInfo for IntegrationModuleEditInfo (#130) --- .../Entity/Integration/BillingInfo.php | 22 ++++ src/Model/Entity/Integration/BillingInfo.php | 45 ++++++++ src/Model/Entity/Integration/Currency.php | 45 ++++++++ .../Integration/IntegrationModuleEditInfo.php | 16 +++ src/Model/Entity/References/DeliveryType.php | 8 ++ tests/src/ResourceGroup/IntegrationTests.php | 100 ++++++++++++++++++ 6 files changed, 236 insertions(+) create mode 100644 src/Model/Callback/Entity/Integration/BillingInfo.php create mode 100644 src/Model/Entity/Integration/BillingInfo.php create mode 100644 src/Model/Entity/Integration/Currency.php diff --git a/src/Model/Callback/Entity/Integration/BillingInfo.php b/src/Model/Callback/Entity/Integration/BillingInfo.php new file mode 100644 index 0000000..b855d10 --- /dev/null +++ b/src/Model/Callback/Entity/Integration/BillingInfo.php @@ -0,0 +1,22 @@ +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; + } }