Files
firefly-iii/app/Services/Bunq/Request/ListDeviceServerRequest.php

81 lines
2.3 KiB
PHP
Raw Normal View History

<?php
/**
* ListDeviceServerRequest.php
* Copyright (c) 2017 thegrumpydictator@gmail.com
*
2017-10-21 08:40:00 +02:00
* This file is part of Firefly III.
*
* Firefly III is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Firefly III is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
2017-12-17 14:44:05 +01:00
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/
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;
/**
2017-11-15 12:25:49 +01:00
* Class ListDeviceServerRequest.
*/
class ListDeviceServerRequest extends BunqRequest
{
/** @var Collection */
private $devices;
2017-11-15 12:25:49 +01:00
/** @var InstallationToken */
private $installationToken;
public function __construct()
{
parent::__construct();
$this->devices = new Collection;
}
/**
*/
public function call(): void
{
2018-03-10 07:16:38 +01:00
$uri = 'device-server';
$data = [];
$headers = $this->getDefaultHeaders();
$headers['X-Bunq-Client-Authentication'] = $this->installationToken->getToken();
$response = $this->sendSignedBunqGet($uri, $data, $headers);
// create device server objects:
$raw = $this->getArrayFromResponse('DeviceServer', $response);
/** @var array $entry */
foreach ($raw as $entry) {
$this->devices->push(new DeviceServer($entry));
}
return;
}
2017-09-09 06:41:45 +02:00
/**
* @return Collection
*/
public function getDevices(): Collection
{
return $this->devices;
}
/**
* @param InstallationToken $installationToken
*/
public function setInstallationToken(InstallationToken $installationToken)
{
$this->installationToken = $installationToken;
}
2017-08-31 06:47:18 +02:00
}