webhook_subscriptions_api = client.webhook_subscriptions
WebhookSubscriptionsApi
- List Webhook Event Types
- List Webhook Subscriptions
- Create Webhook Subscription
- Delete Webhook Subscription
- Retrieve Webhook Subscription
- Update Webhook Subscription
- Update Webhook Subscription Signature Key
- Test Webhook Subscription
Lists all webhook event types that can be subscribed to.
def list_webhook_event_types(self,
api_version=None)
Parameter | Type | Tags | Description |
---|---|---|---|
api_version |
str |
Query, Optional | The API version for which to list event types. Setting this field overrides the default version used by the application. |
This method returns a ApiResponse
instance. The body
property of this instance returns the response data which is of type List Webhook Event Types Response
.
result = webhook_subscriptions_api.list_webhook_event_types()
if result.is_success():
print(result.body)
elif result.is_error():
print(result.errors)
Lists all webhook subscriptions owned by your application.
def list_webhook_subscriptions(self,
cursor=None,
include_disabled=False,
sort_order=None,
limit=None)
Parameter | Type | Tags | Description |
---|---|---|---|
cursor |
str |
Query, Optional | A pagination cursor returned by a previous call to this endpoint. Provide this to retrieve the next set of results for your original query. For more information, see Pagination. |
include_disabled |
bool |
Query, Optional | Includes disabled Subscriptions. By default, all enabled Subscriptions are returned. Default: False |
sort_order |
str (Sort Order) |
Query, Optional | Sorts the returned list by when the Subscription was created with the specified order. This field defaults to ASC. |
limit |
int |
Query, Optional | The maximum number of results to be returned in a single page. It is possible to receive fewer results than the specified limit on a given page. The default value of 100 is also the maximum allowed value. Default: 100 |
This method returns a ApiResponse
instance. The body
property of this instance returns the response data which is of type List Webhook Subscriptions Response
.
include_disabled = False
result = webhook_subscriptions_api.list_webhook_subscriptions(
include_disabled=include_disabled
)
if result.is_success():
print(result.body)
elif result.is_error():
print(result.errors)
Creates a webhook subscription.
def create_webhook_subscription(self,
body)
Parameter | Type | Tags | Description |
---|---|---|---|
body |
Create Webhook Subscription Request |
Body, Required | An object containing the fields to POST for the request. See the corresponding object definition for field details. |
This method returns a ApiResponse
instance. The body
property of this instance returns the response data which is of type Create Webhook Subscription Response
.
body = {
'subscription': {
'name': 'Example Webhook Subscription',
'event_types': [
'payment.created',
'payment.updated'
],
'notification_url': 'https://example-webhook-url.com',
'api_version': '2021-12-15'
},
'idempotency_key': '63f84c6c-2200-4c99-846c-2670a1311fbf'
}
result = webhook_subscriptions_api.create_webhook_subscription(body)
if result.is_success():
print(result.body)
elif result.is_error():
print(result.errors)
Deletes a webhook subscription.
def delete_webhook_subscription(self,
subscription_id)
Parameter | Type | Tags | Description |
---|---|---|---|
subscription_id |
str |
Template, Required | [REQUIRED] The ID of the Subscription to delete. |
This method returns a ApiResponse
instance. The body
property of this instance returns the response data which is of type Delete Webhook Subscription Response
.
subscription_id = 'subscription_id0'
result = webhook_subscriptions_api.delete_webhook_subscription(subscription_id)
if result.is_success():
print(result.body)
elif result.is_error():
print(result.errors)
Retrieves a webhook subscription identified by its ID.
def retrieve_webhook_subscription(self,
subscription_id)
Parameter | Type | Tags | Description |
---|---|---|---|
subscription_id |
str |
Template, Required | [REQUIRED] The ID of the Subscription to retrieve. |
This method returns a ApiResponse
instance. The body
property of this instance returns the response data which is of type Retrieve Webhook Subscription Response
.
subscription_id = 'subscription_id0'
result = webhook_subscriptions_api.retrieve_webhook_subscription(subscription_id)
if result.is_success():
print(result.body)
elif result.is_error():
print(result.errors)
Updates a webhook subscription.
def update_webhook_subscription(self,
subscription_id,
body)
Parameter | Type | Tags | Description |
---|---|---|---|
subscription_id |
str |
Template, Required | [REQUIRED] The ID of the Subscription to update. |
body |
Update Webhook Subscription Request |
Body, Required | An object containing the fields to POST for the request. See the corresponding object definition for field details. |
This method returns a ApiResponse
instance. The body
property of this instance returns the response data which is of type Update Webhook Subscription Response
.
subscription_id = 'subscription_id0'
body = {
'subscription': {
'name': 'Updated Example Webhook Subscription',
'enabled': False
}
}
result = webhook_subscriptions_api.update_webhook_subscription(
subscription_id,
body
)
if result.is_success():
print(result.body)
elif result.is_error():
print(result.errors)
Updates a webhook subscription by replacing the existing signature key with a new one.
def update_webhook_subscription_signature_key(self,
subscription_id,
body)
Parameter | Type | Tags | Description |
---|---|---|---|
subscription_id |
str |
Template, Required | [REQUIRED] The ID of the Subscription to update. |
body |
Update Webhook Subscription Signature Key Request |
Body, Required | An object containing the fields to POST for the request. See the corresponding object definition for field details. |
This method returns a ApiResponse
instance. The body
property of this instance returns the response data which is of type Update Webhook Subscription Signature Key Response
.
subscription_id = 'subscription_id0'
body = {
'idempotency_key': 'ed80ae6b-0654-473b-bbab-a39aee89a60d'
}
result = webhook_subscriptions_api.update_webhook_subscription_signature_key(
subscription_id,
body
)
if result.is_success():
print(result.body)
elif result.is_error():
print(result.errors)
Tests a webhook subscription by sending a test event to the notification URL.
def test_webhook_subscription(self,
subscription_id,
body)
Parameter | Type | Tags | Description |
---|---|---|---|
subscription_id |
str |
Template, Required | [REQUIRED] The ID of the Subscription to test. |
body |
Test Webhook Subscription Request |
Body, Required | An object containing the fields to POST for the request. See the corresponding object definition for field details. |
This method returns a ApiResponse
instance. The body
property of this instance returns the response data which is of type Test Webhook Subscription Response
.
subscription_id = 'subscription_id0'
body = {
'event_type': 'payment.created'
}
result = webhook_subscriptions_api.test_webhook_subscription(
subscription_id,
body
)
if result.is_success():
print(result.body)
elif result.is_error():
print(result.errors)