class SimpleSpark::Endpoints::Webhooks

Provides access to the /webhooks endpoint @note Example webhook @note See: developers.sparkpost.com/api/#/reference/webhooks

Attributes

client[RW]

Public Class Methods

new(client) click to toggle source
# File lib/simple_spark/endpoints/webhooks.rb, line 9
def initialize(client)
  @client = client
end

Public Instance Methods

batch_status(id, limit = nil) click to toggle source

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(values) click to toggle source

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(id) click to toggle source

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(timezone = nil) click to toggle source

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(id) click to toggle source

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
samples(events = nil) click to toggle source

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(id, values) click to toggle source

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
validate(id) click to toggle source

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