mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-26 21:43:53 +00:00
Code clean up.
This commit is contained in:
@@ -19,15 +19,12 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Services\Bunq\Id;
|
||||
|
||||
/**
|
||||
* Class BunqId
|
||||
*
|
||||
* @package FireflyIII\Services\Bunq\Id
|
||||
* Class BunqId.
|
||||
*/
|
||||
class BunqId
|
||||
{
|
||||
|
||||
@@ -19,15 +19,12 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Services\Bunq\Id;
|
||||
|
||||
/**
|
||||
* Class DeviceServerId
|
||||
*
|
||||
* @package Bunq\Id
|
||||
* Class DeviceServerId.
|
||||
*/
|
||||
class DeviceServerId extends BunqId
|
||||
{
|
||||
|
||||
@@ -18,15 +18,12 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Services\Bunq\Id;
|
||||
|
||||
/**
|
||||
* Class DeviceSessionId
|
||||
*
|
||||
* @package Bunq\Id
|
||||
* Class DeviceSessionId.
|
||||
*/
|
||||
class DeviceSessionId extends BunqId
|
||||
{
|
||||
|
||||
@@ -18,15 +18,12 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Services\Bunq\Id;
|
||||
|
||||
/**
|
||||
* Class InstallationId
|
||||
*
|
||||
* @package Bunq\Id
|
||||
* Class InstallationId.
|
||||
*/
|
||||
class InstallationId extends BunqId
|
||||
{
|
||||
|
||||
@@ -18,15 +18,12 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Services\Bunq\Object;
|
||||
|
||||
/**
|
||||
* Class Alias
|
||||
*
|
||||
* @package FireflyIII\Services\Bunq\Object
|
||||
* Class Alias.
|
||||
*/
|
||||
class Alias extends BunqObject
|
||||
{
|
||||
|
||||
@@ -18,15 +18,12 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Services\Bunq\Object;
|
||||
|
||||
/**
|
||||
* Class Amount
|
||||
*
|
||||
* @package FireflyIII\Services\Bunq\Object
|
||||
* Class Amount.
|
||||
*/
|
||||
class Amount extends BunqObject
|
||||
{
|
||||
|
||||
@@ -18,15 +18,12 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Services\Bunq\Object;
|
||||
|
||||
/**
|
||||
* Class Avatar
|
||||
*
|
||||
* @package FireflyIII\Services\Bunq\Object
|
||||
* Class Avatar.
|
||||
*/
|
||||
class Avatar extends BunqObject
|
||||
{
|
||||
|
||||
@@ -18,15 +18,12 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Services\Bunq\Object;
|
||||
|
||||
/**
|
||||
* Class BunqObject
|
||||
*
|
||||
* @package FireflyIII\Services\Bunq\Object
|
||||
* Class BunqObject.
|
||||
*/
|
||||
class BunqObject
|
||||
{
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Services\Bunq\Object;
|
||||
@@ -28,17 +27,17 @@ use FireflyIII\Services\Bunq\Id\DeviceServerId;
|
||||
|
||||
class DeviceServer extends BunqObject
|
||||
{
|
||||
/** @var Carbon */
|
||||
/** @var Carbon */
|
||||
private $created;
|
||||
/** @var string */
|
||||
/** @var string */
|
||||
private $description;
|
||||
/** @var DeviceServerId */
|
||||
/** @var DeviceServerId */
|
||||
private $id;
|
||||
/** @var string */
|
||||
/** @var string */
|
||||
private $ip;
|
||||
/** @var string */
|
||||
/** @var string */
|
||||
private $status;
|
||||
/** @var Carbon */
|
||||
/** @var Carbon */
|
||||
private $updated;
|
||||
|
||||
public function __construct(array $data)
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Services\Bunq\Object;
|
||||
@@ -26,35 +25,33 @@ namespace FireflyIII\Services\Bunq\Object;
|
||||
use Carbon\Carbon;
|
||||
|
||||
/**
|
||||
* Class MonetaryAccountBank
|
||||
*
|
||||
* @package FireflyIII\Services\Bunq\Object
|
||||
* Class MonetaryAccountBank.
|
||||
*/
|
||||
class MonetaryAccountBank extends BunqObject
|
||||
{
|
||||
/** @var array */
|
||||
private $aliases = [];
|
||||
/** @var Avatar */
|
||||
/** @var Avatar */
|
||||
private $avatar;
|
||||
/** @var Amount */
|
||||
/** @var Amount */
|
||||
private $balance;
|
||||
/** @var Carbon */
|
||||
private $created;
|
||||
/** @var string */
|
||||
private $currency = '';
|
||||
/** @var Amount */
|
||||
/** @var Amount */
|
||||
private $dailyLimit;
|
||||
/** @var Amount */
|
||||
/** @var Amount */
|
||||
private $dailySpent;
|
||||
/** @var string */
|
||||
private $description = '';
|
||||
/** @var int */
|
||||
private $id = 0;
|
||||
/** @var MonetaryAccountProfile */
|
||||
/** @var MonetaryAccountProfile */
|
||||
private $monetaryAccountProfile;
|
||||
/** @var array */
|
||||
private $notificationFilters = [];
|
||||
/** @var Amount */
|
||||
/** @var Amount */
|
||||
private $overdraftLimit;
|
||||
/** @var string */
|
||||
private $publicUuid = '';
|
||||
@@ -62,7 +59,7 @@ class MonetaryAccountBank extends BunqObject
|
||||
private $reason = '';
|
||||
/** @var string */
|
||||
private $reasonDescription = '';
|
||||
/** @var MonetaryAccountSetting */
|
||||
/** @var MonetaryAccountSetting */
|
||||
private $setting;
|
||||
/** @var string */
|
||||
private $status = '';
|
||||
|
||||
@@ -18,21 +18,18 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Services\Bunq\Object;
|
||||
|
||||
/**
|
||||
* Class MonetaryAccountProfile
|
||||
*
|
||||
* @package FireflyIII\Services\Bunq\Object
|
||||
* Class MonetaryAccountProfile.
|
||||
*/
|
||||
class MonetaryAccountProfile extends BunqObject
|
||||
{
|
||||
/** @var string */
|
||||
private $profileActionRequired = '';
|
||||
/** @var Amount */
|
||||
/** @var Amount */
|
||||
private $profileAmountRequired;
|
||||
private $profileDrain;
|
||||
private $profileFill;
|
||||
|
||||
@@ -18,15 +18,12 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Services\Bunq\Object;
|
||||
|
||||
/**
|
||||
* Class MonetaryAccountSetting
|
||||
*
|
||||
* @package FireflyIII\Services\Bunq\Object
|
||||
* Class MonetaryAccountSetting.
|
||||
*/
|
||||
class MonetaryAccountSetting extends BunqObject
|
||||
{
|
||||
|
||||
@@ -18,15 +18,12 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Services\Bunq\Object;
|
||||
|
||||
/**
|
||||
* Class NotificationFilter
|
||||
*
|
||||
* @package FireflyIII\Services\Bunq\Object
|
||||
* Class NotificationFilter.
|
||||
*/
|
||||
class NotificationFilter extends BunqObject
|
||||
{
|
||||
|
||||
@@ -18,15 +18,12 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Services\Bunq\Object;
|
||||
|
||||
/**
|
||||
* Class ServerPublicKey
|
||||
*
|
||||
* @package Bunq\Object
|
||||
* Class ServerPublicKey.
|
||||
*/
|
||||
class ServerPublicKey extends BunqObject
|
||||
{
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Services\Bunq\Object;
|
||||
@@ -26,9 +25,7 @@ namespace FireflyIII\Services\Bunq\Object;
|
||||
use Carbon\Carbon;
|
||||
|
||||
/**
|
||||
* Class UserCompany
|
||||
*
|
||||
* @package FireflyIII\Services\Bunq\Object
|
||||
* Class UserCompany.
|
||||
*/
|
||||
class UserCompany extends BunqObject
|
||||
{
|
||||
@@ -69,7 +66,7 @@ class UserCompany extends BunqObject
|
||||
private $status = '';
|
||||
/** @var string */
|
||||
private $subStatus = '';
|
||||
/** @var string */
|
||||
/** @var string */
|
||||
private $typeOfBusinessEntity = '';
|
||||
/** @var array */
|
||||
private $ubos = [];
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Services\Bunq\Object;
|
||||
@@ -26,9 +25,7 @@ namespace FireflyIII\Services\Bunq\Object;
|
||||
use Carbon\Carbon;
|
||||
|
||||
/**
|
||||
* Class UserLight
|
||||
*
|
||||
* @package FireflyIII\Services\Bunq\Object
|
||||
* Class UserLight.
|
||||
*/
|
||||
class UserLight extends BunqObject
|
||||
{
|
||||
@@ -62,7 +59,7 @@ class UserLight extends BunqObject
|
||||
*/
|
||||
public function __construct(array $data)
|
||||
{
|
||||
if (count($data) === 0) {
|
||||
if (0 === count($data)) {
|
||||
return;
|
||||
}
|
||||
$this->id = intval($data['id']);
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Services\Bunq\Object;
|
||||
@@ -26,9 +25,7 @@ namespace FireflyIII\Services\Bunq\Object;
|
||||
use Carbon\Carbon;
|
||||
|
||||
/**
|
||||
* Class UserPerson
|
||||
*
|
||||
* @package Bunq\Object
|
||||
* Class UserPerson.
|
||||
*/
|
||||
class UserPerson extends BunqObject
|
||||
{
|
||||
@@ -101,7 +98,7 @@ class UserPerson extends BunqObject
|
||||
*/
|
||||
public function __construct(array $data)
|
||||
{
|
||||
if (count($data) === 0) {
|
||||
if (0 === count($data)) {
|
||||
return;
|
||||
}
|
||||
$this->id = intval($data['id']);
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Services\Bunq\Request;
|
||||
@@ -31,15 +30,13 @@ use Requests;
|
||||
use Requests_Exception;
|
||||
|
||||
/**
|
||||
* Class BunqRequest
|
||||
*
|
||||
* @package Bunq\Request
|
||||
* Class BunqRequest.
|
||||
*/
|
||||
abstract class BunqRequest
|
||||
{
|
||||
/** @var string */
|
||||
protected $secret = '';
|
||||
/** @var ServerPublicKey */
|
||||
/** @var ServerPublicKey */
|
||||
protected $serverPublicKey;
|
||||
/** @var string */
|
||||
private $privateKey = '';
|
||||
@@ -111,14 +108,15 @@ abstract class BunqRequest
|
||||
* @param string $data
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @throws FireflyException
|
||||
*/
|
||||
protected function generateSignature(string $method, string $uri, array $headers, string $data): string
|
||||
{
|
||||
if (strlen($this->privateKey) === 0) {
|
||||
if (0 === strlen($this->privateKey)) {
|
||||
throw new FireflyException('No private key present.');
|
||||
}
|
||||
if (strtolower($method) === 'get' || strtolower($method) === 'delete') {
|
||||
if ('get' === strtolower($method) || 'delete' === strtolower($method)) {
|
||||
$data = '';
|
||||
}
|
||||
|
||||
@@ -127,7 +125,7 @@ abstract class BunqRequest
|
||||
$headersToSign = ['Cache-Control', 'User-Agent'];
|
||||
ksort($headers);
|
||||
foreach ($headers as $name => $value) {
|
||||
if (in_array($name, $headersToSign) || substr($name, 0, 7) === 'X-Bunq-') {
|
||||
if (in_array($name, $headersToSign) || 'X-Bunq-' === substr($name, 0, 7)) {
|
||||
$toSign .= sprintf("%s: %s\n", $name, $value);
|
||||
}
|
||||
}
|
||||
@@ -202,11 +200,12 @@ abstract class BunqRequest
|
||||
* @param array $headers
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
protected function sendSignedBunqDelete(string $uri, array $headers): array
|
||||
{
|
||||
if (strlen($this->server) === 0) {
|
||||
if (0 === strlen($this->server)) {
|
||||
throw new FireflyException('No bunq server defined');
|
||||
}
|
||||
|
||||
@@ -216,7 +215,7 @@ abstract class BunqRequest
|
||||
try {
|
||||
$response = Requests::delete($fullUri, $headers);
|
||||
} catch (Requests_Exception $e) {
|
||||
return ['Error' => [0 => ['error_description' => $e->getMessage(), 'error_description_translated' => $e->getMessage()],]];
|
||||
return ['Error' => [0 => ['error_description' => $e->getMessage(), 'error_description_translated' => $e->getMessage()]]];
|
||||
}
|
||||
|
||||
$body = $response->body;
|
||||
@@ -235,7 +234,6 @@ abstract class BunqRequest
|
||||
throw new FireflyException(sprintf('Could not verify signature for request to "%s"', $uri));
|
||||
}
|
||||
|
||||
|
||||
return $array;
|
||||
}
|
||||
|
||||
@@ -245,11 +243,12 @@ abstract class BunqRequest
|
||||
* @param array $headers
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
protected function sendSignedBunqGet(string $uri, array $data, array $headers): array
|
||||
{
|
||||
if (strlen($this->server) === 0) {
|
||||
if (0 === strlen($this->server)) {
|
||||
throw new FireflyException('No bunq server defined');
|
||||
}
|
||||
|
||||
@@ -260,7 +259,7 @@ abstract class BunqRequest
|
||||
try {
|
||||
$response = Requests::get($fullUri, $headers);
|
||||
} catch (Requests_Exception $e) {
|
||||
return ['Error' => [0 => ['error_description' => $e->getMessage(), 'error_description_translated' => $e->getMessage()],]];
|
||||
return ['Error' => [0 => ['error_description' => $e->getMessage(), 'error_description_translated' => $e->getMessage()]]];
|
||||
}
|
||||
|
||||
$body = $response->body;
|
||||
@@ -287,6 +286,7 @@ abstract class BunqRequest
|
||||
* @param array $headers
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
protected function sendSignedBunqPost(string $uri, array $data, array $headers): array
|
||||
@@ -298,7 +298,7 @@ abstract class BunqRequest
|
||||
try {
|
||||
$response = Requests::post($fullUri, $headers, $body);
|
||||
} catch (Requests_Exception $e) {
|
||||
return ['Error' => [0 => ['error_description' => $e->getMessage(), 'error_description_translated' => $e->getMessage()],]];
|
||||
return ['Error' => [0 => ['error_description' => $e->getMessage(), 'error_description_translated' => $e->getMessage()]]];
|
||||
}
|
||||
|
||||
$body = $response->body;
|
||||
@@ -316,7 +316,6 @@ abstract class BunqRequest
|
||||
throw new FireflyException(sprintf('Could not verify signature for request to "%s"', $uri));
|
||||
}
|
||||
|
||||
|
||||
return $array;
|
||||
}
|
||||
|
||||
@@ -332,7 +331,7 @@ abstract class BunqRequest
|
||||
try {
|
||||
$response = Requests::delete($fullUri, $headers);
|
||||
} catch (Requests_Exception $e) {
|
||||
return ['Error' => [0 => ['error_description' => $e->getMessage(), 'error_description_translated' => $e->getMessage()],]];
|
||||
return ['Error' => [0 => ['error_description' => $e->getMessage(), 'error_description_translated' => $e->getMessage()]]];
|
||||
}
|
||||
$body = $response->body;
|
||||
$array = json_decode($body, true);
|
||||
@@ -362,7 +361,7 @@ abstract class BunqRequest
|
||||
try {
|
||||
$response = Requests::post($fullUri, $headers, $body);
|
||||
} catch (Requests_Exception $e) {
|
||||
return ['Error' => [0 => ['error_description' => $e->getMessage(), 'error_description_translated' => $e->getMessage()],]];
|
||||
return ['Error' => [0 => ['error_description' => $e->getMessage(), 'error_description_translated' => $e->getMessage()]]];
|
||||
}
|
||||
$body = $response->body;
|
||||
$array = json_decode($body, true);
|
||||
@@ -375,7 +374,6 @@ abstract class BunqRequest
|
||||
$this->throwResponseError($array);
|
||||
}
|
||||
|
||||
|
||||
return $array;
|
||||
}
|
||||
|
||||
@@ -387,7 +385,7 @@ abstract class BunqRequest
|
||||
private function isErrorResponse(array $response): bool
|
||||
{
|
||||
$key = key($response);
|
||||
if ($key === 'Error') {
|
||||
if ('Error' === $key) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -431,6 +429,7 @@ abstract class BunqRequest
|
||||
* @param int $statusCode
|
||||
*
|
||||
* @return bool
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
private function verifyServerSignature(string $body, array $headers, int $statusCode): bool
|
||||
@@ -440,15 +439,14 @@ abstract class BunqRequest
|
||||
$verifyHeaders = [];
|
||||
|
||||
// false when no public key is present
|
||||
if (is_null($this->serverPublicKey)) {
|
||||
if (null === $this->serverPublicKey) {
|
||||
Log::error('No public key present in class, so return FALSE.');
|
||||
|
||||
return false;
|
||||
}
|
||||
foreach ($headers as $header => $value) {
|
||||
|
||||
// skip non-bunq headers or signature
|
||||
if (substr($header, 0, 7) !== 'x-bunq-' || $header === 'x-bunq-server-signature') {
|
||||
if ('x-bunq-' !== substr($header, 0, 7) || 'x-bunq-server-signature' === $header) {
|
||||
continue;
|
||||
}
|
||||
// need to have upper case variant of header:
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Services\Bunq\Request;
|
||||
@@ -27,13 +26,11 @@ use FireflyIII\Services\Bunq\Token\SessionToken;
|
||||
use Log;
|
||||
|
||||
/**
|
||||
* Class DeleteDeviceSessionRequest
|
||||
*
|
||||
* @package FireflyIII\Services\Bunq\Request
|
||||
* Class DeleteDeviceSessionRequest.
|
||||
*/
|
||||
class DeleteDeviceSessionRequest extends BunqRequest
|
||||
{
|
||||
/** @var SessionToken */
|
||||
/** @var SessionToken */
|
||||
private $sessionToken;
|
||||
|
||||
/**
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Services\Bunq\Request;
|
||||
@@ -27,17 +26,15 @@ use FireflyIII\Services\Bunq\Id\DeviceServerId;
|
||||
use FireflyIII\Services\Bunq\Token\InstallationToken;
|
||||
|
||||
/**
|
||||
* Class DeviceServerRequest
|
||||
*
|
||||
* @package Bunq\Request
|
||||
* Class DeviceServerRequest.
|
||||
*/
|
||||
class DeviceServerRequest extends BunqRequest
|
||||
{
|
||||
/** @var string */
|
||||
private $description = '';
|
||||
/** @var DeviceServerId */
|
||||
/** @var DeviceServerId */
|
||||
private $deviceServerId;
|
||||
/** @var InstallationToken */
|
||||
/** @var InstallationToken */
|
||||
private $installationToken;
|
||||
/** @var array */
|
||||
private $permittedIps = [];
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Services\Bunq\Request;
|
||||
@@ -31,21 +30,19 @@ use FireflyIII\Services\Bunq\Token\SessionToken;
|
||||
use Log;
|
||||
|
||||
/**
|
||||
* Class DeviceSessionRequest
|
||||
*
|
||||
* @package FireflyIII\Services\Bunq\Request
|
||||
* Class DeviceSessionRequest.
|
||||
*/
|
||||
class DeviceSessionRequest extends BunqRequest
|
||||
{
|
||||
/** @var DeviceSessionId */
|
||||
/** @var DeviceSessionId */
|
||||
private $deviceSessionId;
|
||||
/** @var InstallationToken */
|
||||
/** @var InstallationToken */
|
||||
private $installationToken;
|
||||
/** @var SessionToken */
|
||||
/** @var SessionToken */
|
||||
private $sessionToken;
|
||||
/** @var UserCompany */
|
||||
/** @var UserCompany */
|
||||
private $userCompany;
|
||||
/** @var UserPerson */
|
||||
/** @var UserPerson */
|
||||
private $userPerson;
|
||||
|
||||
/**
|
||||
@@ -59,7 +56,6 @@ class DeviceSessionRequest extends BunqRequest
|
||||
$headers['X-Bunq-Client-Authentication'] = $this->installationToken->getToken();
|
||||
$response = $this->sendSignedBunqPost($uri, $data, $headers);
|
||||
|
||||
|
||||
$this->deviceSessionId = $this->extractDeviceSessionId($response);
|
||||
$this->sessionToken = $this->extractSessionToken($response);
|
||||
$this->userPerson = $this->extractUserPerson($response);
|
||||
@@ -137,7 +133,6 @@ class DeviceSessionRequest extends BunqRequest
|
||||
$data = $this->getKeyFromResponse('UserCompany', $response);
|
||||
$userCompany = new UserCompany($data);
|
||||
|
||||
|
||||
return $userCompany;
|
||||
}
|
||||
|
||||
@@ -151,7 +146,6 @@ class DeviceSessionRequest extends BunqRequest
|
||||
$data = $this->getKeyFromResponse('UserPerson', $response);
|
||||
$userPerson = new UserPerson($data);
|
||||
|
||||
|
||||
return $userPerson;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Services\Bunq\Request;
|
||||
@@ -29,15 +28,13 @@ use FireflyIII\Services\Bunq\Token\InstallationToken;
|
||||
use Log;
|
||||
|
||||
/**
|
||||
* Class InstallationTokenRequest
|
||||
*
|
||||
* @package FireflyIII\Services\Bunq\Request
|
||||
* Class InstallationTokenRequest.
|
||||
*/
|
||||
class InstallationTokenRequest extends BunqRequest
|
||||
{
|
||||
/** @var InstallationId */
|
||||
private $installationId;
|
||||
/** @var InstallationToken */
|
||||
/** @var InstallationToken */
|
||||
private $installationToken;
|
||||
/** @var string */
|
||||
private $publicKey = '';
|
||||
@@ -48,7 +45,7 @@ class InstallationTokenRequest extends BunqRequest
|
||||
public function call(): void
|
||||
{
|
||||
$uri = '/v1/installation';
|
||||
$data = ['client_public_key' => $this->publicKey,];
|
||||
$data = ['client_public_key' => $this->publicKey];
|
||||
$headers = $this->getDefaultHeaders();
|
||||
$response = $this->sendUnsignedBunqPost($uri, $data, $headers);
|
||||
Log::debug('Installation request response', $response);
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Services\Bunq\Request;
|
||||
@@ -28,15 +27,13 @@ use FireflyIII\Services\Bunq\Token\InstallationToken;
|
||||
use Illuminate\Support\Collection;
|
||||
|
||||
/**
|
||||
* Class ListDeviceServerRequest
|
||||
*
|
||||
* @package FireflyIII\Services\Bunq\Request
|
||||
* Class ListDeviceServerRequest.
|
||||
*/
|
||||
class ListDeviceServerRequest extends BunqRequest
|
||||
{
|
||||
/** @var Collection */
|
||||
private $devices;
|
||||
/** @var InstallationToken */
|
||||
/** @var InstallationToken */
|
||||
private $installationToken;
|
||||
|
||||
public function __construct()
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Services\Bunq\Request;
|
||||
@@ -28,15 +27,13 @@ use FireflyIII\Services\Bunq\Token\SessionToken;
|
||||
use Illuminate\Support\Collection;
|
||||
|
||||
/**
|
||||
* Class ListMonetaryAccountRequest
|
||||
*
|
||||
* @package FireflyIII\Services\Bunq\Request
|
||||
* Class ListMonetaryAccountRequest.
|
||||
*/
|
||||
class ListMonetaryAccountRequest extends BunqRequest
|
||||
{
|
||||
/** @var Collection */
|
||||
/** @var Collection */
|
||||
private $monetaryAccounts;
|
||||
/** @var SessionToken */
|
||||
/** @var SessionToken */
|
||||
private $sessionToken;
|
||||
/** @var int */
|
||||
private $userId = 0;
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Services\Bunq\Request;
|
||||
@@ -29,19 +28,17 @@ use FireflyIII\Services\Bunq\Object\UserPerson;
|
||||
use FireflyIII\Services\Bunq\Token\SessionToken;
|
||||
|
||||
/**
|
||||
* Class ListUserRequest
|
||||
*
|
||||
* @package FireflyIII\Services\Bunq\Request
|
||||
* Class ListUserRequest.
|
||||
*/
|
||||
class ListUserRequest extends BunqRequest
|
||||
{
|
||||
/** @var SessionToken */
|
||||
/** @var SessionToken */
|
||||
private $sessionToken;
|
||||
/** @var UserCompany */
|
||||
/** @var UserCompany */
|
||||
private $userCompany;
|
||||
/** @var UserLight */
|
||||
/** @var UserLight */
|
||||
private $userLight;
|
||||
/** @var UserPerson */
|
||||
/** @var UserPerson */
|
||||
private $userPerson;
|
||||
|
||||
/**
|
||||
@@ -90,7 +87,6 @@ class ListUserRequest extends BunqRequest
|
||||
return $this->userPerson;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param SessionToken $sessionToken
|
||||
*/
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Services\Bunq\Token;
|
||||
@@ -26,19 +25,17 @@ namespace FireflyIII\Services\Bunq\Token;
|
||||
use Carbon\Carbon;
|
||||
|
||||
/**
|
||||
* Class BunqToken
|
||||
*
|
||||
* @package Bunq\Token
|
||||
* Class BunqToken.
|
||||
*/
|
||||
class BunqToken
|
||||
{
|
||||
/** @var Carbon */
|
||||
/** @var Carbon */
|
||||
private $created;
|
||||
/** @var int */
|
||||
private $id = 0;
|
||||
/** @var string */
|
||||
private $token = '';
|
||||
/** @var Carbon */
|
||||
/** @var Carbon */
|
||||
private $updated;
|
||||
|
||||
/**
|
||||
|
||||
@@ -18,15 +18,12 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Services\Bunq\Token;
|
||||
|
||||
/**
|
||||
* Class InstallationToken
|
||||
*
|
||||
* @package FireflyIII\Services\Bunq\Token
|
||||
* Class InstallationToken.
|
||||
*/
|
||||
class InstallationToken extends BunqToken
|
||||
{
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Bunq\Token;
|
||||
@@ -26,9 +25,7 @@ namespace Bunq\Token;
|
||||
namespace FireflyIII\Services\Bunq\Token;
|
||||
|
||||
/**
|
||||
* Class SessionToken
|
||||
*
|
||||
* @package FireflyIII\Services\Bunq\Token
|
||||
* Class SessionToken.
|
||||
*/
|
||||
class SessionToken extends BunqToken
|
||||
{
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Services\Currency;
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Services\Currency;
|
||||
@@ -32,13 +31,11 @@ use Requests;
|
||||
use Requests_Exception;
|
||||
|
||||
/**
|
||||
* Class FixerIO
|
||||
*
|
||||
* @package FireflyIII\Services\Currency
|
||||
* Class FixerIO.
|
||||
*/
|
||||
class FixerIO implements ExchangeRateInterface
|
||||
{
|
||||
/** @var User */
|
||||
/** @var User */
|
||||
protected $user;
|
||||
|
||||
public function getRate(TransactionCurrency $fromCurrency, TransactionCurrency $toCurrency, Carbon $date): CurrencyExchangeRate
|
||||
@@ -57,14 +54,14 @@ class FixerIO implements ExchangeRateInterface
|
||||
// Requests_Exception
|
||||
$rate = 1.0;
|
||||
$content = null;
|
||||
if ($statusCode !== 200) {
|
||||
if (200 !== $statusCode) {
|
||||
Log::error(sprintf('Something went wrong. Received error code %d and body "%s" from FixerIO.', $statusCode, $body));
|
||||
}
|
||||
// get rate from body:
|
||||
if ($statusCode === 200) {
|
||||
if (200 === $statusCode) {
|
||||
$content = json_decode($body, true);
|
||||
}
|
||||
if (!is_null($content)) {
|
||||
if (null !== $content) {
|
||||
$code = $toCurrency->code;
|
||||
$rate = isset($content['rates'][$code]) ? $content['rates'][$code] : '1';
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Services\Password;
|
||||
@@ -28,13 +27,10 @@ use Requests;
|
||||
use Requests_Exception;
|
||||
|
||||
/**
|
||||
* Class PwndVerifier
|
||||
*
|
||||
* @package FireflyIII\Services\Password
|
||||
* Class PwndVerifier.
|
||||
*/
|
||||
class PwndVerifier implements Verifier
|
||||
{
|
||||
|
||||
/**
|
||||
* Verify the given password against (some) service.
|
||||
*
|
||||
@@ -54,7 +50,7 @@ class PwndVerifier implements Verifier
|
||||
return true;
|
||||
}
|
||||
Log::debug(sprintf('Status code returned is %d', $result->status_code));
|
||||
if ($result->status_code === 404) {
|
||||
if (404 === $result->status_code) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -18,15 +18,12 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Services\Password;
|
||||
|
||||
/**
|
||||
* Interface Verifier
|
||||
*
|
||||
* @package FireflyIII\Services\Password
|
||||
* Interface Verifier.
|
||||
*/
|
||||
interface Verifier
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user