|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Lifeboat\Models; |
|
4
|
|
|
|
|
5
|
|
|
use Lifeboat\Exceptions\ApiException; |
|
6
|
|
|
use Lifeboat\Exceptions\OAuthException; |
|
7
|
|
|
use Lifeboat\Services\Addresses; |
|
8
|
|
|
use Lifeboat\Services\ApiService; |
|
9
|
|
|
|
|
10
|
|
|
/** |
|
11
|
|
|
* Class Address |
|
12
|
|
|
* @package Lifeboat\Models |
|
13
|
|
|
* |
|
14
|
|
|
* @property string $Name |
|
15
|
|
|
* @property string $Address |
|
16
|
|
|
* @property string $AddressL2 |
|
17
|
|
|
* @property string $City |
|
18
|
|
|
* @property string $SubdivisionCode |
|
19
|
|
|
* @property string $CountryCode |
|
20
|
|
|
* @property string $PostCode |
|
21
|
|
|
* @property string|null $Notes |
|
22
|
|
|
* @property string|null $Latitude |
|
23
|
|
|
* @property string|null $Longitude |
|
24
|
|
|
* @property string $Email |
|
25
|
|
|
* @property string|null $Tel |
|
26
|
|
|
* @property string|null $VATNo |
|
27
|
|
|
* @property bool $isDefault |
|
28
|
|
|
* @property string $Country |
|
29
|
|
|
* @property string $Subdivision |
|
30
|
|
|
* @property int $CustomerID |
|
31
|
|
|
*/ |
|
32
|
|
|
class Address extends Model { |
|
33
|
|
|
|
|
34
|
|
|
protected static array $casting = [ |
|
35
|
|
|
'isDefault' => 'boolval', |
|
36
|
|
|
'CustomerID' => 'intval' |
|
37
|
|
|
]; |
|
38
|
|
|
|
|
39
|
|
|
/** |
|
40
|
|
|
* @return string |
|
41
|
|
|
*/ |
|
42
|
|
|
public function model(): string |
|
43
|
|
|
{ |
|
44
|
|
|
return 'Address'; |
|
45
|
|
|
} |
|
46
|
|
|
|
|
47
|
|
|
/** |
|
48
|
|
|
* @return Addresses |
|
49
|
|
|
*/ |
|
50
|
|
|
public function getService(): Addresses |
|
51
|
|
|
{ |
|
52
|
|
|
return new Addresses($this->getClient()); |
|
53
|
|
|
} |
|
54
|
|
|
|
|
55
|
|
|
/** |
|
56
|
|
|
* @return Customer|null |
|
57
|
|
|
* @throws ApiException |
|
58
|
|
|
* @throws OAuthException |
|
59
|
|
|
*/ |
|
60
|
|
|
public function Customer(): ?Customer |
|
61
|
|
|
{ |
|
62
|
|
|
if (!$this->CustomerID) return null; |
|
63
|
|
|
|
|
64
|
|
|
/** @var Customer|null $customer */ |
|
65
|
|
|
$customer = $this->getClient()->customers->fetch($this->CustomerID); |
|
66
|
|
|
|
|
67
|
|
|
return $customer; |
|
68
|
|
|
} |
|
69
|
|
|
} |
|
70
|
|
|
|