Class: AccessGrid::Webhooks

Inherits:
Object
  • Object
show all
Defined in:
lib/accessgrid/console.rb

Overview

Manages webhook operations.

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ Webhooks

Returns a new instance of Webhooks.



329
330
331
# File 'lib/accessgrid/console.rb', line 329

def initialize(client)
  @client = client
end

Instance Method Details

#create(name:, url:, subscribed_events:, auth_method: 'bearer_token') ⇒ Object



333
334
335
336
337
338
339
340
341
342
# File 'lib/accessgrid/console.rb', line 333

def create(name:, url:, subscribed_events:, auth_method: 'bearer_token')
  data = {
    name: name,
    url: url,
    subscribed_events: subscribed_events,
    auth_method: auth_method
  }
  response = @client.make_request(:post, '/v1/console/webhooks', data)
  Webhook.new(response)
end

#delete(webhook_id) ⇒ Object



349
350
351
# File 'lib/accessgrid/console.rb', line 349

def delete(webhook_id)
  @client.make_request(:delete, "/v1/console/webhooks/#{webhook_id}")
end

#list(**params) ⇒ Object



344
345
346
347
# File 'lib/accessgrid/console.rb', line 344

def list(**params)
  response = @client.make_request(:get, '/v1/console/webhooks', nil, params)
  (response['webhooks'] || []).map { |wh| Webhook.new(wh) }
end