All code for bunq.

This commit is contained in:
James Cole
2018-05-23 12:36:12 +02:00
parent 4db2ec60e0
commit 2b2f37a8c9
56 changed files with 1168 additions and 4484 deletions

View File

@@ -1,73 +0,0 @@
<?php
/**
* BunqId.php
* Copyright (c) 2017 thegrumpydictator@gmail.com
*
* 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
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/
declare(strict_types=1);
namespace FireflyIII\Services\Bunq\Id;
/**
* @codeCoverageIgnore
* @deprecated
* Class BunqId.
*/
class BunqId
{
/** @var int */
private $id = 0;
/**
* BunqId constructor.
*
* @param null $data
*/
public function __construct($data = null)
{
if (null !== $data) {
$this->id = $data['id'];
}
}
/**
* @return int
*/
public function getId(): int
{
return $this->id;
}
/**
* @param int $id
*/
public function setId(int $id): void
{
$this->id = $id;
}
/**
* @return array
*/
public function toArray(): array
{
return [
'id' => $this->id,
];
}
}

View File

@@ -1,33 +0,0 @@
<?php
/**
* DeviceServerId.php
* Copyright (c) 2017 thegrumpydictator@gmail.com
*
* 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
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/
declare(strict_types=1);
namespace FireflyIII\Services\Bunq\Id;
/**
* @codeCoverageIgnore
* @deprecated
* Class DeviceServerId.
*/
class DeviceServerId extends BunqId
{
}

View File

@@ -1,32 +0,0 @@
<?php
/**
* DeviceSessionId.php
* Copyright (c) 2017 thegrumpydictator@gmail.com
*
* 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
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/
declare(strict_types=1);
namespace FireflyIII\Services\Bunq\Id;
/**
* @codeCoverageIgnore
* @deprecated
* Class DeviceSessionId.
*/
class DeviceSessionId extends BunqId
{
}

View File

@@ -1,32 +0,0 @@
<?php
/**
* InstallationId.php
* Copyright (c) 2017 thegrumpydictator@gmail.com
*
* 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
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/
declare(strict_types=1);
namespace FireflyIII\Services\Bunq\Id;
/**
* @codeCoverageIgnore
* @deprecated
* Class InstallationId.
*/
class InstallationId extends BunqId
{
}

View File

@@ -1,86 +0,0 @@
<?php
/**
* Alias.php
* Copyright (c) 2017 thegrumpydictator@gmail.com
*
* 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
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/
declare(strict_types=1);
namespace FireflyIII\Services\Bunq\Object;
/**
* @codeCoverageIgnore
* @deprecated
* Class Alias.
*/
class Alias extends BunqObject
{
/** @var string */
private $name;
/** @var string */
private $type;
/** @var string */
private $value;
/**
* Alias constructor.
*
* @param array $data
*/
public function __construct(array $data)
{
$this->type = $data['type'];
$this->name = $data['name'];
$this->value = $data['value'];
}
/**
* @return string
*/
public function getName(): string
{
return $this->name;
}
/**
* @return string
*/
public function getType(): string
{
return $this->type;
}
/**
* @return string
*/
public function getValue(): string
{
return $this->value;
}
/**
* @return array
*/
public function toArray(): array
{
return [
'type' => $this->type,
'name' => $this->name,
'value' => $this->value,
];
}
}

View File

@@ -1,75 +0,0 @@
<?php
/**
* Amount.php
* Copyright (c) 2017 thegrumpydictator@gmail.com
*
* 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
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/
declare(strict_types=1);
namespace FireflyIII\Services\Bunq\Object;
/**
* @deprecated
* @codeCoverageIgnore
* Class Amount.
*/
class Amount extends BunqObject
{
/** @var string */
private $currency;
/** @var string */
private $value;
/**
* Amount constructor.
*
* @param array $data
*/
public function __construct(array $data)
{
$this->currency = $data['currency'];
$this->value = $data['value'];
}
/**
* @return string
*/
public function getCurrency(): string
{
return $this->currency;
}
/**
* @return string
*/
public function getValue(): string
{
return $this->value;
}
/**
* @return array
*/
public function toArray(): array
{
return [
'currency' => $this->currency,
'value' => $this->value,
];
}
}

View File

@@ -1,62 +0,0 @@
<?php
/**
* Avatar.php
* Copyright (c) 2017 thegrumpydictator@gmail.com
*
* 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
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/
declare(strict_types=1);
namespace FireflyIII\Services\Bunq\Object;
/**
* @deprecated
* @codeCoverageIgnore
* Class Avatar.
*/
class Avatar extends BunqObject
{
/** @var string */
private $anchorUuid;
/** @var Image */
private $image;
/** @var string */
private $uuid;
/**
* Avatar constructor.
*
* @param array $data
*/
public function __construct(array $data)
{
$this->uuid = $data['uuid'];
$this->anchorUuid = $data['anchor_uuid'];
$this->image = new Image($data['image']);
}
/**
* @return array
*/
public function toArray(): array
{
return [
'uuid' => $this->uuid,
'anchor_uuid' => $this->anchorUuid,
'image' => $this->image->toArray(),
];
}
}

View File

@@ -1,38 +0,0 @@
<?php
/**
* BunqObject.php
* Copyright (c) 2017 thegrumpydictator@gmail.com
*
* 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
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/
declare(strict_types=1);
namespace FireflyIII\Services\Bunq\Object;
/**
* @deprecated
* @codeCoverageIgnore
* Class BunqObject.
*/
abstract class BunqObject
{
/**
* Convert this object to array.
*
* @return array
*/
abstract public function toArray(): array;
}

View File

@@ -1,92 +0,0 @@
<?php
/**
* DeviceServer.php
* Copyright (c) 2017 thegrumpydictator@gmail.com
*
* 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
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/
declare(strict_types=1);
namespace FireflyIII\Services\Bunq\Object;
use Carbon\Carbon;
use FireflyIII\Services\Bunq\Id\DeviceServerId;
use FireflyIII\Exceptions\FireflyException;
/**
* @deprecated
* @codeCoverageIgnore
* Class DeviceServer
*/
class DeviceServer extends BunqObject
{
/** @var Carbon */
private $created;
/** @var string */
private $description;
/** @var DeviceServerId */
private $id;
/** @var string */
private $ip;
/** @var string */
private $status;
/** @var Carbon */
private $updated;
/**
* DeviceServer constructor.
*
* @param array $data
*
*/
public function __construct(array $data)
{
$id = new DeviceServerId();
$id->setId($data['id']);
$this->id = $id;
$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->ip = $data['ip'];
$this->description = $data['description'];
$this->status = $data['status'];
}
/**
* @return DeviceServerId
*/
public function getId(): DeviceServerId
{
return $this->id;
}
/**
* @return string
*/
public function getIp(): string
{
return $this->ip;
}
/**
* @return array
* @throws FireflyException
*/
public function toArray(): array
{
throw new FireflyException(sprintf('Cannot convert %s to array.', \get_class($this)));
}
}

View File

@@ -1,68 +0,0 @@
<?php
/**
* Image.php
* Copyright (c) 2018 thegrumpydictator@gmail.com
*
* 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
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/
declare(strict_types=1);
namespace FireflyIII\Services\Bunq\Object;
/**
* @deprecated
* @codeCoverageIgnore
* Class Image
*/
class Image extends BunqObject
{
/** @var string */
private $attachmentPublicUuid;
/** @var string */
private $contentType;
/** @var int */
private $height;
/** @var int */
private $width;
/**
* Image constructor.
*
* @param array $data
*/
public function __construct(array $data)
{
$this->attachmentPublicUuid = $data['attachment_public_uuid'] ?? null;
$this->height = $data['height'] ?? null;
$this->width = $data['width'] ?? null;
$this->contentType = $data['content_type'] ?? null;
}
/**
* @return array
*/
public function toArray(): array
{
return [
'attachment_public_uuid' => $this->attachmentPublicUuid,
'height' => $this->height,
'width' => $this->width,
'content_type' => $this->contentType,
];
}
}

View File

@@ -1,85 +0,0 @@
<?php
/**
* LabelMonetaryAccount.php
* Copyright (c) 2018 thegrumpydictator@gmail.com
*
* 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
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/
declare(strict_types=1);
namespace FireflyIII\Services\Bunq\Object;
use FireflyIII\Exceptions\FireflyException;
/**
* @deprecated
* @codeCoverageIgnore
* Class LabelMonetaryAccount
*/
class LabelMonetaryAccount extends BunqObject
{
/** @var Avatar */
private $avatar;
/** @var string */
private $country;
/** @var string */
private $iban;
/** @var bool */
private $isLight;
/** @var LabelUser */
private $labelUser;
/**
* LabelMonetaryAccount constructor.
*
* @param array $data
*/
public function __construct(array $data)
{
$this->iban = $data['iban'];
$this->isLight = $data['is_light'];
$this->avatar = isset($data['avatar']) ? new Avatar($data['avatar']) : null;
$this->labelUser = new LabelUser($data['label_user']);
$this->country = $data['country'];
}
/**
* @return string|null
*/
public function getIban(): ?string
{
return $this->iban;
}
/**
* @return LabelUser
*/
public function getLabelUser(): LabelUser
{
return $this->labelUser;
}
/**
* @return array
* @throws FireflyException
*/
public function toArray(): array
{
throw new FireflyException(sprintf('Cannot convert %s to array.', \get_class($this)));
}
}

View File

@@ -1,91 +0,0 @@
<?php
/**
* LabelUser.php
* Copyright (c) 2018 thegrumpydictator@gmail.com
*
* 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
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/
declare(strict_types=1);
namespace FireflyIII\Services\Bunq\Object;
use FireflyIII\Exceptions\FireflyException;
/**
* @deprecated
* @codeCoverageIgnore
* Class LabelUser
*/
class LabelUser extends BunqObject
{
/** @var Avatar */
private $avatar;
/** @var string */
private $country;
/** @var string */
private $displayName;
/** @var string */
private $publicNickName;
/** @var string */
private $uuid;
/**
* LabelUser constructor.
*
* @param array $data
*/
public function __construct(array $data)
{
$this->uuid = $data['uuid'];
$this->displayName = $data['display_name'];
$this->country = $data['country'];
$this->publicNickName = $data['public_nick_name'];
$this->avatar = isset($data['avatar']) ? new Avatar($data['avatar']) : null;
}
/**
* @return Avatar
*/
public function getAvatar(): Avatar
{
return $this->avatar;
}
/**
* @return string
*/
public function getDisplayName(): string
{
return $this->displayName;
}
/**
* @return string
*/
public function getPublicNickName(): string
{
return $this->publicNickName;
}
/**
* @return array
* @throws FireflyException
*/
public function toArray(): array
{
throw new FireflyException(sprintf('Cannot convert %s to array.', \get_class($this)));
}
}

View File

@@ -1,200 +0,0 @@
<?php
/**
* MonetaryAccountBank.php
* Copyright (c) 2017 thegrumpydictator@gmail.com
*
* 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
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/
declare(strict_types=1);
namespace FireflyIII\Services\Bunq\Object;
use Carbon\Carbon;
/**
* @deprecated
* @codeCoverageIgnore
* Class MonetaryAccountBank.
*/
class MonetaryAccountBank extends BunqObject
{
/** @var array */
private $aliases = [];
/** @var Avatar */
private $avatar;
/** @var Amount */
private $balance;
/** @var Carbon */
private $created;
/** @var string */
private $currency;
/** @var Amount */
private $dailyLimit;
/** @var Amount */
private $dailySpent;
/** @var string */
private $description;
/** @var int */
private $id;
/** @var MonetaryAccountProfile */
private $monetaryAccountProfile;
/** @var array */
private $notificationFilters = [];
/** @var Amount */
private $overdraftLimit;
/** @var string */
private $publicUuid;
/** @var string */
private $reason;
/** @var string */
private $reasonDescription;
/** @var MonetaryAccountSetting */
private $setting;
/** @var string */
private $status;
/** @var string */
private $subStatus;
/** @var Carbon */
private $updated;
/** @var int */
private $userId;
/**
* MonetaryAccountBank constructor.
*
* @param array $data
*
*/
public function __construct(array $data)
{
$this->id = $data['id'];
$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->balance = new Amount($data['balance']);
$this->currency = $data['currency'];
$this->dailyLimit = new Amount($data['daily_limit']);
$this->dailySpent = new Amount($data['daily_spent']);
$this->description = $data['description'];
$this->publicUuid = $data['public_uuid'];
$this->status = $data['status'];
$this->subStatus = $data['sub_status'];
$this->userId = $data['user_id'];
$this->monetaryAccountProfile = new MonetaryAccountProfile($data['monetary_account_profile']);
$this->setting = new MonetaryAccountSetting($data['setting']);
$this->overdraftLimit = new Amount($data['overdraft_limit']);
$this->avatar = isset($data['avatar']) ? new Avatar($data['avatar']) : null;
$this->reason = $data['reason'] ?? '';
$this->reasonDescription = $data['reason_description'] ?? '';
// create aliases:
foreach ($data['alias'] as $alias) {
$this->aliases[] = new Alias($alias);
}
/** @var array $filter */
foreach ($data['notification_filters'] as $filter) {
$this->notificationFilters[] = new NotificationFilter($filter);
}
}
/**
* @return array
*/
public function getAliases(): array
{
return $this->aliases;
}
/**
* @return Amount
*/
public function getBalance(): Amount
{
return $this->balance;
}
/**
* @return string
*/
public function getCurrency(): string
{
return $this->currency;
}
/**
* @return string
*/
public function getDescription(): string
{
return $this->description;
}
/**
* @return int
*/
public function getId(): int
{
return $this->id;
}
/**
* @return MonetaryAccountSetting
*/
public function getSetting(): MonetaryAccountSetting
{
return $this->setting;
}
/**
* @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'),
'balance' => $this->balance->toArray(),
'currency' => $this->currency,
'daily_limit' => $this->dailyLimit->toArray(),
'daily_spent' => $this->dailySpent->toArray(),
'description' => $this->description,
'public_uuid' => $this->publicUuid,
'status' => $this->status,
'sub_status' => $this->subStatus,
'user_id' => $this->userId,
'monetary_account_profile' => $this->monetaryAccountProfile->toArray(),
'setting' => $this->setting->toArray(),
'overdraft_limit' => $this->overdraftLimit->toArray(),
'avatar' => null === $this->avatar ? null : $this->avatar->toArray(),
'reason' => $this->reason,
'reason_description' => $this->reasonDescription,
'alias' => [],
'notification_filters' => [],
];
/** @var Alias $alias */
foreach ($this->aliases as $alias) {
$data['alias'][] = $alias->toArray();
}
/** @var NotificationFilter $filter */
foreach ($this->notificationFilters as $filter) {
$data['notification_filters'][] = $filter->toArray();
}
return $data;
}
}

View File

@@ -1,69 +0,0 @@
<?php
/**
* MonetaryAccountProfile.php
* Copyright (c) 2017 thegrumpydictator@gmail.com
*
* 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
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/
declare(strict_types=1);
namespace FireflyIII\Services\Bunq\Object;
/**
* @deprecated
* @codeCoverageIgnore
* Class MonetaryAccountProfile.
*/
class MonetaryAccountProfile extends BunqObject
{
/** @var string */
private $profileActionRequired;
/** @var Amount */
private $profileAmountRequired;
/**
* @var null
*/
private $profileDrain;
/**
* @var null
*/
private $profileFill;
/**
* MonetaryAccountProfile constructor.
*
* @param array $data
*/
public function __construct(array $data)
{
$this->profileDrain = null;
$this->profileFill = null;
$this->profileActionRequired = $data['profile_action_required'];
$this->profileAmountRequired = new Amount($data['profile_amount_required']);
}
/**
* @return array
*/
public function toArray(): array
{
return [
'profile_action_required' => $this->profileActionRequired,
'profile_amount_required' => $this->profileAmountRequired->toArray(),
];
}
}

View File

@@ -1,87 +0,0 @@
<?php
/**
* MonetaryAccountSetting.php
* Copyright (c) 2017 thegrumpydictator@gmail.com
*
* 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
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/
declare(strict_types=1);
namespace FireflyIII\Services\Bunq\Object;
/**
* @deprecated
* @codeCoverageIgnore
* Class MonetaryAccountSetting.
*/
class MonetaryAccountSetting extends BunqObject
{
/** @var string */
private $color;
/** @var string */
private $defaultAvatarStatus;
/** @var string */
private $restrictionChat;
/**
* MonetaryAccountSetting constructor.
*
* @param array $data
*/
public function __construct(array $data)
{
$this->color = $data['color'];
$this->defaultAvatarStatus = $data['default_avatar_status'];
$this->restrictionChat = $data['restriction_chat'];
}
/**
* @return string
*/
public function getColor(): string
{
return $this->color;
}
/**
* @return string
*/
public function getDefaultAvatarStatus(): string
{
return $this->defaultAvatarStatus;
}
/**
* @return string
*/
public function getRestrictionChat(): string
{
return $this->restrictionChat;
}
/**
* @return array
*/
public function toArray(): array
{
return [
'color' => $this->color,
'default_avatar_status' => $this->defaultAvatarStatus,
'restriction_chat' => $this->restrictionChat,
];
}
}

View File

@@ -1,49 +0,0 @@
<?php
/**
* NotificationFilter.php
* Copyright (c) 2017 thegrumpydictator@gmail.com
*
* 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
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/
declare(strict_types=1);
namespace FireflyIII\Services\Bunq\Object;
/**
* @deprecated
* @codeCoverageIgnore
* Class NotificationFilter.
*/
class NotificationFilter extends BunqObject
{
/**
* NotificationFilter constructor.
*
* @param array $data
*/
public function __construct(array $data)
{
}
/**
* @return array
*/
public function toArray(): array
{
return [];
}
}

View File

@@ -1,147 +0,0 @@
<?php
/**
* Payment.php
* Copyright (c) 2018 thegrumpydictator@gmail.com
*
* 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
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/
declare(strict_types=1);
namespace FireflyIII\Services\Bunq\Object;
use Carbon\Carbon;
use FireflyIII\Exceptions\FireflyException;
/**
* @deprecated
* @codeCoverageIgnore
* Class Payment
*/
class Payment extends BunqObject
{
/** @var LabelMonetaryAccount */
private $alias;
/** @var Amount */
private $amount;
/** @var array */
private $attachments = [];
/** @var LabelMonetaryAccount */
private $counterParty;
/** @var Carbon */
private $created;
/** @var string */
private $description;
/** @var int */
private $id;
/** @var string */
private $merchantReference;
/** @var int */
private $monetaryAccountId;
/** @var string */
private $subType;
/** @var string */
private $type;
/** @var Carbon */
private $updated;
/**
* Payment constructor.
*
* @param array $data
*
*/
public function __construct(array $data)
{
$this->id = $data['id'];
$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->monetaryAccountId = (int)$data['monetary_account_id'];
$this->amount = new Amount($data['amount']);
$this->description = $data['description'];
$this->type = $data['type'];
$this->merchantReference = $data['merchant_reference'];
$this->alias = new LabelMonetaryAccount($data['alias']);
$this->counterParty = new LabelMonetaryAccount($data['counterparty_alias']);
$this->subType = $data['sub_type'];
}
/**
* @return Amount
*/
public function getAmount(): Amount
{
return $this->amount;
}
/**
* @return LabelMonetaryAccount|null
*/
public function getCounterParty(): ?LabelMonetaryAccount
{
return $this->counterParty;
}
/**
* @return Carbon
*/
public function getCreated(): Carbon
{
return $this->created;
}
/**
* @return string
*/
public function getDescription(): string
{
return $this->description;
}
/**
* @return int
*/
public function getId(): int
{
return $this->id;
}
/**
* @return string
*/
public function getSubType(): string
{
return $this->subType;
}
/**
* @return string
*/
public function getType(): string
{
return $this->type;
}
/**
* @return array
* @throws FireflyException
*/
public function toArray(): array
{
throw new FireflyException(sprintf('Cannot convert %s to array.', \get_class($this)));
}
}

View File

@@ -1,70 +0,0 @@
<?php
/**
* ServerPublicKey.php
* Copyright (c) 2017 thegrumpydictator@gmail.com
*
* 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
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/
declare(strict_types=1);
namespace FireflyIII\Services\Bunq\Object;
/**
* @deprecated
* @codeCoverageIgnore
* Class ServerPublicKey.
*/
class ServerPublicKey extends BunqObject
{
/** @var string */
private $publicKey;
/**
* ServerPublicKey constructor.
*
* @param array $response
*/
public function __construct(array $response)
{
$this->publicKey = $response['server_public_key'];
}
/**
* @return string
*/
public function getPublicKey(): string
{
return $this->publicKey;
}
/**
* @param string $publicKey
*/
public function setPublicKey(string $publicKey)
{
$this->publicKey = $publicKey;
}
/**
* @return array
*/
public function toArray(): array
{
return [
'server_public_key' => $this->publicKey,
];
}
}

View File

@@ -1,190 +0,0 @@
<?php
/**
* UserCompany.php
* Copyright (c) 2017 thegrumpydictator@gmail.com
*
* 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
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/
declare(strict_types=1);
namespace FireflyIII\Services\Bunq\Object;
use Carbon\Carbon;
/**
* @deprecated
* @codeCoverageIgnore
* Class UserCompany.
*/
class UserCompany extends BunqObject
{
/**
* @var
*/
private $addressMain;
/**
* @var
*/
private $addressPostal;
/** @var array */
private $aliases = [];
/**
* @var
*/
private $avatar;
/** @var string */
private $cocNumber;
/** @var string */
private $counterBankIban;
/** @var Carbon */
private $created;
/**
* @var
*/
private $dailyLimit;
/**
* @var
*/
private $directorAlias;
/** @var string */
private $displayName;
/** @var int */
private $id;
/** @var string */
private $language;
/** @var string */
private $name;
/** @var array */
private $notificationFilters = [];
/** @var string */
private $publicNickName;
/** @var string */
private $publicUuid;
/** @var string */
private $region;
/** @var string */
private $sectorOfIndustry;
/** @var int */
private $sessionTimeout;
/** @var string */
private $status;
/** @var string */
private $subStatus;
/** @var string */
private $typeOfBusinessEntity;
/** @var array */
private $ubos = [];
/** @var Carbon */
private $updated;
/** @var int */
private $versionTos;
/**
* UserCompany constructor.
*
* @param array $data
*
*/
public function __construct(array $data)
{
if (\count($data) === 0 || (isset($data['id']) && (int)$data['id'] === 0)) {
$this->id = 0;
$this->created = new Carbon;
$this->updated = new Carbon;
return;
}
$this->id = (int)$data['id'];
$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'];
$this->sessionTimeout = (int)$data['session_timeout'];
$this->versionTos = (int)$data['version_terms_of_service'];
$this->cocNumber = $data['chamber_of_commerce_number'];
$this->typeOfBusinessEntity = $data['type_of_business_entity'] ?? '';
$this->sectorOfIndustry = $data['sector_of_industry'] ?? '';
$this->counterBankIban = $data['counter_bank_iban'];
$this->name = $data['name'];
// TODO alias
// TODO avatar
// TODO daily_limit_without_confirmation_login
// TODO notification_filters
// TODO address_main
// TODO address_postal
// TODO director_alias
// TODO ubo
// TODO customer
// TODO customer_limit
// TODO billing_contract
// TODO pack_membership
}
/**
* @return int
*/
public function getId(): int
{
return $this->id;
}
/**
* @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,
'version_terms_of_service' => $this->versionTos,
'chamber_of_commerce_number' => $this->cocNumber,
'type_of_business_entity' => $this->typeOfBusinessEntity,
'sector_of_industry' => $this->sectorOfIndustry,
'counter_bank_iban' => $this->counterBankIban,
'name' => $this->name,
];
// TODO alias
// TODO avatar
// TODO daily_limit_without_confirmation_login
// TODO notification_filters
// TODO address_main
// TODO address_postal
// TODO director_alias
// TODO ubo
// TODO customer
// TODO customer_limit
// TODO billing_contract
// TODO pack_membership
return $data;
}
}

View File

@@ -1,89 +0,0 @@
<?php
/**
* UserLight.php
* Copyright (c) 2017 thegrumpydictator@gmail.com
*
* 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
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/
declare(strict_types=1);
namespace FireflyIII\Services\Bunq\Object;
use Carbon\Carbon;
use FireflyIII\Exceptions\FireflyException;
/**
* @deprecated
* @codeCoverageIgnore
* Class UserLight.
*/
class UserLight extends BunqObject
{
/** @var array */
private $aliases = [];
/** @var Carbon */
private $created;
/** @var string */
private $displayName;
/** @var string */
private $firstName;
/** @var int */
private $id;
/** @var string */
private $lastName;
/** @var string */
private $legalName;
/** @var string */
private $middleName;
/** @var string */
private $publicNickName;
/** @var string */
private $publicUuid;
/** @var Carbon */
private $updated;
/**
* UserLight constructor.
*
* @param array $data
*
*/
public function __construct(array $data)
{
if (0 === \count($data)) {
return;
}
$this->id = (int)$data['id'];
$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->publicUuid = $data['public_uuid'];
$this->displayName = $data['display_name'];
$this->publicNickName = $data['public_nick_name'];
$this->firstName = $data['first_name'];
$this->middleName = $data['middle_name'];
$this->lastName = $data['last_name'];
$this->legalName = $data['legal_name'];
// aliases
}
/**
* @return array
* @throws FireflyException
*/
public function toArray(): array
{
throw new FireflyException(sprintf('Cannot convert %s to array.', \get_class($this)));
}
}

View File

@@ -1,212 +0,0 @@
<?php
/**
* UserPerson.php
* Copyright (c) 2017 thegrumpydictator@gmail.com
*
* 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
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/
declare(strict_types=1);
namespace FireflyIII\Services\Bunq\Object;
use Carbon\Carbon;
/**
* @deprecated
* @codeCoverageIgnore
* Class UserPerson.
*/
class UserPerson extends BunqObject
{
/**
* @var
*/
private $addressMain;
/**
* @var
*/
private $addressPostal;
/** @var array */
private $aliases = [];
/**
* @var
*/
private $avatar;
/** @var array */
private $billingContracts = [];
/** @var string */
private $countryOfBirth;
/** @var Carbon */
private $created;
/**
* @var
*/
private $customer;
/**
* @var
*/
private $customerLimit;
/**
* @var
*/
private $dailyLimit;
/** @var Carbon */
private $dateOfBirth;
/** @var string */
private $displayName;
/** @var string */
private $documentCountry;
/** @var string */
private $documentNumber;
/** @var string */
private $documentType;
/** @var string */
private $firstName;
/** @var string */
private $gender;
/** @var int */
private $id;
/** @var string */
private $language;
/** @var string */
private $lastName;
/** @var string */
private $legalName;
/** @var string */
private $middleName;
/** @var string */
private $nationality;
/** @var array */
private $notificationFilters = [];
/** @var string */
private $placeOfBirth;
/** @var string */
private $publicNickName;
/** @var string */
private $publicUuid;
/**
* @var mixed
*/
private $region;
/** @var int */
private $sessionTimeout;
/** @var string */
private $status;
/** @var string */
private $subStatus;
/** @var string */
private $taxResident;
/** @var Carbon */
private $updated;
/** @var int */
private $versionTos;
/**
* UserPerson constructor.
*
* @param array $data
*
*/
public function __construct(array $data)
{
if (0 === \count($data)) {
$this->created = new Carbon;
$this->updated = new Carbon;
$this->dateOfBirth = new Carbon;
return;
}
$this->id = (int)$data['id'];
$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'];
$this->sessionTimeout = (int)$data['session_timeout'];
$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'];
$this->versionTos = (int)$data['version_terms_of_service'];
$this->documentNumber = $data['document_number'];
$this->documentType = $data['document_type'];
$this->documentCountry = $data['document_country_of_issuance'];
// 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
}
/**
* @return int
*/
public function getId(): int
{
return $this->id;
}
/**
* @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;
}
}

View File

@@ -1,527 +0,0 @@
<?php
/**
* BunqRequest.php
* Copyright (c) 2017 thegrumpydictator@gmail.com
*
* 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
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/
declare(strict_types=1);
namespace FireflyIII\Services\Bunq\Request;
use Exception;
use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Services\Bunq\Object\ServerPublicKey;
use Log;
use Requests;
/**
* @deprecated
* @codeCoverageIgnore
* Class BunqRequest.
*/
abstract class BunqRequest
{
/** @var string */
protected $secret = '';
/** @var ServerPublicKey */
protected $serverPublicKey;
/** @var string */
private $privateKey = '';
/** @var string */
private $server;
/**
* @var array
*/
private $upperCaseHeaders
= [
'x-bunq-client-response-id' => 'X-Bunq-Client-Response-Id',
'x-bunq-client-request-id' => 'X-Bunq-Client-Request-Id',
];
/** @var string */
private $version = 'v1';
/**
* BunqRequest constructor.
*/
public function __construct()
{
$this->server = (string)config('import.options.bunq.server');
$this->version = (string)config('import.options.bunq.version');
Log::debug(sprintf('Created new BunqRequest with server "%s" and version "%s"', $this->server, $this->version));
}
/**
*
*/
abstract public function call(): void;
/**
* @return string
*/
public function getServer(): string
{
return $this->server;
}
/**
* @return ServerPublicKey
*/
public function getServerPublicKey(): ServerPublicKey
{
return $this->serverPublicKey;
}
/**
* @param ServerPublicKey $serverPublicKey
*/
public function setServerPublicKey(ServerPublicKey $serverPublicKey)
{
$this->serverPublicKey = $serverPublicKey;
}
/**
* @param string $privateKey
*/
public function setPrivateKey(string $privateKey)
{
$this->privateKey = $privateKey;
}
/**
* @param string $secret
*/
public function setSecret(string $secret)
{
$this->secret = $secret;
}
/**
* @param string $method
* @param string $uri
* @param array $headers
* @param string $data
*
* @return string
*
* @throws FireflyException
*/
protected function generateSignature(string $method, string $uri, array $headers, string $data): string
{
if (0 === \strlen($this->privateKey)) {
throw new FireflyException('No private key present.');
}
if ('get' === strtolower($method) || 'delete' === strtolower($method)) {
$data = '';
}
$uri = sprintf('/%s/%s', $this->version, $uri);
$toSign = sprintf("%s %s\n", strtoupper($method), $uri);
Log::debug(sprintf('Message to sign (without data): %s', $toSign));
$headersToSign = ['Cache-Control', 'User-Agent'];
ksort($headers);
foreach ($headers as $name => $value) {
if (\in_array($name, $headersToSign) || 'X-Bunq-' === substr($name, 0, 7)) {
$toSign .= sprintf("%s: %s\n", $name, $value);
}
}
$toSign .= "\n" . $data;
$signature = '';
openssl_sign($toSign, $signature, $this->privateKey, OPENSSL_ALGO_SHA256);
$signature = base64_encode($signature);
return $signature;
}
/**
* @param string $key
* @param array $response
*
* @return array
*/
protected function getArrayFromResponse(string $key, array $response): array
{
$result = [];
if (isset($response['Response'])) {
foreach ($response['Response'] as $entry) {
$currentKey = key($entry);
$data = current($entry);
if ($currentKey === $key) {
$result[] = $data;
}
}
}
return $result;
}
/**
* @return array
*/
protected function getDefaultHeaders(): array
{
$userAgent = sprintf('FireflyIII v%s', config('firefly.version'));
return [
'X-Bunq-Client-Request-Id' => uniqid('FFIII', true),
'Cache-Control' => 'no-cache',
'User-Agent' => $userAgent,
'X-Bunq-Language' => 'en_US',
'X-Bunq-Region' => 'nl_NL',
'X-Bunq-Geolocation' => '0 0 0 0 NL',
];
}
/**
* @param string $key
* @param array $response
*
* @return array
*/
protected function getKeyFromResponse(string $key, array $response): array
{
if (isset($response['Response'])) {
foreach ($response['Response'] as $entry) {
$currentKey = key($entry);
$data = current($entry);
if ($currentKey === $key) {
return $data;
}
}
}
return [];
}
/**
* @param string $uri
* @param array $headers
*
* @return array
*
* @throws FireflyException
*/
protected function sendSignedBunqDelete(string $uri, array $headers): array
{
if (0 === \strlen($this->server)) {
throw new FireflyException('No bunq server defined');
}
$fullUri = $this->makeUri($uri);
$signature = $this->generateSignature('delete', $uri, $headers, '');
$headers['X-Bunq-Client-Signature'] = $signature;
Log::debug(sprintf('Going to send a signed bunq DELETE to %s', $fullUri));
try {
$response = Requests::delete($fullUri, $headers);
} catch (Exception $e) {
return ['Error' => [0 => ['error_description' => $e->getMessage(), 'error_description_translated' => $e->getMessage()]]];
}
$body = $response->body;
$array = json_decode($body, true);
$responseHeaders = $response->headers->getAll();
$statusCode = (int)$response->status_code;
$array['ResponseHeaders'] = $responseHeaders;
$array['ResponseStatusCode'] = $statusCode;
Log::debug(sprintf('Response to DELETE %s is %s', $fullUri, $body));
if ($this->isErrorResponse($array)) {
$this->throwResponseError($array);
}
if (!$this->verifyServerSignature($body, $responseHeaders, $statusCode)) {
throw new FireflyException(sprintf('Could not verify signature for request to "%s"', $uri));
}
return $array;
}
/**
* @param string $uri
* @param array $data
* @param array $headers
*
* @return array
*
* @throws FireflyException
*/
protected function sendSignedBunqGet(string $uri, array $data, array $headers): array
{
if (0 === \strlen($this->server)) {
throw new FireflyException('No bunq server defined');
}
$body = json_encode($data);
$fullUri = $this->makeUri($uri);
$signature = $this->generateSignature('get', $uri, $headers, $body);
$headers['X-Bunq-Client-Signature'] = $signature;
Log::debug(sprintf('Going to send a signed bunq GET to %s', $fullUri));
try {
$response = Requests::get($fullUri, $headers);
} catch (Exception $e) {
return ['Error' => [0 => ['error_description' => $e->getMessage(), 'error_description_translated' => $e->getMessage()]]];
}
$body = $response->body;
$array = json_decode($body, true);
$responseHeaders = $response->headers->getAll();
$statusCode = (int)$response->status_code;
$array['ResponseHeaders'] = $responseHeaders;
$array['ResponseStatusCode'] = $statusCode;
if ($this->isErrorResponse($array)) {
$this->throwResponseError($array);
}
if (!$this->verifyServerSignature($body, $responseHeaders, $statusCode)) {
throw new FireflyException(sprintf('Could not verify signature for request to "%s"', $uri));
}
return $array;
}
/**
* @param string $uri
* @param array $data
* @param array $headers
*
* @return array
* @throws FireflyException
*/
protected function sendSignedBunqPost(string $uri, array $data, array $headers): array
{
$body = json_encode($data);
$fullUri = $this->makeUri($uri);
$signature = $this->generateSignature('post', $uri, $headers, $body);
$headers['X-Bunq-Client-Signature'] = $signature;
Log::debug(sprintf('Going to send a signed bunq POST request to: %s', $fullUri), $headers);
try {
$response = Requests::post($fullUri, $headers, $body);
} catch (Exception $e) {
return ['Error' => [0 => ['error_description' => $e->getMessage(), 'error_description_translated' => $e->getMessage()]]];
}
Log::debug('Seems to have NO exceptions in Response');
$body = $response->body;
$array = json_decode($body, true);
$responseHeaders = $response->headers->getAll();
$statusCode = (int)$response->status_code;
$array['ResponseHeaders'] = $responseHeaders;
$array['ResponseStatusCode'] = $statusCode;
if ($this->isErrorResponse($array)) {
$this->throwResponseError($array);
}
if (!$this->verifyServerSignature($body, $responseHeaders, $statusCode)) {
throw new FireflyException(sprintf('Could not verify signature for request to "%s"', $uri));
}
return $array;
}
/**
* @param string $uri
* @param array $headers
*
* @return array
* @throws FireflyException
*/
protected function sendUnsignedBunqDelete(string $uri, array $headers): array
{
$fullUri = $this->makeUri($uri);
Log::debug(sprintf('Going to send a UNsigned bunq DELETE to %s', $fullUri));
try {
$response = Requests::delete($fullUri, $headers);
} catch (Exception $e) {
return ['Error' => [0 => ['error_description' => $e->getMessage(), 'error_description_translated' => $e->getMessage()]]];
}
$body = $response->body;
$array = json_decode($body, true);
$responseHeaders = $response->headers->getAll();
$statusCode = $response->status_code;
$array['ResponseHeaders'] = $responseHeaders;
$array['ResponseStatusCode'] = $statusCode;
if ($this->isErrorResponse($array)) {
$this->throwResponseError($array);
}
return $array;
}
/**
* @param string $uri
* @param array $data
* @param array $headers
*
* @return array
* @throws FireflyException
*/
protected function sendUnsignedBunqPost(string $uri, array $data, array $headers): array
{
$body = json_encode($data);
$fullUri = $this->makeUri($uri);
Log::debug(sprintf('Going to send an UNsigned bunq POST to: %s', $fullUri));
try {
$response = Requests::post($fullUri, $headers, $body);
} catch (Exception $e) {
return ['Error' => [0 => ['error_description' => $e->getMessage(), 'error_description_translated' => $e->getMessage()]]];
}
$body = $response->body;
$array = json_decode($body, true);
$responseHeaders = $response->headers->getAll();
$statusCode = $response->status_code;
$array['ResponseHeaders'] = $responseHeaders;
$array['ResponseStatusCode'] = $statusCode;
if ($this->isErrorResponse($array)) {
$this->throwResponseError($array);
}
return $array;
}
/**
* @param array $response
*
* @return bool
*/
private function isErrorResponse(array $response): bool
{
$key = key($response);
if ('Error' === $key) {
Log::error('Response IS an error response!');
return true;
}
Log::debug('Response is not an error response');
return false;
}
/**
* @param array $headers
*
* @return string
*/
private function joinHeaders(array $headers): string
{
$string = '';
foreach ($headers as $header => $value) {
$string .= $header . ': ' . trim($value) . "\n";
}
return $string;
}
/**
* Make full API URI
*
* @param string $uri
*
* @return string
*/
private function makeUri(string $uri): string
{
return 'https://' . $this->server . '/' . $this->version . '/' . $uri;
}
/**
* @param array $response
*
* @throws FireflyException
*/
private function throwResponseError(array $response)
{
$message = [];
if (isset($response['Error'])) {
foreach ($response['Error'] as $error) {
$message[] = $error['error_description'];
}
}
throw new FireflyException('Bunq ERROR ' . $response['ResponseStatusCode'] . ': ' . implode(', ', $message));
}
/**
* @param string $body
* @param array $headers
* @param int $statusCode
*
* @return bool
* @throws FireflyException
*/
private function verifyServerSignature(string $body, array $headers, int $statusCode): bool
{
Log::debug('Going to verify signature for body+headers+status');
$dataToVerify = $statusCode . "\n";
$verifyHeaders = [];
// false when no public key is present
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 ('x-bunq-' !== substr($header, 0, 7) || 'x-bunq-server-signature' === $header) {
continue;
}
// need to have upper case variant of header:
if (!isset($this->upperCaseHeaders[$header])) {
throw new FireflyException(sprintf('No upper case variant for header "%s"', $header));
}
$header = $this->upperCaseHeaders[$header];
$verifyHeaders[$header] = $value[0];
}
// sort verification headers:
ksort($verifyHeaders);
// add them to data to sign:
$dataToVerify .= $this->joinHeaders($verifyHeaders);
$signature = $headers['x-bunq-server-signature'][0];
$dataToVerify .= "\n" . $body;
$result = openssl_verify($dataToVerify, base64_decode($signature), $this->serverPublicKey->getPublicKey(), OPENSSL_ALGO_SHA256);
if (\is_int($result) && $result < 1) {
Log::error(sprintf('Result of verification is %d, return false.', $result));
return false;
}
if (!\is_int($result)) {
Log::error(sprintf('Result of verification is a boolean (%d), return false.', $result));
return false;
}
Log::info('Signature is a match, return true.');
return true;
}
}

View File

@@ -1,57 +0,0 @@
<?php
/**
* DeleteDeviceSessionRequest.php
* Copyright (c) 2017 thegrumpydictator@gmail.com
*
* 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
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/
declare(strict_types=1);
namespace FireflyIII\Services\Bunq\Request;
use FireflyIII\Services\Bunq\Token\SessionToken;
use Log;
/**
* @deprecated
* @codeCoverageIgnore
* Class DeleteDeviceSessionRequest.
*/
class DeleteDeviceSessionRequest extends BunqRequest
{
/** @var SessionToken */
private $sessionToken;
/**
*/
public function call(): void
{
Log::debug('Going to send bunq delete session request.');
$uri = sprintf('session/%d', $this->sessionToken->getId());
$headers = $this->getDefaultHeaders();
$headers['X-Bunq-Client-Authentication'] = $this->sessionToken->getToken();
$this->sendSignedBunqDelete($uri, $headers);
}
/**
* @param SessionToken $sessionToken
*/
public function setSessionToken(SessionToken $sessionToken)
{
$this->sessionToken = $sessionToken;
}
}

View File

@@ -1,93 +0,0 @@
<?php
/**
* DeviceServerRequest.php
* Copyright (c) 2017 thegrumpydictator@gmail.com
*
* 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
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/
declare(strict_types=1);
namespace FireflyIII\Services\Bunq\Request;
use FireflyIII\Services\Bunq\Id\DeviceServerId;
use FireflyIII\Services\Bunq\Token\InstallationToken;
use Log;
/**
* @deprecated
* @codeCoverageIgnore
* Class DeviceServerRequest.
*/
class DeviceServerRequest extends BunqRequest
{
/** @var string */
private $description = '';
/** @var DeviceServerId */
private $deviceServerId;
/** @var InstallationToken */
private $installationToken;
/** @var array */
private $permittedIps = [];
/**
* @throws \FireflyIII\Exceptions\FireflyException
*/
public function call(): void
{
Log::debug('Now in DeviceServerRequest::call()');
$uri = 'device-server';
$data = ['description' => $this->description, 'secret' => $this->secret, 'permitted_ips' => $this->permittedIps];
$headers = $this->getDefaultHeaders();
$headers['X-Bunq-Client-Authentication'] = $this->installationToken->getToken();
$response = $this->sendSignedBunqPost($uri, $data, $headers);
$deviceServerId = new DeviceServerId;
$deviceServerId->setId((int)$response['Response'][0]['Id']['id']);
$this->deviceServerId = $deviceServerId;
}
/**
* @return DeviceServerId
*/
public function getDeviceServerId(): DeviceServerId
{
return $this->deviceServerId;
}
/**
* @param string $description
*/
public function setDescription(string $description)
{
$this->description = $description;
}
/**
* @param InstallationToken $installationToken
*/
public function setInstallationToken(InstallationToken $installationToken)
{
$this->installationToken = $installationToken;
}
/**
* @param array $permittedIps
*/
public function setPermittedIps(array $permittedIps)
{
$this->permittedIps = $permittedIps;
}
}

View File

@@ -1,157 +0,0 @@
<?php
/**
* DeviceSessionRequest.php
* Copyright (c) 2017 thegrumpydictator@gmail.com
*
* 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
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/
declare(strict_types=1);
namespace FireflyIII\Services\Bunq\Request;
use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Services\Bunq\Id\DeviceSessionId;
use FireflyIII\Services\Bunq\Object\UserCompany;
use FireflyIII\Services\Bunq\Object\UserPerson;
use FireflyIII\Services\Bunq\Token\InstallationToken;
use FireflyIII\Services\Bunq\Token\SessionToken;
/**
* @deprecated
* @codeCoverageIgnore
* Class DeviceSessionRequest.
*/
class DeviceSessionRequest extends BunqRequest
{
/** @var DeviceSessionId */
private $deviceSessionId;
/** @var InstallationToken */
private $installationToken;
/** @var SessionToken */
private $sessionToken;
/** @var UserCompany */
private $userCompany;
/** @var UserPerson */
private $userPerson;
/**
* @throws FireflyException
*/
public function call(): void
{
$uri = 'session-server';
$data = ['secret' => $this->secret];
$headers = $this->getDefaultHeaders();
$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);
$this->userCompany = $this->extractUserCompany($response);
}
/**
* @return DeviceSessionId
*/
public function getDeviceSessionId(): DeviceSessionId
{
return $this->deviceSessionId;
}
/**
* @return SessionToken
*/
public function getSessionToken(): SessionToken
{
return $this->sessionToken;
}
/**
* @return UserCompany
*/
public function getUserCompany(): UserCompany
{
return $this->userCompany;
}
/**
* @return UserPerson
*/
public function getUserPerson(): UserPerson
{
return $this->userPerson;
}
/**
* @param InstallationToken $installationToken
*/
public function setInstallationToken(InstallationToken $installationToken)
{
$this->installationToken = $installationToken;
}
/**
* @param array $response
*
* @return DeviceSessionId
*/
private function extractDeviceSessionId(array $response): DeviceSessionId
{
$data = $this->getKeyFromResponse('Id', $response);
$deviceSessionId = new DeviceSessionId;
$deviceSessionId->setId((int)$data['id']);
return $deviceSessionId;
}
/**
* @param array $response
*
* @return SessionToken
*/
private function extractSessionToken(array $response): SessionToken
{
$data = $this->getKeyFromResponse('Token', $response);
return new SessionToken($data);
}
/**
* @param $response
*
* @return UserCompany
*/
private function extractUserCompany($response): UserCompany
{
$data = $this->getKeyFromResponse('UserCompany', $response);
return new UserCompany($data);
}
/**
* @param $response
*
* @return UserPerson
*/
private function extractUserPerson($response): UserPerson
{
$data = $this->getKeyFromResponse('UserPerson', $response);
return new UserPerson($data);
}
}

View File

@@ -1,142 +0,0 @@
<?php
/**
* InstallationTokenRequest.php
* Copyright (c) 2017 thegrumpydictator@gmail.com
*
* 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
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/
declare(strict_types=1);
namespace FireflyIII\Services\Bunq\Request;
use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Services\Bunq\Id\InstallationId;
use FireflyIII\Services\Bunq\Object\ServerPublicKey;
use FireflyIII\Services\Bunq\Token\InstallationToken;
use Log;
/**
* @deprecated
* @codeCoverageIgnore
* Class InstallationTokenRequest.
*/
class InstallationTokenRequest extends BunqRequest
{
/** @var InstallationId */
private $installationId;
/** @var InstallationToken */
private $installationToken;
/** @var string */
private $publicKey = '';
/**
* @throws \FireflyIII\Exceptions\FireflyException
*/
public function call(): void
{
Log::debug('Now in InstallationTokenRequest::call()');
$uri = 'installation';
$data = ['client_public_key' => $this->publicKey];
$headers = $this->getDefaultHeaders();
$response = $this->sendUnsignedBunqPost($uri, $data, $headers);
//Log::debug('Installation request response', $response);
$this->installationId = $this->extractInstallationId($response);
$this->serverPublicKey = $this->extractServerPublicKey($response);
$this->installationToken = $this->extractInstallationToken($response);
Log::debug('No errors! We have installation ID!');
Log::debug(sprintf('Installation ID: %s', $this->installationId->getId()));
Log::debug(sprintf('Installation token: %s', $this->installationToken->getToken()));
Log::debug('Server public key: (not included)');
}
/**
* @return InstallationId
*/
public function getInstallationId(): InstallationId
{
return $this->installationId;
}
/**
* @return InstallationToken
*/
public function getInstallationToken(): InstallationToken
{
return $this->installationToken;
}
/**
* @return string
*/
public function getPublicKey(): string
{
return $this->publicKey;
}
/**
* @param string $publicKey
*/
public function setPublicKey(string $publicKey)
{
$this->publicKey = $publicKey;
}
/**
* @param array $response
*
* @return InstallationId
* @throws FireflyException
*/
private function extractInstallationId(array $response): InstallationId
{
$installationId = new InstallationId;
$data = $this->getKeyFromResponse('Id', $response);
if (!isset($data['id'])) {
Log::error('No installation token in bunq response.', $response);
throw new FireflyException('There is no installation token in the bunq response. Sorry, I cannot continue.');
}
$installationId->setId($data['id']);
return $installationId;
}
/**
* @param array $response
*
* @return InstallationToken
*/
private function extractInstallationToken(array $response): InstallationToken
{
$data = $this->getKeyFromResponse('Token', $response);
return new InstallationToken($data);
}
/**
* @param array $response
*
* @return ServerPublicKey
*/
private function extractServerPublicKey(array $response): ServerPublicKey
{
$data = $this->getKeyFromResponse('ServerPublicKey', $response);
return new ServerPublicKey($data);
}
}

View File

@@ -1,89 +0,0 @@
<?php
/**
* ListDeviceServerRequest.php
* Copyright (c) 2017 thegrumpydictator@gmail.com
*
* 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
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/
declare(strict_types=1);
namespace FireflyIII\Services\Bunq\Request;
use FireflyIII\Services\Bunq\Object\DeviceServer;
use FireflyIII\Services\Bunq\Token\InstallationToken;
use Illuminate\Support\Collection;
use Log;
/**
* @deprecated
* @codeCoverageIgnore
* Class ListDeviceServerRequest.
*/
class ListDeviceServerRequest extends BunqRequest
{
/** @var Collection */
private $devices;
/** @var InstallationToken */
private $installationToken;
public function __construct()
{
parent::__construct();
$this->devices = new Collection;
Log::debug('Constructed ListDeviceServerRequest');
}
/**
* @throws \FireflyIII\Exceptions\FireflyException
*/
public function call(): void
{
Log::debug('Now in ListDeviceServerRequest::call()');
$uri = 'device-server';
$data = [];
$headers = $this->getDefaultHeaders();
$headers['X-Bunq-Client-Authentication'] = $this->installationToken->getToken();
$response = $this->sendSignedBunqGet($uri, $data, $headers);
Log::debug('Returned from sending device-server list request!');
// create device server objects:
$raw = $this->getArrayFromResponse('DeviceServer', $response);
Log::debug(sprintf('Count %d entries in response array.', \count($raw)));
Log::debug('Full response', $response);
/** @var array $entry */
foreach ($raw as $entry) {
$server = new DeviceServer($entry);
Log::debug(sprintf('Created server "%s" with IP "%s"', $server->getId()->getId(), $server->getIp()));
$this->devices->push($server);
}
}
/**
* @return Collection
*/
public function getDevices(): Collection
{
return $this->devices;
}
/**
* @param InstallationToken $installationToken
*/
public function setInstallationToken(InstallationToken $installationToken)
{
$this->installationToken = $installationToken;
}
}

View File

@@ -1,87 +0,0 @@
<?php
/**
* ListMonetaryAccountRequest.php
* Copyright (c) 2017 thegrumpydictator@gmail.com
*
* 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
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/
declare(strict_types=1);
namespace FireflyIII\Services\Bunq\Request;
use FireflyIII\Services\Bunq\Object\MonetaryAccountBank;
use FireflyIII\Services\Bunq\Token\SessionToken;
use Illuminate\Support\Collection;
/**
* @deprecated
* @codeCoverageIgnore
* Class ListMonetaryAccountRequest.
*/
class ListMonetaryAccountRequest extends BunqRequest
{
/** @var Collection */
private $monetaryAccounts;
/** @var SessionToken */
private $sessionToken;
/** @var int */
private $userId = 0;
/**
* @throws \FireflyIII\Exceptions\FireflyException
*/
public function call(): void
{
$this->monetaryAccounts = new Collection;
$uri = sprintf('user/%d/monetary-account', $this->userId);
$data = [];
$headers = $this->getDefaultHeaders();
$headers['X-Bunq-Client-Authentication'] = $this->sessionToken->getToken();
$response = $this->sendSignedBunqGet($uri, $data, $headers);
// create device server objects:
$raw = $this->getArrayFromResponse('MonetaryAccountBank', $response);
foreach ($raw as $entry) {
$account = new MonetaryAccountBank($entry);
$this->monetaryAccounts->push($account);
}
}
/**
* @return Collection
*/
public function getMonetaryAccounts(): Collection
{
return $this->monetaryAccounts;
}
/**
* @param SessionToken $sessionToken
*/
public function setSessionToken(SessionToken $sessionToken)
{
$this->sessionToken = $sessionToken;
}
/**
* @param int $userId
*/
public function setUserId(int $userId)
{
$this->userId = $userId;
}
}

View File

@@ -1,107 +0,0 @@
<?php
/**
* ListPaymentRequest.php
* Copyright (c) 2018 thegrumpydictator@gmail.com
*
* 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
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/
declare(strict_types=1);
namespace FireflyIII\Services\Bunq\Request;
use FireflyIII\Services\Bunq\Object\MonetaryAccountBank;
use FireflyIII\Services\Bunq\Object\Payment;
use FireflyIII\Services\Bunq\Token\SessionToken;
use Illuminate\Support\Collection;
/**
* @deprecated
* @codeCoverageIgnore
* Class ListPaymentRequest
*/
class ListPaymentRequest extends BunqRequest
{
/** @var MonetaryAccountBank */
private $account;
/** @var Collection */
private $payments;
/** @var SessionToken */
private $sessionToken;
/** @var int */
private $userId = 0;
/**
*
* @throws \FireflyIII\Exceptions\FireflyException
*/
public function call(): void
{
$break = false;
$this->payments = new Collection;
$uri = sprintf('user/%d/monetary-account/%d/payment', $this->userId, $this->account->getId());
$headers = $this->getDefaultHeaders();
$headers['X-Bunq-Client-Authentication'] = $this->sessionToken->getToken();
while ($break === false) {
$response = $this->sendSignedBunqGet($uri, [], $headers);
$uri = str_replace('/v1/', '', $response['Pagination']['future_url']);
$break = true;
// create payment objects:
$raw = $this->getArrayFromResponse('Payment', $response);
foreach ($raw as $entry) {
$payment = new Payment($entry);
$this->payments->push($payment);
}
}
}
/**
* @return Collection
*/
public function getPayments(): Collection
{
return $this->payments;
}
/**
* @param MonetaryAccountBank $account
*/
public function setAccount(MonetaryAccountBank $account): void
{
$this->account = $account;
}
/**
* @param SessionToken $sessionToken
*/
public function setSessionToken(SessionToken $sessionToken): void
{
$this->sessionToken = $sessionToken;
}
/**
* @param int $userId
*/
public function setUserId(int $userId): void
{
$this->userId = $userId;
}
}

View File

@@ -1,97 +0,0 @@
<?php
/**
* ListUserRequest.php
* Copyright (c) 2017 thegrumpydictator@gmail.com
*
* 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
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/
declare(strict_types=1);
namespace FireflyIII\Services\Bunq\Request;
use FireflyIII\Services\Bunq\Object\UserCompany;
use FireflyIII\Services\Bunq\Object\UserLight;
use FireflyIII\Services\Bunq\Object\UserPerson;
use FireflyIII\Services\Bunq\Token\SessionToken;
/**
* @deprecated
* @codeCoverageIgnore
* Class ListUserRequest.
*/
class ListUserRequest extends BunqRequest
{
/** @var SessionToken */
private $sessionToken;
/** @var UserCompany */
private $userCompany;
/** @var UserLight */
private $userLight;
/** @var UserPerson */
private $userPerson;
/**
*/
public function call(): void
{
$uri = 'user';
$data = [];
$headers = $this->getDefaultHeaders();
$headers['X-Bunq-Client-Authentication'] = $this->sessionToken->getToken();
$response = $this->sendSignedBunqGet($uri, $data, $headers);
// create user objects:
$light = $this->getKeyFromResponse('UserLight', $response);
$company = $this->getKeyFromResponse('UserCompany', $response);
$person = $this->getKeyFromResponse('UserPerson', $response);
$this->userLight = new UserLight($light);
$this->userCompany = new UserCompany($company);
$this->userPerson = new UserPerson($person);
}
/**
* @return UserCompany
*/
public function getUserCompany(): UserCompany
{
return $this->userCompany;
}
/**
* @return UserLight
*/
public function getUserLight(): UserLight
{
return $this->userLight;
}
/**
* @return UserPerson
*/
public function getUserPerson(): UserPerson
{
return $this->userPerson;
}
/**
* @param SessionToken $sessionToken
*/
public function setSessionToken(SessionToken $sessionToken)
{
$this->sessionToken = $sessionToken;
}
}

View File

@@ -1,109 +0,0 @@
<?php
/**
* BunqToken.php
* Copyright (c) 2017 thegrumpydictator@gmail.com
*
* 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
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/
declare(strict_types=1);
namespace FireflyIII\Services\Bunq\Token;
use Carbon\Carbon;
/**
* @deprecated
* @codeCoverageIgnore
* Class BunqToken.
*/
class BunqToken
{
/** @var Carbon */
private $created;
/** @var int */
private $id = 0;
/** @var string */
private $token = '';
/** @var Carbon */
private $updated;
/**
* BunqToken constructor.
*
* @param array $response
*/
public function __construct(array $response)
{
$this->makeTokenFromResponse($response);
}
/**
* @return Carbon
*/
public function getCreated(): Carbon
{
return $this->created;
}
/**
* @return int
*/
public function getId(): int
{
return $this->id;
}
/**
* @return string
*/
public function getToken(): string
{
return $this->token;
}
/**
* @return Carbon
*/
public function getUpdated(): Carbon
{
return $this->updated;
}
/**
* @return array
*/
public function toArray(): array
{
return [
'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'),
'token' => $this->token,
];
}
/**
* @param array $response
*
*/
protected function makeTokenFromResponse(array $response): void
{
$this->id = $response['id'];
$this->created = Carbon::createFromFormat('Y-m-d H:i:s.u', $response['created']);
$this->updated = Carbon::createFromFormat('Y-m-d H:i:s.u', $response['updated']);
$this->token = $response['token'];
}
}

View File

@@ -1,32 +0,0 @@
<?php
/**
* InstallationToken.php
* Copyright (c) 2017 thegrumpydictator@gmail.com
*
* 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
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/
declare(strict_types=1);
namespace FireflyIII\Services\Bunq\Token;
/**
* @deprecated
* @codeCoverageIgnore
* Class InstallationToken.
*/
class InstallationToken extends BunqToken
{
}

View File

@@ -1,34 +0,0 @@
<?php
/**
* SessionToken.php
* Copyright (c) 2017 thegrumpydictator@gmail.com
*
* 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
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/
declare(strict_types=1);
namespace Bunq\Token;
namespace FireflyIII\Services\Bunq\Token;
/**
* @deprecated
* @codeCoverageIgnore
* Class SessionToken.
*/
class SessionToken extends BunqToken
{
}