Skip to content

Commit

Permalink
Merge pull request #1 from rojtjo/upgrade-to-v10
Browse files Browse the repository at this point in the history
Upgrade to v10
  • Loading branch information
rojtjo committed Dec 20, 2023
2 parents bf7b567 + b217ccc commit 670bffe
Show file tree
Hide file tree
Showing 13 changed files with 80 additions and 42 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion src/Connectors/OfferConnector.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
16 changes: 10 additions & 6 deletions src/Connectors/SubscriptionConnector.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -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);
Expand Down
4 changes: 4 additions & 0 deletions src/Types/Subscription.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)
{
}
Expand All @@ -20,6 +22,8 @@ public static function fromPayload(array $subscription): self
$subscription['id'],
$subscription['resources'],
$subscription['url'],
SubscriptionType::from($subscription['subscriptionType']),
$subscription['enabled'],
);
}
}
12 changes: 12 additions & 0 deletions src/Types/SubscriptionType.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?php

declare(strict_types=1);

namespace Rojtjo\Bol\Types;

enum SubscriptionType: string
{
case Webhook = 'WEBHOOK';

case GCPPubSub = 'GCP_PUBSUB';
}
2 changes: 1 addition & 1 deletion src/Util/RequestUtil.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

final class RequestUtil
{
public const CONTENT_TYPE = 'application/vnd.retailer.v9+json';
public const CONTENT_TYPE = 'application/vnd.retailer.v10+json';

public static function createRequest(string $method, string $uri, array $headers = [], array $query = [], mixed $body = null): Request
{
Expand Down
2 changes: 1 addition & 1 deletion src/Util/ResponseUtil.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public static function assertOk(ResponseInterface $response): void
public static function decodeBody(ResponseInterface $response): mixed
{
$contentType = $response->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);
}

Expand Down
20 changes: 10 additions & 10 deletions tests/Integration/OffersTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand All @@ -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
{
Expand All @@ -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
{
Expand All @@ -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
{
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
20 changes: 10 additions & 10 deletions tests/Integration/OrdersTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand All @@ -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
{
Expand All @@ -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
{
Expand All @@ -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
{
Expand All @@ -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
{
Expand All @@ -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
{
Expand All @@ -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
{
Expand All @@ -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
{
Expand All @@ -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
{
Expand All @@ -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
{
Expand Down
8 changes: 4 additions & 4 deletions tests/Integration/ProcessStatusesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand All @@ -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
{
Expand All @@ -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
{
Expand All @@ -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
{
Expand Down
Loading

0 comments on commit 670bffe

Please sign in to comment.