Class: Posthubify::WebhooksResource

Inherits:
Object
  • Object
show all
Defined in:
lib/posthubify/resources/platform.rb

Overview

Webhook subscriptions (Node sdk .webhooks).

Instance Method Summary collapse

Constructor Details

#initialize(http) ⇒ WebhooksResource

Returns a new instance of WebhooksResource.



6
7
8
# File 'lib/posthubify/resources/platform.rb', line 6

def initialize(http)
  @http = http
end

Instance Method Details

#create(input) ⇒ Object

Create a new webhook (empty events → all events; store the secret from the response).



16
17
18
# File 'lib/posthubify/resources/platform.rb', line 16

def create(input)
  @http.data('POST', '/webhooks', body: input)
end

#delete(id) ⇒ Object

Delete a webhook.



26
27
28
# File 'lib/posthubify/resources/platform.rb', line 26

def delete(id)
  @http.data('DELETE', "/webhooks/#{id}")
end

#listObject

List all webhooks.



11
12
13
# File 'lib/posthubify/resources/platform.rb', line 11

def list
  @http.data('GET', '/webhooks')
end

#logs(limit: nil, status: nil) ⇒ Object

Delivery attempts (newest first).



36
37
38
# File 'lib/posthubify/resources/platform.rb', line 36

def logs(limit: nil, status: nil)
  @http.data('GET', '/webhooks/logs', query: { 'limit' => limit, 'status' => status })
end

#test(id) ⇒ Object

Send a signed webhook.test delivery — setup verification.



31
32
33
# File 'lib/posthubify/resources/platform.rb', line 31

def test(id)
  @http.data('POST', "/webhooks/#{id}/test")
end

#update(id, input) ⇒ Object

Update a webhook (url/events/isActive).



21
22
23
# File 'lib/posthubify/resources/platform.rb', line 21

def update(id, input)
  @http.data('PATCH', "/webhooks/#{id}", body: input)
end