Completed
Push — master ( 6a21b5...b393f5 )
by Matthew
02:21
created

Forum::categoryEndpoint()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
rs 10
cc 2
eloc 2
nc 2
nop 1
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
 * Forum resource
19
 *
20
 * @internal
21
 * @package Freshdesk\Resources
22
 */
23
class Forum extends AbstractResource
24
{
25
26
    use AllTrait, ViewTrait, UpdateTrait, DeleteTrait, MonitorTrait;
27
    
28
    /**
29
     * The forums resource endpoint
30
     *
31
     * @var string
32
     */
33
    protected $endpoint = '/discussions/forums';
34
35
    /**
36
     * The resource endpoint
37
     *
38
     * @var string
39
     */
40
    protected $categoryEndpoint = '/discussions/categories';
41
42
    /**
43
     * Creates the category endpoint (for creating forums)
44
     *
45
     * @param null $id
46
     * @return string
47
     */
48
    private function categoryEndpoint($id = null)
49
    {
50
        return $id == null ? $this->categoryEndpoint : $this->categoryEndpoint . '/' . $id;
51
    }
52
53
    /**
54
     *
55
     * Create a forum for a category.
56
     *
57
     * @param int $id The category Id
58
     * @param array $data
59
     * @return array|null
60
     * @throws \Freshdesk\Exceptions\AccessDeniedException
61
     * @throws \Freshdesk\Exceptions\ApiException
62
     * @throws \Freshdesk\Exceptions\AuthenticationException
63
     * @throws \Freshdesk\Exceptions\ConflictingStateException
64
     * @throws \Freshdesk\Exceptions\NotFoundException
65
     * @throws \Freshdesk\Exceptions\RateLimitExceededException
66
     * @throws \Freshdesk\Exceptions\UnsupportedContentTypeException
67
     * @throws \Freshdesk\Exceptions\MethodNotAllowedException
68
     * @throws \Freshdesk\Exceptions\UnsupportedAcceptHeaderException
69
     * @throws \Freshdesk\Exceptions\ValidationException
70
     */
71
    public function create($id, array $data)
72
    {
73
        return $this->api()->request('POST', $this->categoryEndpoint($id), $data);
74
    }
75
76
}
77