Class: SimpleSpark::Endpoints::Webhooks
- Inherits:
-
Object
- Object
- SimpleSpark::Endpoints::Webhooks
- Defined in:
- lib/simple_spark/endpoints/webhooks.rb
Overview
Example webhook
Provides access to the /webhooks endpoint
Instance Attribute Summary collapse
-
#client ⇒ Object
Returns the value of attribute client.
Instance Method Summary collapse
-
#batch_status(id, limit = nil) ⇒ Array
Batch status information.
-
#create(values) ⇒ Object
Create a webhook.
-
#delete(id) ⇒ Object
Delete a webhook.
-
#initialize(client) ⇒ Webhooks
constructor
A new instance of Webhooks.
-
#list(timezone = nil) ⇒ Array
List currently extant webhooks.
-
#retrieve(id) ⇒ Hash
Retrieve details about a webhook by specifying its id.
-
#samples(events = nil) ⇒ Array
Returns sample event data.
-
#update(id, values) ⇒ Object
Update a Webhook by its ID.
-
#validate(id) ⇒ Object
Validates a Webhook by sending an example message event batch from the Webhooks API to the target URL.
Constructor Details
#initialize(client) ⇒ Webhooks
Returns a new instance of Webhooks.
9 10 11 |
# File 'lib/simple_spark/endpoints/webhooks.rb', line 9 def initialize(client) @client = client end |
Instance Attribute Details
#client ⇒ Object
Returns the value of attribute client.
7 8 9 |
# File 'lib/simple_spark/endpoints/webhooks.rb', line 7 def client @client end |
Instance Method Details
#batch_status(id, limit = nil) ⇒ Array
Batch status information
55 56 57 58 |
# 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) ⇒ Object
Create a webhook
24 25 26 |
# File 'lib/simple_spark/endpoints/webhooks.rb', line 24 def create(values) @client.call(method: :post, path: 'webhooks', body_values: values) end |
#delete(id) ⇒ Object
Delete a webhook
72 73 74 |
# File 'lib/simple_spark/endpoints/webhooks.rb', line 72 def delete(id) @client.call(method: :delete, path: "webhooks/#{id}") end |
#list(timezone = nil) ⇒ Array
List currently extant webhooks
16 17 18 19 |
# 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) ⇒ Hash
Retrieve details about a webhook by specifying its id
32 33 34 |
# File 'lib/simple_spark/endpoints/webhooks.rb', line 32 def retrieve(id) @client.call(method: :get, path: "webhooks/#{id}") end |
#samples(events = nil) ⇒ Array
Returns sample event data
64 65 66 67 |
# 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) ⇒ Object
Update a Webhook by its ID
40 41 42 |
# 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) ⇒ Object
Validates a Webhook by sending an example message event batch from the Webhooks API to the target URL
47 48 49 |
# File 'lib/simple_spark/endpoints/webhooks.rb', line 47 def validate(id) @client.call(method: :post, path: "webhooks/#{id}/validate") end |