Skip to content

Latest commit

 

History

History
340 lines (236 loc) · 10.7 KB

webhook-subscriptions.md

File metadata and controls

340 lines (236 loc) · 10.7 KB

Webhook Subscriptions

webhook_subscriptions_api = client.webhook_subscriptions

Class Name

WebhookSubscriptionsApi

Methods

List Webhook Event Types

Lists all webhook event types that can be subscribed to.

def list_webhook_event_types(self,
                            api_version=None)

Parameters

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.

Response Type

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.

Example Usage

result = webhook_subscriptions_api.list_webhook_event_types()
print(result)

if result.is_success():
    print(result.body)
elif result.is_error():
    print(result.errors)

List Webhook Subscriptions

Lists all webhook subscriptions owned by your application.

def list_webhook_subscriptions(self,
                              cursor=None,
                              include_disabled=False,
                              sort_order=None,
                              limit=None)

Parameters

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.
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

Response Type

This method returns a ApiResponse instance. The body property of this instance returns the response data which is of type List Webhook Subscriptions Response.

Example Usage

include_disabled = False

result = webhook_subscriptions_api.list_webhook_subscriptions(
    include_disabled=include_disabled
)
print(result)

if result.is_success():
    print(result.body)
elif result.is_error():
    print(result.errors)

Create Webhook Subscription

Creates a webhook subscription.

def create_webhook_subscription(self,
                               body)

Parameters

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.

Response Type

This method returns a ApiResponse instance. The body property of this instance returns the response data which is of type Create Webhook Subscription Response.

Example Usage

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)
print(result)

if result.is_success():
    print(result.body)
elif result.is_error():
    print(result.errors)

Delete Webhook Subscription

Deletes a webhook subscription.

def delete_webhook_subscription(self,
                               subscription_id)

Parameters

Parameter Type Tags Description
subscription_id str Template, Required [REQUIRED] The ID of the Subscription to delete.

Response Type

This method returns a ApiResponse instance. The body property of this instance returns the response data which is of type Delete Webhook Subscription Response.

Example Usage

subscription_id = 'subscription_id0'

result = webhook_subscriptions_api.delete_webhook_subscription(subscription_id)
print(result)

if result.is_success():
    print(result.body)
elif result.is_error():
    print(result.errors)

Retrieve Webhook Subscription

Retrieves a webhook subscription identified by its ID.

def retrieve_webhook_subscription(self,
                                 subscription_id)

Parameters

Parameter Type Tags Description
subscription_id str Template, Required [REQUIRED] The ID of the Subscription to retrieve.

Response Type

This method returns a ApiResponse instance. The body property of this instance returns the response data which is of type Retrieve Webhook Subscription Response.

Example Usage

subscription_id = 'subscription_id0'

result = webhook_subscriptions_api.retrieve_webhook_subscription(subscription_id)
print(result)

if result.is_success():
    print(result.body)
elif result.is_error():
    print(result.errors)

Update Webhook Subscription

Updates a webhook subscription.

def update_webhook_subscription(self,
                               subscription_id,
                               body)

Parameters

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.

Response Type

This method returns a ApiResponse instance. The body property of this instance returns the response data which is of type Update Webhook Subscription Response.

Example Usage

subscription_id = 'subscription_id0'

body = {
    'subscription': {
        'name': 'Updated Example Webhook Subscription',
        'enabled': False
    }
}

result = webhook_subscriptions_api.update_webhook_subscription(
    subscription_id,
    body
)
print(result)

if result.is_success():
    print(result.body)
elif result.is_error():
    print(result.errors)

Update Webhook Subscription Signature Key

Updates a webhook subscription by replacing the existing signature key with a new one.

def update_webhook_subscription_signature_key(self,
                                             subscription_id,
                                             body)

Parameters

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.

Response Type

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.

Example Usage

subscription_id = 'subscription_id0'

body = {
    'idempotency_key': 'ed80ae6b-0654-473b-bbab-a39aee89a60d'
}

result = webhook_subscriptions_api.update_webhook_subscription_signature_key(
    subscription_id,
    body
)
print(result)

if result.is_success():
    print(result.body)
elif result.is_error():
    print(result.errors)

Test Webhook Subscription

Tests a webhook subscription by sending a test event to the notification URL.

def test_webhook_subscription(self,
                             subscription_id,
                             body)

Parameters

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.

Response Type

This method returns a ApiResponse instance. The body property of this instance returns the response data which is of type Test Webhook Subscription Response.

Example Usage

subscription_id = 'subscription_id0'

body = {
    'event_type': 'payment.created'
}

result = webhook_subscriptions_api.test_webhook_subscription(
    subscription_id,
    body
)
print(result)

if result.is_success():
    print(result.body)
elif result.is_error():
    print(result.errors)