From e8bfec237bf4b53ad33ddd3c40747c8623f11b52 Mon Sep 17 00:00:00 2001 From: jochemgravendeel Date: Thu, 15 Jan 2026 16:19:50 +0100 Subject: [PATCH 1/4] feat: set basic capabilities proxy --- config/actions.php | 30 +++--- config/pdk-default.php | 3 +- src/Api/PdkCapabilitiesActions.php | 13 +++ src/Api/Response/CapabilitiesResponse.php | 41 ++++++++ src/Api/Service/CapabilitiesApiService.php | 70 ++++++++++++++ .../Capabilities/CapabilitiesAction.php | 71 ++++++++++++++ .../CapabilitiesEndpointRequest.php | 18 ++++ .../Capabilities/CapabilitiesActionTest.php | 93 +++++++++++++++++++ 8 files changed, 327 insertions(+), 12 deletions(-) create mode 100644 src/Api/PdkCapabilitiesActions.php create mode 100644 src/Api/Response/CapabilitiesResponse.php create mode 100644 src/Api/Service/CapabilitiesApiService.php create mode 100644 src/App/Action/Capabilities/CapabilitiesAction.php create mode 100644 src/App/Request/Capabilities/CapabilitiesEndpointRequest.php create mode 100644 tests/Unit/App/Action/Capabilities/CapabilitiesActionTest.php diff --git a/config/actions.php b/config/actions.php index 658f5e457..a36c03c70 100644 --- a/config/actions.php +++ b/config/actions.php @@ -58,6 +58,9 @@ use MyParcelNL\Pdk\App\Request\Addresses\AddressesValidateEndpointRequest; use MyParcelNL\Pdk\App\Action\Addresses\AddressesListAction; use MyParcelNL\Pdk\App\Action\Addresses\AddressesValidateAction; +use MyParcelNL\Pdk\Api\PdkCapabilitiesActions; +use MyParcelNL\Pdk\App\Action\Capabilities\CapabilitiesAction; +use MyParcelNL\Pdk\App\Request\Capabilities\CapabilitiesEndpointRequest; return [ PdkEndpoint::CONTEXT_SHARED => [ @@ -90,6 +93,11 @@ 'request' => AddressesValidateEndpointRequest::class, 'action' => AddressesValidateAction::class, ], + + PdkCapabilitiesActions::PROXY_CAPABILITIES => [ + 'request' => CapabilitiesEndpointRequest::class, + 'action' => CapabilitiesAction::class, + ], ], PdkEndpoint::CONTEXT_BACKEND => [ @@ -162,7 +170,7 @@ 'action' => UpdateOrderAction::class, ], - PdkBackendActions::UPDATE_ORDER_STATUS => [ + PdkBackendActions::UPDATE_ORDER_STATUS => [ 'request' => UpdateOrderStatusEndpointRequest::class, 'action' => UpdateOrderStatusAction::class, ], @@ -170,7 +178,7 @@ /** * Get new shipments data from the API. */ - PdkBackendActions::UPDATE_SHIPMENTS => [ + PdkBackendActions::UPDATE_SHIPMENTS => [ 'request' => UpdateShipmentsEndpointRequest::class, 'action' => UpdateShipmentsAction::class, ], @@ -178,7 +186,7 @@ /** * Soft delete shipments in the plugin. */ - PdkBackendActions::DELETE_SHIPMENTS => [ + PdkBackendActions::DELETE_SHIPMENTS => [ 'request' => DeleteShipmentsEndpointRequest::class, 'action' => DeleteShipmentsAction::class, ], @@ -186,7 +194,7 @@ /** * Print shipment labels */ - PdkBackendActions::PRINT_SHIPMENTS => [ + PdkBackendActions::PRINT_SHIPMENTS => [ 'request' => PrintShipmentsEndpointRequest::class, 'action' => PrintShipmentsAction::class, ], @@ -194,7 +202,7 @@ /** * Update plugin settings */ - PdkBackendActions::UPDATE_PLUGIN_SETTINGS => [ + PdkBackendActions::UPDATE_PLUGIN_SETTINGS => [ 'request' => UpdatePluginSettingsEndpointRequest::class, 'action' => UpdatePluginSettingsAction::class, ], @@ -202,7 +210,7 @@ /** * Update product settings */ - PdkBackendActions::UPDATE_PRODUCT_SETTINGS => [ + PdkBackendActions::UPDATE_PRODUCT_SETTINGS => [ 'request' => UpdateProductSettingsEndpointRequest::class, 'action' => UpdateProductSettingsAction::class, ], @@ -210,7 +218,7 @@ /** * Create return shipment */ - PdkBackendActions::EXPORT_RETURN => [ + PdkBackendActions::EXPORT_RETURN => [ 'request' => ExportReturnEndpointRequest::class, 'action' => ExportReturnAction::class, ], @@ -218,7 +226,7 @@ /** * Create webhooks */ - PdkBackendActions::CREATE_WEBHOOKS => [ + PdkBackendActions::CREATE_WEBHOOKS => [ 'request' => CreateWebhooksEndpointRequest::class, 'action' => CreateWebhooksAction::class, ], @@ -226,7 +234,7 @@ /** * Delete webhooks */ - PdkBackendActions::DELETE_WEBHOOKS => [ + PdkBackendActions::DELETE_WEBHOOKS => [ 'request' => DeleteWebhooksEndpointRequest::class, 'action' => DeleteWebhooksAction::class, ], @@ -234,7 +242,7 @@ /** * Fetch webhooks */ - PdkBackendActions::FETCH_WEBHOOKS => [ + PdkBackendActions::FETCH_WEBHOOKS => [ 'request' => FetchWebhooksEndpointRequest::class, 'action' => FetchWebhooksAction::class, ], @@ -242,7 +250,7 @@ /** * Download logs */ - PdkBackendActions::DOWNLOAD_LOGS => [ + PdkBackendActions::DOWNLOAD_LOGS => [ 'request' => DownloadLogsEndpointRequest::class, 'action' => DownloadLogsAction::class, ], diff --git a/config/pdk-default.php b/config/pdk-default.php index b9f4e2b7a..90e58d9a2 100644 --- a/config/pdk-default.php +++ b/config/pdk-default.php @@ -38,7 +38,8 @@ 'apiUrl' => env('PDK_API_URL', 'https://api.myparcel.nl'), 'printingApiUrl' => env('PDK_PRINTING_API_URL', 'https://printing.api.myparcel.nl'), 'addressesServiceUrl' => env('PDK_ADDRESSES_SERVICE_URL', 'https://address.api.myparcel.nl'), - + 'capabilitiesServiceUrl' => env('PDK_CAPABILITIES_SERVICE_URL', 'https://api.myparcel.nl'), + /** * Security settings for the proxy */ diff --git a/src/Api/PdkCapabilitiesActions.php b/src/Api/PdkCapabilitiesActions.php new file mode 100644 index 000000000..1050952d2 --- /dev/null +++ b/src/Api/PdkCapabilitiesActions.php @@ -0,0 +1,13 @@ +body = $response->getBody(); + $this->statusCode = $response->getStatusCode(); + } + + public function getBody(): ?string + { + return $this->body; + } + + public function getSymfonyResponse(): Response + { + return new Response($this->body, $this->statusCode, ['Content-Type' => 'application/json']); + } +} diff --git a/src/Api/Service/CapabilitiesApiService.php b/src/Api/Service/CapabilitiesApiService.php new file mode 100644 index 000000000..bc8a49a9c --- /dev/null +++ b/src/Api/Service/CapabilitiesApiService.php @@ -0,0 +1,70 @@ +baseUrl ?? Pdk::get('capabilitiesServiceUrl'); + + if (! $baseUrl) { + throw new RuntimeException('Capabilities service URL is not configured'); + } + + return $baseUrl; + } + + /** + * @return array + */ + public function getHeaders(): array + { + $apiKey = Settings::get(AccountSettings::API_KEY, AccountSettings::ID); + + if (! $apiKey) { + throw new RuntimeException('API key is not configured'); + } + + return [ + 'Authorization' => sprintf('bearer %s', base64_encode($apiKey)), + 'User-Agent' => $this->getUserAgentHeader(), + ]; + } + + /** + * @return string + */ + protected function getUserAgentHeader(): string + { + $userAgentStrings = []; + $userAgents = array_merge( + (array) (Pdk::get('userAgent') ?? []), + [ + 'MyParcelNL-PDK' => Pdk::get('pdkVersion'), + 'php' => PHP_VERSION, + ] + ); + + foreach ($userAgents as $platform => $version) { + if ($version) { + $userAgentStrings[] = sprintf('%s/%s', $platform, $version); + } + } + + return implode(' ', $userAgentStrings); + } +} diff --git a/src/App/Action/Capabilities/CapabilitiesAction.php b/src/App/Action/Capabilities/CapabilitiesAction.php new file mode 100644 index 000000000..75125b5a2 --- /dev/null +++ b/src/App/Action/Capabilities/CapabilitiesAction.php @@ -0,0 +1,71 @@ +apiService = $apiService; + } + + /** + * @param \Symfony\Component\HttpFoundation\Request $request + * + * @return \Symfony\Component\HttpFoundation\Response + */ + public function handle(Request $request): Response + { + $corsHandler = Pdk::get(CorsHandler::class); + + if ($request->isMethod('OPTIONS')) { + return $corsHandler->handlePreflightRequest($request) ?? new Response(); + } + + /** @var \MyParcelNL\Pdk\Api\Response\CapabilitiesResponse $response */ + $response = $this->apiService->doRequest($this->buildRequest($request), CapabilitiesResponse::class); + + $symfonyResponse = $response->getSymfonyResponse(); + + return $corsHandler->addCorsHeaders($request, $symfonyResponse); + } + + /** + * @param \Symfony\Component\HttpFoundation\Request $incomingRequest + * + * @return \MyParcelNL\Pdk\Api\Request\Request + */ + public function buildRequest(Request $incomingRequest): ApiRequest + { + $query = $incomingRequest->query->all(); + $path = $query['path'] ?? ''; + $method = $incomingRequest->getMethod(); + + unset($query['action'], $query['pdk_action'], $query['path']); + + return new ApiRequest([ + 'method' => $method, + 'path' => $path ? '/' . ltrim((string) $path, '/') : '', + 'parameters' => $query, + ]); + } +} diff --git a/src/App/Request/Capabilities/CapabilitiesEndpointRequest.php b/src/App/Request/Capabilities/CapabilitiesEndpointRequest.php new file mode 100644 index 000000000..e4af2e24c --- /dev/null +++ b/src/App/Request/Capabilities/CapabilitiesEndpointRequest.php @@ -0,0 +1,18 @@ + '/delivery-options', + 'carrier' => 'postnl', + 'cc' => 'NL', + 'action' => 'proxyCapabilities', + 'pdk_action' => 'proxyCapabilities', + ]); + + $mockService = Mockery::mock(CapabilitiesApiService::class); + $action = new CapabilitiesAction($mockService); + + $request = $action->buildRequest($incomingRequest); + + expect($request->getPath())->toBe('/delivery-options') + ->and($request->getMethod())->toBe('GET') + ->and($request->getQueryString())->toBe('carrier=postnl&cc=NL'); +}); + +it('uses incoming request method', function () { + $incomingRequest = Request::create('/', 'POST', [ + 'path' => '/delivery-options', + ]); + + $mockService = Mockery::mock(CapabilitiesApiService::class); + $action = new CapabilitiesAction($mockService); + + $request = $action->buildRequest($incomingRequest); + + expect($request->getMethod())->toBe('POST'); +}); + +it('handles OPTIONS preflight request', function () { + $request = Request::create('/', 'OPTIONS'); + + $mockCorsHandler = Mockery::mock(CorsHandler::class); + $mockCorsHandler->shouldReceive('handlePreflightRequest') + ->with($request) + ->andReturn(new Response('', 204)); + + Pdk::set(CorsHandler::class, $mockCorsHandler); + + $mockService = Mockery::mock(CapabilitiesApiService::class); + // Service should NOT be called for OPTIONS + $mockService->shouldNotReceive('doRequest'); + + $action = new CapabilitiesAction($mockService); + $response = $action->handle($request); + + expect($response->getStatusCode())->toBe(204); +}); + +it('adds CORS headers to response', function () { + $request = Request::create('/', 'GET'); + + $mockService = Mockery::mock(CapabilitiesApiService::class); + $mockResponse = Mockery::mock(CapabilitiesResponse::class); + $symfonyResponse = new Response('{}', 200); + + $mockResponse->shouldReceive('getSymfonyResponse')->andReturn($symfonyResponse); + $mockService->shouldReceive('doRequest')->once()->andReturn($mockResponse); + + $mockCorsHandler = Mockery::mock(CorsHandler::class); + $mockCorsHandler->shouldReceive('addCorsHeaders') + ->with($request, $symfonyResponse) + ->andReturn($symfonyResponse); + + Pdk::set(CorsHandler::class, $mockCorsHandler); + + $action = new CapabilitiesAction($mockService); + $response = $action->handle($request); + + expect($response)->toBe($symfonyResponse); +}); From dd7dbfaec26b97ab57a34836370fcd2740e44ac8 Mon Sep 17 00:00:00 2001 From: jochemgravendeel Date: Fri, 16 Jan 2026 14:53:20 +0100 Subject: [PATCH 2/4] set basic capabilities proxy --- config/pdk-services.php | 6 ++++++ ...data_with_data_set_delivery_options_config__1.json | 11 +++++++++++ ...s_component_with_data_set_delivery_options__1.json | 11 +++++++++++ 3 files changed, 28 insertions(+) diff --git a/config/pdk-services.php b/config/pdk-services.php index 92ab2c4bd..387d9e492 100644 --- a/config/pdk-services.php +++ b/config/pdk-services.php @@ -7,6 +7,7 @@ use MyParcelNL\Pdk\Account\Service\AccountSettingsService; use MyParcelNL\Pdk\Api\Contract\ApiServiceInterface; use MyParcelNL\Pdk\Api\Service\AddressesApiService; +use MyParcelNL\Pdk\Api\Service\CapabilitiesApiService; use MyParcelNL\Pdk\Api\Service\MyParcelApiService; use MyParcelNL\Pdk\App\Account\Contract\PdkAccountRepositoryInterface; use MyParcelNL\Pdk\App\Api\Contract\PdkActionsServiceInterface; @@ -197,6 +198,11 @@ */ AddressesApiService::class => autowire(), + /** + * Capabilities API proxy + */ + CapabilitiesApiService::class => autowire(), + /** * @todo remove in v3.0.0 */ diff --git a/tests/__snapshots__/ContextServiceTest__it_gets_context_data_with_data_set_delivery_options_config__1.json b/tests/__snapshots__/ContextServiceTest__it_gets_context_data_with_data_set_delivery_options_config__1.json index a53a71c57..8cc2e7a17 100644 --- a/tests/__snapshots__/ContextServiceTest__it_gets_context_data_with_data_set_delivery_options_config__1.json +++ b/tests/__snapshots__/ContextServiceTest__it_gets_context_data_with_data_set_delivery_options_config__1.json @@ -40,6 +40,17 @@ "property": "validate", "responseProperty": null }, + "proxyCapabilities": { + "body": null, + "headers": [], + "method": "GET", + "parameters": { + "action": "proxyCapabilities" + }, + "path": "", + "property": "capabilities", + "responseProperty": null + }, "fetchContext": { "body": null, "headers": [], diff --git a/tests/__snapshots__/FrontendRenderServiceTest__it_renders_component_with_data_set_delivery_options__1.json b/tests/__snapshots__/FrontendRenderServiceTest__it_renders_component_with_data_set_delivery_options__1.json index e977ccd6d..1b79d5f5f 100644 --- a/tests/__snapshots__/FrontendRenderServiceTest__it_renders_component_with_data_set_delivery_options__1.json +++ b/tests/__snapshots__/FrontendRenderServiceTest__it_renders_component_with_data_set_delivery_options__1.json @@ -55,6 +55,17 @@ "property": "validate", "responseProperty": null }, + "proxyCapabilities": { + "body": null, + "headers": [], + "method": "GET", + "parameters": { + "action": "proxyCapabilities" + }, + "path": "", + "property": "capabilities", + "responseProperty": null + }, "fetchContext": { "body": null, "headers": [], From 7328d3fe022c37c5548c57318c539763f91c328a Mon Sep 17 00:00:00 2001 From: jochemgravendeel Date: Tue, 20 Jan 2026 12:39:55 +0100 Subject: [PATCH 3/4] add tests --- .../Api/Response/CapabilitiesResponseTest.php | 34 ++++ .../Service/CapabilitiesApiServiceTest.php | 146 ++++++++++++++++++ 2 files changed, 180 insertions(+) create mode 100644 tests/Unit/Api/Response/CapabilitiesResponseTest.php create mode 100644 tests/Unit/Api/Service/CapabilitiesApiServiceTest.php diff --git a/tests/Unit/Api/Response/CapabilitiesResponseTest.php b/tests/Unit/Api/Response/CapabilitiesResponseTest.php new file mode 100644 index 000000000..bbb53ea68 --- /dev/null +++ b/tests/Unit/Api/Response/CapabilitiesResponseTest.php @@ -0,0 +1,34 @@ + [ + 'capabilities' => ['standard', 'evening'], + ], + ]); + $response = new CapabilitiesResponse(new ClientResponse($exampleJson, 201)); + + expect($response->getBody())->toBe($exampleJson); +}); + +it('can get the symfony response', function () { + $exampleJson = json_encode([ + 'data' => [ + 'capabilities' => ['standard', 'evening'], + ], + ]); + + $response = new CapabilitiesResponse(new ClientResponse($exampleJson, 200)); + + expect($response->getSymfonyResponse())->toBeInstanceOf(Response::class); + expect($response->getSymfonyResponse()->getStatusCode())->toBe(200); + expect($response->getSymfonyResponse()->getContent())->toBe($exampleJson); +}); diff --git a/tests/Unit/Api/Service/CapabilitiesApiServiceTest.php b/tests/Unit/Api/Service/CapabilitiesApiServiceTest.php new file mode 100644 index 000000000..77392e2e3 --- /dev/null +++ b/tests/Unit/Api/Service/CapabilitiesApiServiceTest.php @@ -0,0 +1,146 @@ +clientAdapter = $this->createMock(ClientAdapterInterface::class); + $this->service = new CapabilitiesApiService($this->clientAdapter); + + // Reset all mocked properties to default values + mockPdkProperty('capabilitiesServiceUrl', 'https://api.myparcel.nl'); + mockPdkProperty('userAgent', []); + mockPdkProperty('pdkVersion', '1.0.0'); + + // Set default API key for most tests + TestBootstrapper::hasApiKey('test-api-key'); +}); + +// Base URL configuration tests +it('uses configured service url for base url', function () { + expect($this->service->getBaseUrl()) + ->toBe('https://api.myparcel.nl'); +}); + +it('uses property if set for base url', function () { + $expectedUrl = 'https://custom-api.myparcel.nl'; + $this->service->setBaseUrl($expectedUrl); + + expect($this->service->getBaseUrl()) + ->toBe($expectedUrl); +}); + +it('throws exception if base url is not configured', function () { + mockPdkProperty('capabilitiesServiceUrl', null); + + expect(fn() => $this->service->getBaseUrl()) + ->toThrow(\RuntimeException::class, 'Capabilities service URL is not configured'); +}); + +// API Key configuration tests +it('injects bearer token in headers', function () { + $apiKey = 'test-api-key'; + TestBootstrapper::hasApiKey($apiKey); + + $headers = $this->service->getHeaders(); + + expect($headers) + ->toHaveKey('Authorization') + ->and($headers['Authorization']) + ->toBe('bearer ' . base64_encode($apiKey)); +}); + +it('throws exception if api key is not configured', function () { + TestBootstrapper::hasApiKey(null); + + expect(fn() => $this->service->getHeaders()) + ->toThrow(\RuntimeException::class, 'API key is not configured'); +}); + +// User Agent configuration tests +it('includes default user agent in headers', function () { + mockPdkProperty('userAgent', []); + mockPdkProperty('pdkVersion', '1.0.0'); + + $headers = $this->service->getHeaders(); + + expect($headers) + ->toHaveKey('User-Agent') + ->and($headers['User-Agent']) + ->toContain('MyParcelNL-PDK/1.0.0') + ->and($headers['User-Agent']) + ->toContain('php/' . PHP_VERSION); +}); + +it('includes custom user agent in headers', function () { + mockPdkProperty('userAgent', ['CustomApp' => '1.0.0']); + mockPdkProperty('pdkVersion', '1.0.0'); + + $headers = $this->service->getHeaders(); + + expect($headers) + ->toHaveKey('User-Agent') + ->and($headers['User-Agent']) + ->toContain('CustomApp/1.0.0') + ->and($headers['User-Agent']) + ->toContain('MyParcelNL-PDK/1.0.0') + ->and($headers['User-Agent']) + ->toContain('php/' . PHP_VERSION); +}); + +it('includes multiple custom user agents in headers', function () { + mockPdkProperty('userAgent', [ + 'CustomApp' => '1.0.0', + 'AnotherApp' => '2.0.0', + ]); + mockPdkProperty('pdkVersion', '1.0.0'); + + $headers = $this->service->getHeaders(); + + expect($headers) + ->toHaveKey('User-Agent') + ->and($headers['User-Agent']) + ->toContain('CustomApp/1.0.0') + ->and($headers['User-Agent']) + ->toContain('AnotherApp/2.0.0') + ->and($headers['User-Agent']) + ->toContain('MyParcelNL-PDK/1.0.0') + ->and($headers['User-Agent']) + ->toContain('php/' . PHP_VERSION); +}); + +it('handles empty user agent configuration', function () { + mockPdkProperty('userAgent', []); + mockPdkProperty('pdkVersion', null); + + $headers = $this->service->getHeaders(); + + expect($headers) + ->toHaveKey('User-Agent') + ->and($headers['User-Agent']) + ->toBe('php/' . PHP_VERSION); +}); + +it('handles empty pdk version configuration', function () { + mockPdkProperty('userAgent', ['CustomApp' => '1.0.0']); + mockPdkProperty('pdkVersion', null); + + $headers = $this->service->getHeaders(); + + expect($headers) + ->toHaveKey('User-Agent') + ->and($headers['User-Agent']) + ->toContain('CustomApp/1.0.0') + ->and($headers['User-Agent']) + ->toContain('php/' . PHP_VERSION); +}); From cbb3df611a103970561cd6004f2b51c637bd98eb Mon Sep 17 00:00:00 2001 From: jochemgravendeel Date: Tue, 20 Jan 2026 14:19:49 +0100 Subject: [PATCH 4/4] update snapshots --- ...h_data_set_delivery_options_config__1.json | 487 ++++++----------- ...ent_with_data_set_delivery_options__1.json | 515 ++++++------------ 2 files changed, 336 insertions(+), 666 deletions(-) diff --git a/tests/__snapshots__/ContextServiceTest__it_gets_context_data_with_data_set_delivery_options_config__1.json b/tests/__snapshots__/ContextServiceTest__it_gets_context_data_with_data_set_delivery_options_config__1.json index f961844bf..7c85bfe75 100644 --- a/tests/__snapshots__/ContextServiceTest__it_gets_context_data_with_data_set_delivery_options_config__1.json +++ b/tests/__snapshots__/ContextServiceTest__it_gets_context_data_with_data_set_delivery_options_config__1.json @@ -1,333 +1,168 @@ { - "checkout": { - "platformConfig": { - "carriers": [ - { - "name": "postnl", - "active": true, - "subscription": -1, - "packageTypes": [ - "package", - "mailbox", - "letter", - "digital_stamp", - "package_small" - ], - "deliveryTypes": [ - "morning", - "standard", - "evening", - "pickup" - ], - "deliveryCountries": [ - "NL", - "BE" - ], - "pickupCountries": [ - "NL", - "BE", - "DK", - "SE", - "DE" - ], - "smallPackagePickupCountries": [ - "NL", - "BE" - ], - "fakeDelivery": true, - "shipmentOptionsPerPackageType": { - "package": [ - "only_recipient", - "signature" - ], - "mailbox": [ - "priority_delivery" - ], - "letter": [], - "digital_stamp": [], - "package_small": [ - "only_recipient", - "signature" - ] - }, - "features": [ - "deliveryDaysWindow", - "dropOffDays", - "dropOffDelay", - "pickupMapAllowLoadMore" - ], - "addressFields": [ - "postalCode", - "street", - "city" - ] - }, - { - "name": "dpd", - "active": true, - "subscription": -1, - "packageTypes": [ - "package", - "mailbox" - ], - "deliveryTypes": [ - "standard", - "pickup" - ], - "deliveryCountries": [ - "AT", - "BE", - "BG", - "CZ", - "DK", - "EE", - "FI", - "FR", - "DE", - "GR", - "HU", - "IE", - "IT", - "LV", - "LI", - "LT", - "LU", - "NL", - "PL", - "PT", - "RO", - "SK", - "SI", - "ES", - "SE" - ], - "pickupCountries": [ - "AT", - "BE", - "CZ", - "DK", - "EE", - "FI", - "FR", - "DE", - "HU", - "LV", - "LT", - "LU", - "NL", - "PL", - "PT", - "SK", - "SI", - "ES", - "GB" - ], - "shipmentOptionsPerPackageType": { - "package": [] - }, - "features": [ - "dropOffDays", - "dropOffDelay" - ], - "addressFields": [ - "postalCode", - "street", - "city" - ] - }, - { - "name": "dhlforyou", - "active": true, - "subscription": -1, - "packageTypes": [ - "package", - "mailbox", - "package_small" - ], - "deliveryTypes": [ - "standard", - "pickup" - ], - "deliveryCountries": [ - "NL", - "BE" - ], - "pickupCountries": [ - "NL", - "BE" - ], - "smallPackagePickupCountries": [ - "NL", - "BE" - ], - "shipmentOptionsPerPackageType": { - "package": [ - "age_check", - "only_recipient", - "same_day_delivery", - "signature", - "saturday_delivery", - "hide_sender", - "insurance" - ] - }, - "features": [ - "deliveryDaysWindow", - "dropOffDays", - "dropOffDelay" - ], - "addressFields": [ - "city", - "postalCode" - ] - }, - { - "name": "dhlparcelconnect", - "active": true, - "subscription": -1, - "packageTypes": [ - "package" - ], - "deliveryTypes": [ - "standard", - "pickup" - ], - "shipmentOptionsPerPackageType": { - "package": [ - "signature" - ] - } - }, - { - "name": "dhleuroplus", - "active": true, - "subscription": -1, - "packageTypes": [ - "package" - ], - "deliveryTypes": [ - "standard" - ], - "shipmentOptionsPerPackageType": { - "package": [ - "signature", - "saturday_delivery", - "hide_sender", - "insurance" - ] - } - }, - { - "name": "upsstandard", - "active": true, - "subscription": -1, - "packageTypes": [ - "package" - ], - "deliveryTypes": [ - "standard", - "pickup" - ], - "shipmentOptionsPerPackageType": { - "package": [ - "age_check", - "only_recipient", - "return", - "signature", - "collect", - "insurance" - ] - }, - "addressFields": [ - "postalCode", - "street", - "city" - ] - }, - { - "name": "upsexpresssaver", - "active": true, - "subscription": -1, - "packageTypes": [ - "package" - ], - "deliveryTypes": [ - "express", - "pickup" - ], - "shipmentOptionsPerPackageType": { - "package": [ - "age_check", - "only_recipient", - "return", - "signature", - "collect", - "insurance" - ] - }, - "addressFields": [ - "postalCode", - "street", - "city" - ], - "unsupportedParameters": [ - "package_type" - ] - } + "checkout": { + "platformConfig": { + "carriers": [ + { + "name": "postnl", + "active": true, + "subscription": -1, + "packageTypes": ["package", "mailbox", "letter", "digital_stamp", "package_small"], + "deliveryTypes": ["morning", "standard", "evening", "pickup"], + "deliveryCountries": ["NL", "BE"], + "pickupCountries": ["NL", "BE", "DK", "SE", "DE"], + "smallPackagePickupCountries": ["NL", "BE"], + "fakeDelivery": true, + "shipmentOptionsPerPackageType": { + "package": ["only_recipient", "signature"], + "mailbox": ["priority_delivery"], + "letter": [], + "digital_stamp": [], + "package_small": ["only_recipient", "signature"] + }, + "features": ["deliveryDaysWindow", "dropOffDays", "dropOffDelay", "pickupMapAllowLoadMore"], + "addressFields": ["postalCode", "street", "city"] + }, + { + "name": "dpd", + "active": true, + "subscription": -1, + "packageTypes": ["package", "mailbox"], + "deliveryTypes": ["standard", "pickup"], + "deliveryCountries": [ + "AT", + "BE", + "BG", + "CZ", + "DK", + "EE", + "FI", + "FR", + "DE", + "GR", + "HU", + "IE", + "IT", + "LV", + "LI", + "LT", + "LU", + "NL", + "PL", + "PT", + "RO", + "SK", + "SI", + "ES", + "SE" + ], + "pickupCountries": [ + "AT", + "BE", + "CZ", + "DK", + "EE", + "FI", + "FR", + "DE", + "HU", + "LV", + "LT", + "LU", + "NL", + "PL", + "PT", + "SK", + "SI", + "ES", + "GB" + ], + "shipmentOptionsPerPackageType": { + "package": [] + }, + "features": ["dropOffDays", "dropOffDelay"], + "addressFields": ["postalCode", "street", "city"] + }, + { + "name": "dhlforyou", + "active": true, + "subscription": -1, + "packageTypes": ["package", "mailbox", "package_small"], + "deliveryTypes": ["standard", "pickup"], + "deliveryCountries": ["NL", "BE"], + "pickupCountries": ["NL", "BE"], + "smallPackagePickupCountries": ["NL", "BE"], + "shipmentOptionsPerPackageType": { + "package": [ + "age_check", + "only_recipient", + "same_day_delivery", + "signature", + "saturday_delivery", + "hide_sender", + "insurance" ] + }, + "features": ["deliveryDaysWindow", "dropOffDays", "dropOffDelay"], + "addressFields": ["city", "postalCode"] + }, + { + "name": "dhlparcelconnect", + "active": true, + "subscription": -1, + "packageTypes": ["package"], + "deliveryTypes": ["standard", "pickup"], + "shipmentOptionsPerPackageType": { + "package": ["signature"] + } + }, + { + "name": "dhleuroplus", + "active": true, + "subscription": -1, + "packageTypes": ["package"], + "deliveryTypes": ["standard"], + "shipmentOptionsPerPackageType": { + "package": ["signature", "saturday_delivery", "hide_sender", "insurance"] + } }, - "strings": { - "morning": "Ochtend" + { + "name": "upsstandard", + "active": true, + "subscription": -1, + "packageTypes": ["package"], + "deliveryTypes": ["standard", "pickup"], + "shipmentOptionsPerPackageType": { + "package": ["age_check", "only_recipient", "return", "signature", "collect", "insurance"] + }, + "addressFields": ["postalCode", "street", "city"] }, - "settings": { - "actions": { - "baseUrl": "FRONTEND_URL", - "endpoints": { - "fetchCheckoutContext": { - "body": null, - "headers": [], - "method": "GET", - "parameters": { - "action": "fetchCheckoutContext" - }, - "path": "", - "property": "context", - "responseProperty": null - }, - "proxyAddressList": { - "body": null, - "headers": [], - "method": "GET", - "parameters": { - "action": "proxyAddressList" - }, - "path": "", - "property": "addresses", - "responseProperty": null - }, - "proxyAddressValidate": { - "body": null, - "headers": [], - "method": "GET", - "parameters": { - "action": "proxyAddressValidate" - }, - "path": "", - "property": "validate", - "responseProperty": null - }, - "fetchContext": { - "body": null, - "headers": [], - "method": "GET", - "parameters": { - "action": "fetchContext" - }, - "path": "", - "property": "context", - "responseProperty": null - } - } + { + "name": "upsexpresssaver", + "active": true, + "subscription": -1, + "packageTypes": ["package"], + "deliveryTypes": ["express", "pickup"], + "shipmentOptionsPerPackageType": { + "package": ["age_check", "only_recipient", "return", "signature", "collect", "insurance"] + }, + "addressFields": ["postalCode", "street", "city"], + "unsupportedParameters": ["package_type"] + } + ] + }, + "strings": { + "morning": "Ochtend" + }, + "settings": { + "actions": { + "baseUrl": "FRONTEND_URL", + "endpoints": { + "fetchCheckoutContext": { + "body": null, + "headers": [], + "method": "GET", + "parameters": { + "action": "fetchCheckoutContext" }, "path": "", "property": "context", diff --git a/tests/__snapshots__/FrontendRenderServiceTest__it_renders_component_with_data_set_delivery_options__1.json b/tests/__snapshots__/FrontendRenderServiceTest__it_renders_component_with_data_set_delivery_options__1.json index 0af287d0f..82171d812 100644 --- a/tests/__snapshots__/FrontendRenderServiceTest__it_renders_component_with_data_set_delivery_options__1.json +++ b/tests/__snapshots__/FrontendRenderServiceTest__it_renders_component_with_data_set_delivery_options__1.json @@ -1,348 +1,183 @@ { - "checkout": { - "config": { - "allowRetry": false, - "basePrice": 0, - "carrierSettings": [], - "currency": "EUR", - "locale": "nl-NL", - "packageType": "package", - "allowPickupLocationsViewSelection": true, - "platform": "myparcel", - "priceStandardDelivery": 0, - "showPriceSurcharge": false, - "closedDays": [], - "excludeParcelLockers": false, - "apiBaseUrl": "https:\/\/api.myparcel.nl" + "checkout": { + "config": { + "allowRetry": false, + "basePrice": 0, + "carrierSettings": [], + "currency": "EUR", + "locale": "nl-NL", + "packageType": "package", + "allowPickupLocationsViewSelection": true, + "platform": "myparcel", + "priceStandardDelivery": 0, + "showPriceSurcharge": false, + "closedDays": [], + "excludeParcelLockers": false, + "apiBaseUrl": "https://api.myparcel.nl" + }, + "platformConfig": { + "carriers": [ + { + "name": "postnl", + "active": true, + "subscription": -1, + "packageTypes": ["package", "mailbox", "letter", "digital_stamp", "package_small"], + "deliveryTypes": ["morning", "standard", "evening", "pickup"], + "deliveryCountries": ["NL", "BE"], + "pickupCountries": ["NL", "BE", "DK", "SE", "DE"], + "smallPackagePickupCountries": ["NL", "BE"], + "fakeDelivery": true, + "shipmentOptionsPerPackageType": { + "package": ["only_recipient", "signature"], + "mailbox": ["priority_delivery"], + "letter": [], + "digital_stamp": [], + "package_small": ["only_recipient", "signature"] + }, + "features": ["deliveryDaysWindow", "dropOffDays", "dropOffDelay", "pickupMapAllowLoadMore"], + "addressFields": ["postalCode", "street", "city"] }, - "platformConfig": { - "carriers": [ - { - "name": "postnl", - "active": true, - "subscription": -1, - "packageTypes": [ - "package", - "mailbox", - "letter", - "digital_stamp", - "package_small" - ], - "deliveryTypes": [ - "morning", - "standard", - "evening", - "pickup" - ], - "deliveryCountries": [ - "NL", - "BE" - ], - "pickupCountries": [ - "NL", - "BE", - "DK", - "SE", - "DE" - ], - "smallPackagePickupCountries": [ - "NL", - "BE" - ], - "fakeDelivery": true, - "shipmentOptionsPerPackageType": { - "package": [ - "only_recipient", - "signature" - ], - "mailbox": [ - "priority_delivery" - ], - "letter": [], - "digital_stamp": [], - "package_small": [ - "only_recipient", - "signature" - ] - }, - "features": [ - "deliveryDaysWindow", - "dropOffDays", - "dropOffDelay", - "pickupMapAllowLoadMore" - ], - "addressFields": [ - "postalCode", - "street", - "city" - ] - }, - { - "name": "dpd", - "active": true, - "subscription": -1, - "packageTypes": [ - "package", - "mailbox" - ], - "deliveryTypes": [ - "standard", - "pickup" - ], - "deliveryCountries": [ - "AT", - "BE", - "BG", - "CZ", - "DK", - "EE", - "FI", - "FR", - "DE", - "GR", - "HU", - "IE", - "IT", - "LV", - "LI", - "LT", - "LU", - "NL", - "PL", - "PT", - "RO", - "SK", - "SI", - "ES", - "SE" - ], - "pickupCountries": [ - "AT", - "BE", - "CZ", - "DK", - "EE", - "FI", - "FR", - "DE", - "HU", - "LV", - "LT", - "LU", - "NL", - "PL", - "PT", - "SK", - "SI", - "ES", - "GB" - ], - "shipmentOptionsPerPackageType": { - "package": [] - }, - "features": [ - "dropOffDays", - "dropOffDelay" - ], - "addressFields": [ - "postalCode", - "street", - "city" - ] - }, - { - "name": "dhlforyou", - "active": true, - "subscription": -1, - "packageTypes": [ - "package", - "mailbox", - "package_small" - ], - "deliveryTypes": [ - "standard", - "pickup" - ], - "deliveryCountries": [ - "NL", - "BE" - ], - "pickupCountries": [ - "NL", - "BE" - ], - "smallPackagePickupCountries": [ - "NL", - "BE" - ], - "shipmentOptionsPerPackageType": { - "package": [ - "age_check", - "only_recipient", - "same_day_delivery", - "signature", - "saturday_delivery", - "hide_sender", - "insurance" - ] - }, - "features": [ - "deliveryDaysWindow", - "dropOffDays", - "dropOffDelay" - ], - "addressFields": [ - "city", - "postalCode" - ] - }, - { - "name": "dhlparcelconnect", - "active": true, - "subscription": -1, - "packageTypes": [ - "package" - ], - "deliveryTypes": [ - "standard", - "pickup" - ], - "shipmentOptionsPerPackageType": { - "package": [ - "signature" - ] - } - }, - { - "name": "dhleuroplus", - "active": true, - "subscription": -1, - "packageTypes": [ - "package" - ], - "deliveryTypes": [ - "standard" - ], - "shipmentOptionsPerPackageType": { - "package": [ - "signature", - "saturday_delivery", - "hide_sender", - "insurance" - ] - } - }, - { - "name": "upsstandard", - "active": true, - "subscription": -1, - "packageTypes": [ - "package" - ], - "deliveryTypes": [ - "standard", - "pickup" - ], - "shipmentOptionsPerPackageType": { - "package": [ - "age_check", - "only_recipient", - "return", - "signature", - "collect", - "insurance" - ] - }, - "addressFields": [ - "postalCode", - "street", - "city" - ] - }, - { - "name": "upsexpresssaver", - "active": true, - "subscription": -1, - "packageTypes": [ - "package" - ], - "deliveryTypes": [ - "express", - "pickup" - ], - "shipmentOptionsPerPackageType": { - "package": [ - "age_check", - "only_recipient", - "return", - "signature", - "collect", - "insurance" - ] - }, - "addressFields": [ - "postalCode", - "street", - "city" - ], - "unsupportedParameters": [ - "package_type" - ] - } + { + "name": "dpd", + "active": true, + "subscription": -1, + "packageTypes": ["package", "mailbox"], + "deliveryTypes": ["standard", "pickup"], + "deliveryCountries": [ + "AT", + "BE", + "BG", + "CZ", + "DK", + "EE", + "FI", + "FR", + "DE", + "GR", + "HU", + "IE", + "IT", + "LV", + "LI", + "LT", + "LU", + "NL", + "PL", + "PT", + "RO", + "SK", + "SI", + "ES", + "SE" + ], + "pickupCountries": [ + "AT", + "BE", + "CZ", + "DK", + "EE", + "FI", + "FR", + "DE", + "HU", + "LV", + "LT", + "LU", + "NL", + "PL", + "PT", + "SK", + "SI", + "ES", + "GB" + ], + "shipmentOptionsPerPackageType": { + "package": [] + }, + "features": ["dropOffDays", "dropOffDelay"], + "addressFields": ["postalCode", "street", "city"] + }, + { + "name": "dhlforyou", + "active": true, + "subscription": -1, + "packageTypes": ["package", "mailbox", "package_small"], + "deliveryTypes": ["standard", "pickup"], + "deliveryCountries": ["NL", "BE"], + "pickupCountries": ["NL", "BE"], + "smallPackagePickupCountries": ["NL", "BE"], + "shipmentOptionsPerPackageType": { + "package": [ + "age_check", + "only_recipient", + "same_day_delivery", + "signature", + "saturday_delivery", + "hide_sender", + "insurance" ] + }, + "features": ["deliveryDaysWindow", "dropOffDays", "dropOffDelay"], + "addressFields": ["city", "postalCode"] + }, + { + "name": "dhlparcelconnect", + "active": true, + "subscription": -1, + "packageTypes": ["package"], + "deliveryTypes": ["standard", "pickup"], + "shipmentOptionsPerPackageType": { + "package": ["signature"] + } + }, + { + "name": "dhleuroplus", + "active": true, + "subscription": -1, + "packageTypes": ["package"], + "deliveryTypes": ["standard"], + "shipmentOptionsPerPackageType": { + "package": ["signature", "saturday_delivery", "hide_sender", "insurance"] + } }, - "strings": { - "morning": "Ochtend" + { + "name": "upsstandard", + "active": true, + "subscription": -1, + "packageTypes": ["package"], + "deliveryTypes": ["standard", "pickup"], + "shipmentOptionsPerPackageType": { + "package": ["age_check", "only_recipient", "return", "signature", "collect", "insurance"] + }, + "addressFields": ["postalCode", "street", "city"] }, - "settings": { - "actions": { - "baseUrl": "FRONTEND_URL", - "endpoints": { - "fetchCheckoutContext": { - "body": null, - "headers": [], - "method": "GET", - "parameters": { - "action": "fetchCheckoutContext" - }, - "path": "", - "property": "context", - "responseProperty": null - }, - "proxyAddressList": { - "body": null, - "headers": [], - "method": "GET", - "parameters": { - "action": "proxyAddressList" - }, - "path": "", - "property": "addresses", - "responseProperty": null - }, - "proxyAddressValidate": { - "body": null, - "headers": [], - "method": "GET", - "parameters": { - "action": "proxyAddressValidate" - }, - "path": "", - "property": "validate", - "responseProperty": null - }, - "fetchContext": { - "body": null, - "headers": [], - "method": "GET", - "parameters": { - "action": "fetchContext" - }, - "path": "", - "property": "context", - "responseProperty": null - } - } + { + "name": "upsexpresssaver", + "active": true, + "subscription": -1, + "packageTypes": ["package"], + "deliveryTypes": ["express", "pickup"], + "shipmentOptionsPerPackageType": { + "package": ["age_check", "only_recipient", "return", "signature", "collect", "insurance"] + }, + "addressFields": ["postalCode", "street", "city"], + "unsupportedParameters": ["package_type"] + } + ] + }, + "strings": { + "morning": "Ochtend" + }, + "settings": { + "actions": { + "baseUrl": "FRONTEND_URL", + "endpoints": { + "fetchCheckoutContext": { + "body": null, + "headers": [], + "method": "GET", + "parameters": { + "action": "fetchCheckoutContext" }, "path": "", "property": "context",