|
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
|
|
|
|