drip-ruby 3.4.1 → 3.5.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/.github/pull_request_template.md +39 -0
- data/.github/workflows/ci.yml +35 -0
- data/.rubocop.yml +27 -6
- data/.rubocop_todo.yml +1 -97
- data/CHANGELOG.md +48 -1
- data/Gemfile +9 -8
- data/README.md +1 -2
- data/drip-ruby.gemspec +4 -4
- data/flake.lock +61 -0
- data/flake.nix +32 -0
- data/lib/drip/client/accounts.rb +3 -1
- data/lib/drip/client/broadcasts.rb +3 -1
- data/lib/drip/client/campaign_subscriptions.rb +3 -1
- data/lib/drip/client/campaigns.rb +6 -4
- data/lib/drip/client/configuration.rb +9 -1
- data/lib/drip/client/conversions.rb +3 -1
- data/lib/drip/client/forms.rb +3 -1
- data/lib/drip/client/http_client.rb +30 -11
- data/lib/drip/client/orders.rb +1 -1
- data/lib/drip/client/shopper_activity.rb +26 -2
- data/lib/drip/client/subscribers.rb +18 -5
- data/lib/drip/client/webhooks.rb +4 -2
- data/lib/drip/client/workflow_triggers.rb +5 -3
- data/lib/drip/client/workflows.rb +5 -5
- data/lib/drip/client.rb +3 -3
- data/lib/drip/collection.rb +2 -2
- data/lib/drip/resource.rb +6 -6
- data/lib/drip/resources/tag.rb +0 -5
- data/lib/drip/response.rb +21 -18
- data/lib/drip/version.rb +1 -1
- data/test/drip/client/accounts_test.rb +18 -2
- data/test/drip/client/broadcasts_test.rb +2 -2
- data/test/drip/client/campaign_subscriptions_test.rb +1 -1
- data/test/drip/client/campaigns_test.rb +5 -5
- data/test/drip/client/configuration_test.rb +14 -1
- data/test/drip/client/conversions_test.rb +2 -2
- data/test/drip/client/custom_fields_test.rb +1 -1
- data/test/drip/client/events_test.rb +1 -1
- data/test/drip/client/forms_test.rb +2 -2
- data/test/drip/client/http_client_test.rb +32 -2
- data/test/drip/client/orders_test.rb +1 -1
- data/test/drip/client/shopper_activity_test.rb +35 -1
- data/test/drip/client/subscribers_test.rb +45 -2
- data/test/drip/client/tags_test.rb +1 -1
- data/test/drip/client/users_test.rb +1 -1
- data/test/drip/client/webhooks_test.rb +1 -1
- data/test/drip/client/workflow_triggers_test.rb +2 -2
- data/test/drip/client/workflows_test.rb +18 -2
- data/test/drip/client_test.rb +8 -6
- data/test/drip/collection_test.rb +1 -1
- data/test/drip/collections/account_test.rb +1 -1
- data/test/drip/collections/broadcasts_test.rb +1 -1
- data/test/drip/collections/campaign_subscriptions_test.rb +1 -1
- data/test/drip/collections/campaigns_test.rb +1 -1
- data/test/drip/collections/errors_test.rb +1 -1
- data/test/drip/collections/orders_test.rb +1 -1
- data/test/drip/collections/purchases_test.rb +1 -1
- data/test/drip/collections/tags_test.rb +1 -1
- data/test/drip/collections/webhooks_test.rb +1 -1
- data/test/drip/collections/workflow_triggers_test.rb +1 -1
- data/test/drip/collections/workflows_test.rb +1 -1
- data/test/drip/collections_test.rb +1 -1
- data/test/drip/request_test.rb +1 -1
- data/test/drip/resource_test.rb +1 -1
- data/test/drip/resources/account_test.rb +1 -1
- data/test/drip/resources/order_test.rb +1 -1
- data/test/drip/resources/subscriber_test.rb +1 -1
- data/test/drip/resources/tag_test.rb +1 -1
- data/test/drip/resources_test.rb +1 -1
- data/test/drip/response_test.rb +1 -1
- data/test/test_helper.rb +2 -2
- metadata +11 -53
- data/.travis.yml +0 -7
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
require_relative '../../test_helper'
|
|
4
4
|
|
|
5
5
|
class Drip::Client::ShopperActivityTest < Drip::TestCase
|
|
6
6
|
def setup
|
|
@@ -186,4 +186,38 @@ class Drip::Client::ShopperActivityTest < Drip::TestCase
|
|
|
186
186
|
assert_raises(ArgumentError) { @client.create_product_activity_event(@options) }
|
|
187
187
|
end
|
|
188
188
|
end
|
|
189
|
+
|
|
190
|
+
context "#create_checkout_activity_event" do
|
|
191
|
+
setup do
|
|
192
|
+
@email = "drippy@drip.com"
|
|
193
|
+
@options = {
|
|
194
|
+
email: @email,
|
|
195
|
+
provider: "shopify",
|
|
196
|
+
action: "created",
|
|
197
|
+
occurred_at: "2019-01-28T12:15:23Z",
|
|
198
|
+
checkout_id: "B01J4",
|
|
199
|
+
total_price: 11.16
|
|
200
|
+
}
|
|
201
|
+
@response_status = 202
|
|
202
|
+
@response_body = "{}"
|
|
203
|
+
|
|
204
|
+
stub_request(:post, "https://api.getdrip.com/v3/12345/shopper_activity/checkout").
|
|
205
|
+
with(headers: { "Content-Type" => "application/json" }).
|
|
206
|
+
to_return(status: @response_status, body: @response_body, headers: {})
|
|
207
|
+
end
|
|
208
|
+
|
|
209
|
+
should "send the right request" do
|
|
210
|
+
expected = Drip::Response.new(@response_status, JSON.parse(@response_body))
|
|
211
|
+
assert_equal expected, @client.create_checkout_activity_event(@options)
|
|
212
|
+
end
|
|
213
|
+
|
|
214
|
+
should "return error with missing fields" do
|
|
215
|
+
%i[provider action checkout_id].each do |key|
|
|
216
|
+
params = @options.dup
|
|
217
|
+
params.delete(key)
|
|
218
|
+
|
|
219
|
+
assert_raises(ArgumentError) { @client.create_checkout_activity_event(params) }
|
|
220
|
+
end
|
|
221
|
+
end
|
|
222
|
+
end
|
|
189
223
|
end
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
require_relative '../../test_helper'
|
|
4
4
|
|
|
5
5
|
class Drip::Client::SubscribersTest < Drip::TestCase
|
|
6
6
|
def setup
|
|
@@ -81,9 +81,15 @@ class Drip::Client::SubscribersTest < Drip::TestCase
|
|
|
81
81
|
|
|
82
82
|
should "allow request with drip id keyword argument" do
|
|
83
83
|
expected = Drip::Response.new(@response_status, JSON.parse(@response_body))
|
|
84
|
-
assert_equal expected, @client.create_or_update_subscriber(id:
|
|
84
|
+
assert_equal expected, @client.create_or_update_subscriber(id: 123_456)
|
|
85
85
|
assert_requested :post, "https://api.getdrip.com/v2/12345/subscribers", body: '{"subscribers":[{"id":123456}]}', times: 1
|
|
86
86
|
end
|
|
87
|
+
|
|
88
|
+
should "allow request with bigcommerce_subscriber_id keyword argument" do
|
|
89
|
+
expected = Drip::Response.new(@response_status, JSON.parse(@response_body))
|
|
90
|
+
assert_equal expected, @client.create_or_update_subscriber(external_ids: { "bigcommerce_subscriber_id" => "2" })
|
|
91
|
+
assert_requested :post, "https://api.getdrip.com/v2/12345/subscribers", body: '{"subscribers":[{"external_ids":{"bigcommerce_subscriber_id":"2"}}]}', times: 1
|
|
92
|
+
end
|
|
87
93
|
end
|
|
88
94
|
|
|
89
95
|
context "#create_or_update_subscribers" do
|
|
@@ -158,6 +164,25 @@ class Drip::Client::SubscribersTest < Drip::TestCase
|
|
|
158
164
|
end
|
|
159
165
|
end
|
|
160
166
|
|
|
167
|
+
context "#subscribe with a campaign id that needs escaping" do
|
|
168
|
+
setup do
|
|
169
|
+
@email = "derrick@getdrip.com"
|
|
170
|
+
@campaign_id = "abc/123 xyz"
|
|
171
|
+
@data = { "time_zone" => "America/Los_Angeles" }
|
|
172
|
+
|
|
173
|
+
@response_status = 201
|
|
174
|
+
@response_body = "{}"
|
|
175
|
+
|
|
176
|
+
stub_request(:post, "https://api.getdrip.com/v2/12345/campaigns/#{CGI.escape @campaign_id}/subscribers").
|
|
177
|
+
to_return(status: @response_status, body: @response_body, headers: {})
|
|
178
|
+
end
|
|
179
|
+
|
|
180
|
+
should "escape the campaign id in the request path" do
|
|
181
|
+
expected = Drip::Response.new(@response_status, JSON.parse(@response_body))
|
|
182
|
+
assert_equal expected, @client.subscribe(@email, @campaign_id, @data)
|
|
183
|
+
end
|
|
184
|
+
end
|
|
185
|
+
|
|
161
186
|
context "#unsubscribe" do
|
|
162
187
|
context "if no campaign id is provided" do
|
|
163
188
|
setup do
|
|
@@ -193,6 +218,24 @@ class Drip::Client::SubscribersTest < Drip::TestCase
|
|
|
193
218
|
assert_equal expected, @client.unsubscribe(@id, campaign_id: @campaign)
|
|
194
219
|
end
|
|
195
220
|
end
|
|
221
|
+
|
|
222
|
+
context "if a campaign id that needs escaping is provided" do
|
|
223
|
+
setup do
|
|
224
|
+
@id = "derrick@getdrip.com"
|
|
225
|
+
@campaign = "abc/123 xyz"
|
|
226
|
+
|
|
227
|
+
@response_status = 201
|
|
228
|
+
@response_body = "{}"
|
|
229
|
+
|
|
230
|
+
stub_request(:post, "https://api.getdrip.com/v2/12345/subscribers/#{CGI.escape @id}/remove?campaign_id=#{CGI.escape @campaign}").
|
|
231
|
+
to_return(status: @response_status, body: @response_body, headers: {})
|
|
232
|
+
end
|
|
233
|
+
|
|
234
|
+
should "escape the campaign id in the query string" do
|
|
235
|
+
expected = Drip::Response.new(@response_status, JSON.parse(@response_body))
|
|
236
|
+
assert_equal expected, @client.unsubscribe(@id, campaign_id: @campaign)
|
|
237
|
+
end
|
|
238
|
+
end
|
|
196
239
|
end
|
|
197
240
|
|
|
198
241
|
context "#unsubscribe_from_all" do
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
require_relative '../../test_helper'
|
|
4
4
|
|
|
5
5
|
class Drip::Client::WorkflowTriggersTest < Drip::TestCase
|
|
6
6
|
def setup
|
|
@@ -9,7 +9,7 @@ class Drip::Client::WorkflowTriggersTest < Drip::TestCase
|
|
|
9
9
|
|
|
10
10
|
context "#workflow_triggers" do
|
|
11
11
|
setup do
|
|
12
|
-
@id =
|
|
12
|
+
@id = 9_999_999
|
|
13
13
|
@response_status = 200
|
|
14
14
|
@response_body = "{}"
|
|
15
15
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
require_relative '../../test_helper'
|
|
4
4
|
|
|
5
5
|
class Drip::Client::WorkflowsTest < Drip::TestCase
|
|
6
6
|
def setup
|
|
@@ -38,6 +38,22 @@ class Drip::Client::WorkflowsTest < Drip::TestCase
|
|
|
38
38
|
end
|
|
39
39
|
end
|
|
40
40
|
|
|
41
|
+
context "#workflow with an id that needs escaping" do
|
|
42
|
+
setup do
|
|
43
|
+
@response_status = 200
|
|
44
|
+
@response_body = "{}"
|
|
45
|
+
@id = "abc/123 xyz"
|
|
46
|
+
|
|
47
|
+
stub_request(:get, "https://api.getdrip.com/v2/12345/workflows/#{CGI.escape @id}").
|
|
48
|
+
to_return(status: @response_status, body: @response_body, headers: {})
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
should "escape the id in the request path" do
|
|
52
|
+
expected = Drip::Response.new(@response_status, JSON.parse(@response_body))
|
|
53
|
+
assert_equal expected, @client.workflow(@id)
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
|
|
41
57
|
context "#activate_workflow" do
|
|
42
58
|
setup do
|
|
43
59
|
@response_status = 204
|
|
@@ -76,7 +92,7 @@ class Drip::Client::WorkflowsTest < Drip::TestCase
|
|
|
76
92
|
"email" => "someone@example.com",
|
|
77
93
|
"time_zone" => "America/Los_Angeles"
|
|
78
94
|
}
|
|
79
|
-
@id =
|
|
95
|
+
@id = 9_999_999
|
|
80
96
|
@payload = { "subscribers" => [@data] }.to_json
|
|
81
97
|
|
|
82
98
|
@response_status = 204
|
data/test/drip/client_test.rb
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
require_relative '../test_helper'
|
|
4
4
|
require "base64"
|
|
5
5
|
|
|
6
6
|
class Drip::ClientTest < Drip::TestCase
|
|
@@ -43,7 +43,8 @@ class Drip::ClientTest < Drip::TestCase
|
|
|
43
43
|
api_key: "aaaa",
|
|
44
44
|
access_token: "bbbb",
|
|
45
45
|
http_open_timeout: 20,
|
|
46
|
-
http_timeout: 25
|
|
46
|
+
http_timeout: 25,
|
|
47
|
+
skip_analytics: true
|
|
47
48
|
)
|
|
48
49
|
|
|
49
50
|
assert_equal "1234567", client.account_id
|
|
@@ -51,6 +52,7 @@ class Drip::ClientTest < Drip::TestCase
|
|
|
51
52
|
assert_equal "bbbb", client.access_token
|
|
52
53
|
assert_equal 20, client.http_open_timeout
|
|
53
54
|
assert_equal 25, client.http_timeout
|
|
55
|
+
assert client.skip_analytics, "config should skip analytics"
|
|
54
56
|
end
|
|
55
57
|
|
|
56
58
|
should "accept options after initialization" do
|
|
@@ -65,7 +67,7 @@ class Drip::ClientTest < Drip::TestCase
|
|
|
65
67
|
setup do
|
|
66
68
|
@client = Drip::Client.new do |config|
|
|
67
69
|
config.api_key = "Hello world"
|
|
68
|
-
config.account_id =
|
|
70
|
+
config.account_id = 12_345
|
|
69
71
|
end
|
|
70
72
|
end
|
|
71
73
|
|
|
@@ -112,7 +114,7 @@ class Drip::ClientTest < Drip::TestCase
|
|
|
112
114
|
should "return a resource and note deprecation" do
|
|
113
115
|
client = Drip::Client.new
|
|
114
116
|
resource = nil
|
|
115
|
-
assert_output(nil, /^\[DEPRECATED\] Drip
|
|
117
|
+
assert_output(nil, /^\[DEPRECATED\] Drip::Client\#generate_resource is deprecated/) { resource = client.generate_resource("hello", {}) }
|
|
116
118
|
assert_equal({ "hello" => [{}] }, resource)
|
|
117
119
|
end
|
|
118
120
|
end
|
|
@@ -122,7 +124,7 @@ class Drip::ClientTest < Drip::TestCase
|
|
|
122
124
|
should "return default content type and print warning" do
|
|
123
125
|
client = Drip::Client.new
|
|
124
126
|
content_type = nil
|
|
125
|
-
assert_output(nil, /^\[DEPRECATED\] Drip
|
|
127
|
+
assert_output(nil, /^\[DEPRECATED\] Drip::Client\#content_type is deprecated/) { content_type = client.content_type }
|
|
126
128
|
assert_equal "application/vnd.api+json", content_type
|
|
127
129
|
end
|
|
128
130
|
end
|
|
@@ -135,7 +137,7 @@ class Drip::ClientTest < Drip::TestCase
|
|
|
135
137
|
|
|
136
138
|
client = Drip::Client.new
|
|
137
139
|
response = nil
|
|
138
|
-
assert_output(nil, /^\[DEPRECATED\] Drip
|
|
140
|
+
assert_output(nil, /^\[DEPRECATED\] Drip::Client\#get please use the API endpoint specific methods/) { response = client.get("testpath") }
|
|
139
141
|
assert_equal({}, response.body)
|
|
140
142
|
end
|
|
141
143
|
end
|
data/test/drip/request_test.rb
CHANGED
data/test/drip/resource_test.rb
CHANGED
data/test/drip/resources_test.rb
CHANGED
data/test/drip/response_test.rb
CHANGED
data/test/test_helper.rb
CHANGED
|
@@ -3,12 +3,12 @@
|
|
|
3
3
|
require 'simplecov'
|
|
4
4
|
SimpleCov.start
|
|
5
5
|
|
|
6
|
-
$LOAD_PATH.unshift File.expand_path('
|
|
6
|
+
$LOAD_PATH.unshift File.expand_path('../lib', __dir__)
|
|
7
7
|
|
|
8
8
|
require "drip"
|
|
9
9
|
require "minitest/autorun"
|
|
10
10
|
require "shoulda-context"
|
|
11
|
-
require "mocha/
|
|
11
|
+
require "mocha/minitest"
|
|
12
12
|
require "webmock/minitest"
|
|
13
13
|
|
|
14
14
|
class Drip::TestCase < Minitest::Test
|
metadata
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: drip-ruby
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 3.
|
|
4
|
+
version: 3.5.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Drip
|
|
8
|
-
autorequire:
|
|
9
8
|
bindir: bin
|
|
10
9
|
cert_chain: []
|
|
11
|
-
date:
|
|
10
|
+
date: 1980-01-01 00:00:00.000000000 Z
|
|
12
11
|
dependencies: []
|
|
13
12
|
description: A simple wrapper for the Drip API
|
|
14
13
|
email:
|
|
@@ -17,16 +16,19 @@ executables: []
|
|
|
17
16
|
extensions: []
|
|
18
17
|
extra_rdoc_files: []
|
|
19
18
|
files:
|
|
19
|
+
- ".github/pull_request_template.md"
|
|
20
|
+
- ".github/workflows/ci.yml"
|
|
20
21
|
- ".gitignore"
|
|
21
22
|
- ".rubocop.yml"
|
|
22
23
|
- ".rubocop_todo.yml"
|
|
23
|
-
- ".travis.yml"
|
|
24
24
|
- CHANGELOG.md
|
|
25
25
|
- Gemfile
|
|
26
26
|
- LICENSE.txt
|
|
27
27
|
- README.md
|
|
28
28
|
- Rakefile
|
|
29
29
|
- drip-ruby.gemspec
|
|
30
|
+
- flake.lock
|
|
31
|
+
- flake.nix
|
|
30
32
|
- lib/drip.rb
|
|
31
33
|
- lib/drip/client.rb
|
|
32
34
|
- lib/drip/client/accounts.rb
|
|
@@ -125,8 +127,8 @@ files:
|
|
|
125
127
|
homepage: http://github.com/DripEmail/drip-ruby
|
|
126
128
|
licenses:
|
|
127
129
|
- MIT
|
|
128
|
-
metadata:
|
|
129
|
-
|
|
130
|
+
metadata:
|
|
131
|
+
rubygems_mfa_required: 'true'
|
|
130
132
|
rdoc_options: []
|
|
131
133
|
require_paths:
|
|
132
134
|
- lib
|
|
@@ -134,58 +136,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
134
136
|
requirements:
|
|
135
137
|
- - ">="
|
|
136
138
|
- !ruby/object:Gem::Version
|
|
137
|
-
version: '
|
|
139
|
+
version: '3.1'
|
|
138
140
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
139
141
|
requirements:
|
|
140
142
|
- - ">="
|
|
141
143
|
- !ruby/object:Gem::Version
|
|
142
144
|
version: '0'
|
|
143
145
|
requirements: []
|
|
144
|
-
rubygems_version: 3.
|
|
145
|
-
signing_key:
|
|
146
|
+
rubygems_version: 3.7.2
|
|
146
147
|
specification_version: 4
|
|
147
148
|
summary: A Ruby gem for interacting with the Drip API
|
|
148
|
-
test_files:
|
|
149
|
-
- test/drip/client/accounts_test.rb
|
|
150
|
-
- test/drip/client/broadcasts_test.rb
|
|
151
|
-
- test/drip/client/campaign_subscriptions_test.rb
|
|
152
|
-
- test/drip/client/campaigns_test.rb
|
|
153
|
-
- test/drip/client/configuration_test.rb
|
|
154
|
-
- test/drip/client/conversions_test.rb
|
|
155
|
-
- test/drip/client/custom_fields_test.rb
|
|
156
|
-
- test/drip/client/events_test.rb
|
|
157
|
-
- test/drip/client/forms_test.rb
|
|
158
|
-
- test/drip/client/http_client_test.rb
|
|
159
|
-
- test/drip/client/orders_test.rb
|
|
160
|
-
- test/drip/client/shopper_activity_test.rb
|
|
161
|
-
- test/drip/client/subscribers_test.rb
|
|
162
|
-
- test/drip/client/tags_test.rb
|
|
163
|
-
- test/drip/client/users_test.rb
|
|
164
|
-
- test/drip/client/webhooks_test.rb
|
|
165
|
-
- test/drip/client/workflow_triggers_test.rb
|
|
166
|
-
- test/drip/client/workflows_test.rb
|
|
167
|
-
- test/drip/client_test.rb
|
|
168
|
-
- test/drip/collection_test.rb
|
|
169
|
-
- test/drip/collections/account_test.rb
|
|
170
|
-
- test/drip/collections/broadcasts_test.rb
|
|
171
|
-
- test/drip/collections/campaign_subscriptions_test.rb
|
|
172
|
-
- test/drip/collections/campaigns_test.rb
|
|
173
|
-
- test/drip/collections/errors_test.rb
|
|
174
|
-
- test/drip/collections/orders_test.rb
|
|
175
|
-
- test/drip/collections/purchases_test.rb
|
|
176
|
-
- test/drip/collections/tags_test.rb
|
|
177
|
-
- test/drip/collections/webhooks_test.rb
|
|
178
|
-
- test/drip/collections/workflow_triggers_test.rb
|
|
179
|
-
- test/drip/collections/workflows_test.rb
|
|
180
|
-
- test/drip/collections_test.rb
|
|
181
|
-
- test/drip/request_test.rb
|
|
182
|
-
- test/drip/resource_test.rb
|
|
183
|
-
- test/drip/resources/account_test.rb
|
|
184
|
-
- test/drip/resources/order_test.rb
|
|
185
|
-
- test/drip/resources/subscriber_test.rb
|
|
186
|
-
- test/drip/resources/tag_test.rb
|
|
187
|
-
- test/drip/resources_test.rb
|
|
188
|
-
- test/drip/response_test.rb
|
|
189
|
-
- test/fixtures/resources/not_found_error.json
|
|
190
|
-
- test/fixtures/resources/subscriber.json
|
|
191
|
-
- test/test_helper.rb
|
|
149
|
+
test_files: []
|