Module: Drip::Client::Webhooks

Included in:
Drip::Client
Defined in:
lib/drip/client/webhooks.rb

Instance Method Summary collapse

Instance Method Details

#create_webhook(post_url, include_received_email, events) ⇒ Object

Public: Create a webhook.

post_url - Required. The String url that the webhook will post to. include_received_email - Optional. A Boolean specifying whether we should send a

notification whenever a subscriber receives an email.
Defaults to false.

events - Optional. An Array of which events we should send

notifications for. Eligible events can be found in the
webhooks documentation here: https://www.getdrip.com/docs/webhooks#events.
By default, we will send notifications for all events except
`subscrber.received_email`.

Returns a Drip::Response See www.getdrip.com/docs/rest-api#subscriber_batches



35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/drip/client/webhooks.rb', line 35

def create_webhook(post_url, include_received_email, events)
  include_received_email = include_received_email ? true : false
  url = "v2/#{}/webhooks"

  make_json_api_request :post, url, private_generate_resource(
    "webhooks",
    {
      "post_url" => post_url,
      "include_received_email" => include_received_email,
      "events" => events
    }
  )
end

#delete_webhook(id) ⇒ Object

Public: List all webhooks. id - Required. The String id of the webhook

Returns a Drip::Response. See www.getdrip.com/docs/rest-api#webhooks



54
55
56
# File 'lib/drip/client/webhooks.rb', line 54

def delete_webhook(id)
  make_json_api_request :delete, "v2/#{}/webhooks/#{id}"
end

#webhook(id) ⇒ Object

Public: Fetch a webhook id - Required. The String id of the webhook

Returns a Drip::Response. See www.getdrip.com/docs/rest-api#webhooks



17
18
19
# File 'lib/drip/client/webhooks.rb', line 17

def webhook(id)
  make_json_api_request :get, "v2/#{}/webhooks/#{id}"
end

#webhooksObject

Public: List all webhooks.

Returns a Drip::Response. See www.getdrip.com/docs/rest-api#webhooks



8
9
10
# File 'lib/drip/client/webhooks.rb', line 8

def webhooks
  make_json_api_request :get, "v2/#{}/webhooks"
end