Skip to content

Commit

Permalink
update sales order fulfillment
Browse files Browse the repository at this point in the history
  • Loading branch information
aelsaidy committed Aug 31, 2020
1 parent 60133cb commit 855f8a2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
12 changes: 6 additions & 6 deletions src/DataType/SalesOrderFulfillment.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,23 @@
* @property string $fulfilled_at
* @property float|null $cost
* @property string|null $tracking_number
* @property array $sales_order_lines
* @property array $fulfillment_lines
*/
class SalesOrderFulfillment extends DataType
{
/**
* Add line to fulfill
*
* @param int $salesOrderId
* @param int $salesOrderLineId
* @param int $quantity
*/
public function addFulfillmentLine( int $salesOrderId, int $quantity )
public function addFulfillmentLine( int $salesOrderLineId, int $quantity )
{
if ( ! isset( $this->sales_order_lines ) )
if ( ! isset( $this->fulfillment_lines ) )
{
$this->sales_order_lines = [];
$this->fulfillment_lines = [];
}

$this->sales_order_lines[] = [ 'id' => $salesOrderId, 'quantity' => $quantity ];
$this->fulfillment_lines[] = [ 'sales_order_line_id' => $salesOrderLineId, 'quantity' => $quantity ];
}
}
9 changes: 5 additions & 4 deletions src/Service/SalesOrders.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use InvalidArgumentException;
use Skuio\Sdk\DataType\Import;
use Skuio\Sdk\DataType\SalesOrder;
use Skuio\Sdk\DataType\SalesOrderFulfillment;
use Skuio\Sdk\Query;
use Skuio\Sdk\Request\FulfillSalesOrderRequest;
use Skuio\Sdk\Response;
Expand Down Expand Up @@ -193,19 +194,19 @@ public function bulkDelete(Query $filters = null, array $salesOrdersIds = null )
/**
* Fulfill sales order
*
* @param FulfillSalesOrderRequest $request
* @param SalesOrderFulfillment $orderFulfillment
*
* @return Response
* @throws Exception
*/
public function fulfill( FulfillSalesOrderRequest $request )
public function fulfill( SalesOrderFulfillment $orderFulfillment )
{
if ( empty( $request->sales_order_id ) )
if ( empty( $orderFulfillment->sales_order_id ) )
{
throw new InvalidArgumentException( 'The "sales_order_id" field is required' );
}

return $this->authorizedRequest( "{$this->endpoint}/{$request->sales_order_id}/fulfill", $request->toJson(), self::METHOD_POST );
return $this->authorizedRequest( "{$this->endpoint}/{$orderFulfillment->sales_order_id}/fulfill", $orderFulfillment->toJson(), self::METHOD_POST );
}

/**
Expand Down

0 comments on commit 855f8a2

Please sign in to comment.