Class: Seam::Clients::Webhooks

Inherits:
Object
  • Object
show all
Defined in:
lib/seam/routes/webhooks.rb

Instance Method Summary collapse

Constructor Details

#initialize(client:, defaults:) ⇒ Webhooks

Returns a new instance of Webhooks.



6
7
8
9
# File 'lib/seam/routes/webhooks.rb', line 6

def initialize(client:, defaults:)
  @client = client
  @defaults = defaults
end

Instance Method Details

#create(url:, event_types: nil) ⇒ Seam::Resources::Webhook

Creates a new webhook.

Parameters:

  • url

    URL for the new webhook.

  • event_types (defaults to: nil)

    Types of events that you want the new webhook to receive.

Returns:



15
16
17
18
19
# File 'lib/seam/routes/webhooks.rb', line 15

def create(url:, event_types: nil)
  res = @client.post("/webhooks/create", {url: url, event_types: event_types}.compact)

  Seam::Resources::Webhook.load_from_response(res.body["webhook"])
end

#delete(webhook_id:) ⇒ nil

Deletes a specified webhook.

Parameters:

  • webhook_id

    ID of the webhook that you want to delete.

Returns:

  • (nil)

    OK



24
25
26
27
28
# File 'lib/seam/routes/webhooks.rb', line 24

def delete(webhook_id:)
  @client.post("/webhooks/delete", {webhook_id: webhook_id}.compact)

  nil
end

#get(webhook_id:) ⇒ Seam::Resources::Webhook

Gets a specified webhook.

Parameters:

  • webhook_id

    ID of the webhook that you want to get.

Returns:



33
34
35
36
37
# File 'lib/seam/routes/webhooks.rb', line 33

def get(webhook_id:)
  res = @client.post("/webhooks/get", {webhook_id: webhook_id}.compact)

  Seam::Resources::Webhook.load_from_response(res.body["webhook"])
end

#listSeam::Resources::Webhook

Returns a list of all webhooks.

Returns:



41
42
43
44
45
# File 'lib/seam/routes/webhooks.rb', line 41

def list
  res = @client.post("/webhooks/list")

  Seam::Resources::Webhook.load_from_response(res.body["webhooks"])
end

#update(event_types:, webhook_id:) ⇒ nil

Updates a specified webhook.

Parameters:

  • event_types

    Types of events that you want the webhook to receive.

  • webhook_id

    ID of the webhook that you want to update.

Returns:

  • (nil)

    OK



51
52
53
54
55
# File 'lib/seam/routes/webhooks.rb', line 51

def update(event_types:, webhook_id:)
  @client.post("/webhooks/update", {event_types: event_types, webhook_id: webhook_id}.compact)

  nil
end