Skip to content

Commit 87d9e1d

Browse files
authored
Merge pull request #30 from Oneflow/development
feat: added shipment slaDays and item printQuantity properties
2 parents 683422f + 7b2f268 commit 87d9e1d

File tree

3 files changed

+151
-123
lines changed

3 files changed

+151
-123
lines changed

src/order/orderData/item/item.php

Lines changed: 135 additions & 123 deletions
Original file line numberDiff line numberDiff line change
@@ -23,141 +23,153 @@ public function init() {
2323
$this->__addProperty("sourceItemId", "", true);
2424
$this->__addProperty("sku");
2525
$this->__addProperty("quantity", 1, true);
26+
$this->__addProperty("printQuantity");
2627
$this->__addProperty("shrinkWrap", false);
2728
$this->__addProperty("barcode", "", false);
2829
$this->__addProperty("dispatchAlert");
2930
$this->__addArray("extraData",null);
3031

3132
$this->__addProperty("colour");
32-
}
33-
34-
/**
35-
* newComponent function.
36-
*
37-
* @access public
38-
* @param string $code
39-
* @return OneFlowComponent
40-
*/
41-
public function newComponent($code){
42-
$count = count($this->components);
43-
$component = new OneFlowComponent();
44-
$component->setCode($code);
45-
$this->components[$count] = $component;
46-
47-
return $this->components[$count];
48-
}
49-
50-
/**
51-
* addTextComponent function.
52-
*
53-
* @access public
54-
* @return OneFlowComponent
55-
*/
56-
public function addTextComponent() {
57-
return $this->newComponent('text');
58-
}
59-
60-
/**
61-
* addTextComponent function.
62-
*
63-
* @access public
64-
* @param string $barcode
65-
* @return string
66-
*/
67-
public function setBarcode($barcode) {
68-
return $this->barcode = $barcode;
69-
}
70-
71-
/**
72-
* addCoverComponent function.
73-
*
74-
* @access public
75-
* @return OneFlowComponent
76-
*/
77-
public function addCoverComponent() {
78-
return $this->newComponent('cover');
79-
}
80-
81-
/**
82-
* setDispatchAlert function.
83-
*
84-
* @access public
85-
* @param mixed $dispatchAlert
86-
* @return void
87-
*/
88-
public function setDispatchAlert($dispatchAlert) {
89-
$this->dispatchAlert = $dispatchAlert;
90-
}
91-
92-
/**
93-
* setShipment function.
94-
*
95-
* @access public
96-
* @param mixed $shipment
97-
* @return void
98-
*/
99-
public function setShipment($shipment) {
100-
$this->shipmentIndex = $shipment->shipmentIndex;
101-
}
102-
103-
/**
104-
* setBinding function.
105-
*
106-
* @access public
107-
* @param mixed $binding
108-
* @return boolean
109-
*/
110-
public function setBinding($binding) {
33+
}
34+
35+
/**
36+
* newComponent function.
37+
*
38+
* @access public
39+
* @param string $code
40+
* @return OneFlowComponent
41+
*/
42+
public function newComponent($code){
43+
$count = count($this->components);
44+
$component = new OneFlowComponent();
45+
$component->setCode($code);
46+
$this->components[$count] = $component;
47+
48+
return $this->components[$count];
49+
}
50+
51+
/**
52+
* addTextComponent function.
53+
*
54+
* @access public
55+
* @return OneFlowComponent
56+
*/
57+
public function addTextComponent() {
58+
return $this->newComponent('text');
59+
}
60+
61+
/**
62+
* addTextComponent function.
63+
*
64+
* @access public
65+
* @param string $barcode
66+
* @return string
67+
*/
68+
public function setBarcode($barcode) {
69+
return $this->barcode = $barcode;
70+
}
71+
72+
/**
73+
* addCoverComponent function.
74+
*
75+
* @access public
76+
* @return OneFlowComponent
77+
*/
78+
public function addCoverComponent() {
79+
return $this->newComponent('cover');
80+
}
81+
82+
/**
83+
* setDispatchAlert function.
84+
*
85+
* @access public
86+
* @param mixed $dispatchAlert
87+
* @return void
88+
*/
89+
public function setDispatchAlert($dispatchAlert) {
90+
$this->dispatchAlert = $dispatchAlert;
91+
}
92+
93+
/**
94+
* setShipment function.
95+
*
96+
* @access public
97+
* @param mixed $shipment
98+
* @return void
99+
*/
100+
public function setShipment($shipment) {
101+
$this->shipmentIndex = $shipment->shipmentIndex;
102+
}
103+
104+
/**
105+
* setBinding function.
106+
*
107+
* @access public
108+
* @param mixed $binding
109+
* @return boolean
110+
*/
111+
public function setBinding($binding) {
111112
$this->__addList("binding", Array("perfect", "saddle", "wiro", "pur", "threadSawn"));
112113
$this->binding = $binding;
113114
return true;
114-
}
115-
116-
/**
117-
* setFolding function.
118-
*
119-
* @access public
120-
* @param mixed $folding
121-
* @return boolean
122-
*/
123-
public function setFolding($folding) {
115+
}
116+
117+
/**
118+
* setFolding function.
119+
*
120+
* @access public
121+
* @param mixed $folding
122+
* @return boolean
123+
*/
124+
public function setFolding($folding) {
124125
$this->__addList("folding", Array("half", "gate", "cross", "concertina", "z", "2", "3"));
125126
$this->folding = $folding;
126127
return true;
127-
}
128-
129-
/**
130-
* setQuantity function.
131-
*
132-
* @access public
133-
* @param mixed $quantity
134-
* @return void
135-
*/
136-
public function setQuantity($quantity) {
137-
$this->quantity = $quantity;
138-
}
139-
140-
/**
141-
* setSourceItemId function.
142-
*
143-
* @access public
144-
* @param mixed $sourceItemId
145-
* @return void
146-
*/
147-
public function setSourceItemId($sourceItemId) {
148-
$this->sourceItemId = $sourceItemId;
149-
}
150-
151-
/**
152-
* setSKU function.
153-
*
154-
* @access public
155-
* @param mixed $skuCode
156-
* @return void
157-
*/
158-
public function setSKU($skuCode) {
159-
$this->sku = $skuCode;
160-
}
128+
}
129+
130+
/**
131+
* setQuantity function.
132+
*
133+
* @access public
134+
* @param mixed $quantity
135+
* @return void
136+
*/
137+
public function setQuantity($quantity) {
138+
$this->quantity = $quantity;
139+
}
140+
141+
/**
142+
* setPrintQuantity function.
143+
*
144+
* @access public
145+
* @param integer $printQuantity
146+
* @return void
147+
*/
148+
public function setPrintQuantity($printQuantity) {
149+
$this->printQuantity = $printQuantity;
150+
}
151+
152+
/**
153+
* setSourceItemId function.
154+
*
155+
* @access public
156+
* @param mixed $sourceItemId
157+
* @return void
158+
*/
159+
public function setSourceItemId($sourceItemId) {
160+
$this->sourceItemId = $sourceItemId;
161+
}
162+
163+
/**
164+
* setSKU function.
165+
*
166+
* @access public
167+
* @param mixed $skuCode
168+
* @return void
169+
*/
170+
public function setSKU($skuCode) {
171+
$this->sku = $skuCode;
172+
}
161173

162174
/**
163175
* setExtraData function.

src/order/orderData/shipment/shipment.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ public function init() {
2828
$this->__addProperty("pspBranding", true);
2929
$this->__addProperty("labelName");
3030
$this->__addProperty("cost");
31+
$this->__addProperty("slaDays");
3132
$this->__addProperty("dispatchAlert");
3233
}
3334

@@ -171,6 +172,17 @@ public function setCarrierByAlias($alias) {
171172
public function setLabelName($labelName) {
172173
$this->labelName = $labelName;
173174
}
175+
176+
/**
177+
* setSlaDays function.
178+
*
179+
* @access public
180+
* @param integer $slaDays
181+
* @return void
182+
*/
183+
public function setSlaDays($slaDays) {
184+
$this->slaDays = $slaDays;
185+
}
174186
}
175187

176188
?>

tests/order/orderTest.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ public function testCanBuildASingleItemOrder()
1919
]);
2020

2121
$item = $orderData->newSKUItem('skuCode', 'itemId', 5);
22+
$item->setPrintQuantity(1);
2223
$item->setBarcode('customItemBarcode');
2324
$item->setDispatchAlert('my item dispatch alert');
2425
$item->setExtraData([
@@ -75,6 +76,7 @@ public function testCanBuildASingleItemOrder()
7576
$shipment->newAttachment('http://site.com/attachment.pdf', 'insert');
7677
$shipment->setDispatchAlert('my shipment dispatch alert');
7778
$shipment->setLabelName('labelName');
79+
$shipment->setSlaDays(5);
7880

7981
$item->setShipment($shipment);
8082
$stockItem->setShipment($shipment);
@@ -107,6 +109,7 @@ public function testCanBuildASingleItemOrder()
107109
$this->assertEquals('itemId', $outputItem->sourceItemId);
108110
$this->assertEquals('customItemBarcode', $outputItem->barcode);
109111
$this->assertEquals(5, $outputItem->quantity);
112+
$this->assertEquals(1, $outputItem->printQuantity);
110113
$this->assertEquals(0, $outputItem->shipmentIndex);
111114
$this->assertEquals('my item dispatch alert', $outputItem->dispatchAlert);
112115
$this->assertObjectHasAttribute('extraData', $outputItem);
@@ -176,6 +179,7 @@ public function testCanBuildASingleItemOrder()
176179
$this->assertEquals('carrierCode', $outputShipment->carrier->code);
177180
$this->assertEquals('carrierService', $outputShipment->carrier->service);
178181
$this->assertEquals('carrierAlias', $outputShipment->carrier->alias);
182+
$this->assertEquals(5, $outputShipment->slaDays);
179183

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

0 commit comments

Comments
 (0)