-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathWebhookServiceInterface.php
More file actions
110 lines (100 loc) · 4.12 KB
/
WebhookServiceInterface.php
File metadata and controls
110 lines (100 loc) · 4.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
<?php
/**
* The interface for the WebhookService.
*
* @link https://docs.unzer.com/
*
*/
namespace UnzerSDK\Interfaces;
use RuntimeException;
use UnzerSDK\Exceptions\UnzerApiException;
use UnzerSDK\Resources\AbstractUnzerResource;
use UnzerSDK\Resources\Webhook;
interface WebhookServiceInterface
{
/**
* Creates Webhook resource
*
* @param string $url The url the registered webhook event should be send to.
* @param string $event The event to be registered.
*
* @return Webhook The newly created webhook resource.
*
* @throws UnzerApiException An UnzerApiException is thrown if there is an error returned on API-request.
* @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK.
*/
public function createWebhook(string $url, string $event): Webhook;
/**
* Updates the given local Webhook object using the API.
* Retrieves a Webhook resource, if the webhook parameter is the webhook id.
*
* @param Webhook|string $webhook
*
* @return Webhook The fetched webhook object.
*
* @throws UnzerApiException An UnzerApiException is thrown if there is an error returned on API-request.
* @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK.
*/
public function fetchWebhook($webhook): Webhook;
/**
* Updates the Webhook resource of the api with the given object.
*
* @param Webhook $webhook
*
* @return Webhook The webhook object returned after update.
*
* @throws UnzerApiException An UnzerApiException is thrown if there is an error returned on API-request.
* @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK.
*/
public function updateWebhook(Webhook $webhook): Webhook;
/**
* Deletes the given Webhook resource.
*
* @param Webhook|string $webhook The webhook object or the id of the webhook to be deleted.
*
* @return Webhook|AbstractUnzerResource|null Null if delete succeeded or the webhook object if not.
*
* @throws UnzerApiException An UnzerApiException is thrown if there is an error returned on API-request.
* @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK.
*/
public function deleteWebhook($webhook);
/**
* Retrieves all registered webhooks and returns them in an array.
*
* @return array An array containing all registered webhooks.
*
* @throws UnzerApiException An UnzerApiException is thrown if there is an error returned on API-request.
* @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK.
*/
public function fetchAllWebhooks(): array;
/**
* Deletes all registered webhooks.
*
* @throws UnzerApiException An UnzerApiException is thrown if there is an error returned on API-request.
* @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK.
*/
public function deleteAllWebhooks();
/**
* Registers multiple Webhook events at once.
*
* @param string $url The url the registered webhook events should be send to.
* @param array $events The events to be registered.
*
* @return array
*
* @throws UnzerApiException An UnzerApiException is thrown if there is an error returned on API-request.
* @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK.
*/
public function registerMultipleWebhooks(string $url, array $events): array;
/**
* Fetches the resource corresponding to the given eventData.
*
* @param string|null $eventJson
*
* @return AbstractUnzerResource
*
* @throws UnzerApiException An UnzerApiException is thrown if there is an error returned on API-request.
* @throws RuntimeException A RuntimeException is thrown when there is an error while using the SDK.
*/
public function fetchResourceFromEvent(?string $eventJson = null): AbstractUnzerResource;
}