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>

Creates a webhook in the account.

Parameters:

  • account_id (Integer)

    the account ID

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

Returns:

Raises:

See Also:



45
46
47
48
49
50
# File 'lib/dnsimple/client/webhooks.rb', line 45

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>

Deletes a webook from the account.

WARNING: this cannot be undone.

Parameters:

  • account_id (Integer)

    the account ID

  • webhook_id (#to_s)

    The webhook ID

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

Returns:

Raises:

See Also:



82
83
84
85
86
# File 'lib/dnsimple/client/webhooks.rb', line 82

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 (Integer)

    the account ID

  • webhook_id (#to_s)

    The webhook ID

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

Returns:

Raises:

See Also:



63
64
65
66
67
# File 'lib/dnsimple/client/webhooks.rb', line 63

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_webhooks

Lists ALL the webhooks in the account.

Examples:

List all webhooks

client.webhooks.list(1010)

List all webhooks, provide a specific page

client.webhooks.list(1010, page: 2)

List all webhooks, provide sorting policy

client.webhooks.list(1010, sort: "id:asc")

Parameters:

  • account_id (Integer)

    the account ID

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

    the filtering and sorting options

Options Hash (options):

  • :page (Integer)

    current page (pagination)

  • :per_page (Integer)

    number of entries to return (pagination)

  • :sort (String)

    sorting policy

Returns:

Raises:

See Also:



28
29
30
31
32
# File 'lib/dnsimple/client/webhooks.rb', line 28

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

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