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\Support\Repository; |
13
|
|
|
|
14
|
|
|
use Linode\Entity; |
15
|
|
|
use Linode\Internal\AbstractRepository; |
16
|
|
|
use Linode\LinodeClient; |
17
|
|
|
use Linode\Support\SupportTicketReply; |
18
|
|
|
use Linode\Support\SupportTicketReplyRepositoryInterface; |
19
|
|
|
|
20
|
|
|
/** |
21
|
|
|
* @codeCoverageIgnore This class was autogenerated. |
22
|
|
|
*/ |
23
|
|
|
class SupportTicketReplyRepository extends AbstractRepository implements SupportTicketReplyRepositoryInterface |
24
|
|
|
{ |
25
|
|
|
/** |
26
|
|
|
* @param int $ticketId The ID of the Support Ticket. |
27
|
|
|
*/ |
28
|
|
|
public function __construct(LinodeClient $client, protected int $ticketId) |
29
|
|
|
{ |
30
|
|
|
parent::__construct($client); |
31
|
|
|
} |
32
|
|
|
|
33
|
|
|
public function createTicketReply(array $parameters = []): SupportTicketReply |
34
|
|
|
{ |
35
|
|
|
$response = $this->client->post($this->getBaseUri(), $parameters); |
36
|
|
|
$contents = $response->getBody()->getContents(); |
37
|
|
|
$json = json_decode($contents, true); |
38
|
|
|
|
39
|
|
|
return new SupportTicketReply($this->client, $json); |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
protected function getBaseUri(): string |
43
|
|
|
{ |
44
|
|
|
return sprintf('/support/tickets/%s/replies', $this->ticketId); |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
protected function getSupportedFields(): array |
48
|
|
|
{ |
49
|
|
|
return [ |
50
|
|
|
SupportTicketReply::FIELD_ID, |
51
|
|
|
SupportTicketReply::FIELD_CREATED_BY, |
52
|
|
|
SupportTicketReply::FIELD_CREATED, |
53
|
|
|
SupportTicketReply::FIELD_GRAVATAR_ID, |
54
|
|
|
SupportTicketReply::FIELD_FROM_LINODE, |
55
|
|
|
SupportTicketReply::FIELD_DESCRIPTION, |
56
|
|
|
]; |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
protected function jsonToEntity(array $json): Entity |
60
|
|
|
{ |
61
|
|
|
return new SupportTicketReply($this->client, $json); |
62
|
|
|
} |
63
|
|
|
} |
64
|
|
|
|