Bol.com API documentation can be found here.
- Uses bol.com API v3.
- Strict type checking.
- Support multiple bol.com accounts.
A client pool is used to support multiple bol.com accounts. We can configure the pool with a default client if only one seller account will be active.
<?php declare(strict_types=1);
$messageBus = new \BolCom\RetailerApi\Infrastructure\MessageBus(
\BolCom\RetailerApi\Infrastructure\ClientPool::configure(
new \BolCom\RetailerApi\Client\ClientConfig('clientId', 'clientSecret')
)
);
/** @var \BolCom\RetailerApi\Model\Order\Order $order */
$order = $messageBus->dispatch(\BolCom\RetailerApi\Model\Order\Query\GetOrder::with(
\BolCom\RetailerApi\Model\Order\OrderId::fromString('7616222250')
));
To support multiple accounts you can create your own ClientPool
and add multiple clients to the pool.
<?php declare(strict_types=1);
$clientPool = new \BolCom\RetailerApi\Infrastructure\ClientPool([
'account1' => new \BolCom\RetailerApi\Client(new \BolCom\RetailerApi\Client\ClientConfig('clientId1', 'clientSecret1')),
'account2' => new \BolCom\RetailerApi\Client(new \BolCom\RetailerApi\Client\ClientConfig('clientId2', 'clientSecret2')),
]);
$messageBus = new \BolCom\RetailerApi\Infrastructure\MessageBus($clientPool);
//Request from a specific client
/** @var \BolCom\RetailerApi\Model\Order\Order $order */
$order = $messageBus->dispatch(\BolCom\RetailerApi\Model\Order\Query\GetOrder::with(
\BolCom\RetailerApi\Model\Order\OrderId::fromString('7616222250')
), 'account2');
//Request from all clients
foreach ($clientPool->names() as $name) {
/** @var \BolCom\RetailerApi\Model\Order\Order $order */
$order = $messageBus->dispatch(\BolCom\RetailerApi\Model\Order\Query\GetOrder::with(
\BolCom\RetailerApi\Model\Order\OrderId::fromString('7616222250')
), $name);
}
Place this code in your phpunit.xml
and update the values with your own test credentials.
<php>
<const name="BOL_CLIENT_ID" value="test_value"/>
<const name="BOL_CLIENT_SECRET" value="test_value"/>
</php>
/** @var \BolCom\RetailerApi\Model\Commission\Commission $commission */
$commission = $messageBus->dispatch(\BolCom\RetailerApi\Model\Commission\Query\GetCommission::with(
\BolCom\RetailerApi\Model\Offer\Ean::fromString('9781785882364'),
\BolCom\RetailerApi\Model\Offer\Condition::IS_NEW(),
\BolCom\RetailerApi\Model\CurrencyAmount::fromScalar(10.11)
));
/** @var \BolCom\RetailerApi\Model\Commission\Query\GetCommissionList $commissionList */
$commissionList = $messageBus->dispatch(\BolCom\RetailerApi\Model\Commission\Query\GetCommissionList::with(
\BolCom\RetailerApi\Model\Commission\CommissionQuery::fromArray([
'ean' => '9781785882364',
'condition' => \BolCom\RetailerApi\Model\Offer\Condition::IS_NEW,
'price' => 10.11
])
));
@todo: pricing.bundlePrices: Collection with only 1 element is allowed at this time.
/** @var \BolCom\RetailerApi\Model\ProcessStatus\ProcessStatus $processStatus */
$processStatus = $messageBus->dispatch(\BolCom\RetailerApi\Model\Offer\Command\CreateOffer::with(
\BolCom\RetailerApi\Model\Offer\RetailerOfferUpsert::fromArray([
'ean' => '9781785882364',
'condition' => [
'name' => \BolCom\RetailerApi\Model\Offer\Condition::IS_NEW,
'category' => \BolCom\RetailerApi\Model\Offer\ConditionCategory::IS_NEW
],
'referenceCode' => 'SKU123',
'onHoldByRetailer' => false,
'unknownProductTitle' => 'My Title',
'pricing' => [
'bundlePrices' => [
['quantity' => 1, 'price' => 10]
]
],
'stock' => [
'amount' => 12,
'managedByRetailer' => true
],
'fulfilment' => [
'type' => \BolCom\RetailerApi\Model\Offer\FulfilmentMethod::FBR,
'deliveryCode' => \BolCom\RetailerApi\Model\Offer\DeliveryCode::DC12d
]
])
));
/** @var \BolCom\RetailerApi\Model\ProcessStatus\ProcessStatus $processStatus */
$processStatus = $messageBus->dispatch(\BolCom\RetailerApi\Model\Offer\Command\DeleteOffer::with(
\BolCom\RetailerApi\Model\Offer\OfferId::fromString('6ff736b5-cdd0-4150-8c67-78269ee986f5')
));
/** @var \BolCom\RetailerApi\Model\Offer\RetailerOffer $offer */
$offer = $messageBus->dispatch(\BolCom\RetailerApi\Model\Offer\Command\GetOffer::with(
\BolCom\RetailerApi\Model\Offer\OfferId::fromString('6ff736b5-cdd0-4150-8c67-78269ee986f5')
));
/** @var \BolCom\RetailerApi\Model\ProcessStatus\ProcessStatus $processStatus */
$processStatus = $messageBus->dispatch(\BolCom\RetailerApi\Model\Offer\Command\UpdateOffer::with(
\BolCom\RetailerApi\Model\Offer\OfferId::fromString('6ff736b5-cdd0-4150-8c67-78269ee986f5'),
\BolCom\RetailerApi\Model\Offer\RetailerOfferUpdate::fromArray([
'referenceCode' => 'SKU123',
'onHoldByRetailer' => false,
'unknownProductTitle' => 'My Title',
'fulfilment' => [
'type' => \BolCom\RetailerApi\Model\Offer\FulfilmentMethod::FBR,
'deliveryCode' => \BolCom\RetailerApi\Model\Offer\DeliveryCode::DC12d
]
])
));
@todo: pricing.bundlePrices: Collection with only 1 element is allowed at this time.
/** @var \BolCom\RetailerApi\Model\ProcessStatus\ProcessStatus $processStatus */
$processStatus = $messageBus->dispatch(\BolCom\RetailerApi\Model\Offer\Command\UpdateOfferPrice::with(
\BolCom\RetailerApi\Model\Offer\OfferId::fromString('6ff736b5-cdd0-4150-8c67-78269ee986f5'),
\BolCom\RetailerApi\Model\Offer\Pricing::fromArray([
'bundlePrices' => [
['quantity' => 1, 'price' => 12]
]
])
));
/** @var \BolCom\RetailerApi\Model\ProcessStatus\ProcessStatus $processStatus */
$processStatus = $messageBus->dispatch(\BolCom\RetailerApi\Model\Offer\Command\UpdateOfferStock::with(
\BolCom\RetailerApi\Model\Offer\OfferId::fromString('6ff736b5-cdd0-4150-8c67-78269ee986f5'),
\BolCom\RetailerApi\Model\Offer\Stock::fromArray([
'amount' => 97,
'managedByRetailer' => false
])
));
/** @var \BolCom\RetailerApi\Model\ProcessStatus\ProcessStatus $processStatus */
$processStatus = $messageBus->dispatch(\BolCom\RetailerApi\Model\Order\Command\CancelOrder::with(
\BolCom\RetailerApi\Model\Order\OrderItemId::fromString('6107434013'),
\BolCom\RetailerApi\Model\DateTime::fromString((new \DateTime())->format(\DateTime::ATOM)),
\BolCom\RetailerApi\Model\Order\CancellationReason::REQUESTED_BY_CUSTOMER()
));
/** @var null|\BolCom\RetailerApi\Model\Order\OrderList $orderList */
$orderList = $messageBus->dispatch(\BolCom\RetailerApi\Model\Order\Query\GetAllOpenOrders::with(
1,
\BolCom\RetailerApi\Model\Offer\FulfilmentMethod::FBR()
));
/** @var \BolCom\RetailerApi\Model\Order\Order $order */
$order = $messageBus->dispatch(\BolCom\RetailerApi\Model\Order\Query\GetOrder::with(
\BolCom\RetailerApi\Model\Order\OrderId::fromString('7616222250')
));
Either provide Transport or ShippingLabelCode, not both.
/** @var \BolCom\RetailerApi\Model\ProcessStatus\ProcessStatus $processStatus */
$processStatus = $messageBus->dispatch(\BolCom\RetailerApi\Model\Order\Command\ShipOrderItem::with(
\BolCom\RetailerApi\Model\Order\OrderItemId::fromString('6107434013'),
'Shipment Reference',
null,
\BolCom\RetailerApi\Model\Transport\TransportInstruction::fromArray([
'transporterCode' => 'TNT',
'trackAndTrace' => '123456789'
])
));
/** @var \BolCom\RetailerApi\Model\ProcessStatus\ProcessStatus $processStatus */
$processStatus = $messageBus->dispatch(\BolCom\RetailerApi\Model\Order\Command\ShipOrderItem::with(
\BolCom\RetailerApi\Model\Order\OrderItemId::fromString('6107434013'),
'Shipment Reference',
'PLR00000001',
null
));
/** @var null|\BolCom\RetailerApi\Model\ProcessStatus\ProcessStatuses $processStatuses */
$processStatuses = $messageBus->dispatch(\BolCom\RetailerApi\Model\ProcessStatus\Query\GetStatusByEntity::with(
\BolCom\RetailerApi\Model\ProcessStatus\EntityId::fromString('6107432387'),
\BolCom\RetailerApi\Model\ProcessStatus\EventType::fromValue('CANCEL_ORDER'),
1
));
/** @var \BolCom\RetailerApi\Model\ProcessStatus\ProcessStatuses $processStatuses */
$processStatuses = $messageBus->dispatch(\BolCom\RetailerApi\Model\ProcessStatus\Query\GetStatusByProcessIds::with(
...[6107432387]
));
/** @var null|\BolCom\RetailerApi\Model\Rma\ReturnItemList $returnItemList */
$returnItemList = $messageBus->dispatch(\BolCom\RetailerApi\Model\Rma\Query\GetAllReturns::with(
1,
false,
\BolCom\RetailerApi\Model\Offer\FulfilmentMethod::FBR()
));
/** @var \BolCom\RetailerApi\Model\ProcessStatus\ProcessStatus $processStatus */
$processStatus = $messageBus->dispatch(\BolCom\RetailerApi\Model\Rma\Command\HandleReturn::with(
\BolCom\RetailerApi\Model\Rma\RmaId::fromScalar(31234567),
\BolCom\RetailerApi\Model\Rma\HandlingResult::RETURN_RECEIVED(),
\BolCom\RetailerApi\Model\Rma\QuantityReturned::fromScalar(1)
));
/** @var \BolCom\RetailerApi\Model\Shipment\Shipment $shipment */
$shipment = $messageBus->dispatch(\BolCom\RetailerApi\Model\Shipment\Query\GetShipment::with(
\BolCom\RetailerApi\Model\Shipment\ShipmentId::fromScalar(541757635)
));
/** @var null|\BolCom\RetailerApi\Model\Shipment\ShipmentList $shipmentList */
$shipmentList = $messageBus->dispatch(\BolCom\RetailerApi\Model\Shipment\Query\GetShipmentList::with(
1,
\BolCom\RetailerApi\Model\Offer\FulfilmentMethod::FBR(),
\BolCom\RetailerApi\Model\Order\OrderId::fromString('7616222250')
));
/** @var \BolCom\RetailerApi\Model\ShippingLabel\ShippingLabelList $shippingLabelList */
$shippingLabelList = $messageBus->dispatch(\BolCom\RetailerApi\Model\ShippingLabel\Query\GetShippingLabels::with(
\BolCom\RetailerApi\Model\Order\OrderItemId::fromString('6107434013')
));
/** @var \BolCom\RetailerApi\Model\ShippingLabel\ShippingLabelPdfList $shippingLabelPdfList */
$shippingLabelPdfList = $messageBus->dispatch(\BolCom\RetailerApi\Model\Transport\Query\GetShippingLabel::with(
\BolCom\RetailerApi\Model\Transport\TransportId::fromScalar(312778947)
));