Skip to content

Commit

Permalink
Set Peaks internal order id when uploading order
Browse files Browse the repository at this point in the history
  • Loading branch information
loevgaard committed Jun 19, 2024
1 parent d8ebc9b commit 741a776
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ public function __invoke(ProcessUploadOrderRequest $message): void
$salesOrder = new SalesOrder();
$this->salesOrderDataMapper->map($order, $salesOrder);

$this->peakWMSClient->salesOrder()->create($salesOrder);

$response = $this->peakWMSClient->salesOrder()->create($salesOrder);
$uploadOrderRequest->setPeakOrderId($response->id);
$this->uploadOrderRequestWorkflow->apply($order, UploadOrderRequestWorkflow::TRANSITION_UPLOAD);
} catch (\Throwable $e) {
$uploadOrderRequest->setError($e->getMessage());
Expand Down
12 changes: 12 additions & 0 deletions src/Model/UploadOrderRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ class UploadOrderRequest implements UploadOrderRequestInterface

protected ?string $error = null;

protected ?int $peakOrderId = null;

public function getId(): ?int
{
return $this->id;
Expand Down Expand Up @@ -84,4 +86,14 @@ public function setError(?string $error): void
{
$this->error = $error;
}

public function getPeakOrderId(): ?int
{
return $this->peakOrderId;
}

public function setPeakOrderId(?int $peakOrderId): void
{
$this->peakOrderId = $peakOrderId;
}
}
7 changes: 7 additions & 0 deletions src/Model/UploadOrderRequestInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,11 @@ public function setResponse(?string $response): void;
public function getError(): ?string;

public function setError(?string $error): void;

/**
* If the order was uploaded successfully, this method will return the peak order id
*/
public function getPeakOrderId(): ?int;

public function setPeakOrderId(?int $peakOrderId): void;
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@

<field name="version" type="integer" version="true"/>
<field name="state" type="string"/>
<field name="request" type="text" nullable="true"/>
<field name="response" type="text" nullable="true"/>
<field name="error" type="text" nullable="true"/>

<one-to-one field="order" target-entity="Sylius\Component\Order\Model\OrderInterface" inversed-by="peakWMSUploadOrderRequest">
<join-column name="order_id" referenced-column-name="id" nullable="false" unique="true" on-delete="CASCADE"/>
Expand Down

0 comments on commit 741a776

Please sign in to comment.