Token::show()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 2
crap 1
1
<?php
2
3
namespace Trello\Api;
4
5
use Trello\Exception\InvalidArgumentException;
6
7
/**
8
 * Trello Token API
9
 * @link https://trello.com/docs/api/token
10
 *
11
 * Fully implemented.
12
 */
13
class Token extends AbstractApi
14
{
15
    /**
16
     * Base path of tokens api
17
     * @var string
18
     */
19
    protected $path = 'tokens';
20
21
    /**
22
     * Token fields
23
     * @link https://trello.com/docs/api/token/#get-1-tokens-token-field
24
     * @var array
25
     */
26
    public static $fields = array(
27
        'identifier',
28
        'idMember',
29
        'dateCreated',
30
        'dateExpires',
31
        'permissions'
32
    );
33
34
    /**
35
     * Find a token by id
36
     * @link https://trello.com/docs/api/token/#get-1-tokens-idtoken
37
     *
38
     * @param string $id     the token's id
39
     * @param array  $params optional attributes
40
     *
41
     * @return array
42
     */
43 1
    public function show($id, array $params = array())
44
    {
45 1
        return $this->get($this->getPath().'/'.rawurlencode($id), $params);
46
    }
47
48
    /**
49
     * Remove a token
50
     * @link https://trello.com/docs/api/token/#delete-1-tokens-idtoken
51
     *
52
     * @param string $id the token's id
53
     *
54
     * @return array
55
     */
56 1
    public function remove($id)
57
    {
58 1
        return $this->delete($this->getPath().'/'.rawurlencode($id));
59
    }
60
61
    /**
62
     * Get a given token's member
63
     * @link https://trello.com/docs/api/token/#get-1-tokens-token-member
64
     *
65
     * @param string $id     the token's id
66
     * @param array  $params optional parameters
67
     *
68
     * @return array
69
     */
70 1
    public function getMember($id, array $params = array())
71
    {
72 1
        return $this->get($this->getPath().'/'.rawurlencode($id).'/member', $params);
73
    }
74
75
    /**
76
     * Get a given token's member's field
77
     * @link https://trello.com/docs/api/token/#get-1-tokens-token-member-field
78
     *
79
     * @param string $id     the token's id
80
     *
81
     * @return array
82
     */
83 2
    public function getMemberField($id, $field)
84
    {
85 2
        $this->validateAllowedParameters(Member::$fields, $field, 'field');
86
87 1
        return $this->get($this->getPath().'/'.rawurlencode($id).'/member/'.rawurlencode($field));
88
    }
89
90
    /**
91
     * Webhooks API
92
     *
93
     * @return Token\Webhooks
94
     */
95 1
    public function webhooks()
96
    {
97 1
        return new Token\Webhooks($this->client);
98
    }
99
}
100