1 | <?php |
||
48 | class Api |
||
49 | { |
||
50 | /** |
||
51 | * Agent resources |
||
52 | * |
||
53 | * @api |
||
54 | * @var Agent |
||
55 | */ |
||
56 | public $agents; |
||
57 | |||
58 | /** |
||
59 | * Company resources |
||
60 | * |
||
61 | * @api |
||
62 | * @var Company |
||
63 | */ |
||
64 | public $companies; |
||
65 | |||
66 | /** |
||
67 | * Contact resources |
||
68 | * |
||
69 | * @api |
||
70 | * @var Contact |
||
71 | */ |
||
72 | public $contacts; |
||
73 | |||
74 | /** |
||
75 | * Group resources |
||
76 | * |
||
77 | * @api |
||
78 | * @var Group |
||
79 | */ |
||
80 | public $groups; |
||
81 | |||
82 | /** |
||
83 | * Ticket resources |
||
84 | * |
||
85 | * @api |
||
86 | * @var Ticket |
||
87 | */ |
||
88 | public $tickets; |
||
89 | |||
90 | /** |
||
91 | * TimeEntry resources |
||
92 | * |
||
93 | * @api |
||
94 | * @var TimeEntry |
||
95 | */ |
||
96 | public $timeEntries; |
||
97 | |||
98 | /** |
||
99 | * Conversation resources |
||
100 | * |
||
101 | * @api |
||
102 | * @var Conversation |
||
103 | */ |
||
104 | public $conversations; |
||
105 | |||
106 | /** |
||
107 | * Category resources |
||
108 | * |
||
109 | * @api |
||
110 | * @var Category |
||
111 | */ |
||
112 | public $categories; |
||
113 | |||
114 | /** |
||
115 | * Forum resources |
||
116 | * |
||
117 | * @api |
||
118 | * @var Forum |
||
119 | */ |
||
120 | public $forums; |
||
121 | |||
122 | /** |
||
123 | * Topic resources |
||
124 | * |
||
125 | * @api |
||
126 | * @var Topic |
||
127 | */ |
||
128 | public $topics; |
||
129 | |||
130 | /** |
||
131 | * Comment resources |
||
132 | * |
||
133 | * @api |
||
134 | * @var Comment |
||
135 | */ |
||
136 | public $comments; |
||
137 | |||
138 | //Admin |
||
139 | |||
140 | /** |
||
141 | * Email Config resources |
||
142 | * |
||
143 | * @api |
||
144 | * @var EmailConfig |
||
145 | */ |
||
146 | public $emailConfigs; |
||
147 | |||
148 | /** |
||
149 | * Access Product resources |
||
150 | * |
||
151 | * @api |
||
152 | * @var Product |
||
153 | */ |
||
154 | public $products; |
||
155 | |||
156 | /** |
||
157 | * Business Hours resources |
||
158 | * |
||
159 | * @api |
||
160 | * @var BusinessHour |
||
161 | */ |
||
162 | public $businessHours; |
||
163 | |||
164 | /** |
||
165 | * SLA Policy resources |
||
166 | * |
||
167 | * @api |
||
168 | * @var SLAPolicy |
||
169 | */ |
||
170 | public $slaPolicies; |
||
171 | |||
172 | /** |
||
173 | * @internal |
||
174 | * @var Client |
||
175 | */ |
||
176 | protected $client; |
||
177 | |||
178 | /** |
||
179 | * @internal |
||
180 | * @var string |
||
181 | */ |
||
182 | private $baseUrl; |
||
183 | |||
184 | /** |
||
185 | * Constructs a new api instance |
||
186 | * |
||
187 | * @api |
||
188 | * @param $apiKey |
||
189 | * @param $domain |
||
190 | * @throws Exceptions\InvalidConfigurationException |
||
191 | */ |
||
192 | public function __construct($apiKey, $domain) |
||
207 | |||
208 | |||
209 | /** |
||
210 | * Internal method for handling requests |
||
211 | * |
||
212 | * @internal |
||
213 | * @param $method |
||
214 | * @param $endpoint |
||
215 | * @param array|null $data |
||
216 | * @param array|null $query |
||
217 | * @return mixed|null |
||
218 | * @throws ApiException |
||
219 | * @throws ConflictingStateException |
||
220 | * @throws RateLimitExceededException |
||
221 | * @throws UnsupportedContentTypeException |
||
222 | */ |
||
223 | public function request($method, $endpoint, array $data = null, array $query = null) |
||
235 | |||
236 | /** |
||
237 | * Performs the request |
||
238 | * |
||
239 | * @internal |
||
240 | * |
||
241 | * @param $method |
||
242 | * @param $url |
||
243 | * @param $options |
||
244 | * @return mixed|null |
||
245 | * @throws AccessDeniedException |
||
246 | * @throws ApiException |
||
247 | * @throws AuthenticationException |
||
248 | * @throws ConflictingStateException |
||
249 | */ |
||
250 | private function performRequest($method, $url, $options) { |
||
269 | |||
270 | |||
271 | /** |
||
272 | * @param $apiKey |
||
273 | * @param $domain |
||
274 | * @throws Exceptions\InvalidConfigurationException |
||
275 | * @internal |
||
276 | * |
||
277 | */ |
||
278 | private function validateConstructorArgs($apiKey, $domain) |
||
288 | |||
289 | /** |
||
290 | * @internal |
||
291 | */ |
||
292 | private function setupResources() |
||
317 | |||
318 | } |