File tree Expand file tree Collapse file tree 1 file changed +30
-1
lines changed Expand file tree Collapse file tree 1 file changed +30
-1
lines changed Original file line number Diff line number Diff line change 4
4
5
5
6
6
class SeamWebhook :
7
+ """
8
+ A class to handle Seam webhook verification.
9
+
10
+ This class provides functionality to verify incoming webhook payloads
11
+ using the Svix library.
12
+ """
13
+
7
14
def __init__ (self , secret : str ):
15
+ """
16
+ Initialize the SeamWebhook instance.
17
+
18
+ Args:
19
+ secret (str): The secret key used for webhook verification.
20
+ """
8
21
self ._webhook = Webhook (secret )
9
22
10
23
def verify (self , payload : str , headers : Dict [str , str ]) -> SeamEvent :
24
+ """
25
+ Verify the incoming webhook payload and headers.
26
+
27
+ This method normalizes the headers, verifies the payload using the Svix
28
+ Webhook instance, and returns a SeamEvent object.
29
+
30
+ Args:
31
+ payload (str): The webhook payload as a string.
32
+ headers (Dict[str, str]): A dictionary of HTTP headers.
33
+
34
+ Returns:
35
+ SeamEvent: An instance of SeamEvent created from the verified payload.
36
+
37
+ Raises:
38
+ Any exceptions raised by the Svix Webhook.verify() method.
39
+ """
11
40
normalized_headers = {k .lower (): v for k , v in headers .items ()}
12
41
res = self ._webhook .verify (payload , normalized_headers )
13
42
14
- return SeamEvent .from_dict (res )
43
+ return SeamEvent .from_dict (res )
You can’t perform that action at this time.
0 commit comments