Class: FlexOps::Resources::Webhooks
- Inherits:
-
Object
- Object
- FlexOps::Resources::Webhooks
- Defined in:
- lib/flexops/resources/webhooks.rb
Class Method Summary collapse
Instance Method Summary collapse
- #create(request) ⇒ Object
- #delete(webhook_id) ⇒ Object
- #get(webhook_id) ⇒ Object
-
#initialize(http, ws_id_proc) ⇒ Webhooks
constructor
A new instance of Webhooks.
- #list ⇒ Object
- #list_delivery_logs(webhook_id) ⇒ Object
- #rotate_secret(webhook_id) ⇒ Object
- #update(webhook_id, data) ⇒ Object
Constructor Details
#initialize(http, ws_id_proc) ⇒ Webhooks
Returns a new instance of Webhooks.
14 15 16 17 |
# File 'lib/flexops/resources/webhooks.rb', line 14 def initialize(http, ws_id_proc) @http = http @ws_id = ws_id_proc end |
Class Method Details
.verify_signature(payload, signature, secret) ⇒ Object
47 48 49 50 |
# File 'lib/flexops/resources/webhooks.rb', line 47 def self.verify_signature(payload, signature, secret) expected = OpenSSL::HMAC.hexdigest("SHA256", secret, payload) OpenSSL.secure_compare(expected, signature) end |
Instance Method Details
#create(request) ⇒ Object
27 28 29 |
# File 'lib/flexops/resources/webhooks.rb', line 27 def create(request) @http.post("#{ws_path}/webhooks", body: request) end |
#delete(webhook_id) ⇒ Object
35 36 37 |
# File 'lib/flexops/resources/webhooks.rb', line 35 def delete(webhook_id) @http.delete("#{ws_path}/webhooks/#{webhook_id}") end |
#get(webhook_id) ⇒ Object
23 24 25 |
# File 'lib/flexops/resources/webhooks.rb', line 23 def get(webhook_id) @http.get("#{ws_path}/webhooks/#{webhook_id}") end |
#list ⇒ Object
19 20 21 |
# File 'lib/flexops/resources/webhooks.rb', line 19 def list @http.get("#{ws_path}/webhooks") end |
#list_delivery_logs(webhook_id) ⇒ Object
43 44 45 |
# File 'lib/flexops/resources/webhooks.rb', line 43 def list_delivery_logs(webhook_id) @http.get("#{ws_path}/webhooks/#{webhook_id}/deliveries") end |
#rotate_secret(webhook_id) ⇒ Object
39 40 41 |
# File 'lib/flexops/resources/webhooks.rb', line 39 def rotate_secret(webhook_id) @http.post("#{ws_path}/webhooks/#{webhook_id}/rotate-secret") end |
#update(webhook_id, data) ⇒ Object
31 32 33 |
# File 'lib/flexops/resources/webhooks.rb', line 31 def update(webhook_id, data) @http.put("#{ws_path}/webhooks/#{webhook_id}", body: data) end |