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



377
378
379
# File 'lib/unitpost/resources.rb', line 377

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

#delete(id) ⇒ Object



389
390
391
# File 'lib/unitpost/resources.rb', line 389

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

#get(id) ⇒ Object



381
382
383
# File 'lib/unitpost/resources.rb', line 381

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

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



369
370
371
# File 'lib/unitpost/resources.rb', line 369

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



373
374
375
# File 'lib/unitpost/resources.rb', line 373

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

#test(id) ⇒ Object



393
394
395
# File 'lib/unitpost/resources.rb', line 393

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

#update(id, body) ⇒ Object



385
386
387
# File 'lib/unitpost/resources.rb', line 385

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.



401
402
403
404
405
406
407
408
# File 'lib/unitpost/resources.rb', line 401

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