Files
firefly-iii/app/Services/Spectre/Request/NewCustomerRequest.php

62 lines
1.7 KiB
PHP
Raw Normal View History

<?php
/**
* NewCustomerRequest.php
* Copyright (c) 2019 thegrumpydictator@gmail.com
*
* This file is part of Firefly III (https://github.com/firefly-iii).
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program 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 Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
declare(strict_types=1);
namespace FireflyIII\Services\Spectre\Request;
2017-12-27 17:22:44 +01:00
use FireflyIII\Services\Spectre\Object\Customer;
2018-06-20 16:27:57 +02:00
use Log;
2018-08-06 19:14:30 +02:00
/**
* Class NewCustomerRequest
2019-07-31 16:53:09 +02:00
* @codeCoverageIgnore
*/
class NewCustomerRequest extends SpectreRequest
{
2017-12-27 17:22:44 +01:00
/** @var Customer */
protected $customer;
/**
* @throws \FireflyIII\Exceptions\FireflyException
*/
public function call(): void
{
2018-08-06 19:14:30 +02:00
$data = [
'data' => [
'identifier' => 'default_ff3_customer',
],
];
2018-08-06 19:14:30 +02:00
$uri = '/api/v4/customers/';
2018-06-20 16:27:57 +02:00
Log::debug(sprintf('Going to call %s with info:', $uri), $data);
2017-12-28 18:38:59 +01:00
$response = $this->sendSignedSpectrePost($uri, $data);
// create customer:
2017-12-27 17:22:44 +01:00
$this->customer = new Customer($response['data']);
}
/**
2017-12-27 17:22:44 +01:00
* @return Customer
*/
2017-12-27 17:22:44 +01:00
public function getCustomer(): Customer
{
return $this->customer;
}
2017-12-22 18:32:43 +01:00
}