class SimpleSpark::Endpoints::Webhooks
Provides access to the /webhooks endpoint @note Example webhook @note See: developers.sparkpost.com/api/#/reference/webhooks
Attributes
Public Class Methods
# File lib/simple_spark/endpoints/webhooks.rb, line 9 def initialize(client) @client = client end
Public Instance Methods
Batch status information @param id [String] the ID of the webhook @return [Array] a list of status hash objects @note See: developers.sparkpost.com/api/#/reference/webhooks/batch-status
# File lib/simple_spark/endpoints/webhooks.rb, line 55 def batch_status(id, limit = nil) query_params = limit.nil? ? {} : { limit: limit } @client.call(method: :get, path: "webhooks/#{id}/batch-status", query_values: query_params) end
Create a webhook @param values [Hash] the values to create the webhook with @note See: developers.sparkpost.com/api/#/reference/webhooks/create
# File lib/simple_spark/endpoints/webhooks.rb, line 24 def create(values) @client.call(method: :post, path: 'webhooks', body_values: values) end
Delete a webhook @param id [String] the ID @note See: developers.sparkpost.com/api/#/reference/webhooks/update-and-delete
# File lib/simple_spark/endpoints/webhooks.rb, line 72 def delete(id) @client.call(method: :delete, path: "webhooks/#{id}") end
List currently extant webhooks @return [Array] a list of Webhook hash objects @note See: developers.sparkpost.com/api/#/reference/webhooks/list
# File lib/simple_spark/endpoints/webhooks.rb, line 16 def list(timezone = nil) query_params = timezone.nil? ? {} : { timezone: timezone } @client.call(method: :get, path: 'webhooks', query_values: query_params) end
Retrieve details about a webhook by specifying its id @param id [String] the ID of the webhook @return [Hash] an Webhook hash object @note See: developers.sparkpost.com/api/#/reference/webhooks/retrieve
# File lib/simple_spark/endpoints/webhooks.rb, line 32 def retrieve(id) @client.call(method: :get, path: "webhooks/#{id}") end
Returns sample event data @param events [String] Event types for which to get a sample payload @return [Array] a list of sample event hash objects @note See: developers.sparkpost.com/api/#/reference/webhooks/events-samples
# File lib/simple_spark/endpoints/webhooks.rb, line 64 def samples(events = nil) query_params = events.nil? ? {} : { events: events } @client.call(method: :get, path: 'webhooks/events/samples', query_values: query_params) end
Update a Webhook by its ID @param id [String] the ID of the webhook @param values [Hash] the values to update the webhook with @note See: developers.sparkpost.com/api/#/reference/webhooks/update-and-delete
# File lib/simple_spark/endpoints/webhooks.rb, line 40 def update(id, values) @client.call(method: :put, path: "webhooks/#{id}", body_values: values) end
Validates a Webhook by sending an example message event batch from the Webhooks
API to the target URL @param id [String] the ID of the webhook @note See: developers.sparkpost.com/api/#/reference/webhooks/validate
# File lib/simple_spark/endpoints/webhooks.rb, line 47 def validate(id) @client.call(method: :post, path: "webhooks/#{id}/validate") end