Module: Orderspace::Endpoint::Webhooks
- Includes:
- Structs
- Included in:
- Client::WebhooksEndpoint
- Defined in:
- lib/orderspace/endpoint/webhooks.rb
Overview
Contains the methods to interact with the webhooks endpoint.
Instance Method Summary collapse
-
#create(webhook) ⇒ Object
Creates a new webhook.
-
#delete_webhook(webhook) ⇒ Object
Deletes the webhook.
-
#get_webhook(id) ⇒ Object
Gets a webhook by it’s id.
-
#list_webhooks ⇒ Object
Lists all the webhooks you’ve registered.
-
#update_webhook(webhook) ⇒ Object
Updates the current webhook.
Methods included from Structs
Instance Method Details
#create(webhook) ⇒ Object
Creates a new webhook
16 17 18 19 |
# File 'lib/orderspace/endpoint/webhooks.rb', line 16 def create(webhook) response = client.post('webhooks', { webhook: Orderspace::Structs.hashify(webhook) }) parse_webhook response end |
#delete_webhook(webhook) ⇒ Object
Deletes the webhook
50 51 52 |
# File 'lib/orderspace/endpoint/webhooks.rb', line 50 def delete_webhook(webhook) parse_webhook client.delete("webhooks/#{webhook.id}") end |
#get_webhook(id) ⇒ Object
Gets a webhook by it’s id
34 35 36 |
# File 'lib/orderspace/endpoint/webhooks.rb', line 34 def get_webhook(id) parse_webhook client.get("webhooks/#{id}") end |
#list_webhooks ⇒ Object
Lists all the webhooks you’ve registered
25 26 27 28 |
# File 'lib/orderspace/endpoint/webhooks.rb', line 25 def list_webhooks response = client.get('webhooks') Orderspace::Structs.from(JSON.parse(response.body), WebhookList) end |
#update_webhook(webhook) ⇒ Object
Updates the current webhook
42 43 44 |
# File 'lib/orderspace/endpoint/webhooks.rb', line 42 def update_webhook(webhook) parse_webhook client.put("webhooks/#{webhook.id}") end |