Class: Qrdot::WebhooksResource
- Inherits:
-
Object
- Object
- Qrdot::WebhooksResource
- Defined in:
- lib/qrdot/client.rb
Instance Method Summary collapse
- #create(payload) ⇒ Object
- #delete(id) ⇒ Object
-
#initialize(client) ⇒ WebhooksResource
constructor
A new instance of WebhooksResource.
- #list ⇒ Object
- #list_deliveries(id, limit: nil) ⇒ Object
- #replay(id, payload) ⇒ Object
- #test(id, payload = {}) ⇒ Object
- #update(id, patch) ⇒ Object
- #verify_signature(secret, raw_body, header, tolerance_sec: 300) ⇒ Object
Constructor Details
#initialize(client) ⇒ WebhooksResource
Returns a new instance of WebhooksResource.
201 202 203 |
# File 'lib/qrdot/client.rb', line 201 def initialize(client) @c = client end |
Instance Method Details
#create(payload) ⇒ Object
205 206 207 208 209 |
# File 'lib/qrdot/client.rb', line 205 def create(payload) payload = payload.dup payload[:events] ||= payload["events"] || ["qr.scanned"] @c.request("POST", "/v1/webhooks", body: payload) end |
#delete(id) ⇒ Object
219 220 221 |
# File 'lib/qrdot/client.rb', line 219 def delete(id) @c.request("DELETE", "/v1/webhooks/#{URI.encode_www_form_component(id)}") end |
#list ⇒ Object
211 212 213 |
# File 'lib/qrdot/client.rb', line 211 def list @c.request("GET", "/v1/webhooks") end |
#list_deliveries(id, limit: nil) ⇒ Object
227 228 229 230 |
# File 'lib/qrdot/client.rb', line 227 def list_deliveries(id, limit: nil) qs = limit.nil? ? "" : "?limit=#{URI.encode_www_form_component(limit.to_s)}" @c.request("GET", "/v1/webhooks/#{URI.encode_www_form_component(id)}/deliveries#{qs}") end |
#replay(id, payload) ⇒ Object
232 233 234 |
# File 'lib/qrdot/client.rb', line 232 def replay(id, payload) @c.request("POST", "/v1/webhooks/#{URI.encode_www_form_component(id)}/replay", body: payload) end |
#test(id, payload = {}) ⇒ Object
223 224 225 |
# File 'lib/qrdot/client.rb', line 223 def test(id, payload = {}) @c.request("POST", "/v1/webhooks/#{URI.encode_www_form_component(id)}/test", body: payload) end |
#update(id, patch) ⇒ Object
215 216 217 |
# File 'lib/qrdot/client.rb', line 215 def update(id, patch) @c.request("PATCH", "/v1/webhooks/#{URI.encode_www_form_component(id)}", body: patch) end |
#verify_signature(secret, raw_body, header, tolerance_sec: 300) ⇒ Object
236 237 238 |
# File 'lib/qrdot/client.rb', line 236 def verify_signature(secret, raw_body, header, tolerance_sec: 300) Qrdot.verify_webhook_signature(secret, raw_body, header, tolerance_sec: tolerance_sec) end |