Skip to content

Commit 14b0159

Browse files
committed
Implemented A/T schema changes.
1 parent 58ba2e4 commit 14b0159

File tree

2 files changed

+33
-11
lines changed

2 files changed

+33
-11
lines changed

src/Api/Builders/StockItemRetailAdvertsInfoBuilder.php

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
namespace Olsgreen\AutoTrader\Api\Builders;
44

5+
use Olsgreen\AutoTrader\Api\Enums\VatStatuses;
6+
57
class StockItemRetailAdvertsInfoBuilder extends AbstractBuilder
68
{
79
protected $attentionGrabber;
@@ -20,19 +22,19 @@ class StockItemRetailAdvertsInfoBuilder extends AbstractBuilder
2022

2123
protected $profileAdvert;
2224

23-
protected $vatExcluded;
25+
protected $vatStatus;
2426

2527
protected $priceOnApplication;
2628

27-
protected $price;
29+
protected $suppliedPrice;
2830

2931
public function __construct(array $attributes = [])
3032
{
3133
parent::__construct($attributes);
3234

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', [])
3638
);
3739

3840
$this->autotraderAdvert = new StockItemAdvertInfoBuilder(
@@ -61,16 +63,24 @@ public function __construct(array $attributes = [])
6163
);
6264
}
6365

64-
public function setVatExcluded($state): StockItemRetailAdvertsInfoBuilder
66+
public function setVatStatus($status): StockItemRetailAdvertsInfoBuilder
6567
{
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;
6777

6878
return $this;
6979
}
7080

71-
public function getVatExcluded(): bool
81+
public function getVatStatus(): string
7282
{
73-
return $this->vatExcluded;
83+
return $this->vatStatus;
7484
}
7585

7686
public function setPriceOnApplication($state): StockItemRetailAdvertsInfoBuilder
@@ -151,8 +161,8 @@ public function toArray(): array
151161
$this->validate();
152162

153163
return $this->filterPrepareOutput([
154-
'price' => $this->price->toArray(),
155-
'vatExcluded' => $this->vatExcluded,
164+
'suppliedPrice' => $this->suppliedPrice->toArray(),
165+
'vatStatus' => $this->vatStatus,
156166
'priceOnApplication' => $this->priceOnApplication,
157167
'attentionGrabber' => $this->attentionGrabber,
158168
'description' => $this->description,

src/Api/Enums/VatStatuses.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?php
2+
3+
namespace Olsgreen\AutoTrader\Api\Enums;
4+
5+
class VatStatuses extends AbstractEnum
6+
{
7+
const NO_VAT = 'No VAT';
8+
9+
const INC_VAT = 'Inc VAT';
10+
11+
const EX_VAT = 'Ex VAT';
12+
}

0 commit comments

Comments
 (0)