mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-09-05 12:12:18 +00:00
99 lines
2.8 KiB
PHP
99 lines
2.8 KiB
PHP
<?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;
|
|
|
|
/**
|
|
* 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];
|
|
|
|
Log::debug('Data we send along: ', $data);
|
|
|
|
$headers = $this->getDefaultHeaders();
|
|
$headers['X-Bunq-Client-Authentication'] = $this->installationToken->getToken();
|
|
|
|
Log::debug('Headers we send along: ', $headers);
|
|
|
|
$response = $this->sendSignedBunqPost($uri, $data, $headers);
|
|
$deviceServerId = new DeviceServerId;
|
|
$deviceServerId->setId(intval($response['Response'][0]['Id']['id']));
|
|
$this->deviceServerId = $deviceServerId;
|
|
|
|
return;
|
|
}
|
|
|
|
/**
|
|
* @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;
|
|
}
|
|
}
|