Passed
Push — master ( bfa63a...41a424 )
by Artem
01:47
created

ServiceTransferRepository::getSupportedFields()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 8
c 1
b 0
f 0
dl 0
loc 10
rs 10
cc 1
nc 1
nop 0
1
<?php
2
3
// ---------------------------------------------------------------------
4
//
5
//  Copyright (C) 2018-2024 Artem Rodygin
6
//
7
//  You should have received a copy of the MIT License along with
8
//  this file. If not, see <https://opensource.org/licenses/MIT>.
9
//
10
// ---------------------------------------------------------------------
11
12
namespace Linode\Account\Repository;
13
14
use Linode\Account\ServiceTransfer;
15
use Linode\Account\ServiceTransferRepositoryInterface;
16
use Linode\Entity;
17
use Linode\Internal\AbstractRepository;
18
19
/**
20
 * @codeCoverageIgnore This class was autogenerated.
21
 */
22
class ServiceTransferRepository extends AbstractRepository implements ServiceTransferRepositoryInterface
23
{
24
    public function createServiceTransfer(array $parameters = []): ServiceTransfer
25
    {
26
        $response = $this->client->post($this->getBaseUri(), $parameters);
27
        $contents = $response->getBody()->getContents();
28
        $json     = json_decode($contents, true);
29
30
        return new ServiceTransfer($this->client, $json);
31
    }
32
33
    public function deleteServiceTransfer(string $token): void
34
    {
35
        $this->client->delete(sprintf('%s/%s', $this->getBaseUri(), $token));
36
    }
37
38
    public function acceptServiceTransfer(string $token): void
39
    {
40
        $this->client->post(sprintf('%s/%s/accept', $this->getBaseUri(), $token));
41
    }
42
43
    protected function getBaseUri(): string
44
    {
45
        return '/account/service-transfers';
46
    }
47
48
    protected function getSupportedFields(): array
49
    {
50
        return [
51
            ServiceTransfer::FIELD_TOKEN,
52
            ServiceTransfer::FIELD_STATUS,
53
            ServiceTransfer::FIELD_EXPIRY,
54
            ServiceTransfer::FIELD_IS_SENDER,
55
            ServiceTransfer::FIELD_CREATED,
56
            ServiceTransfer::FIELD_UPDATED,
57
            ServiceTransfer::FIELD_ENTITIES,
58
        ];
59
    }
60
61
    protected function jsonToEntity(array $json): Entity
62
    {
63
        return new ServiceTransfer($this->client, $json);
64
    }
65
}
66