1 | <?php |
||
2 | /** |
||
3 | * UserPerson.php |
||
4 | * Copyright (c) 2017 [email protected] |
||
5 | * |
||
6 | * This file is part of Firefly III. |
||
7 | * |
||
8 | * Firefly III is free software: you can redistribute it and/or modify |
||
9 | * it under the terms of the GNU General Public License as published by |
||
10 | * the Free Software Foundation, either version 3 of the License, or |
||
11 | * (at your option) any later version. |
||
12 | * |
||
13 | * Firefly III is distributed in the hope that it will be useful, |
||
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||
16 | * GNU General Public License for more details. |
||
17 | * |
||
18 | * You should have received a copy of the GNU General Public License |
||
19 | * along with Firefly III. If not, see <http://www.gnu.org/licenses/>. |
||
20 | */ |
||
21 | declare(strict_types=1); |
||
22 | |||
23 | namespace FireflyIII\Services\Bunq\Object; |
||
24 | |||
25 | use Carbon\Carbon; |
||
26 | |||
27 | /** |
||
28 | * Class UserPerson. |
||
29 | */ |
||
30 | class UserPerson extends BunqObject |
||
31 | { |
||
32 | /** |
||
33 | * @var |
||
34 | */ |
||
35 | private $addressMain; |
||
36 | /** |
||
37 | * @var |
||
38 | */ |
||
39 | private $addressPostal; |
||
40 | /** @var array */ |
||
41 | private $aliases = []; |
||
42 | /** |
||
43 | * @var |
||
44 | */ |
||
45 | private $avatar; |
||
46 | /** @var array */ |
||
47 | private $billingContracts = []; |
||
48 | /** @var string */ |
||
49 | private $countryOfBirth; |
||
50 | /** @var Carbon */ |
||
51 | private $created; |
||
52 | /** |
||
53 | * @var |
||
54 | */ |
||
55 | private $customer; |
||
56 | /** |
||
57 | * @var |
||
58 | */ |
||
59 | private $customerLimit; |
||
60 | /** |
||
61 | * @var |
||
62 | */ |
||
63 | private $dailyLimit; |
||
64 | /** @var Carbon */ |
||
65 | private $dateOfBirth; |
||
66 | /** @var string */ |
||
67 | private $displayName; |
||
68 | /** @var string */ |
||
69 | private $documentCountry; |
||
70 | /** @var string */ |
||
71 | private $documentNumber; |
||
72 | /** @var string */ |
||
73 | private $documentType; |
||
74 | /** @var string */ |
||
75 | private $firstName; |
||
76 | /** @var string */ |
||
77 | private $gender; |
||
78 | /** @var int */ |
||
79 | private $id; |
||
80 | /** @var string */ |
||
81 | private $language; |
||
82 | /** @var string */ |
||
83 | private $lastName; |
||
84 | /** @var string */ |
||
85 | private $legalName; |
||
86 | /** @var string */ |
||
87 | private $middleName; |
||
88 | /** @var string */ |
||
89 | private $nationality; |
||
90 | /** @var array */ |
||
91 | private $notificationFilters = []; |
||
92 | /** @var string */ |
||
93 | private $placeOfBirth; |
||
94 | /** @var string */ |
||
95 | private $publicNickName; |
||
96 | /** @var string */ |
||
97 | private $publicUuid; |
||
98 | /** |
||
99 | * @var mixed |
||
100 | */ |
||
101 | private $region; |
||
102 | /** @var int */ |
||
103 | private $sessionTimeout; |
||
104 | /** @var string */ |
||
105 | private $status; |
||
106 | /** @var string */ |
||
107 | private $subStatus; |
||
108 | /** @var string */ |
||
109 | private $taxResident; |
||
110 | /** @var Carbon */ |
||
111 | private $updated; |
||
112 | /** @var int */ |
||
113 | private $versionTos; |
||
114 | |||
115 | /** |
||
116 | * UserPerson constructor. |
||
117 | * |
||
118 | * @param array $data |
||
119 | * |
||
120 | */ |
||
121 | public function __construct(array $data) |
||
122 | { |
||
123 | if (0 === count($data)) { |
||
124 | $this->created = new Carbon; |
||
125 | $this->updated = new Carbon; |
||
126 | $this->dateOfBirth = new Carbon; |
||
127 | |||
128 | return; |
||
129 | } |
||
130 | |||
131 | $this->id = (int)$data['id']; |
||
132 | $this->created = Carbon::createFromFormat('Y-m-d H:i:s.u', $data['created']); |
||
133 | $this->updated = Carbon::createFromFormat('Y-m-d H:i:s.u', $data['updated']); |
||
134 | $this->status = $data['status']; |
||
135 | $this->subStatus = $data['sub_status']; |
||
136 | $this->publicUuid = $data['public_uuid']; |
||
137 | $this->displayName = $data['display_name']; |
||
138 | $this->publicNickName = $data['public_nick_name']; |
||
139 | $this->language = $data['language']; |
||
140 | $this->region = $data['region']; |
||
141 | $this->sessionTimeout = (int)$data['session_timeout']; |
||
142 | $this->firstName = $data['first_name']; |
||
143 | $this->middleName = $data['middle_name']; |
||
144 | $this->lastName = $data['last_name']; |
||
145 | $this->legalName = $data['legal_name']; |
||
146 | $this->taxResident = $data['tax_resident']; |
||
147 | $this->dateOfBirth = Carbon::createFromFormat('Y-m-d', $data['date_of_birth']); |
||
148 | $this->placeOfBirth = $data['place_of_birth']; |
||
149 | $this->countryOfBirth = $data['country_of_birth']; |
||
150 | $this->nationality = $data['nationality']; |
||
151 | $this->gender = $data['gender']; |
||
152 | $this->versionTos = (int)$data['version_terms_of_service']; |
||
153 | $this->documentNumber = $data['document_number']; |
||
154 | $this->documentType = $data['document_type']; |
||
155 | $this->documentCountry = $data['document_country_of_issuance']; |
||
156 | |||
157 | // TODO create aliases |
||
0 ignored issues
–
show
Coding Style
Best Practice
introduced
by
Loading history...
|
|||
158 | // TODO create avatar |
||
0 ignored issues
–
show
|
|||
159 | // TODO create daily limit |
||
0 ignored issues
–
show
|
|||
160 | // TODO create notification filters |
||
0 ignored issues
–
show
|
|||
161 | // TODO create address main, postal |
||
0 ignored issues
–
show
|
|||
162 | // TODO document front, back attachment |
||
0 ignored issues
–
show
|
|||
163 | // TODO customer, customer_limit |
||
0 ignored issues
–
show
|
|||
164 | // TODO billing contracts |
||
0 ignored issues
–
show
|
|||
165 | } |
||
166 | |||
167 | /** |
||
168 | * @return int |
||
169 | */ |
||
170 | public function getId(): int |
||
171 | { |
||
172 | return $this->id; |
||
173 | } |
||
174 | |||
175 | /** |
||
176 | * @return array |
||
177 | */ |
||
178 | public function toArray(): array |
||
179 | { |
||
180 | $data = [ |
||
181 | 'id' => $this->id, |
||
182 | 'created' => $this->created->format('Y-m-d H:i:s.u'), |
||
183 | 'updated' => $this->updated->format('Y-m-d H:i:s.u'), |
||
184 | 'status' => $this->status, |
||
185 | 'sub_status' => $this->subStatus, |
||
186 | 'public_uuid' => $this->publicUuid, |
||
187 | 'display_name' => $this->displayName, |
||
188 | 'public_nick_name' => $this->publicNickName, |
||
189 | 'language' => $this->language, |
||
190 | 'region' => $this->region, |
||
191 | 'session_timeout' => $this->sessionTimeout, |
||
192 | 'first_name' => $this->firstName, |
||
193 | 'middle_name' => $this->middleName, |
||
194 | 'last_name' => $this->lastName, |
||
195 | 'legal_name' => $this->legalName, |
||
196 | 'tax_resident' => $this->taxResident, |
||
197 | 'date_of_birth' => $this->dateOfBirth->format('Y-m-d'), |
||
198 | 'place_of_birth' => $this->placeOfBirth, |
||
199 | 'country_of_birth' => $this->countryOfBirth, |
||
200 | 'nationality' => $this->nationality, |
||
201 | 'gender' => $this->gender, |
||
202 | 'version_terms_of_service' => $this->versionTos, |
||
203 | 'document_number' => $this->documentNumber, |
||
204 | 'document_type' => $this->documentType, |
||
205 | 'document_country_of_issuance' => $this->documentCountry, |
||
206 | ]; |
||
207 | |||
208 | return $data; |
||
209 | } |
||
210 | } |
||
211 |