Class: SimpleSpark::Endpoints::Webhooks

Inherits:
Object
  • Object
show all
Defined in:
lib/simple_spark/endpoints/webhooks.rb

Overview

Note:

Example webhook

Provides access to the /webhooks endpoint

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ Webhooks



9
10
11
# File 'lib/simple_spark/endpoints/webhooks.rb', line 9

def initialize(client)
  @client = client
end

Instance Attribute Details

#clientObject

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



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



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



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



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



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