drip-ruby 3.2.0 → 3.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.rubocop.yml +5 -1
- data/.rubocop_todo.yml +17 -9
- data/.travis.yml +1 -1
- data/CHANGELOG.md +20 -1
- data/Gemfile +10 -0
- data/drip-ruby.gemspec +3 -11
- data/lib/drip/client.rb +44 -66
- data/lib/drip/client/accounts.rb +2 -2
- data/lib/drip/client/broadcasts.rb +2 -2
- data/lib/drip/client/campaign_subscriptions.rb +1 -1
- data/lib/drip/client/campaigns.rb +5 -5
- data/lib/drip/client/configuration.rb +28 -0
- data/lib/drip/client/conversions.rb +2 -2
- data/lib/drip/client/custom_fields.rb +1 -1
- data/lib/drip/client/events.rb +4 -4
- data/lib/drip/client/forms.rb +2 -2
- data/lib/drip/client/http_client.rb +64 -0
- data/lib/drip/client/orders.rb +3 -3
- data/lib/drip/client/shopper_activity.rb +78 -0
- data/lib/drip/client/subscribers.rb +13 -13
- data/lib/drip/client/tags.rb +3 -3
- data/lib/drip/client/webhooks.rb +5 -5
- data/lib/drip/client/workflow_triggers.rb +3 -3
- data/lib/drip/client/workflows.rb +6 -6
- data/lib/drip/request.rb +31 -0
- data/lib/drip/response.rb +13 -13
- data/lib/drip/version.rb +1 -1
- data/test/drip/client/configuration_test.rb +122 -0
- data/test/drip/client/http_client_test.rb +96 -0
- data/test/drip/client/shopper_activity_test.rb +175 -0
- data/test/drip/client_test.rb +32 -97
- data/test/drip/collection_test.rb +14 -0
- data/test/drip/collections/account_test.rb +8 -0
- data/test/drip/collections/broadcasts_test.rb +8 -0
- data/test/drip/collections/campaign_subscriptions_test.rb +8 -0
- data/test/drip/collections/campaigns_test.rb +8 -0
- data/test/drip/collections/errors_test.rb +8 -0
- data/test/drip/collections/orders_test.rb +8 -0
- data/test/drip/collections/purchases_test.rb +8 -0
- data/test/drip/collections/tags_test.rb +8 -0
- data/test/drip/collections/webhooks_test.rb +8 -0
- data/test/drip/collections/workflow_triggers_test.rb +8 -0
- data/test/drip/collections/workflows_test.rb +8 -0
- data/test/drip/request_test.rb +58 -0
- data/test/drip/resource_test.rb +12 -0
- data/test/drip/resources/tag_test.rb +13 -0
- data/test/drip/response_test.rb +33 -0
- data/test/test_helper.rb +3 -0
- metadata +42 -104
@@ -10,7 +10,7 @@ module Drip
|
|
10
10
|
# Returns a Drip::Response.
|
11
11
|
# See https://www.getdrip.com/docs/rest-api#conversions
|
12
12
|
def conversions(options = {})
|
13
|
-
get "
|
13
|
+
make_json_api_request :get, "v2/#{account_id}/goals", options
|
14
14
|
end
|
15
15
|
|
16
16
|
# Public: Fetch a conversion.
|
@@ -20,7 +20,7 @@ module Drip
|
|
20
20
|
# Returns a Drip::Response.
|
21
21
|
# See https://www.getdrip.com/docs/rest-api#conversions
|
22
22
|
def conversion(id)
|
23
|
-
get "
|
23
|
+
make_json_api_request :get, "v2/#{account_id}/goals/#{id}"
|
24
24
|
end
|
25
25
|
end
|
26
26
|
end
|
data/lib/drip/client/events.rb
CHANGED
@@ -14,7 +14,7 @@ module Drip
|
|
14
14
|
# See https://www.getdrip.com/docs/rest-api#record_event
|
15
15
|
def track_event(email, action, properties = {}, options = {})
|
16
16
|
data = options.merge({ "email" => email, "action" => action, "properties" => properties })
|
17
|
-
post "
|
17
|
+
make_json_api_request :post, "v2/#{account_id}/events", private_generate_resource("events", data)
|
18
18
|
end
|
19
19
|
|
20
20
|
# Public: Track a collection of events all at once.
|
@@ -27,8 +27,8 @@ module Drip
|
|
27
27
|
# Returns a Drip::Response.
|
28
28
|
# See https://www.getdrip.com/docs/rest-api#event_batches
|
29
29
|
def track_events(events)
|
30
|
-
url = "
|
31
|
-
post url,
|
30
|
+
url = "v2/#{account_id}/events/batches"
|
31
|
+
make_json_api_request :post, url, private_generate_resource("batches", { "events" => events })
|
32
32
|
end
|
33
33
|
|
34
34
|
# Public: Fetch all custom event actions.
|
@@ -41,7 +41,7 @@ module Drip
|
|
41
41
|
# Returns a Drip::Response.
|
42
42
|
# See https://www.getdrip.com/docs/rest-api#events
|
43
43
|
def event_actions(options = {})
|
44
|
-
get "
|
44
|
+
make_json_api_request :get, "v2/#{account_id}/event_actions", options
|
45
45
|
end
|
46
46
|
end
|
47
47
|
end
|
data/lib/drip/client/forms.rb
CHANGED
@@ -6,7 +6,7 @@ module Drip
|
|
6
6
|
# Returns a Drip::Response.
|
7
7
|
# See https://www.getdrip.com/docs/rest-api#forms
|
8
8
|
def forms
|
9
|
-
get "
|
9
|
+
make_json_api_request :get, "v2/#{account_id}/forms"
|
10
10
|
end
|
11
11
|
|
12
12
|
# Public: Fetch a form.
|
@@ -16,7 +16,7 @@ module Drip
|
|
16
16
|
# Returns a Drip::Response.
|
17
17
|
# See https://www.getdrip.com/docs/rest-api#forms
|
18
18
|
def form(id)
|
19
|
-
get "
|
19
|
+
make_json_api_request :get, "v2/#{account_id}/forms/#{id}"
|
20
20
|
end
|
21
21
|
end
|
22
22
|
end
|
@@ -0,0 +1,64 @@
|
|
1
|
+
module Drip
|
2
|
+
class Client
|
3
|
+
class HTTPClient
|
4
|
+
REDIRECT_LIMIT = 10
|
5
|
+
private_constant :REDIRECT_LIMIT
|
6
|
+
|
7
|
+
def initialize(config)
|
8
|
+
@config = config
|
9
|
+
end
|
10
|
+
|
11
|
+
def make_request(drip_request, redirected_url: nil, step: 0)
|
12
|
+
raise TooManyRedirectsError, 'too many HTTP redirects' if step >= REDIRECT_LIMIT
|
13
|
+
|
14
|
+
uri = redirected_url || drip_request.url.tap do |orig_url|
|
15
|
+
next if drip_request.http_verb != :get
|
16
|
+
|
17
|
+
orig_url.query = URI.encode_www_form(drip_request.options)
|
18
|
+
end
|
19
|
+
|
20
|
+
response = Net::HTTP.start(uri.host, uri.port, connection_options(uri.scheme)) do |http|
|
21
|
+
request = drip_request.verb_klass.new uri
|
22
|
+
request.body = drip_request.body
|
23
|
+
|
24
|
+
add_standard_headers(request)
|
25
|
+
request['Content-Type'] = drip_request.content_type
|
26
|
+
|
27
|
+
http.request request
|
28
|
+
end
|
29
|
+
|
30
|
+
return make_request(drip_request, redirected_url: URI(response["Location"]), step: step + 1) if response.is_a?(Net::HTTPRedirection)
|
31
|
+
|
32
|
+
response
|
33
|
+
end
|
34
|
+
|
35
|
+
private
|
36
|
+
|
37
|
+
def add_standard_headers(request)
|
38
|
+
request['User-Agent'] = "Drip Ruby v#{Drip::VERSION}"
|
39
|
+
request['Accept'] = "*/*"
|
40
|
+
|
41
|
+
if @config.access_token
|
42
|
+
request['Authorization'] = "Bearer #{@config.access_token}"
|
43
|
+
else
|
44
|
+
request.basic_auth @config.api_key, ""
|
45
|
+
end
|
46
|
+
|
47
|
+
request
|
48
|
+
end
|
49
|
+
|
50
|
+
def connection_options(uri_scheme)
|
51
|
+
options = { use_ssl: uri_scheme == "https" }
|
52
|
+
|
53
|
+
if @config.http_open_timeout
|
54
|
+
options[:open_timeout] = @config.http_open_timeout
|
55
|
+
options[:ssl_timeout] = @config.http_open_timeout
|
56
|
+
end
|
57
|
+
|
58
|
+
options[:read_timeout] = @config.http_timeout if @config.http_timeout
|
59
|
+
|
60
|
+
options
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
data/lib/drip/client/orders.rb
CHANGED
@@ -11,7 +11,7 @@ module Drip
|
|
11
11
|
# See https://developer.drip.com/#orders
|
12
12
|
def create_or_update_order(email, options = {})
|
13
13
|
data = options.merge(email: email)
|
14
|
-
post "
|
14
|
+
make_json_api_request :post, "v2/#{account_id}/orders", private_generate_resource("orders", data)
|
15
15
|
end
|
16
16
|
|
17
17
|
# Public: Create or update a batch of orders.
|
@@ -21,7 +21,7 @@ module Drip
|
|
21
21
|
# Returns a Drip::Response.
|
22
22
|
# See https://developer.drip.com/#create-or-update-a-batch-of-orders
|
23
23
|
def create_or_update_orders(orders)
|
24
|
-
post "
|
24
|
+
make_json_api_request :post, "v2/#{account_id}/orders/batches", private_generate_resource("batches", { "orders" => orders })
|
25
25
|
end
|
26
26
|
|
27
27
|
# Public: Create or update a refund.
|
@@ -38,7 +38,7 @@ module Drip
|
|
38
38
|
# Returns a Drip::Response.
|
39
39
|
# See https://developer.drip.com/#create-or-update-a-refund
|
40
40
|
def create_or_update_refund(options)
|
41
|
-
post "
|
41
|
+
make_json_api_request :post, "v2/#{account_id}/refunds", private_generate_resource("refunds", options)
|
42
42
|
end
|
43
43
|
end
|
44
44
|
end
|
@@ -0,0 +1,78 @@
|
|
1
|
+
module Drip
|
2
|
+
class Client
|
3
|
+
module ShopperActivity
|
4
|
+
# Public: Create a cart activity event.
|
5
|
+
#
|
6
|
+
# options - Required. A Hash of additional cart options. Refer to the
|
7
|
+
# Drip API docs for the required schema.
|
8
|
+
#
|
9
|
+
# Returns a Drip::Response.
|
10
|
+
# See https://developer.drip.com/#cart-activity
|
11
|
+
def create_cart_activity_event(data = {})
|
12
|
+
raise ArgumentError, 'email: or person_id: parameter required' if !data.key?(:email) && !data.key?(:person_id)
|
13
|
+
|
14
|
+
%i[provider action cart_id cart_url].each do |key|
|
15
|
+
raise ArgumentError, "#{key}: parameter required" unless data.key?(key)
|
16
|
+
end
|
17
|
+
|
18
|
+
data[:occurred_at] = Time.now.iso8601 unless data.key?(:occurred_at)
|
19
|
+
make_json_request :post, "v3/#{account_id}/shopper_activity/cart", data
|
20
|
+
end
|
21
|
+
|
22
|
+
# Public: Create an order activity event.
|
23
|
+
#
|
24
|
+
# options - Required. A Hash of additional order options. Refer to the
|
25
|
+
# Drip API docs for the required schema.
|
26
|
+
#
|
27
|
+
# Returns a Drip::Response.
|
28
|
+
# See https://developer.drip.com/#order-activity
|
29
|
+
def create_order_activity_event(data = {})
|
30
|
+
raise ArgumentError, 'email: or person_id: parameter required' if !data.key?(:email) && !data.key?(:person_id)
|
31
|
+
|
32
|
+
%i[provider action order_id].each do |key|
|
33
|
+
raise ArgumentError, "#{key}: parameter required" unless data.key?(key)
|
34
|
+
end
|
35
|
+
|
36
|
+
data[:occurred_at] = Time.now.iso8601 unless data.key?(:occurred_at)
|
37
|
+
make_json_request :post, "v3/#{account_id}/shopper_activity/order", data
|
38
|
+
end
|
39
|
+
|
40
|
+
# Public: Create a batch of order activity events.
|
41
|
+
#
|
42
|
+
# records - Required. An array of hashes containing orders attributes.
|
43
|
+
# Refer to the Drip API docs for the required schema.
|
44
|
+
#
|
45
|
+
# Returns a Drip::Response.
|
46
|
+
# See https://developer.drip.com/#create-or-update-a-batch-of-orders
|
47
|
+
def create_order_activity_events(records = [])
|
48
|
+
records.each_with_index do |record, i|
|
49
|
+
raise ArgumentError, "email: or person_id: parameter required in record #{i}" if !record.key?(:email) && !record.key?(:person_id)
|
50
|
+
|
51
|
+
%i[provider action order_id].each do |key|
|
52
|
+
raise ArgumentError, "#{key}: parameter required in record #{i}" unless record.key?(key)
|
53
|
+
end
|
54
|
+
|
55
|
+
record[:occurred_at] = Time.now.iso8601 unless record.key?(:occurred_at)
|
56
|
+
end
|
57
|
+
|
58
|
+
make_json_request :post, "v3/#{account_id}/shopper_activity/order/batch", records
|
59
|
+
end
|
60
|
+
|
61
|
+
# Public: Create a product activity event.
|
62
|
+
#
|
63
|
+
# options - Required. A Hash of additional product options. Refer to the
|
64
|
+
# Drip API docs for the required schema.
|
65
|
+
#
|
66
|
+
# Returns a Drip::Response.
|
67
|
+
# See https://developer.drip.com/#product-activity
|
68
|
+
def create_product_activity_event(data = {})
|
69
|
+
%i[provider action product_id name price].each do |key|
|
70
|
+
raise ArgumentError, "#{key}: parameter required" unless data.key?(key)
|
71
|
+
end
|
72
|
+
|
73
|
+
data[:occurred_at] = Time.now.iso8601 unless data.key?(:occurred_at)
|
74
|
+
make_json_request :post, "v3/#{account_id}/shopper_activity/product", data
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
@@ -16,7 +16,7 @@ module Drip
|
|
16
16
|
# Returns a Drip::Response.
|
17
17
|
# See https://www.getdrip.com/docs/rest-api#list_subscribers
|
18
18
|
def subscribers(options = {})
|
19
|
-
get "
|
19
|
+
make_json_api_request :get, "v2/#{account_id}/subscribers", options
|
20
20
|
end
|
21
21
|
|
22
22
|
# Public: Fetch a subscriber.
|
@@ -26,7 +26,7 @@ module Drip
|
|
26
26
|
# Returns a Drip::Response.
|
27
27
|
# See https://www.getdrip.com/docs/rest-api#fetch_subscriber
|
28
28
|
def subscriber(id_or_email)
|
29
|
-
get "
|
29
|
+
make_json_api_request :get, "v2/#{account_id}/subscribers/#{CGI.escape id_or_email}"
|
30
30
|
end
|
31
31
|
|
32
32
|
# Public: Create or update a subscriber.
|
@@ -51,7 +51,7 @@ module Drip
|
|
51
51
|
data[:email] = args[0] if args[0].is_a? String
|
52
52
|
data.merge!(args.last) if args.last.is_a? Hash
|
53
53
|
raise ArgumentError, 'email: or id: parameter required' if !data.key?(:email) && !data.key?(:id)
|
54
|
-
post "
|
54
|
+
make_json_api_request :post, "v2/#{account_id}/subscribers", private_generate_resource("subscribers", data)
|
55
55
|
end
|
56
56
|
|
57
57
|
# Public: Create or update a collection of subscribers.
|
@@ -70,8 +70,8 @@ module Drip
|
|
70
70
|
# Returns a Drip::Response
|
71
71
|
# See https://www.getdrip.com/docs/rest-api#subscriber_batches
|
72
72
|
def create_or_update_subscribers(subscribers)
|
73
|
-
url = "
|
74
|
-
post url,
|
73
|
+
url = "v2/#{account_id}/subscribers/batches"
|
74
|
+
make_json_api_request :post, url, private_generate_resource("batches", { "subscribers" => subscribers })
|
75
75
|
end
|
76
76
|
|
77
77
|
# Public: Unsubscribe a collection of subscribers.
|
@@ -82,8 +82,8 @@ module Drip
|
|
82
82
|
# Returns a Drip::Response
|
83
83
|
# See https://www.getdrip.com/docs/rest-api#subscriber_batches
|
84
84
|
def unsubscribe_subscribers(subscribers)
|
85
|
-
url = "
|
86
|
-
post url,
|
85
|
+
url = "v2/#{account_id}/unsubscribes/batches"
|
86
|
+
make_json_api_request :post, url, private_generate_resource("batches", { "subscribers" => subscribers })
|
87
87
|
end
|
88
88
|
|
89
89
|
# Public: Unsubscribe a subscriber globally or from a specific campaign.
|
@@ -96,9 +96,9 @@ module Drip
|
|
96
96
|
# Returns a Drip::Response.
|
97
97
|
# See https://www.getdrip.com/docs/rest-api#unsubscribe
|
98
98
|
def unsubscribe(id_or_email, options = {})
|
99
|
-
url = "
|
99
|
+
url = "v2/#{account_id}/subscribers/#{CGI.escape id_or_email}/remove"
|
100
100
|
url += options[:campaign_id] ? "?campaign_id=#{options[:campaign_id]}" : ""
|
101
|
-
post url
|
101
|
+
make_json_api_request :post, url
|
102
102
|
end
|
103
103
|
|
104
104
|
# Public: Subscribe to a campaign.
|
@@ -126,8 +126,8 @@ module Drip
|
|
126
126
|
# See https://www.getdrip.com/docs/rest-api#subscribe
|
127
127
|
def subscribe(email, campaign_id, options = {})
|
128
128
|
data = options.merge("email" => email)
|
129
|
-
url = "
|
130
|
-
post url,
|
129
|
+
url = "v2/#{account_id}/campaigns/#{campaign_id}/subscribers"
|
130
|
+
make_json_api_request :post, url, private_generate_resource("subscribers", data)
|
131
131
|
end
|
132
132
|
|
133
133
|
# Public: Delete a subscriber.
|
@@ -137,7 +137,7 @@ module Drip
|
|
137
137
|
# Returns No Content.
|
138
138
|
# See https://www.getdrip.com/docs/rest-api#fdelete_subscriber
|
139
139
|
def delete_subscriber(id_or_email)
|
140
|
-
delete "
|
140
|
+
make_json_api_request :delete, "v2/#{account_id}/subscribers/#{CGI.escape id_or_email}"
|
141
141
|
end
|
142
142
|
|
143
143
|
# Public: Unsubscribe a subscriber from all mailings.
|
@@ -147,7 +147,7 @@ module Drip
|
|
147
147
|
# Returns No Content.
|
148
148
|
# See https://www.getdrip.com/docs/rest-api#fdelete_subscriber
|
149
149
|
def unsubscribe_from_all(id_or_email)
|
150
|
-
post "
|
150
|
+
make_json_api_request :post, "v2/#{account_id}/subscribers/#{CGI.escape id_or_email}/unsubscribe_all"
|
151
151
|
end
|
152
152
|
end
|
153
153
|
end
|
data/lib/drip/client/tags.rb
CHANGED
@@ -8,7 +8,7 @@ module Drip
|
|
8
8
|
# Returns a Drip::Response.
|
9
9
|
# See https://www.getdrip.com/docs/rest-api#tags
|
10
10
|
def tags
|
11
|
-
get "
|
11
|
+
make_json_api_request :get, "v2/#{account_id}/tags"
|
12
12
|
end
|
13
13
|
|
14
14
|
# Public: Apply a tag to a subscriber.
|
@@ -20,7 +20,7 @@ module Drip
|
|
20
20
|
# See https://www.getdrip.com/docs/rest-api#apply_tag
|
21
21
|
def apply_tag(email, tag)
|
22
22
|
data = { "email" => email, "tag" => tag }
|
23
|
-
post "
|
23
|
+
make_json_api_request :post, "v2/#{account_id}/tags", private_generate_resource("tags", data)
|
24
24
|
end
|
25
25
|
|
26
26
|
# Public: Remove a tag from a subscriber.
|
@@ -31,7 +31,7 @@ module Drip
|
|
31
31
|
# Returns a Drip::Response.
|
32
32
|
# See https://www.getdrip.com/docs/rest-api#remove_tag
|
33
33
|
def remove_tag(email, tag)
|
34
|
-
delete "
|
34
|
+
make_json_api_request :delete, "v2/#{account_id}/subscribers/#{CGI.escape email}/tags/#{CGI.escape tag}"
|
35
35
|
end
|
36
36
|
end
|
37
37
|
end
|
data/lib/drip/client/webhooks.rb
CHANGED
@@ -6,7 +6,7 @@ module Drip
|
|
6
6
|
# Returns a Drip::Response.
|
7
7
|
# See https://www.getdrip.com/docs/rest-api#webhooks
|
8
8
|
def webhooks
|
9
|
-
get "
|
9
|
+
make_json_api_request :get, "v2/#{account_id}/webhooks"
|
10
10
|
end
|
11
11
|
|
12
12
|
# Public: Fetch a webhook
|
@@ -15,7 +15,7 @@ module Drip
|
|
15
15
|
# Returns a Drip::Response.
|
16
16
|
# See https://www.getdrip.com/docs/rest-api#webhooks
|
17
17
|
def webhook(id)
|
18
|
-
get "
|
18
|
+
make_json_api_request :get, "v2/#{account_id}/webhooks/#{id}"
|
19
19
|
end
|
20
20
|
|
21
21
|
# Public: Create a webhook.
|
@@ -34,9 +34,9 @@ module Drip
|
|
34
34
|
# See https://www.getdrip.com/docs/rest-api#subscriber_batches
|
35
35
|
def create_webhook(post_url, include_received_email, events)
|
36
36
|
include_received_email = include_received_email ? true : false
|
37
|
-
url = "
|
37
|
+
url = "v2/#{account_id}/webhooks"
|
38
38
|
|
39
|
-
post url,
|
39
|
+
make_json_api_request :post, url, private_generate_resource(
|
40
40
|
"webhooks",
|
41
41
|
{
|
42
42
|
"post_url" => post_url,
|
@@ -52,7 +52,7 @@ module Drip
|
|
52
52
|
# Returns a Drip::Response.
|
53
53
|
# See https://www.getdrip.com/docs/rest-api#webhooks
|
54
54
|
def delete_webhook(id)
|
55
|
-
delete "
|
55
|
+
make_json_api_request :delete, "v2/#{account_id}/webhooks/#{id}"
|
56
56
|
end
|
57
57
|
end
|
58
58
|
end
|
@@ -7,7 +7,7 @@ module Drip
|
|
7
7
|
# Returns a Drip::Response.
|
8
8
|
# See https://www.getdrip.com/docs/rest-api#workflow_triggers
|
9
9
|
def workflow_triggers(id)
|
10
|
-
get "
|
10
|
+
make_json_api_request :get, "v2/#{account_id}/workflows/#{id}/triggers"
|
11
11
|
end
|
12
12
|
|
13
13
|
# Public: Create a workflow trigger.
|
@@ -22,7 +22,7 @@ module Drip
|
|
22
22
|
# Returns a Drip::Response.
|
23
23
|
# See https://www.getdrip.com/docs/rest-api#workflows
|
24
24
|
def create_workflow_trigger(id, options = {})
|
25
|
-
post "
|
25
|
+
make_json_api_request :post, "v2/#{account_id}/workflows/#{id}/triggers", private_generate_resource("triggers", options)
|
26
26
|
end
|
27
27
|
|
28
28
|
# Public: Update a workflow trigger.
|
@@ -37,7 +37,7 @@ module Drip
|
|
37
37
|
# Returns a Drip::Response.
|
38
38
|
# See https://www.getdrip.com/docs/rest-api#workflows
|
39
39
|
def update_workflow_trigger(id, options = {})
|
40
|
-
put "
|
40
|
+
make_json_api_request :put, "v2/#{account_id}/workflows/#{id}/triggers", private_generate_resource("triggers", options)
|
41
41
|
end
|
42
42
|
end
|
43
43
|
end
|
@@ -12,7 +12,7 @@ module Drip
|
|
12
12
|
# Returns a Drip::Response.
|
13
13
|
# See https://www.getdrip.com/docs/rest-api#workflows
|
14
14
|
def workflows(options = {})
|
15
|
-
get "
|
15
|
+
make_json_api_request :get, "v2/#{account_id}/workflows", options
|
16
16
|
end
|
17
17
|
|
18
18
|
# Public: Fetch a workflow.
|
@@ -21,7 +21,7 @@ module Drip
|
|
21
21
|
# Returns a Drip::Response.
|
22
22
|
# See https://www.getdrip.com/docs/rest-api#workflows
|
23
23
|
def workflow(id)
|
24
|
-
get "
|
24
|
+
make_json_api_request :get, "v2/#{account_id}/workflows/#{id}"
|
25
25
|
end
|
26
26
|
|
27
27
|
# Public: Activate a workflow.
|
@@ -30,7 +30,7 @@ module Drip
|
|
30
30
|
# Returns a Drip::Response.
|
31
31
|
# See https://www.getdrip.com/docs/rest-api#workflows
|
32
32
|
def activate_workflow(id)
|
33
|
-
post "
|
33
|
+
make_json_api_request :post, "v2/#{account_id}/workflows/#{id}/activate"
|
34
34
|
end
|
35
35
|
|
36
36
|
# Public: Pause a workflow.
|
@@ -39,7 +39,7 @@ module Drip
|
|
39
39
|
# Returns a Drip::Response.
|
40
40
|
# See https://www.getdrip.com/docs/rest-api#workflows
|
41
41
|
def pause_workflow(id)
|
42
|
-
post "
|
42
|
+
make_json_api_request :post, "v2/#{account_id}/workflows/#{id}/pause"
|
43
43
|
end
|
44
44
|
|
45
45
|
# Public: Start someone on a workflow.
|
@@ -63,7 +63,7 @@ module Drip
|
|
63
63
|
# Returns a Drip::Response.
|
64
64
|
# See https://www.getdrip.com/docs/rest-api#workflows
|
65
65
|
def start_subscriber_workflow(id, options = {})
|
66
|
-
post "
|
66
|
+
make_json_api_request :post, "v2/#{account_id}/workflows/#{id}/subscribers", private_generate_resource("subscribers", options)
|
67
67
|
end
|
68
68
|
|
69
69
|
# Public: Remove someone from a workflow.
|
@@ -73,7 +73,7 @@ module Drip
|
|
73
73
|
# Returns a Drip::Response.
|
74
74
|
# See https://www.getdrip.com/docs/rest-api#workflows
|
75
75
|
def remove_subscriber_workflow(workflow_id, id_or_email)
|
76
|
-
delete "
|
76
|
+
make_json_api_request :delete, "v2/#{account_id}/workflows/#{workflow_id}/subscribers/#{CGI.escape id_or_email}"
|
77
77
|
end
|
78
78
|
end
|
79
79
|
end
|