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

Methods included from Structs

from, hashify, validate

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

Parameters:



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

Parameters:

  • id (String)

    the id of the webhook



34
35
36
# File 'lib/orderspace/endpoint/webhooks.rb', line 34

def get_webhook(id)
  parse_webhook client.get("webhooks/#{id}")
end

#list_webhooksObject

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

Parameters:



42
43
44
# File 'lib/orderspace/endpoint/webhooks.rb', line 42

def update_webhook(webhook)
  parse_webhook client.put("webhooks/#{webhook.id}")
end