Skip to content

Commit

Permalink
feat: added shipment slaDays and item printQuantity properties
Browse files Browse the repository at this point in the history
  • Loading branch information
joseandrespg committed Nov 9, 2018
1 parent f8f7419 commit 7b2f268
Show file tree
Hide file tree
Showing 3 changed files with 151 additions and 123 deletions.
258 changes: 135 additions & 123 deletions src/order/orderData/item/item.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,141 +23,153 @@ public function init() {
$this->__addProperty("sourceItemId", "", true);
$this->__addProperty("sku");
$this->__addProperty("quantity", 1, true);
$this->__addProperty("printQuantity");
$this->__addProperty("shrinkWrap", false);
$this->__addProperty("barcode", "", false);
$this->__addProperty("dispatchAlert");
$this->__addArray("extraData",null);

$this->__addProperty("colour");
}

/**
* newComponent function.
*
* @access public
* @param string $code
* @return OneFlowComponent
*/
public function newComponent($code){
$count = count($this->components);
$component = new OneFlowComponent();
$component->setCode($code);
$this->components[$count] = $component;

return $this->components[$count];
}

/**
* addTextComponent function.
*
* @access public
* @return OneFlowComponent
*/
public function addTextComponent() {
return $this->newComponent('text');
}

/**
* addTextComponent function.
*
* @access public
* @param string $barcode
* @return string
*/
public function setBarcode($barcode) {
return $this->barcode = $barcode;
}

/**
* addCoverComponent function.
*
* @access public
* @return OneFlowComponent
*/
public function addCoverComponent() {
return $this->newComponent('cover');
}

/**
* setDispatchAlert function.
*
* @access public
* @param mixed $dispatchAlert
* @return void
*/
public function setDispatchAlert($dispatchAlert) {
$this->dispatchAlert = $dispatchAlert;
}

/**
* setShipment function.
*
* @access public
* @param mixed $shipment
* @return void
*/
public function setShipment($shipment) {
$this->shipmentIndex = $shipment->shipmentIndex;
}

/**
* setBinding function.
*
* @access public
* @param mixed $binding
* @return boolean
*/
public function setBinding($binding) {
}

/**
* newComponent function.
*
* @access public
* @param string $code
* @return OneFlowComponent
*/
public function newComponent($code){
$count = count($this->components);
$component = new OneFlowComponent();
$component->setCode($code);
$this->components[$count] = $component;

return $this->components[$count];
}

/**
* addTextComponent function.
*
* @access public
* @return OneFlowComponent
*/
public function addTextComponent() {
return $this->newComponent('text');
}

/**
* addTextComponent function.
*
* @access public
* @param string $barcode
* @return string
*/
public function setBarcode($barcode) {
return $this->barcode = $barcode;
}

/**
* addCoverComponent function.
*
* @access public
* @return OneFlowComponent
*/
public function addCoverComponent() {
return $this->newComponent('cover');
}

/**
* setDispatchAlert function.
*
* @access public
* @param mixed $dispatchAlert
* @return void
*/
public function setDispatchAlert($dispatchAlert) {
$this->dispatchAlert = $dispatchAlert;
}

/**
* setShipment function.
*
* @access public
* @param mixed $shipment
* @return void
*/
public function setShipment($shipment) {
$this->shipmentIndex = $shipment->shipmentIndex;
}

/**
* setBinding function.
*
* @access public
* @param mixed $binding
* @return boolean
*/
public function setBinding($binding) {
$this->__addList("binding", Array("perfect", "saddle", "wiro", "pur", "threadSawn"));
$this->binding = $binding;
return true;
}

/**
* setFolding function.
*
* @access public
* @param mixed $folding
* @return boolean
*/
public function setFolding($folding) {
}

/**
* setFolding function.
*
* @access public
* @param mixed $folding
* @return boolean
*/
public function setFolding($folding) {
$this->__addList("folding", Array("half", "gate", "cross", "concertina", "z", "2", "3"));
$this->folding = $folding;
return true;
}

/**
* setQuantity function.
*
* @access public
* @param mixed $quantity
* @return void
*/
public function setQuantity($quantity) {
$this->quantity = $quantity;
}

/**
* setSourceItemId function.
*
* @access public
* @param mixed $sourceItemId
* @return void
*/
public function setSourceItemId($sourceItemId) {
$this->sourceItemId = $sourceItemId;
}

/**
* setSKU function.
*
* @access public
* @param mixed $skuCode
* @return void
*/
public function setSKU($skuCode) {
$this->sku = $skuCode;
}
}

/**
* setQuantity function.
*
* @access public
* @param mixed $quantity
* @return void
*/
public function setQuantity($quantity) {
$this->quantity = $quantity;
}

/**
* setPrintQuantity function.
*
* @access public
* @param integer $printQuantity
* @return void
*/
public function setPrintQuantity($printQuantity) {
$this->printQuantity = $printQuantity;
}

/**
* setSourceItemId function.
*
* @access public
* @param mixed $sourceItemId
* @return void
*/
public function setSourceItemId($sourceItemId) {
$this->sourceItemId = $sourceItemId;
}

/**
* setSKU function.
*
* @access public
* @param mixed $skuCode
* @return void
*/
public function setSKU($skuCode) {
$this->sku = $skuCode;
}

/**
* setExtraData function.
Expand Down
12 changes: 12 additions & 0 deletions src/order/orderData/shipment/shipment.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public function init() {
$this->__addProperty("pspBranding", true);
$this->__addProperty("labelName");
$this->__addProperty("cost");
$this->__addProperty("slaDays");
$this->__addProperty("dispatchAlert");
}

Expand Down Expand Up @@ -171,6 +172,17 @@ public function setCarrierByAlias($alias) {
public function setLabelName($labelName) {
$this->labelName = $labelName;
}

/**
* setSlaDays function.
*
* @access public
* @param integer $slaDays
* @return void
*/
public function setSlaDays($slaDays) {
$this->slaDays = $slaDays;
}
}

?>
4 changes: 4 additions & 0 deletions tests/order/orderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public function testCanBuildASingleItemOrder()
]);

$item = $orderData->newSKUItem('skuCode', 'itemId', 5);
$item->setPrintQuantity(1);
$item->setBarcode('customItemBarcode');
$item->setDispatchAlert('my item dispatch alert');
$item->setExtraData([
Expand Down Expand Up @@ -75,6 +76,7 @@ public function testCanBuildASingleItemOrder()
$shipment->newAttachment('http://site.com/attachment.pdf', 'insert');
$shipment->setDispatchAlert('my shipment dispatch alert');
$shipment->setLabelName('labelName');
$shipment->setSlaDays(5);

$item->setShipment($shipment);
$stockItem->setShipment($shipment);
Expand Down Expand Up @@ -107,6 +109,7 @@ public function testCanBuildASingleItemOrder()
$this->assertEquals('itemId', $outputItem->sourceItemId);
$this->assertEquals('customItemBarcode', $outputItem->barcode);
$this->assertEquals(5, $outputItem->quantity);
$this->assertEquals(1, $outputItem->printQuantity);
$this->assertEquals(0, $outputItem->shipmentIndex);
$this->assertEquals('my item dispatch alert', $outputItem->dispatchAlert);
$this->assertObjectHasAttribute('extraData', $outputItem);
Expand Down Expand Up @@ -176,6 +179,7 @@ public function testCanBuildASingleItemOrder()
$this->assertEquals('carrierCode', $outputShipment->carrier->code);
$this->assertEquals('carrierService', $outputShipment->carrier->service);
$this->assertEquals('carrierAlias', $outputShipment->carrier->alias);
$this->assertEquals(5, $outputShipment->slaDays);

$this->assertEquals(1, count($outputShipment->attachments));
$outputAttachment = $outputShipment->attachments[0];
Expand Down

0 comments on commit 7b2f268

Please sign in to comment.