|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* Created by PhpStorm. |
|
4
|
|
|
* User: Matt |
|
5
|
|
|
* Date: 20/04/2016 |
|
6
|
|
|
* Time: 2:32 PM |
|
7
|
|
|
*/ |
|
8
|
|
|
|
|
9
|
|
|
namespace Freshdesk\Resources; |
|
10
|
|
|
|
|
11
|
|
|
use Freshdesk\Resources\Traits\AllTrait; |
|
12
|
|
|
use Freshdesk\Resources\Traits\CreateTrait; |
|
13
|
|
|
use Freshdesk\Resources\Traits\DeleteTrait; |
|
14
|
|
|
use Freshdesk\Resources\Traits\UpdateTrait; |
|
15
|
|
|
use Freshdesk\Resources\Traits\ViewTrait; |
|
16
|
|
|
|
|
17
|
|
|
/** |
|
18
|
|
|
* |
|
19
|
|
|
* Contact resource |
|
20
|
|
|
* |
|
21
|
|
|
* Provides access to the contact resources |
|
22
|
|
|
* |
|
23
|
|
|
* @package Api\Resources |
|
24
|
|
|
*/ |
|
25
|
|
|
class Contact extends AbstractResource |
|
26
|
|
|
{ |
|
27
|
|
|
use AllTrait, CreateTrait, ViewTrait, UpdateTrait, DeleteTrait; |
|
28
|
|
|
|
|
29
|
|
|
/** |
|
30
|
|
|
* The resource endpoint |
|
31
|
|
|
* |
|
32
|
|
|
* @var string |
|
33
|
|
|
* @internal |
|
34
|
|
|
*/ |
|
35
|
|
|
protected $endpoint = '/contacts'; |
|
36
|
|
|
|
|
37
|
|
|
/** |
|
38
|
|
|
* List contact fields |
|
39
|
|
|
* |
|
40
|
|
|
* The agent whose credentials (API key or username/password) are being used to make this API call should be |
|
41
|
|
|
* authorised to view the contact fields |
|
42
|
|
|
* |
|
43
|
|
|
* @api |
|
44
|
|
|
* @param array|null $query |
|
45
|
|
|
* @return array|null |
|
46
|
|
|
* @throws \Freshdesk\Exceptions\AccessDeniedException |
|
47
|
|
|
* @throws \Freshdesk\Exceptions\ApiException |
|
48
|
|
|
* @throws \Freshdesk\Exceptions\AuthenticationException |
|
49
|
|
|
* @throws \Freshdesk\Exceptions\ConflictingStateException |
|
50
|
|
|
* @throws \Freshdesk\Exceptions\NotFoundException |
|
51
|
|
|
* @throws \Freshdesk\Exceptions\RateLimitExceededException |
|
52
|
|
|
* @throws \Freshdesk\Exceptions\UnsupportedContentTypeException |
|
53
|
|
|
* @throws \Freshdesk\Exceptions\MethodNotAllowedException |
|
54
|
|
|
* @throws \Freshdesk\Exceptions\UnsupportedAcceptHeaderException |
|
55
|
|
|
* @throws \Freshdesk\Exceptions\ValidationException |
|
56
|
|
|
*/ |
|
57
|
|
|
public function fields(array $query = null) |
|
58
|
|
|
{ |
|
59
|
|
|
return $this->api()->request('GET', '/contact_fields', null, $query); |
|
60
|
|
|
} |
|
61
|
|
|
|
|
62
|
|
|
/** |
|
63
|
|
|
* Convert a contact into an agent |
|
64
|
|
|
* |
|
65
|
|
|
* Note: |
|
66
|
|
|
* 1. The contact must have an email address in order to be converted into an agent. |
|
67
|
|
|
* 2. If your account has already reached the maximum number of agents, the API request will fail with HTTP error code 403 |
|
68
|
|
|
* 3. The agent whose credentials (API key, username and password) were used to make this API call should be authorised to convert a contact into an agent |
|
69
|
|
|
* |
|
70
|
|
|
* @param int $id The agent id |
|
71
|
|
|
* @param array|null $query |
|
72
|
|
|
* @return array|null |
|
73
|
|
|
* @throws \Freshdesk\Exceptions\AccessDeniedException |
|
74
|
|
|
* @throws \Freshdesk\Exceptions\ApiException |
|
75
|
|
|
* @throws \Freshdesk\Exceptions\AuthenticationException |
|
76
|
|
|
* @throws \Freshdesk\Exceptions\ConflictingStateException |
|
77
|
|
|
* @throws \Freshdesk\Exceptions\NotFoundException |
|
78
|
|
|
* @throws \Freshdesk\Exceptions\RateLimitExceededException |
|
79
|
|
|
* @throws \Freshdesk\Exceptions\UnsupportedContentTypeException |
|
80
|
|
|
* @throws \Freshdesk\Exceptions\MethodNotAllowedException |
|
81
|
|
|
* @throws \Freshdesk\Exceptions\UnsupportedAcceptHeaderException |
|
82
|
|
|
* @throws \Freshdesk\Exceptions\ValidationException |
|
83
|
|
|
*/ |
|
84
|
|
|
public function makeAgent($id, array $query = null) |
|
85
|
|
|
{ |
|
86
|
|
|
$end = $id . '/make_agent'; |
|
87
|
|
|
|
|
88
|
|
|
return $this->api()->request('GET', $this->endpoint($end), null, $query); |
|
89
|
|
|
} |
|
90
|
|
|
|
|
91
|
|
|
/** |
|
92
|
|
|
* Restore a contact |
|
93
|
|
|
* |
|
94
|
|
|
* |
|
95
|
|
|
* @param int $id The contact id |
|
96
|
|
|
* @return array|null |
|
97
|
|
|
* @throws \Freshdesk\Exceptions\AccessDeniedException |
|
98
|
|
|
* @throws \Freshdesk\Exceptions\ApiException |
|
99
|
|
|
* @throws \Freshdesk\Exceptions\AuthenticationException |
|
100
|
|
|
* @throws \Freshdesk\Exceptions\ConflictingStateException |
|
101
|
|
|
* @throws \Freshdesk\Exceptions\NotFoundException |
|
102
|
|
|
* @throws \Freshdesk\Exceptions\RateLimitExceededException |
|
103
|
|
|
* @throws \Freshdesk\Exceptions\UnsupportedContentTypeException |
|
104
|
|
|
* @throws \Freshdesk\Exceptions\MethodNotAllowedException |
|
105
|
|
|
* @throws \Freshdesk\Exceptions\UnsupportedAcceptHeaderException |
|
106
|
|
|
* @throws \Freshdesk\Exceptions\ValidationException |
|
107
|
|
|
*/ |
|
108
|
|
|
public function restore($id) |
|
109
|
|
|
{ |
|
110
|
|
|
$end = $id . '/restore'; |
|
111
|
|
|
return $this->api()->request('PUT', $this->endpoint($end), null, []); |
|
112
|
|
|
} |
|
113
|
|
|
} |
|
114
|
|
|
|