Class: Calendlyr::WebhookResource

Inherits:
Resource
  • Object
show all
Defined in:
lib/calendlyr/resources/webhooks.rb

Constant Summary

Constants inherited from Resource

Resource::ERROR_CODES

Instance Attribute Summary

Attributes inherited from Resource

#client

Instance Method Summary collapse

Methods inherited from Resource

#initialize

Constructor Details

This class inherits a constructor from Calendlyr::Resource

Instance Method Details

#create(url:, events:, organization_uri:, scope:, signing_key: nil, user_uri: nil) ⇒ Object



8
9
10
11
# File 'lib/calendlyr/resources/webhooks.rb', line 8

def create(url:, events:, organization_uri:, scope:, signing_key: nil, user_uri: nil)
  body = {url: url, events: events, organization: organization_uri, user: user_uri, scope: scope, signing_key: signing_key}.compact
  Webhook.new post_request("webhook_subscriptions", body: body).dig("resource").merge(client: client)
end

#delete(webhook_uuid:) ⇒ Object



17
18
19
# File 'lib/calendlyr/resources/webhooks.rb', line 17

def delete(webhook_uuid:)
  delete_request("webhook_subscriptions/#{webhook_uuid}")
end

#list(organization_uri:, scope:, **params) ⇒ Object



3
4
5
6
# File 'lib/calendlyr/resources/webhooks.rb', line 3

def list(organization_uri:, scope:, **params)
  response = get_request("webhook_subscriptions", params: {organization: organization_uri, scope: scope}.merge(params).compact)
  Collection.from_response(response, key: "collection", type: Webhook, client: client)
end

#retrieve(webhook_uuid:) ⇒ Object



13
14
15
# File 'lib/calendlyr/resources/webhooks.rb', line 13

def retrieve(webhook_uuid:)
  Webhook.new get_request("webhook_subscriptions/#{webhook_uuid}").dig("resource").merge(client: client)
end