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



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

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



56
57
58
# File 'lib/drip/client/webhooks.rb', line 56

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



19
20
21
# File 'lib/drip/client/webhooks.rb', line 19

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



10
11
12
# File 'lib/drip/client/webhooks.rb', line 10

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