diff --git a/README.md b/README.md index ddbb1ae..dbc1ebc 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ [![Latest Version on Packagist](https://img.shields.io/packagist/v/rojtjo/bol-api-client.svg?style=flat-square)](https://packagist.org/packages/rojtjo/bol-api-client) [![Tests](https://github.com/rojtjo/bol-api-client/actions/workflows/tests.yml/badge.svg)](https://github.com/rojtjo/bol-api-client/actions/workflows/tests.yml) -Interact with the Bol.com API v9. +Interact with the Bol.com API v10. ## Installation diff --git a/src/Connectors/OfferConnector.php b/src/Connectors/OfferConnector.php index 520bf07..dec9e73 100644 --- a/src/Connectors/OfferConnector.php +++ b/src/Connectors/OfferConnector.php @@ -75,7 +75,7 @@ public function requestOfferExportFile(): ProcessStatus public function retrieveOfferExportFile(string $exportId): ExportOfferCollection { $data = $this->send('GET', "offers/export/$exportId", headers: [ - 'Accept' => 'application/vnd.retailer.v9+csv', + 'Accept' => 'application/vnd.retailer.v10+csv', ]); return ExportOfferCollection::fromPayload($data); diff --git a/src/Connectors/SubscriptionConnector.php b/src/Connectors/SubscriptionConnector.php index 91b7058..f12eb80 100644 --- a/src/Connectors/SubscriptionConnector.php +++ b/src/Connectors/SubscriptionConnector.php @@ -10,6 +10,7 @@ use Rojtjo\Bol\Types\SignatureKeyCollection; use Rojtjo\Bol\Types\Subscription; use Rojtjo\Bol\Types\SubscriptionCollection; +use Rojtjo\Bol\Types\SubscriptionType; final class SubscriptionConnector extends ConnectorAbstract { @@ -39,21 +40,24 @@ public function findSubscription(string $subscriptionId): Subscription return Subscription::fromPayload($data); } - public function createSubscription(array $resources, string $url): ProcessStatus + public function createSubscription(array $resources, string $url, SubscriptionType $subscriptionType): ProcessStatus { $data = $this->send('POST', 'subscriptions', body: [ - 'resources' => $resources, - 'url' => $url, + 'resources' => $resources, + 'url' => $url, + 'subscriptionType' => $subscriptionType->value, ]); return ProcessStatus::fromPayload($data); } - public function updateSubscription(string $subscriptionId, array $resources, string $url): ProcessStatus + public function updateSubscription(string $subscriptionId, array $resources, string $url, SubscriptionType $subscriptionType, bool $enabled): ProcessStatus { $data = $this->send('PUT', "subscriptions/$subscriptionId", body: [ - 'resources' => $resources, - 'url' => $url, + 'resources' => $resources, + 'url' => $url, + 'subscriptionType' => $subscriptionType->value, + 'enabled' => $enabled ]); return ProcessStatus::fromPayload($data); diff --git a/src/Types/Subscription.php b/src/Types/Subscription.php index ec3d7ce..3fa38f1 100644 --- a/src/Types/Subscription.php +++ b/src/Types/Subscription.php @@ -10,6 +10,8 @@ public function __construct( public readonly string $id, public readonly array $resources, public readonly string $url, + public readonly SubscriptionType $subscriptionType, + public readonly bool $enabled, ) { } @@ -20,6 +22,8 @@ public static function fromPayload(array $subscription): self $subscription['id'], $subscription['resources'], $subscription['url'], + SubscriptionType::from($subscription['subscriptionType']), + $subscription['enabled'], ); } } diff --git a/src/Types/SubscriptionType.php b/src/Types/SubscriptionType.php new file mode 100644 index 0000000..5a325e0 --- /dev/null +++ b/src/Types/SubscriptionType.php @@ -0,0 +1,12 @@ +getHeaderLine('Content-Type'); - if (str_contains($contentType, 'application/vnd.retailer.v9+json')) { + if (str_contains($contentType, 'application/vnd.retailer.v10+json')) { return self::decodeJson($response); } diff --git a/tests/Integration/OffersTest.php b/tests/Integration/OffersTest.php index decd7eb..5f11727 100644 --- a/tests/Integration/OffersTest.php +++ b/tests/Integration/OffersTest.php @@ -23,7 +23,7 @@ final class OffersTest extends IntegrationTestCase { /** * @test - * @see https://api.bol.com/retailer/public/Retailer-API/demo/v9-OFFERS.html#_create_an_offer_export_csv_file + * @see https://api.bol.com/retailer/public/Retailer-API/demo/v10-OFFERS.html#_create_an_offer_export_csv_file */ public function create_an_offer_export_csv_file(): void { @@ -36,7 +36,7 @@ public function create_an_offer_export_csv_file(): void /** * @test - * @see https://api.bol.com/retailer/public/Retailer-API/demo/v9-OFFERS.html#_retrieve_an_offer_export_csv_file + * @see https://api.bol.com/retailer/public/Retailer-API/demo/v10-OFFERS.html#_retrieve_an_offer_export_csv_file */ public function retrieve_an_offer_export_csv_file(): void { @@ -49,7 +49,7 @@ public function retrieve_an_offer_export_csv_file(): void /** * @test - * @see https://api.bol.com/retailer/public/Retailer-API/demo/v9-OFFERS.html#_retrieve_an_offer + * @see https://api.bol.com/retailer/public/Retailer-API/demo/v10-OFFERS.html#_retrieve_an_offer */ public function retrieve_an_offer(): void { @@ -62,7 +62,7 @@ public function retrieve_an_offer(): void /** * @test - * @see https://api.bol.com/retailer/public/Retailer-API/demo/v9-OFFERS.html#_update_of_an_already_existing_offer_with_offerid_13722de8_8182_d161_5422_4a0a1caab5c8 + * @see https://api.bol.com/retailer/public/Retailer-API/demo/v10-OFFERS.html#_update_of_an_already_existing_offer_with_offerid_13722de8_8182_d161_5422_4a0a1caab5c8 */ public function create_fbr_offer_for_ean_9780471117094_with_condition_new_with_vvb_proposition(): void { @@ -98,7 +98,7 @@ public function create_fbr_offer_for_ean_9780471117094_with_condition_new_with_v /** * @test - * @see https://api.bol.com/retailer/public/Retailer-API/demo/v9-OFFERS.html#_create_fbr_offer_for_ean_0045496420253_with_condition_moderate + * @see https://api.bol.com/retailer/public/Retailer-API/demo/v10-OFFERS.html#_create_fbr_offer_for_ean_0045496420253_with_condition_moderate */ public function create_fbr_offer_for_ean_0045496420253_with_condition_moderate(): void @@ -136,7 +136,7 @@ function create_fbr_offer_for_ean_0045496420253_with_condition_moderate(): void /** * @test - * @see https://api.bol.com/retailer/public/Retailer-API/demo/v9-OFFERS.html#_delete_an_already_existing_offer_that_is_known_with_offerid_13722de8_8182_d161_5422_4a0a1caab5c8 + * @see https://api.bol.com/retailer/public/Retailer-API/demo/v10-OFFERS.html#_delete_an_already_existing_offer_that_is_known_with_offerid_13722de8_8182_d161_5422_4a0a1caab5c8 */ public function delete_an_already_existing_offer_that_is_known_with_offerid_13722de8_8182_d161_5422_4a0a1caab5c8(): void @@ -150,7 +150,7 @@ function delete_an_already_existing_offer_that_is_known_with_offerid_13722de8_81 /** * @test - * @see https://api.bol.com/retailer/public/Retailer-API/demo/v9-OFFERS.html#_update_the_price_for_a_specific_offer + * @see https://api.bol.com/retailer/public/Retailer-API/demo/v10-OFFERS.html#_update_the_price_for_a_specific_offer */ public function update_the_price_for_a_specific_offer(): void @@ -174,7 +174,7 @@ function update_the_price_for_a_specific_offer(): void /** * @test - * @see https://api.bol.com/retailer/public/Retailer-API/demo/v9-OFFERS.html#_update_the_current_stock_level_for_offerid_13722de8_8182_d161_5422_4a0a1caab5c8 + * @see https://api.bol.com/retailer/public/Retailer-API/demo/v10-OFFERS.html#_update_the_current_stock_level_for_offerid_13722de8_8182_d161_5422_4a0a1caab5c8 */ public function update_the_current_stock_level_for_offerid_13722de8_8182_d161_5422_4a0a1caab5c8(): void @@ -190,7 +190,7 @@ function update_the_current_stock_level_for_offerid_13722de8_8182_d161_5422_4a0a /** * @test - * @see https://api.bol.com/retailer/public/Retailer-API/demo/v9-OFFERS.html#_update_of_an_already_existing_offer_with_offerid_13722de8_8182_d161_5422_4a0a1caab5c8 + * @see https://api.bol.com/retailer/public/Retailer-API/demo/v10-OFFERS.html#_update_of_an_already_existing_offer_with_offerid_13722de8_8182_d161_5422_4a0a1caab5c8 */ public function update_of_an_already_existing_offer_with_offerid_13722de8_8182_d161_5422_4a0a1caab5c8(): void @@ -214,7 +214,7 @@ function update_of_an_already_existing_offer_with_offerid_13722de8_8182_d161_542 /** * @test - * @see https://api.bol.com/retailer/public/Retailer-API/demo/v9-OFFERS.html#_update_of_an_already_existing_offer_with_offerid_13722de8_8182_d161_5422_4a0a1caab5c8_2 + * @see https://api.bol.com/retailer/public/Retailer-API/demo/v10-OFFERS.html#_update_of_an_already_existing_offer_with_offerid_13722de8_8182_d161_5422_4a0a1caab5c8_2 */ public function update_of_an_already_existing_offer_with_offerid_13722de8_8182_d161_5422_4a0a1caab5c8_2(): void diff --git a/tests/Integration/OrdersTest.php b/tests/Integration/OrdersTest.php index 0163ca6..f3a0587 100644 --- a/tests/Integration/OrdersTest.php +++ b/tests/Integration/OrdersTest.php @@ -11,7 +11,7 @@ final class OrdersTest extends IntegrationTestCase { /** * @test - * @see https://api.bol.com/retailer/public/Retailer-API/demo/v9-ORDERS.html#_get_single_fbb_order_with_order_id_1042823870 + * @see https://api.bol.com/retailer/public/Retailer-API/demo/v10-ORDERS.html#_get_single_fbb_order_with_order_id_1042823870 */ public function get_single_fbb_order_with_order_id_1042823870(): void { @@ -24,7 +24,7 @@ public function get_single_fbb_order_with_order_id_1042823870(): void /** * @test - * @see https://api.bol.com/retailer/public/Retailer-API/demo/v9-ORDERS.html#_get_single_fbr_order_with_order_id_1042831430 + * @see https://api.bol.com/retailer/public/Retailer-API/demo/v10-ORDERS.html#_get_single_fbr_order_with_order_id_1042831430 */ public function get_single_fbr_order_with_order_id_1042831430(): void { @@ -37,7 +37,7 @@ public function get_single_fbr_order_with_order_id_1042831430(): void /** * @test - * @see https://api.bol.com/retailer/public/Retailer-API/demo/v9-ORDERS.html#_get_single_fbr_order_with_order_id_1042831430 + * @see https://api.bol.com/retailer/public/Retailer-API/demo/v10-ORDERS.html#_get_single_fbr_order_with_order_id_1042831430 */ public function get_single_fbb_order_with_order_id_1043965710(): void { @@ -50,7 +50,7 @@ public function get_single_fbb_order_with_order_id_1043965710(): void /** * @test - * @see https://api.bol.com/retailer/public/Retailer-API/demo/v9-ORDERS.html#_get_single_fbr_order_with_order_id_a4k8290lp0 + * @see https://api.bol.com/retailer/public/Retailer-API/demo/v10-ORDERS.html#_get_single_fbr_order_with_order_id_a4k8290lp0 */ public function get_single_fbr_order_with_order_id_a4k8290lp0(): void { @@ -63,7 +63,7 @@ public function get_single_fbr_order_with_order_id_a4k8290lp0(): void /** * @test - * @see https://api.bol.com/retailer/public/Retailer-API/demo/v9-ORDERS.html#_get_single_fbr_order_with_order_id_1043946570 + * @see https://api.bol.com/retailer/public/Retailer-API/demo/v10-ORDERS.html#_get_single_fbr_order_with_order_id_1043946570 */ public function get_single_fbr_order_with_order_id_1043946570(): void { @@ -76,7 +76,7 @@ public function get_single_fbr_order_with_order_id_1043946570(): void /** * @test - * @see https://api.bol.com/retailer/public/Retailer-API/demo/v9-ORDERS.html#_get_single_fbr_order_with_order_id_b3k8290lp0 + * @see https://api.bol.com/retailer/public/Retailer-API/demo/v10-ORDERS.html#_get_single_fbr_order_with_order_id_b3k8290lp0 */ public function get_single_fbr_order_with_order_id_b3k8290lp0(): void { @@ -89,7 +89,7 @@ public function get_single_fbr_order_with_order_id_b3k8290lp0(): void /** * @test - * @see https://api.bol.com/retailer/public/Retailer-API/demo/v9-ORDERS.html#_get_fbb_orders_with_status_all + * @see https://api.bol.com/retailer/public/Retailer-API/demo/v10-ORDERS.html#_get_fbb_orders_with_status_all */ public function get_fbb_orders_with_status_all(): void { @@ -102,7 +102,7 @@ public function get_fbb_orders_with_status_all(): void /** * @test - * @see https://api.bol.com/retailer/public/Retailer-API/demo/v9-ORDERS.html#_get_fbb_orders_with_status_open + * @see https://api.bol.com/retailer/public/Retailer-API/demo/v10-ORDERS.html#_get_fbb_orders_with_status_open */ public function get_fbb_orders_with_status_open(): void { @@ -115,7 +115,7 @@ public function get_fbb_orders_with_status_open(): void /** * @test - * @see https://api.bol.com/retailer/public/Retailer-API/demo/v9-ORDERS.html#_get_fbr_orders_with_status_all + * @see https://api.bol.com/retailer/public/Retailer-API/demo/v10-ORDERS.html#_get_fbr_orders_with_status_all */ public function get_fbr_orders_with_status_all(): void { @@ -128,7 +128,7 @@ public function get_fbr_orders_with_status_all(): void /** * @test - * @see https://api.bol.com/retailer/public/Retailer-API/demo/v9-ORDERS.html#_get_fbr_orders_with_status_open + * @see https://api.bol.com/retailer/public/Retailer-API/demo/v10-ORDERS.html#_get_fbr_orders_with_status_open */ public function get_fbr_orders_with_status_open(): void { diff --git a/tests/Integration/ProcessStatusesTest.php b/tests/Integration/ProcessStatusesTest.php index fed0687..97906b8 100644 --- a/tests/Integration/ProcessStatusesTest.php +++ b/tests/Integration/ProcessStatusesTest.php @@ -8,7 +8,7 @@ final class ProcessStatusesTest extends IntegrationTestCase { /** * @test - * @see https://api.bol.com/retailer/public/Retailer-API/demo/v9-PROCESS_STATUS.html#_generate_a_process_status_pending_using_entity_id_and_event_type + * @see https://api.bol.com/retailer/public/Retailer-API/demo/v10-PROCESS_STATUS.html#_generate_a_process_status_pending_using_entity_id_and_event_type */ public function generate_a_process_status_pending_using_entity_id_and_event_type(): void { @@ -21,7 +21,7 @@ public function generate_a_process_status_pending_using_entity_id_and_event_type /** * @test - * @see https://api.bol.com/retailer/public/Retailer-API/demo/v9-PROCESS_STATUS.html#_generate_a_process_status_failure_using_entity_id_and_event_type + * @see https://api.bol.com/retailer/public/Retailer-API/demo/v10-PROCESS_STATUS.html#_generate_a_process_status_failure_using_entity_id_and_event_type */ public function generate_a_process_status_failure_using_entity_id_and_event_type(): void { @@ -34,7 +34,7 @@ public function generate_a_process_status_failure_using_entity_id_and_event_type /** * @test - * @see https://api.bol.com/retailer/public/Retailer-API/demo/v9-PROCESS_STATUS.html#_generate_a_process_status_timeout_using_entity_id_and_event_type + * @see https://api.bol.com/retailer/public/Retailer-API/demo/v10-PROCESS_STATUS.html#_generate_a_process_status_timeout_using_entity_id_and_event_type */ public function generate_a_process_status_timeout_using_entity_id_and_event_type(): void { @@ -47,7 +47,7 @@ public function generate_a_process_status_timeout_using_entity_id_and_event_type /** * @test - * @see https://api.bol.com/retailer/public/Retailer-API/demo/v9-PROCESS_STATUS.html#_generate_a_process_status_success_using_entity_id_and_event_type + * @see https://api.bol.com/retailer/public/Retailer-API/demo/v10-PROCESS_STATUS.html#_generate_a_process_status_success_using_entity_id_and_event_type */ public function generate_a_process_status_success_using_entity_id_and_event_type(): void { diff --git a/tests/Integration/SubscriptionsTest.php b/tests/Integration/SubscriptionsTest.php index 437817d..1b9eba5 100644 --- a/tests/Integration/SubscriptionsTest.php +++ b/tests/Integration/SubscriptionsTest.php @@ -4,11 +4,13 @@ namespace Tests\Integration; +use Rojtjo\Bol\Types\SubscriptionType; + final class SubscriptionsTest extends IntegrationTestCase { /** * @test - * @see https://api.bol.com/retailer/public/api/demo/v9-SUBSCRIPTIONS.html#_retrieve_push_notification_subscription_list + * @see https://api.bol.com/retailer/public/Retailer-API/demo/v10-SUBSCRIPTIONS.html#_retrieve_push_notification_subscription_list */ public function retrieve_push_notification_subscription_list(): void { @@ -21,7 +23,7 @@ public function retrieve_push_notification_subscription_list(): void /** * @test - * @see https://api.bol.com/retailer/public/api/demo/v9-SUBSCRIPTIONS.html#_trigger_sending_of_a_test_push_notification_for_subscription + * @see https://api.bol.com/retailer/public/Retailer-API/demo/v10-SUBSCRIPTIONS.html#_trigger_sending_of_a_test_push_notification_for_subscription */ public function trigger_sending_of_a_test_push_notification_for_subscription(): void { @@ -34,20 +36,24 @@ public function trigger_sending_of_a_test_push_notification_for_subscription(): /** * @test - * @see https://api.bol.com/retailer/public/api/demo/v9-SUBSCRIPTIONS.html#_create_push_notification_subscription + * @see https://api.bol.com/retailer/public/Retailer-API/demo/v10-SUBSCRIPTIONS.html#_create_push_notification_subscription */ public function create_push_notification_subscription(): void { $processStatus = $this->bol ->subscriptions() - ->createSubscription(['PROCESS_STATUS'], 'https://www.example.com/push'); + ->createSubscription( + ['PROCESS_STATUS'], + 'https://www.example.com/push', + SubscriptionType::Webhook, + ); $this->assertMatchesObjectSnapshot($processStatus->withFixedTimestamp()); } /** * @test - * @see https://api.bol.com/retailer/public/api/demo/v9-SUBSCRIPTIONS.html#_delete_existing_push_notification_subscription + * @see https://api.bol.com/retailer/public/Retailer-API/demo/v10-SUBSCRIPTIONS.html#_delete_existing_push_notification_subscription */ public function delete_existing_push_notification_subscription(): void { @@ -60,7 +66,7 @@ public function delete_existing_push_notification_subscription(): void /** * @test - * @see https://api.bol.com/retailer/public/api/demo/v9-SUBSCRIPTIONS.html#_retrieve_push_notification_subscription + * @see https://api.bol.com/retailer/public/Retailer-API/demo/v10-SUBSCRIPTIONS.html#_retrieve_push_notification_subscription */ public function retrieve_push_notification_subscription(): void { @@ -73,13 +79,19 @@ public function retrieve_push_notification_subscription(): void /** * @test - * @see https://api.bol.com/retailer/public/api/demo/v9-SUBSCRIPTIONS.html#_update_existing_push_notification_subscription + * @see https://api.bol.com/retailer/public/Retailer-API/demo/v10-SUBSCRIPTIONS.html#_update_existing_push_notification_subscription */ public function update_existing_push_notification_subscription(): void { $processStatus = $this->bol ->subscriptions() - ->updateSubscription('1234', ['PROCESS_STATUS'], 'https://www.example.com/push'); + ->updateSubscription( + '1234', + ['PROCESS_STATUS'], + 'https://www.example.com/push', + SubscriptionType::Webhook, + false, + ); $this->assertMatchesObjectSnapshot($processStatus->withFixedTimestamp()); } diff --git a/tests/Integration/__snapshots__/SubscriptionsTest__retrieve_push_notification_subscription__1.yml b/tests/Integration/__snapshots__/SubscriptionsTest__retrieve_push_notification_subscription__1.yml index 4711bf4..b0826d7 100644 --- a/tests/Integration/__snapshots__/SubscriptionsTest__retrieve_push_notification_subscription__1.yml +++ b/tests/Integration/__snapshots__/SubscriptionsTest__retrieve_push_notification_subscription__1.yml @@ -2,3 +2,7 @@ id: '1234' resources: - PROCESS_STATUS url: 'https://www.example.com/push' +subscriptionType: + name: Webhook + value: WEBHOOK +enabled: true diff --git a/tests/Integration/__snapshots__/SubscriptionsTest__retrieve_push_notification_subscription_list__1.yml b/tests/Integration/__snapshots__/SubscriptionsTest__retrieve_push_notification_subscription_list__1.yml index e375db0..110a6a1 100644 --- a/tests/Integration/__snapshots__/SubscriptionsTest__retrieve_push_notification_subscription_list__1.yml +++ b/tests/Integration/__snapshots__/SubscriptionsTest__retrieve_push_notification_subscription_list__1.yml @@ -2,3 +2,5 @@ id: '1234' resources: [PROCESS_STATUS] url: 'https://www.example.com/push' + subscriptionType: { name: Webhook, value: WEBHOOK } + enabled: true