Module: Dnsimple::Client::Webhooks

Included in:
WebhooksService
Defined in:
lib/dnsimple/client/webhooks.rb

Instance Method Summary collapse

Instance Method Details

#create_webhook(account_id, attributes, options = {}) ⇒ Dnsimple::Response<Dnsimple::Struct::Webhook> Also known as: create

Creates a webhook in the account.

Parameters:

  • account_id (Fixnum)

    the account ID

  • attributes (Hash)
  • options (Hash) (defaults to: {})

Returns:

Raises:

See Also:



35
36
37
38
39
40
# File 'lib/dnsimple/client/webhooks.rb', line 35

def create_webhook(, attributes, options = {})
  Extra.validate_mandatory_attributes(attributes, [:url])
  response = client.post(Client.versioned("/%s/webhooks" % []), attributes, options)

  Dnsimple::Response.new(response, Struct::Webhook.new(response["data"]))
end

#delete_webhook(account_id, webhook_id, options = {}) ⇒ Dnsimple::Response<nil> Also known as: delete

Deletes a webook from the account.

WARNING: this cannot be undone.

Parameters:

  • account_id (Fixnum)

    the account ID

  • webhook_id (#to_s)

    The webhook ID

  • options (Hash) (defaults to: {})

Returns:

Raises:

See Also:



73
74
75
76
77
# File 'lib/dnsimple/client/webhooks.rb', line 73

def delete_webhook(, webhook_id, options = {})
  response = client.delete(Client.versioned("/%s/webhooks/%s" % [, webhook_id]), nil, options)

  Dnsimple::Response.new(response, nil)
end

#webhook(account_id, webhook_id, options = {}) ⇒ Dnsimple::Response<Dnsimple::Struct::Webhook>

Gets a webhook from the account.

Parameters:

  • account_id (Fixnum)

    the account ID

  • webhook_id (#to_s)

    The webhook ID

  • options (Hash) (defaults to: {})

Returns:

Raises:

See Also:



54
55
56
57
58
# File 'lib/dnsimple/client/webhooks.rb', line 54

def webhook(, webhook_id, options = {})
  response = client.get(Client.versioned("/%s/webhooks/%s" % [, webhook_id]), options)

  Dnsimple::Response.new(response, Struct::Webhook.new(response["data"]))
end

#webhooks(account_id, options = {}) ⇒ Dnsimple::CollectionResponse<Dnsimple::Struct::Webhook> Also known as: list, list_webhooks

Lists ALL the webhooks in the account.

Examples:

List all webhooks

client.webhooks.list(1010)

Parameters:

  • account_id (Fixnum)

    the account ID

  • options (Hash) (defaults to: {})

    the filtering and sorting option

Returns:

Raises:

See Also:



17
18
19
20
21
# File 'lib/dnsimple/client/webhooks.rb', line 17

def webhooks(, options = {})
  response = client.get(Client.versioned("/%s/webhooks" % []), options)

  Dnsimple::CollectionResponse.new(response, response["data"].map { |r| Struct::Webhook.new(r) })
end