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(api_version: nil)
Parameter | Type | Tags | Description |
---|---|---|---|
api_version |
String |
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 data
property in this instance returns the response data which is of type List Webhook Event Types Response Hash
.
result = webhook_subscriptions_api.list_webhook_event_types
if result.success?
puts result.data
elsif result.error?
warn result.errors
end
Lists all webhook subscriptions owned by your application.
def list_webhook_subscriptions(cursor: nil,
include_disabled: false,
sort_order: nil,
limit: nil)
Parameter | Type | Tags | Description |
---|---|---|---|
cursor |
String |
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 |
TrueClass | FalseClass |
Query, Optional | Includes disabled Subscriptions. By default, all enabled Subscriptions are returned. Default: false |
sort_order |
String (Sort Order) |
Query, Optional | Sorts the returned list by when the Subscription was created with the specified order. This field defaults to ASC. |
limit |
Integer |
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 data
property in this instance returns the response data which is of type List Webhook Subscriptions Response Hash
.
include_disabled = false
result = webhook_subscriptions_api.list_webhook_subscriptions(include_disabled: include_disabled)
if result.success?
puts result.data
elsif result.error?
warn result.errors
end
Creates a webhook subscription.
def create_webhook_subscription(body:)
Parameter | Type | Tags | Description |
---|---|---|---|
body |
Create Webhook Subscription Request Hash |
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 data
property in this instance returns the response data which is of type Create Webhook Subscription Response Hash
.
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: body)
if result.success?
puts result.data
elsif result.error?
warn result.errors
end
Deletes a webhook subscription.
def delete_webhook_subscription(subscription_id:)
Parameter | Type | Tags | Description |
---|---|---|---|
subscription_id |
String |
Template, Required | [REQUIRED] The ID of the Subscription to delete. |
This method returns a ApiResponse
instance. The data
property in this instance returns the response data which is of type Delete Webhook Subscription Response Hash
.
subscription_id = 'subscription_id0'
result = webhook_subscriptions_api.delete_webhook_subscription(subscription_id: subscription_id)
if result.success?
puts result.data
elsif result.error?
warn result.errors
end
Retrieves a webhook subscription identified by its ID.
def retrieve_webhook_subscription(subscription_id:)
Parameter | Type | Tags | Description |
---|---|---|---|
subscription_id |
String |
Template, Required | [REQUIRED] The ID of the Subscription to retrieve. |
This method returns a ApiResponse
instance. The data
property in this instance returns the response data which is of type Retrieve Webhook Subscription Response Hash
.
subscription_id = 'subscription_id0'
result = webhook_subscriptions_api.retrieve_webhook_subscription(subscription_id: subscription_id)
if result.success?
puts result.data
elsif result.error?
warn result.errors
end
Updates a webhook subscription.
def update_webhook_subscription(subscription_id:,
body:)
Parameter | Type | Tags | Description |
---|---|---|---|
subscription_id |
String |
Template, Required | [REQUIRED] The ID of the Subscription to update. |
body |
Update Webhook Subscription Request Hash |
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 data
property in this instance returns the response data which is of type Update Webhook Subscription Response Hash
.
subscription_id = 'subscription_id0'
body = {
:subscription => {
:name => 'Updated Example Webhook Subscription',
:enabled => false
}
}
result = webhook_subscriptions_api.update_webhook_subscription(
subscription_id: subscription_id,
body: body
)
if result.success?
puts result.data
elsif result.error?
warn result.errors
end
Updates a webhook subscription by replacing the existing signature key with a new one.
def update_webhook_subscription_signature_key(subscription_id:,
body:)
Parameter | Type | Tags | Description |
---|---|---|---|
subscription_id |
String |
Template, Required | [REQUIRED] The ID of the Subscription to update. |
body |
Update Webhook Subscription Signature Key Request Hash |
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 data
property in this instance returns the response data which is of type Update Webhook Subscription Signature Key Response Hash
.
subscription_id = 'subscription_id0'
body = {
:idempotency_key => 'ed80ae6b-0654-473b-bbab-a39aee89a60d'
}
result = webhook_subscriptions_api.update_webhook_subscription_signature_key(
subscription_id: subscription_id,
body: body
)
if result.success?
puts result.data
elsif result.error?
warn result.errors
end
Tests a webhook subscription by sending a test event to the notification URL.
def test_webhook_subscription(subscription_id:,
body:)
Parameter | Type | Tags | Description |
---|---|---|---|
subscription_id |
String |
Template, Required | [REQUIRED] The ID of the Subscription to test. |
body |
Test Webhook Subscription Request Hash |
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 data
property in this instance returns the response data which is of type Test Webhook Subscription Response Hash
.
subscription_id = 'subscription_id0'
body = {
:event_type => 'payment.created'
}
result = webhook_subscriptions_api.test_webhook_subscription(
subscription_id: subscription_id,
body: body
)
if result.success?
puts result.data
elsif result.error?
warn result.errors
end