Module: Unit::Webhook

Defined in:
lib/unit/models/webhook/webhook.rb,
lib/unit/models/webhook/list_webhook_params.rb,
lib/unit/models/webhook/patch_webhook_request.rb,
lib/unit/models/webhook/create_webhook_request.rb

Defined Under Namespace

Classes: CreateWebhookRequest, ListWebhookParams, PatchWebhookRequest

Constant Summary collapse

WEBHOOK_LIMIT =
100
WEBHOOK_OFFSET =
0

Class Method Summary collapse

Class Method Details

.create_webhook(label:, url:, token:, content_type:, delivery_mode:, include_resources: nil, subscription_type: nil) ⇒ Object

Create a webhook

Parameters:

  • label (String)
  • url (String)
  • token (String)
  • content_type (String)
  • delivery_mode (String)
  • include_resources (Boolean) (defaults to: nil)
    • optional

  • subscription_type (String) (defaults to: nil)
    • optional

See Also:



21
22
23
24
25
26
# File 'lib/unit/models/webhook/webhook.rb', line 21

def create_webhook(label:, url:, token:, content_type:, delivery_mode:,
                   include_resources: nil, subscription_type: nil)
  request = CreateWebhookRequest.new(label, url, token, content_type, delivery_mode,
                                     include_resources, subscription_type)
  Unit::Resource::WebhookResource.create_webhook(request)
end

.disable_webhook(webhook_id:) ⇒ Object

Request to disable a webhook

Parameters:

  • webhook_id (String)

See Also:



75
76
77
# File 'lib/unit/models/webhook/webhook.rb', line 75

def disable_webhook(webhook_id:)
  Unit::Resource::WebhookResource.disable_webhook(webhook_id)
end

.enable_webhook(webhook_id:) ⇒ Object

Request to enable a webhook

Parameters:

  • webhook_id (String)

See Also:



68
69
70
# File 'lib/unit/models/webhook/webhook.rb', line 68

def enable_webhook(webhook_id:)
  Unit::Resource::WebhookResource.enable_webhook(webhook_id)
end

.get_webhook(webhook_id:) ⇒ Object

Request to get a webhook

Parameters:

  • webhook_id (String)

See Also:



61
62
63
# File 'lib/unit/models/webhook/webhook.rb', line 61

def get_webhook(webhook_id:)
  Unit::Resource::WebhookResource.get_webhook(webhook_id)
end

.list_webhooks(limit: WEBHOOK_LIMIT, offset: WEBHOOK_OFFSET, since: nil, until_: nil, from_id: nil, told: nil) ⇒ Object

Request to list webhooks

Parameters:

  • limit (Integer) (defaults to: WEBHOOK_LIMIT)
  • offset (Integer) (defaults to: WEBHOOK_OFFSET)
  • since (String) (defaults to: nil)
    • optional

  • until_ (String) (defaults to: nil)
    • optional

  • from_id (Integer) (defaults to: nil)
    • optional

  • told (Integer) (defaults to: nil)
    • optional

See Also:



36
37
38
39
40
# File 'lib/unit/models/webhook/webhook.rb', line 36

def list_webhooks(limit: WEBHOOK_LIMIT, offset: WEBHOOK_OFFSET, since: nil,
                  until_: nil, from_id: nil, told: nil)
  request = ListWebhookParams.new(limit, offset, since, until_, from_id, told)
  Unit::Resource::WebhookResource.list_webhooks(request)
end

.update_webhook(webhook_id:, label:, url:, content_type:, token:, include_resources: nil, subscription_type: nil) ⇒ Object

Request to patch webhook

Parameters:

  • webhook_id (String)
  • label (String)
  • url (String)
  • content_type (String)
  • token (String)
  • include_resources (Boolean) (defaults to: nil)
    • optional

  • subscription_type (String) (defaults to: nil)
    • optional

See Also:



51
52
53
54
55
56
# File 'lib/unit/models/webhook/webhook.rb', line 51

def update_webhook(webhook_id:, label:, url:, content_type:, token:,
                   include_resources: nil, subscription_type: nil)
  request = PatchWebhookRequest.new(webhook_id, label, url, content_type, token,
                                    include_resources, subscription_type)
  Unit::Resource::WebhookResource.update_webhook(request)
end