2017-08-18 17:08:30 +02:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* UserPerson.php
|
|
|
|
* Copyright (c) 2017 thegrumpydictator@gmail.com
|
|
|
|
*
|
2017-10-21 08:40:00 +02:00
|
|
|
* This file is part of Firefly III.
|
|
|
|
*
|
|
|
|
* Firefly III is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* Firefly III is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
2017-12-17 14:44:05 +01:00
|
|
|
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
2017-08-18 17:08:30 +02:00
|
|
|
*/
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
|
|
namespace FireflyIII\Services\Bunq\Object;
|
|
|
|
|
|
|
|
use Carbon\Carbon;
|
|
|
|
|
|
|
|
/**
|
2017-11-15 12:25:49 +01:00
|
|
|
* Class UserPerson.
|
2017-08-18 17:08:30 +02:00
|
|
|
*/
|
|
|
|
class UserPerson extends BunqObject
|
|
|
|
{
|
2017-12-17 14:30:53 +01:00
|
|
|
/**
|
|
|
|
* @var
|
|
|
|
*/
|
2017-08-18 17:08:30 +02:00
|
|
|
private $addressMain;
|
2017-12-17 14:30:53 +01:00
|
|
|
/**
|
|
|
|
* @var
|
|
|
|
*/
|
2017-08-18 17:08:30 +02:00
|
|
|
private $addressPostal;
|
|
|
|
/** @var array */
|
|
|
|
private $aliases = [];
|
2017-12-17 14:30:53 +01:00
|
|
|
/**
|
|
|
|
* @var
|
|
|
|
*/
|
2017-08-18 17:08:30 +02:00
|
|
|
private $avatar;
|
|
|
|
/** @var array */
|
|
|
|
private $billingContracts = [];
|
|
|
|
/** @var string */
|
2018-04-02 14:50:17 +02:00
|
|
|
private $countryOfBirth;
|
2017-08-18 17:08:30 +02:00
|
|
|
/** @var Carbon */
|
|
|
|
private $created;
|
2017-12-17 14:30:53 +01:00
|
|
|
/**
|
|
|
|
* @var
|
|
|
|
*/
|
2017-08-18 17:08:30 +02:00
|
|
|
private $customer;
|
2017-12-17 14:30:53 +01:00
|
|
|
/**
|
|
|
|
* @var
|
|
|
|
*/
|
2017-08-18 17:08:30 +02:00
|
|
|
private $customerLimit;
|
2017-12-17 14:30:53 +01:00
|
|
|
/**
|
|
|
|
* @var
|
|
|
|
*/
|
2017-08-18 17:08:30 +02:00
|
|
|
private $dailyLimit;
|
|
|
|
/** @var Carbon */
|
|
|
|
private $dateOfBirth;
|
|
|
|
/** @var string */
|
2018-04-02 14:50:17 +02:00
|
|
|
private $displayName;
|
2017-08-18 17:08:30 +02:00
|
|
|
/** @var string */
|
2018-04-02 14:50:17 +02:00
|
|
|
private $documentCountry;
|
2017-08-18 17:08:30 +02:00
|
|
|
/** @var string */
|
2018-04-02 14:50:17 +02:00
|
|
|
private $documentNumber;
|
2017-08-18 17:08:30 +02:00
|
|
|
/** @var string */
|
2018-04-02 14:50:17 +02:00
|
|
|
private $documentType;
|
2017-08-18 17:08:30 +02:00
|
|
|
/** @var string */
|
2018-04-02 14:50:17 +02:00
|
|
|
private $firstName;
|
2017-08-18 17:08:30 +02:00
|
|
|
/** @var string */
|
2018-04-02 14:50:17 +02:00
|
|
|
private $gender;
|
2017-08-18 17:08:30 +02:00
|
|
|
/** @var int */
|
2018-04-02 14:50:17 +02:00
|
|
|
private $id;
|
2017-08-18 17:08:30 +02:00
|
|
|
/** @var string */
|
2018-04-02 14:50:17 +02:00
|
|
|
private $language;
|
2017-08-18 17:08:30 +02:00
|
|
|
/** @var string */
|
2018-04-02 14:50:17 +02:00
|
|
|
private $lastName;
|
2017-08-18 17:08:30 +02:00
|
|
|
/** @var string */
|
2018-04-02 14:50:17 +02:00
|
|
|
private $legalName;
|
2017-08-18 17:08:30 +02:00
|
|
|
/** @var string */
|
2018-04-02 14:50:17 +02:00
|
|
|
private $middleName;
|
2017-08-18 17:08:30 +02:00
|
|
|
/** @var string */
|
2018-04-02 14:50:17 +02:00
|
|
|
private $nationality;
|
2017-08-18 17:08:30 +02:00
|
|
|
/** @var array */
|
|
|
|
private $notificationFilters = [];
|
|
|
|
/** @var string */
|
2018-04-02 14:50:17 +02:00
|
|
|
private $placeOfBirth;
|
2017-08-18 17:08:30 +02:00
|
|
|
/** @var string */
|
2018-04-02 14:50:17 +02:00
|
|
|
private $publicNickName;
|
2017-08-18 17:08:30 +02:00
|
|
|
/** @var string */
|
2018-04-02 14:50:17 +02:00
|
|
|
private $publicUuid;
|
2017-12-17 14:30:53 +01:00
|
|
|
/**
|
|
|
|
* @var mixed
|
|
|
|
*/
|
2017-08-18 17:08:30 +02:00
|
|
|
private $region;
|
|
|
|
/** @var int */
|
2018-04-02 14:50:17 +02:00
|
|
|
private $sessionTimeout;
|
2017-08-18 17:08:30 +02:00
|
|
|
/** @var string */
|
2018-04-02 14:50:17 +02:00
|
|
|
private $status;
|
2017-08-18 17:08:30 +02:00
|
|
|
/** @var string */
|
2018-04-02 14:50:17 +02:00
|
|
|
private $subStatus;
|
2017-08-18 17:08:30 +02:00
|
|
|
/** @var string */
|
2018-04-02 14:50:17 +02:00
|
|
|
private $taxResident;
|
2017-08-18 17:08:30 +02:00
|
|
|
/** @var Carbon */
|
|
|
|
private $updated;
|
|
|
|
/** @var int */
|
2018-04-02 14:50:17 +02:00
|
|
|
private $versionTos;
|
2017-08-18 17:08:30 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* UserPerson constructor.
|
|
|
|
*
|
|
|
|
* @param array $data
|
2018-03-29 19:01:47 +02:00
|
|
|
*
|
2017-08-18 17:08:30 +02:00
|
|
|
*/
|
|
|
|
public function __construct(array $data)
|
|
|
|
{
|
2017-11-15 12:25:49 +01:00
|
|
|
if (0 === count($data)) {
|
2018-03-10 20:25:42 +01:00
|
|
|
$this->created = new Carbon;
|
|
|
|
$this->updated = new Carbon;
|
|
|
|
$this->dateOfBirth = new Carbon;
|
|
|
|
|
2017-08-19 09:22:44 +02:00
|
|
|
return;
|
|
|
|
}
|
2018-03-10 20:25:42 +01:00
|
|
|
|
2018-04-02 14:50:17 +02:00
|
|
|
$this->id = (int)$data['id'];
|
2017-08-18 17:08:30 +02:00
|
|
|
$this->created = Carbon::createFromFormat('Y-m-d H:i:s.u', $data['created']);
|
|
|
|
$this->updated = Carbon::createFromFormat('Y-m-d H:i:s.u', $data['updated']);
|
|
|
|
$this->status = $data['status'];
|
|
|
|
$this->subStatus = $data['sub_status'];
|
|
|
|
$this->publicUuid = $data['public_uuid'];
|
|
|
|
$this->displayName = $data['display_name'];
|
|
|
|
$this->publicNickName = $data['public_nick_name'];
|
|
|
|
$this->language = $data['language'];
|
|
|
|
$this->region = $data['region'];
|
2018-04-02 14:50:17 +02:00
|
|
|
$this->sessionTimeout = (int)$data['session_timeout'];
|
2017-08-18 17:08:30 +02:00
|
|
|
$this->firstName = $data['first_name'];
|
|
|
|
$this->middleName = $data['middle_name'];
|
|
|
|
$this->lastName = $data['last_name'];
|
|
|
|
$this->legalName = $data['legal_name'];
|
|
|
|
$this->taxResident = $data['tax_resident'];
|
|
|
|
$this->dateOfBirth = Carbon::createFromFormat('Y-m-d', $data['date_of_birth']);
|
|
|
|
$this->placeOfBirth = $data['place_of_birth'];
|
|
|
|
$this->countryOfBirth = $data['country_of_birth'];
|
|
|
|
$this->nationality = $data['nationality'];
|
|
|
|
$this->gender = $data['gender'];
|
2018-04-02 14:50:17 +02:00
|
|
|
$this->versionTos = (int)$data['version_terms_of_service'];
|
2017-08-18 17:08:30 +02:00
|
|
|
$this->documentNumber = $data['document_number'];
|
|
|
|
$this->documentType = $data['document_type'];
|
|
|
|
$this->documentCountry = $data['document_country_of_issuance'];
|
|
|
|
|
2018-03-10 20:25:42 +01:00
|
|
|
// TODO create aliases
|
|
|
|
// TODO create avatar
|
|
|
|
// TODO create daily limit
|
|
|
|
// TODO create notification filters
|
|
|
|
// TODO create address main, postal
|
|
|
|
// TODO document front, back attachment
|
|
|
|
// TODO customer, customer_limit
|
|
|
|
// TODO billing contracts
|
2017-08-18 17:08:30 +02:00
|
|
|
}
|
|
|
|
|
2017-08-19 16:46:06 +02:00
|
|
|
/**
|
|
|
|
* @return int
|
|
|
|
*/
|
|
|
|
public function getId(): int
|
|
|
|
{
|
|
|
|
return $this->id;
|
|
|
|
}
|
2018-03-10 20:25:42 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @return array
|
|
|
|
*/
|
|
|
|
public function toArray(): array
|
|
|
|
{
|
|
|
|
$data = [
|
|
|
|
'id' => $this->id,
|
|
|
|
'created' => $this->created->format('Y-m-d H:i:s.u'),
|
|
|
|
'updated' => $this->updated->format('Y-m-d H:i:s.u'),
|
|
|
|
'status' => $this->status,
|
|
|
|
'sub_status' => $this->subStatus,
|
|
|
|
'public_uuid' => $this->publicUuid,
|
|
|
|
'display_name' => $this->displayName,
|
|
|
|
'public_nick_name' => $this->publicNickName,
|
|
|
|
'language' => $this->language,
|
|
|
|
'region' => $this->region,
|
|
|
|
'session_timeout' => $this->sessionTimeout,
|
|
|
|
'first_name' => $this->firstName,
|
|
|
|
'middle_name' => $this->middleName,
|
|
|
|
'last_name' => $this->lastName,
|
|
|
|
'legal_name' => $this->legalName,
|
|
|
|
'tax_resident' => $this->taxResident,
|
|
|
|
'date_of_birth' => $this->dateOfBirth->format('Y-m-d'),
|
|
|
|
'place_of_birth' => $this->placeOfBirth,
|
|
|
|
'country_of_birth' => $this->countryOfBirth,
|
|
|
|
'nationality' => $this->nationality,
|
|
|
|
'gender' => $this->gender,
|
|
|
|
'version_terms_of_service' => $this->versionTos,
|
|
|
|
'document_number' => $this->documentNumber,
|
|
|
|
'document_type' => $this->documentType,
|
|
|
|
'document_country_of_issuance' => $this->documentCountry,
|
|
|
|
];
|
|
|
|
|
|
|
|
return $data;
|
|
|
|
}
|
2017-08-31 06:47:18 +02:00
|
|
|
}
|