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