Module: Millionsend::Webhooks

Defined in:
lib/millionsend/webhooks.rb

Overview

Webhook endpoints. The signing secret is returned on create and on get.

Class Method Summary collapse

Class Method Details

.create(params) ⇒ Object

POST /webhooks — endpoint, events, signing_secret (optional; pass an existing whsec_ value to keep a receiver verifying unchanged).



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

def create(params)
  Millionsend::Request.new(method: :post, path: "/webhooks", body: params).perform
end

.get(id) ⇒ Object

GET /webhooks/:id — includes signing_secret and previous_secret_expires_at (nil unless a rotation's overlap window is open).



15
16
17
# File 'lib/millionsend/webhooks.rb', line 15

def get(id)
  Millionsend::Request.new(method: :get, path: member_path(id)).perform
end

.list(options = {}) ⇒ Object

GET /webhooks — accepts limit:/after:/before:.



20
21
22
# File 'lib/millionsend/webhooks.rb', line 20

def list(options = {})
  Millionsend::Request.new(method: :get, path: "/webhooks", query: Millionsend::Util.list_query(options)).perform
end

.remove(id) ⇒ Object

DELETE /webhooks/:id



30
31
32
# File 'lib/millionsend/webhooks.rb', line 30

def remove(id)
  Millionsend::Request.new(method: :delete, path: member_path(id)).perform
end

.rotate(id, params = {}) ⇒ Object

POST /webhooks/:id/rotate — signing_secret (optional whsec_ value to bring your own; omitted mints one) and overlap_hours (0..72, default 24) during which deliveries carry both signatures. Returns { object:, id:, signing_secret:, previous_secret_expires_at: }.



38
39
40
# File 'lib/millionsend/webhooks.rb', line 38

def rotate(id, params = {})
  Millionsend::Request.new(method: :post, path: "#{member_path(id)}/rotate", body: params).perform
end

.update(id, params) ⇒ Object

PATCH /webhooks/:id — endpoint, events, status ("enabled"/"disabled").



25
26
27
# File 'lib/millionsend/webhooks.rb', line 25

def update(id, params)
  Millionsend::Request.new(method: :patch, path: member_path(id), body: params).perform
end