Skip to content

Commit 0d87a66

Browse files
committed
adds webhook status patch
1 parent 16a4e1a commit 0d87a66

File tree

3 files changed

+22
-0
lines changed

3 files changed

+22
-0
lines changed

method/resource.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,10 @@ def _update_with_id(self, _id: str, data: Dict) -> MethodResponse[T]:
238238
def _update(self, data: Dict) -> MethodResponse[T]:
239239
return self._make_request('PUT', data=data)
240240

241+
@MethodError.catch
242+
def _patch_with_id(self, _id: str, data: Dict) -> MethodResponse[T]:
243+
return self._make_request('PATCH', path=_id, data=data)
244+
241245
@MethodError.catch
242246
def _update_with_sub_path(self, path: str, data: Dict) -> MethodResponse[T]:
243247
return self._make_request('PUT', path=path, data=data)

method/resources/Webhook.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,10 @@ class WebhookCreateOpts(TypedDict):
8989
expand_event: Optional[bool]
9090

9191

92+
class WebhookUpdateOpts(TypedDict):
93+
status: Optional[str]
94+
95+
9296
class WebhookResource(Resource):
9397
def __init__(self, config: Configuration):
9498
super(WebhookResource, self).__init__(config.add_path('webhooks'))
@@ -105,3 +109,6 @@ def list(self) -> MethodResponse[List[Webhook]]:
105109

106110
def create(self, opts: WebhookCreateOpts, request_opts: Optional[RequestOpts] = None) -> MethodResponse[Webhook]:
107111
return super(WebhookResource, self)._create(opts, request_opts)
112+
113+
def update(self, _id: str, opts: WebhookUpdateOpts) -> MethodResponse[Webhook]:
114+
return super(WebhookResource, self)._patch_with_id(_id, opts)

test/resources/Webhook_test.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
webhooks_retrieve_response = None
1313
webhooks_list_response = None
1414
webhooks_delete_response = None
15+
webhooks_update_response = None
1516

1617
def test_create_webhooks():
1718
global webhooks_create_response
@@ -66,6 +67,16 @@ def test_list_webhooks():
6667
assert webhooks_create_response['id'] in webhook_ids
6768

6869

70+
def test_update_webhook():
71+
global webhooks_update_response
72+
73+
webhooks_update_response = method.webhooks.update(webhooks_create_response['id'], {
74+
'status': 'disabled'
75+
})
76+
77+
assert webhooks_update_response['status'] == 'disabled'
78+
79+
6980
def test_delete_webhook():
7081
global webhooks_delete_response
7182

0 commit comments

Comments
 (0)