UpdateTrait::api()
last analyzed

Size

Total Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 1
c 0
b 0
f 0
nc 1
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: Matthew
5
 * Date: 21/04/2016
6
 * Time: 9:10 AM
7
 */
8
9
namespace Freshdesk\Resources\Traits;
10
11
12
/**
13
 * Update Trait
14
 *
15
 * @package Freshdesk\Resources\Traits
16
 */
17
trait UpdateTrait
18
{
19
20
    /**
21
     * @param integer $end string
22
     * @return string
23
     * @internal
24
     */
25
    abstract protected function endpoint($end = null);
26
27
    /**
28
     * @return \Freshdesk\Api
29
     * @internal
30
     */
31
    abstract protected function api();
32
33
    /**
34
     * Update a resource
35
     *
36
     * Updates the resources for the given $id with the supplied data/.
37
     *
38
     * @api
39
     * @param int $id The resource id
40
     * @param array $data The data
41
     * @return array|null
42
     * @throws \Freshdesk\Exceptions\AccessDeniedException
43
     * @throws \Freshdesk\Exceptions\ApiException
44
     * @throws \Freshdesk\Exceptions\AuthenticationException
45
     * @throws \Freshdesk\Exceptions\ConflictingStateException
46
     * @throws \Freshdesk\Exceptions\NotFoundException
47
     * @throws \Freshdesk\Exceptions\RateLimitExceededException
48
     * @throws \Freshdesk\Exceptions\UnsupportedContentTypeException
49
     * @throws \Freshdesk\Exceptions\MethodNotAllowedException
50
     * @throws \Freshdesk\Exceptions\UnsupportedAcceptHeaderException
51
     * @throws \Freshdesk\Exceptions\ValidationException
52
     */
53
    public function update($id, array $data)
54
    {
55
        return $this->api()->request('PUT', $this->endpoint($id), $data);
56
    }
57
}
58