Skip to content

Commit

Permalink
Upgrade to v8
Browse files Browse the repository at this point in the history
  • Loading branch information
rojtjo committed Dec 18, 2023
1 parent 246a6c0 commit 9e08ba0
Show file tree
Hide file tree
Showing 23 changed files with 85 additions and 56 deletions.
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.v7+csv',
'Accept' => 'application/vnd.retailer.v8+csv',
]);

return ExportOfferCollection::fromPayload($data);
Expand Down
14 changes: 11 additions & 3 deletions src/Connectors/OrderConnector.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,19 @@ protected function api(): Api
return Api::Retailer;
}

public function orders(FulfilmentMethod $fulfilment = FulfilmentMethod::ByRetailer, OrderStatus $status = OrderStatus::Open): ReducedOrderCollection
public function orders(
FulfilmentMethod $fulfilment = FulfilmentMethod::ByRetailer,
OrderStatus $status = OrderStatus::Open,
?int $changeIntervalMinute = null,
?string $latestChangeDate = null,

): ReducedOrderCollection
{
$data = $this->send('GET', 'orders', query: [
'fulfilment-method' => $fulfilment,
'status' => $status,
'fulfilment-method' => $fulfilment,
'status' => $status,
'change-internal-minute' => $changeIntervalMinute,
'latest-change-date' => $latestChangeDate,
]);

return ReducedOrderCollection::fromPayload($data);
Expand Down
3 changes: 3 additions & 0 deletions src/Types/Order.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

namespace Rojtjo\Bol\Types;

use DateTimeImmutable;

final class Order
{
public function __construct(
Expand Down Expand Up @@ -91,6 +93,7 @@ public static function fromPayload(array $payload): self
$orderItem['additionalServices'] ?? [],
),
),
new DateTimeImmutable($orderItem['latestChangedDateTime'])
),
$payload['orderItems'],
),
Expand Down
3 changes: 3 additions & 0 deletions src/Types/OrderItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

namespace Rojtjo\Bol\Types;

use DateTimeImmutable;

final class OrderItem
{
public function __construct(
Expand All @@ -18,6 +20,7 @@ public function __construct(
public readonly float $unitPrice,
public readonly float $commission,
public readonly AdditionalServiceCollection $additionalServices,
public readonly DateTimeImmutable $latestChangedDateTime,
)
{
}
Expand Down
3 changes: 3 additions & 0 deletions src/Types/OrderStatus.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,8 @@
enum OrderStatus: string
{
case Open = 'OPEN';

case Shipped = 'shipped';

case All = 'ALL';
}
6 changes: 6 additions & 0 deletions src/Types/ReducedOrder.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

namespace Rojtjo\Bol\Types;

use DateTimeImmutable;

final class ReducedOrder
{
/**
Expand All @@ -26,9 +28,13 @@ public static function fromPayload(array $payload): self
fn (array $item) => new ReducedOrderItem(
orderItemId: (string) $item['orderItemId'],
ean: (string) $item['ean'],
fulfilmentMethod: FulfilmentMethod::from($item['fulfilmentMethod']),
fulfilmentStatus: OrderStatus::from($item['fulfilmentStatus']),
quantity: (int) $item['quantity'],
quantityShipped: (int) $item['quantityShipped'],
quantityCancelled: (int) $item['quantityCancelled'],
cancellationRequest: (bool) $item['cancellationRequest'],
latestChangedDateTime: new DateTimeImmutable($item['latestChangedDateTime']),
),
$payload['orderItems'] ?? [],
),
Expand Down
6 changes: 6 additions & 0 deletions src/Types/ReducedOrderItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,20 @@

namespace Rojtjo\Bol\Types;

use DateTimeImmutable;

final class ReducedOrderItem
{
public function __construct(
public readonly string $orderItemId,
public readonly string $ean,
public readonly FulfilmentMethod $fulfilmentMethod,
public readonly OrderStatus $fulfilmentStatus,
public readonly int $quantity,
public readonly int $quantityShipped,
public readonly int $quantityCancelled,
public readonly bool $cancellationRequest,
public readonly DateTimeImmutable $latestChangedDateTime,
)
{
}
Expand Down
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.v7+json';
public const CONTENT_TYPE = 'application/vnd.retailer.v8+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.v7+json')) {
if (str_contains($contentType, 'application/vnd.retailer.v8+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/v7-OFFERS.html#_create_an_offer_export_csv_file
* @see https://api.bol.com/retailer/public/Retailer-API/demo/v8-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/v7-OFFERS.html#_retrieve_an_offer_export_csv_file
* @see https://api.bol.com/retailer/public/Retailer-API/demo/v8-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/v7-OFFERS.html#_retrieve_an_offer
* @see https://api.bol.com/retailer/public/Retailer-API/demo/v8-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/v7-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/v8-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/v7-OFFERS.html#_create_fbr_offer_for_ean_0045496420253_with_condition_moderate
* @see https://api.bol.com/retailer/public/Retailer-API/demo/v8-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/v7-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/v8-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/v7-OFFERS.html#_update_the_price_for_a_specific_offer
* @see https://api.bol.com/retailer/public/Retailer-API/demo/v8-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/v7-OFFERS.html#_update_the_current_stock_level_for_offerid_13722de8_8182_d161_5422_4a0a1caab5c8
* @see https://api.bol.com/retailer/public/Retailer-API/demo/v8-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/v7-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/v8-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/v7-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/v8-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/v7-ORDERS.html#_get_single_fbb_order_with_order_id_1042823870
* @see https://api.bol.com/retailer/public/Retailer-API/demo/v8-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/v7-ORDERS.html#_get_single_fbr_order_with_order_id_1042831430
* @see https://api.bol.com/retailer/public/Retailer-API/demo/v8-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/v7-ORDERS.html#_get_single_fbr_order_with_order_id_1042831430
* @see https://api.bol.com/retailer/public/Retailer-API/demo/v8-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/v7-ORDERS.html#_get_single_fbr_order_with_order_id_a4k8290lp0
* @see https://api.bol.com/retailer/public/Retailer-API/demo/v8-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/v7-ORDERS.html#_get_single_fbr_order_with_order_id_1043946570
* @see https://api.bol.com/retailer/public/Retailer-API/demo/v8-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/v7-ORDERS.html#_get_single_fbr_order_with_order_id_b3k8290lp0
* @see https://api.bol.com/retailer/public/Retailer-API/demo/v8-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/v7-ORDERS.html#_get_fbb_orders_with_status_all
* @see https://api.bol.com/retailer/public/Retailer-API/demo/v8-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/v7-ORDERS.html#_get_fbb_orders_with_status_open
* @see https://api.bol.com/retailer/public/Retailer-API/demo/v8-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/v7-ORDERS.html#_get_fbr_orders_with_status_all
* @see https://api.bol.com/retailer/public/Retailer-API/demo/v8-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/v7-ORDERS.html#_get_fbr_orders_with_status_open
* @see https://api.bol.com/retailer/public/Retailer-API/demo/v8-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/v7-PROCESS_STATUS.html#_generate_a_process_status_pending_using_entity_id_and_event_type
* @see https://api.bol.com/retailer/public/Retailer-API/demo/v8-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/v7-PROCESS_STATUS.html#_generate_a_process_status_failure_using_entity_id_and_event_type
* @see https://api.bol.com/retailer/public/Retailer-API/demo/v8-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/v7-PROCESS_STATUS.html#_generate_a_process_status_timeout_using_entity_id_and_event_type
* @see https://api.bol.com/retailer/public/Retailer-API/demo/v8-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/v7-PROCESS_STATUS.html#_generate_a_process_status_success_using_entity_id_and_event_type
* @see https://api.bol.com/retailer/public/Retailer-API/demo/v8-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 9e08ba0

Please sign in to comment.