Class: Unitpost::Resources::Webhooks

Inherits:
Base
  • Object
show all
Defined in:
lib/unitpost/resources.rb

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from Unitpost::Resources::Base

Instance Method Details

#create(body) ⇒ Object



387
388
389
# File 'lib/unitpost/resources.rb', line 387

def create(body)
  @http.request("POST", "/webhooks", body: body)
end

#delete(id) ⇒ Object



399
400
401
# File 'lib/unitpost/resources.rb', line 399

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

#get(id) ⇒ Object



391
392
393
# File 'lib/unitpost/resources.rb', line 391

def get(id)
  @http.request("GET", "/webhooks/#{enc(id)}")
end

#list(limit: nil, after: nil, before: nil) ⇒ Object



379
380
381
# File 'lib/unitpost/resources.rb', line 379

def list(limit: nil, after: nil, before: nil)
  @http.request("GET", "/webhooks", query: list_params(limit: limit, after: after, before: before))
end

#list_all(**params) ⇒ Object



383
384
385
# File 'lib/unitpost/resources.rb', line 383

def list_all(**params)
  paginate("/webhooks", params)
end

#test(id) ⇒ Object



403
404
405
# File 'lib/unitpost/resources.rb', line 403

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

#update(id, body) ⇒ Object



395
396
397
# File 'lib/unitpost/resources.rb', line 395

def update(id, body)
  @http.request("PATCH", "/webhooks/#{enc(id)}", body: body)
end

#verify(payload:, secret:, headers:, tolerance_seconds: 300) ⇒ Object

Verify a delivery's signature and return the parsed event. Alias of Unitpost.verify_webhook / Unitpost::Webhooks.verify for a Resend-style client.webhooks.verify(...). Raises Unitpost::WebhookVerificationError on a missing/invalid/stale signature.



411
412
413
414
415
416
417
418
# File 'lib/unitpost/resources.rb', line 411

def verify(payload:, secret:, headers:, tolerance_seconds: 300)
  Unitpost::Webhooks.verify(
    payload: payload,
    secret: secret,
    headers: headers,
    tolerance_seconds: tolerance_seconds,
  )
end