1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace RevolutPHP; |
4
|
|
|
|
5
|
|
|
class WebhooksV2 |
6
|
|
|
{ |
7
|
|
|
const ENDPOINT = '2.0/webhooks'; |
8
|
|
|
|
9
|
|
|
/** |
10
|
|
|
* @var Client |
11
|
|
|
*/ |
12
|
|
|
private $client; |
13
|
|
|
|
14
|
|
|
/** |
15
|
|
|
* Webhook constructor. |
16
|
|
|
* @param Client $client |
17
|
|
|
*/ |
18
|
|
|
public function __construct(Client $client) |
19
|
|
|
{ |
20
|
|
|
$this->client = $client; |
21
|
|
|
} |
22
|
|
|
|
23
|
|
|
/** |
24
|
|
|
* @see https://developer.revolut.com/docs/business/create-webhook |
25
|
|
|
* |
26
|
|
|
* @param array $json |
27
|
|
|
* @return mixed |
28
|
|
|
* @throws \GuzzleHttp\Exception\GuzzleException |
29
|
|
|
*/ |
30
|
|
|
public function create(array $json) |
31
|
|
|
{ |
32
|
|
|
return $this->client->post(self::ENDPOINT, $json); |
33
|
|
|
} |
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* @see https://developer.revolut.com/docs/business/get-webhooks |
37
|
|
|
* |
38
|
|
|
* @return mixed |
39
|
|
|
* @throws \GuzzleHttp\Exception\GuzzleException |
40
|
|
|
*/ |
41
|
|
|
public function all() |
42
|
|
|
{ |
43
|
|
|
return $this->client->get(self::ENDPOINT); |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
/** |
47
|
|
|
* @see https://developer.revolut.com/docs/business/get-webhook |
48
|
|
|
* |
49
|
|
|
* @param string $id |
50
|
|
|
* @return mixed |
51
|
|
|
* @throws \GuzzleHttp\Exception\GuzzleException |
52
|
|
|
*/ |
53
|
|
|
public function get(string $id) |
54
|
|
|
{ |
55
|
|
|
return $this->client->get(self::ENDPOINT.'/'.$id); |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
/** |
59
|
|
|
* @see https://developer.revolut.com/docs/business/update-webhook |
60
|
|
|
* |
61
|
|
|
* @param string $id |
62
|
|
|
* @param array $json |
63
|
|
|
* @return mixed |
64
|
|
|
* @throws \GuzzleHttp\Exception\GuzzleException |
65
|
|
|
*/ |
66
|
|
|
public function update(string $id, array $json) |
67
|
|
|
{ |
68
|
|
|
return $this->client->patch(self::ENDPOINT.'/'.$id, $json); |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
/** |
72
|
|
|
* @see https://developer.revolut.com/docs/business/delete-webhook |
73
|
|
|
* |
74
|
|
|
* @param string $id |
75
|
|
|
* @return mixed |
76
|
|
|
* @throws \GuzzleHttp\Exception\GuzzleException |
77
|
|
|
*/ |
78
|
|
|
public function delete(string $id) |
79
|
|
|
{ |
80
|
|
|
return $this->client->delete(self::ENDPOINT.'/'.$id); |
81
|
|
|
} |
82
|
|
|
|
83
|
|
|
/** |
84
|
|
|
* @see https://developer.revolut.com/docs/business/rotate-webhook-signing-secret |
85
|
|
|
* |
86
|
|
|
* @param string $id |
87
|
|
|
* @param array $json |
88
|
|
|
* @return mixed |
89
|
|
|
* @throws \GuzzleHttp\Exception\GuzzleException |
90
|
|
|
*/ |
91
|
|
|
public function rotateSigningSecret(string $id, array $json) |
92
|
|
|
{ |
93
|
|
|
return $this->client->post(self::ENDPOINT.'/'.$id.'/rotate-signing-secret', $json); |
94
|
|
|
} |
95
|
|
|
|
96
|
|
|
/** |
97
|
|
|
* @see https://developer.revolut.com/docs/business/failed-events |
98
|
|
|
* |
99
|
|
|
* @param string $id |
100
|
|
|
* @param int|null $limit |
101
|
|
|
* @param \DateTime|null $createdBefore |
102
|
|
|
* @return mixed |
103
|
|
|
* @throws \GuzzleHttp\Exception\GuzzleException |
104
|
|
|
*/ |
105
|
|
|
public function getFailedEvents(string $id, int $limit = null, \DateTime $createdBefore = null) |
106
|
|
|
{ |
107
|
|
|
$args = []; |
108
|
|
|
if (null !== $limit) { |
109
|
|
|
$args['limit'] = $limit; |
110
|
|
|
} |
111
|
|
|
if (null !== $limit) { |
112
|
|
|
$args['created_before'] = $createdBefore->format(\DateTime::ISO8601); |
|
|
|
|
113
|
|
|
} |
114
|
|
|
|
115
|
|
|
$query = http_build_query($args); |
116
|
|
|
|
117
|
|
|
$endpoint = self::ENDPOINT.'/'.$id.'/failed-events'; |
118
|
|
|
$endpoint = implode('?', array_filter([$endpoint, $query])); |
119
|
|
|
|
120
|
|
|
return $this->client->get($endpoint); |
121
|
|
|
} |
122
|
|
|
} |
123
|
|
|
|
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.