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 https://www.getdrip.com/docs/rest-api#subscriber_batches



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

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 https://www.getdrip.com/docs/rest-api#webhooks



58
59
60
# File 'lib/drip/client/webhooks.rb', line 58

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

#webhook(id) ⇒ Object

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

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



21
22
23
# File 'lib/drip/client/webhooks.rb', line 21

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

#webhooksObject

Public: List all webhooks.

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



12
13
14
# File 'lib/drip/client/webhooks.rb', line 12

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