Files
firefly-iii/app/Services/Spectre/Object/Login.php

191 lines
5.5 KiB
PHP
Raw Normal View History

2018-01-02 15:17:31 +01:00
<?php
/**
* Login.php
2020-02-16 13:56:35 +01:00
* Copyright (c) 2019 james@firefly-iii.org
2018-01-02 15:17:31 +01:00
*
* This file is part of Firefly III (https://github.com/firefly-iii).
2018-01-02 15:17:31 +01:00
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
2018-01-02 15:17:31 +01:00
*
* This program is distributed in the hope that it will be useful,
2018-01-02 15:17:31 +01:00
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
2018-01-02 15:17:31 +01:00
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
2018-01-02 15:17:31 +01:00
*/
declare(strict_types=1);
namespace FireflyIII\Services\Spectre\Object;
use Carbon\Carbon;
/**
* Class Login
2018-08-06 19:14:30 +02:00
*
2018-07-28 06:27:30 +02:00
* @codeCoverageIgnore
* @SuppressWarnings(PHPMD.ShortVariable)
* @SuppressWarnings(PHPMD.TooManyFields)
2018-01-02 15:17:31 +01:00
*/
class Login extends SpectreObject
{
/** @var Carbon */
private $consentGivenAt;
/** @var array */
private $consentTypes;
/** @var string */
private $countryCode;
/** @var Carbon */
private $createdAt;
/** @var int */
private $customerId;
/** @var bool */
private $dailyRefresh;
/** @var Holder */
private $holderInfo;
/** @var int */
private $id;
/** @var Attempt */
private $lastAttempt;
/** @var Carbon */
private $lastSuccessAt;
/** @var Carbon */
private $nextRefreshPossibleAt;
/** @var string */
private $providerCode;
/** @var int */
private $providerId;
/** @var string */
private $providerName;
/** @var bool */
private $showConsentConfirmation;
/** @var string */
private $status;
/** @var bool */
private $storeCredentials;
/** @var Carbon */
private $updatedAt;
/**
* Login constructor.
*
* @param array $data
*/
public function __construct(array $data)
{
$this->consentGivenAt = new Carbon($data['consent_given_at']);
$this->consentTypes = $data['consent_types'];
$this->countryCode = $data['country_code'];
$this->createdAt = new Carbon($data['created_at']);
$this->updatedAt = new Carbon($data['updated_at']);
$this->customerId = $data['customer_id'];
$this->dailyRefresh = $data['daily_refresh'];
$this->holderInfo = new Holder($data['holder_info']);
2018-04-28 05:25:29 +02:00
$this->id = (int)$data['id'];
2018-01-02 15:17:31 +01:00
$this->lastAttempt = new Attempt($data['last_attempt']);
$this->lastSuccessAt = new Carbon($data['last_success_at']);
$this->nextRefreshPossibleAt = new Carbon($data['next_refresh_possible_at']);
$this->providerCode = $data['provider_code'];
$this->providerId = $data['provider_id'];
$this->providerName = $data['provider_name'];
$this->showConsentConfirmation = $data['show_consent_confirmation'];
$this->status = $data['status'];
$this->storeCredentials = $data['store_credentials'];
}
/**
* @return string
*/
public function getCountryCode(): string
{
return $this->countryCode;
}
2018-01-03 19:17:30 +01:00
/**
* @return int
*/
public function getId(): int
{
return $this->id;
}
2018-01-02 15:17:31 +01:00
/**
* @return Attempt
*/
public function getLastAttempt(): Attempt
{
return $this->lastAttempt;
}
/**
* @return Carbon
*/
public function getLastSuccessAt(): Carbon
{
return $this->lastSuccessAt;
}
/**
* @return string
*/
public function getProviderName(): string
{
return $this->providerName;
}
/**
* @return string
*/
public function getStatus(): string
{
return $this->status;
}
/**
* @return Carbon
*/
public function getUpdatedAt(): Carbon
{
return $this->updatedAt;
}
2018-01-03 19:17:30 +01:00
/**
* @return array
*/
public function toArray(): array
{
$array = [
'consent_given_at' => $this->consentGivenAt->toIso8601String(),
'consent_types' => $this->consentTypes,
'country_code' => $this->countryCode,
'created_at' => $this->createdAt->toIso8601String(),
'updated_at' => $this->updatedAt->toIso8601String(),
'customer_id' => $this->customerId,
'daily_refresh' => $this->dailyRefresh,
'holder_info' => $this->holderInfo->toArray(),
'id' => $this->id,
'last_attempt' => $this->lastAttempt->toArray(),
'last_success_at' => $this->lastSuccessAt->toIso8601String(),
'next_refresh_possible_at' => $this->nextRefreshPossibleAt->toIso8601String(),
2018-01-03 19:17:30 +01:00
'provider_code' => $this->providerCode,
'provider_id' => $this->providerId,
'provider_name' => $this->providerName,
'show_consent_confirmation' => $this->showConsentConfirmation,
'status' => $this->status,
'store_credentials' => $this->storeCredentials,
];
return $array;
}
2018-01-02 15:17:31 +01:00
2018-03-05 19:35:58 +01:00
}