1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Trello\Api\Token; |
4
|
|
|
|
5
|
|
|
use Trello\Api\AbstractApi; |
6
|
|
|
|
7
|
|
|
/** |
8
|
|
|
* Trello Token Webhooks API |
9
|
|
|
* @link https://trello.com/docs/api/token |
10
|
|
|
* |
11
|
|
|
* Fully implemented. |
12
|
|
|
*/ |
13
|
|
|
class Webhooks extends AbstractApi |
14
|
|
|
{ |
15
|
|
|
protected $path = 'tokens/#id#/webhooks'; |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* Get webhooks related to a given token |
19
|
|
|
* @link https://trello.com/docs/api/token/#get-1-tokens-token-webhooks |
20
|
|
|
* |
21
|
|
|
* @param string $id the token's id |
22
|
|
|
* @param array $params optional parameters |
23
|
|
|
* |
24
|
|
|
* @return array |
25
|
|
|
*/ |
26
|
1 |
|
public function all($id, array $params = array()) |
27
|
|
|
{ |
28
|
1 |
|
return $this->get($this->getPath($id), $params); |
29
|
|
|
} |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* Get a webhook |
33
|
|
|
* @link https://trello.com/docs/api/token/#get-1-tokens-token-webhooks-idwebhook |
34
|
|
|
* |
35
|
|
|
* @param string $id the token's id |
36
|
|
|
* @param string $webhookId the webhook's id |
37
|
|
|
* |
38
|
|
|
* @return array |
39
|
|
|
*/ |
40
|
1 |
|
public function show($id, $webhookId) |
41
|
|
|
{ |
42
|
1 |
|
return $this->get($this->getPath($id).'/'.rawurlencode($webhookId)); |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* Create a webhook |
47
|
|
|
* @link https://trello.com/docs/api/token/#post-1-tokens-token-webhooks |
48
|
|
|
* |
49
|
|
|
* @param string $id the id of the token the webhook should be created on |
50
|
|
|
* @param array $params optional attributes |
51
|
|
|
* |
52
|
|
|
* @return array card info |
53
|
|
|
*/ |
54
|
3 |
|
public function create($id, array $params) |
55
|
|
|
{ |
56
|
3 |
|
$this->validateRequiredParameters(array('callbackURL', 'idModel'), $params); |
57
|
|
|
|
58
|
1 |
|
return $this->post($this->getPath($id), $params); |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
/** |
62
|
|
|
* Update a webhook |
63
|
|
|
* @link https://trello.com/docs/api/token/#put-1-tokens-token-webhooks |
64
|
|
|
* |
65
|
|
|
* @param string $id the id of the token the webhook is attached to |
66
|
|
|
* @param array $params optional attributes |
67
|
|
|
* |
68
|
|
|
* @return array card info |
69
|
|
|
*/ |
70
|
3 |
|
public function update($id, array $params) |
71
|
|
|
{ |
72
|
3 |
|
$this->validateRequiredParameters(array('callbackURL', 'idModel'), $params); |
73
|
|
|
|
74
|
1 |
|
return $this->put($this->getPath($id), $params); |
75
|
|
|
} |
76
|
|
|
|
77
|
|
|
/** |
78
|
|
|
* Remove a webhook |
79
|
|
|
* @link https://trello.com/docs/api/token/#delete-1-tokens-token-webhooks-idwebhook |
80
|
|
|
* |
81
|
|
|
* @param string $id the id of the token the webhook is attached to |
82
|
|
|
* @param string $webhookId id of the webhook to remove |
83
|
|
|
* |
84
|
|
|
* @return array card info |
85
|
|
|
*/ |
86
|
1 |
|
public function remove($id, $webhookId) |
87
|
|
|
{ |
88
|
1 |
|
return $this->delete($this->getPath($id).'/'.rawurlencode($webhookId)); |
89
|
|
|
} |
90
|
|
|
} |
91
|
|
|
|