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\DeleteTrait; |
13
|
|
|
use Freshdesk\Resources\Traits\MonitorTrait; |
14
|
|
|
use Freshdesk\Resources\Traits\UpdateTrait; |
15
|
|
|
use Freshdesk\Resources\Traits\ViewTrait; |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* |
19
|
|
|
* Forum resource |
20
|
|
|
* |
21
|
|
|
* Provides access to the forum resources |
22
|
|
|
* |
23
|
|
|
* @package Api\Resources |
24
|
|
|
*/ |
25
|
|
|
class Forum extends AbstractResource |
26
|
|
|
{ |
27
|
|
|
|
28
|
|
|
use AllTrait, ViewTrait, UpdateTrait, DeleteTrait, MonitorTrait; |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* The forums resource endpoint |
32
|
|
|
* |
33
|
|
|
* @var string |
34
|
|
|
* @internal |
35
|
|
|
*/ |
36
|
|
|
protected $endpoint = '/discussions/forums'; |
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* The resource endpoint |
40
|
|
|
* |
41
|
|
|
* @var string |
42
|
|
|
* @internal |
43
|
|
|
*/ |
44
|
|
|
protected $categoryEndpoint = '/discussions/categories'; |
45
|
|
|
|
46
|
|
|
/** |
47
|
|
|
* Creates the category endpoint (for creating forums) |
48
|
|
|
* |
49
|
|
|
* @param integer $id |
50
|
|
|
* @return string |
51
|
|
|
* @internal |
52
|
|
|
*/ |
53
|
|
|
private function categoryEndpoint($id = null) |
54
|
|
|
{ |
55
|
|
|
return $id === null ? $this->categoryEndpoint : $this->categoryEndpoint . '/' . $id; |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
/** |
59
|
|
|
* |
60
|
|
|
* Create a forum for a category. |
61
|
|
|
* |
62
|
|
|
* @api |
63
|
|
|
* @param int $id The category Id |
64
|
|
|
* @param array $data |
65
|
|
|
* @return array|null |
66
|
|
|
* @throws \Freshdesk\Exceptions\AccessDeniedException |
67
|
|
|
* @throws \Freshdesk\Exceptions\ApiException |
68
|
|
|
* @throws \Freshdesk\Exceptions\AuthenticationException |
69
|
|
|
* @throws \Freshdesk\Exceptions\ConflictingStateException |
70
|
|
|
* @throws \Freshdesk\Exceptions\NotFoundException |
71
|
|
|
* @throws \Freshdesk\Exceptions\RateLimitExceededException |
72
|
|
|
* @throws \Freshdesk\Exceptions\UnsupportedContentTypeException |
73
|
|
|
* @throws \Freshdesk\Exceptions\MethodNotAllowedException |
74
|
|
|
* @throws \Freshdesk\Exceptions\UnsupportedAcceptHeaderException |
75
|
|
|
* @throws \Freshdesk\Exceptions\ValidationException |
76
|
|
|
*/ |
77
|
|
|
public function create($id, array $data) |
78
|
|
|
{ |
79
|
|
|
return $this->api()->request('POST', $this->categoryEndpoint($id), $data); |
80
|
|
|
} |
81
|
|
|
} |
82
|
|
|
|