1
|
|
|
<?php |
2
|
|
|
declare(strict_types=1); |
3
|
|
|
|
4
|
|
|
namespace SetBased\ClubCollect\Resource; |
5
|
|
|
|
6
|
|
|
use SetBased\ClubCollect\ClubCollectApiClient; |
7
|
|
|
use SetBased\ClubCollect\Exception\ClubCollectApiException; |
8
|
|
|
use SetBased\ClubCollect\Helper\Cast; |
9
|
|
|
|
10
|
|
|
/** |
11
|
|
|
* An entity representing the address of a customer. |
12
|
|
|
*/ |
13
|
|
|
class CustomerAddress extends BaseResource |
14
|
|
|
{ |
15
|
|
|
//-------------------------------------------------------------------------------------------------------------------- |
16
|
|
|
/** |
17
|
|
|
* @var string|null |
18
|
|
|
*/ |
19
|
|
|
public $address1; |
20
|
|
|
|
21
|
|
|
/** |
22
|
|
|
* @var string|null |
23
|
|
|
*/ |
24
|
|
|
public $address2; |
25
|
|
|
|
26
|
|
|
/** |
27
|
|
|
* @var string|null |
28
|
|
|
*/ |
29
|
|
|
public $city; |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* @var string|null |
33
|
|
|
*/ |
34
|
|
|
public $countryCode; |
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* @var string|null |
38
|
|
|
*/ |
39
|
|
|
public $houseNumber; |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* @var string|null |
43
|
|
|
*/ |
44
|
|
|
public $locality; |
45
|
|
|
|
46
|
|
|
/** |
47
|
|
|
* @var string|null |
48
|
|
|
*/ |
49
|
|
|
public $state; |
50
|
|
|
|
51
|
|
|
/** |
52
|
|
|
* @var string|null |
53
|
|
|
*/ |
54
|
|
|
public $zipCode; |
55
|
|
|
|
56
|
|
|
//-------------------------------------------------------------------------------------------------------------------- |
57
|
|
|
/** |
58
|
|
|
* Object constructor. |
59
|
|
|
* |
60
|
|
|
* @param ClubCollectApiClient $client The API client. |
61
|
|
|
* @param array $response The API response. |
62
|
|
|
* |
63
|
|
|
* @throws ClubCollectApiException |
64
|
|
|
*/ |
65
|
|
|
public function __construct(ClubCollectApiClient $client, array $response) |
66
|
|
|
{ |
67
|
|
|
parent::__construct($client); |
68
|
|
|
|
69
|
|
|
try |
70
|
|
|
{ |
71
|
|
|
$this->address1 = Cast::toOptString($response['address1']); |
72
|
|
|
$this->address2 = Cast::toOptString($response['address2']); |
73
|
|
|
$this->city = Cast::toOptString($response['city']); |
74
|
|
|
$this->countryCode = Cast::toOptString($response['country_code']); |
75
|
|
|
$this->houseNumber = Cast::toOptString($response['house_number']); |
76
|
|
|
$this->locality = Cast::toOptString($response['locality']); |
77
|
|
|
$this->state = Cast::toOptString($response['state']); |
78
|
|
|
$this->zipCode = Cast::toOptString($response['zipcode']); |
79
|
|
|
} |
80
|
|
|
catch (\Throwable $exception) |
81
|
|
|
{ |
82
|
|
|
throw new ClubCollectApiException([$exception], 'Failed to create a customer address'); |
83
|
|
|
} |
84
|
|
|
} |
85
|
|
|
|
86
|
|
|
//-------------------------------------------------------------------------------------------------------------------- |
87
|
|
|
} |
88
|
|
|
|
89
|
|
|
//---------------------------------------------------------------------------------------------------------------------- |
90
|
|
|
|