2
2
3
3
namespace Olsgreen \AutoTrader \Api \Builders ;
4
4
5
+ use Olsgreen \AutoTrader \Api \Enums \VatStatuses ;
6
+
5
7
class StockItemRetailAdvertsInfoBuilder extends AbstractBuilder
6
8
{
7
9
protected $ attentionGrabber ;
@@ -20,19 +22,19 @@ class StockItemRetailAdvertsInfoBuilder extends AbstractBuilder
20
22
21
23
protected $ profileAdvert ;
22
24
23
- protected $ vatExcluded ;
25
+ protected $ vatStatus ;
24
26
25
27
protected $ priceOnApplication ;
26
28
27
- protected $ price ;
29
+ protected $ suppliedPrice ;
28
30
29
31
public function __construct (array $ attributes = [])
30
32
{
31
33
parent ::__construct ($ attributes );
32
34
33
- $ this ->price = new StockItemPriceInfoBuilder (
34
- 'Price ' ,
35
- $ this ->dataGet ($ attributes , 'price ' , [])
35
+ $ this ->suppliedPrice = new StockItemPriceInfoBuilder (
36
+ 'Supplied Price ' ,
37
+ $ this ->dataGet ($ attributes , 'suppliedPrice ' , [])
36
38
);
37
39
38
40
$ this ->autotraderAdvert = new StockItemAdvertInfoBuilder (
@@ -61,16 +63,24 @@ public function __construct(array $attributes = [])
61
63
);
62
64
}
63
65
64
- public function setVatExcluded ( $ state ): StockItemRetailAdvertsInfoBuilder
66
+ public function setVatStatus ( $ status ): StockItemRetailAdvertsInfoBuilder
65
67
{
66
- $ this ->vatExcluded = boolval ($ state );
68
+ $ statuses = new VatStatuses ();
69
+
70
+ if (!$ statuses ->contains ($ status )) {
71
+ throw new \Exception (
72
+ sprintf ('\'%s \' is an invalid VAT status. ' , $ status )
73
+ );
74
+ }
75
+
76
+ $ this ->vatStatus = $ status ;
67
77
68
78
return $ this ;
69
79
}
70
80
71
- public function getVatExcluded (): bool
81
+ public function getVatStatus (): string
72
82
{
73
- return $ this ->vatExcluded ;
83
+ return $ this ->vatStatus ;
74
84
}
75
85
76
86
public function setPriceOnApplication ($ state ): StockItemRetailAdvertsInfoBuilder
@@ -151,8 +161,8 @@ public function toArray(): array
151
161
$ this ->validate ();
152
162
153
163
return $ this ->filterPrepareOutput ([
154
- 'price ' => $ this ->price ->toArray (),
155
- 'vatExcluded ' => $ this ->vatExcluded ,
164
+ 'suppliedPrice ' => $ this ->suppliedPrice ->toArray (),
165
+ 'vatStatus ' => $ this ->vatStatus ,
156
166
'priceOnApplication ' => $ this ->priceOnApplication ,
157
167
'attentionGrabber ' => $ this ->attentionGrabber ,
158
168
'description ' => $ this ->description ,
0 commit comments