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

PaymentMethodRepository::getSupportedFields()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 6
c 1
b 0
f 0
dl 0
loc 8
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\PaymentMethod;
15
use Linode\Account\PaymentMethodRepositoryInterface;
16
use Linode\Entity;
17
use Linode\Internal\AbstractRepository;
18
19
/**
20
 * @codeCoverageIgnore This class was autogenerated.
21
 */
22
class PaymentMethodRepository extends AbstractRepository implements PaymentMethodRepositoryInterface
23
{
24
    public function createPaymentMethod(array $parameters = []): void
25
    {
26
        $this->client->post($this->getBaseUri(), $parameters);
27
    }
28
29
    public function deletePaymentMethod(int $paymentMethodId): void
30
    {
31
        $this->client->delete(sprintf('%s/%s', $this->getBaseUri(), $paymentMethodId));
32
    }
33
34
    public function makePaymentMethodDefault(int $paymentMethodId): void
35
    {
36
        $this->client->post(sprintf('%s/%s/make-default', $this->getBaseUri(), $paymentMethodId));
37
    }
38
39
    protected function getBaseUri(): string
40
    {
41
        return '/account/payment-methods';
42
    }
43
44
    protected function getSupportedFields(): array
45
    {
46
        return [
47
            PaymentMethod::FIELD_ID,
48
            PaymentMethod::FIELD_TYPE,
49
            PaymentMethod::FIELD_IS_DEFAULT,
50
            PaymentMethod::FIELD_CREATED,
51
            PaymentMethod::FIELD_DATA,
52
        ];
53
    }
54
55
    protected function jsonToEntity(array $json): Entity
56
    {
57
        return new PaymentMethod($this->client, $json);
58
    }
59
}
60