drip-ruby 2.0.0 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.rubocop.yml +14 -1
- data/.rubocop_todo.yml +51 -85
- data/.travis.yml +1 -0
- data/CHANGELOG.md +62 -0
- data/Rakefile +4 -2
- data/drip-ruby.gemspec +6 -6
- data/lib/drip/client.rb +45 -34
- data/lib/drip/client/orders.rb +4 -4
- data/lib/drip/errors.rb +3 -0
- data/lib/drip/response.rb +5 -5
- data/lib/drip/version.rb +1 -1
- data/test/drip/client/accounts_test.rb +6 -15
- data/test/drip/client/broadcasts_test.rb +6 -15
- data/test/drip/client/campaign_subscriptions_test.rb +3 -11
- data/test/drip/client/campaigns_test.rb +15 -27
- data/test/drip/client/conversions_test.rb +6 -15
- data/test/drip/client/custom_fields_test.rb +3 -11
- data/test/drip/client/events_test.rb +12 -23
- data/test/drip/client/forms_test.rb +6 -15
- data/test/drip/client/orders_test.rb +48 -58
- data/test/drip/client/subscribers_test.rb +33 -51
- data/test/drip/client/tags_test.rb +9 -19
- data/test/drip/client/webhooks_test.rb +12 -23
- data/test/drip/client/workflow_triggers_test.rb +9 -19
- data/test/drip/client/workflows_test.rb +18 -31
- data/test/drip/client_test.rb +70 -3
- data/test/test_helper.rb +1 -8
- metadata +26 -27
- data/lib/drip/client/purchases.rb +0 -23
- data/test/drip/client/purchases_test.rb +0 -47
@@ -2,25 +2,17 @@ require File.dirname(__FILE__) + '/../../test_helper.rb'
|
|
2
2
|
|
3
3
|
class Drip::Client::WorkflowTriggersTest < Drip::TestCase
|
4
4
|
def setup
|
5
|
-
@stubs = Faraday::Adapter::Test::Stubs.new
|
6
|
-
|
7
|
-
@connection = Faraday.new do |builder|
|
8
|
-
builder.adapter :test, @stubs
|
9
|
-
end
|
10
|
-
|
11
5
|
@client = Drip::Client.new { |c| c.account_id = "12345" }
|
12
|
-
@client.expects(:connection).at_least_once.returns(@connection)
|
13
6
|
end
|
14
7
|
|
15
8
|
context "#workflow_triggers" do
|
16
9
|
setup do
|
17
10
|
@id = 9999999
|
18
11
|
@response_status = 200
|
19
|
-
@response_body = stub
|
12
|
+
@response_body = "stub"
|
20
13
|
|
21
|
-
|
22
|
-
|
23
|
-
end
|
14
|
+
stub_request(:get, "https://api.getdrip.com/v2/12345/workflows/#{@id}/triggers").
|
15
|
+
to_return(status: @response_status, body: @response_body, headers: {})
|
24
16
|
end
|
25
17
|
|
26
18
|
should "send the right request" do
|
@@ -43,11 +35,10 @@ class Drip::Client::WorkflowTriggersTest < Drip::TestCase
|
|
43
35
|
@payload = { "triggers" => [@data] }.to_json
|
44
36
|
|
45
37
|
@response_status = 200
|
46
|
-
@response_body = stub
|
38
|
+
@response_body = "stub"
|
47
39
|
|
48
|
-
|
49
|
-
|
50
|
-
end
|
40
|
+
stub_request(:post, "https://api.getdrip.com/v2/12345/workflows/#{@id}/triggers").
|
41
|
+
to_return(status: @response_status, body: @response_body, headers: {})
|
51
42
|
end
|
52
43
|
|
53
44
|
should "send the right request" do
|
@@ -70,11 +61,10 @@ class Drip::Client::WorkflowTriggersTest < Drip::TestCase
|
|
70
61
|
@payload = { "triggers" => [@data] }.to_json
|
71
62
|
|
72
63
|
@response_status = 200
|
73
|
-
@response_body = stub
|
64
|
+
@response_body = "stub"
|
74
65
|
|
75
|
-
|
76
|
-
|
77
|
-
end
|
66
|
+
stub_request(:put, "https://api.getdrip.com/v2/12345/workflows/#{@id}/triggers").
|
67
|
+
to_return(status: @response_status, body: @response_body, headers: {})
|
78
68
|
end
|
79
69
|
|
80
70
|
should "send the right request" do
|
@@ -2,24 +2,16 @@ require File.dirname(__FILE__) + '/../../test_helper.rb'
|
|
2
2
|
|
3
3
|
class Drip::Client::WorkflowsTest < Drip::TestCase
|
4
4
|
def setup
|
5
|
-
@stubs = Faraday::Adapter::Test::Stubs.new
|
6
|
-
|
7
|
-
@connection = Faraday.new do |builder|
|
8
|
-
builder.adapter :test, @stubs
|
9
|
-
end
|
10
|
-
|
11
5
|
@client = Drip::Client.new { |c| c.account_id = "12345" }
|
12
|
-
@client.expects(:connection).at_least_once.returns(@connection)
|
13
6
|
end
|
14
7
|
|
15
8
|
context "#workflows" do
|
16
9
|
setup do
|
17
10
|
@response_status = 200
|
18
|
-
@response_body = stub
|
11
|
+
@response_body = "stub"
|
19
12
|
|
20
|
-
|
21
|
-
|
22
|
-
end
|
13
|
+
stub_request(:get, "https://api.getdrip.com/v2/12345/workflows").
|
14
|
+
to_return(status: @response_status, body: @response_body, headers: {})
|
23
15
|
end
|
24
16
|
|
25
17
|
should "send the right request" do
|
@@ -31,12 +23,11 @@ class Drip::Client::WorkflowsTest < Drip::TestCase
|
|
31
23
|
context "#workflow" do
|
32
24
|
setup do
|
33
25
|
@response_status = 200
|
34
|
-
@response_body = stub
|
26
|
+
@response_body = "stub"
|
35
27
|
@id = 1234
|
36
28
|
|
37
|
-
|
38
|
-
|
39
|
-
end
|
29
|
+
stub_request(:get, "https://api.getdrip.com/v2/12345/workflows/#{@id}").
|
30
|
+
to_return(status: @response_status, body: @response_body, headers: {})
|
40
31
|
end
|
41
32
|
|
42
33
|
should "send the right request" do
|
@@ -48,12 +39,11 @@ class Drip::Client::WorkflowsTest < Drip::TestCase
|
|
48
39
|
context "#activate_workflow" do
|
49
40
|
setup do
|
50
41
|
@response_status = 204
|
51
|
-
@response_body =
|
42
|
+
@response_body = nil
|
52
43
|
@id = 1234
|
53
44
|
|
54
|
-
|
55
|
-
|
56
|
-
end
|
45
|
+
stub_request(:post, "https://api.getdrip.com/v2/12345/workflows/#{@id}/activate").
|
46
|
+
to_return(status: @response_status, body: @response_body, headers: {})
|
57
47
|
end
|
58
48
|
|
59
49
|
should "send the right request" do
|
@@ -65,12 +55,11 @@ class Drip::Client::WorkflowsTest < Drip::TestCase
|
|
65
55
|
context "#pause_workflow" do
|
66
56
|
setup do
|
67
57
|
@response_status = 204
|
68
|
-
@response_body =
|
58
|
+
@response_body = nil
|
69
59
|
@id = 1234
|
70
60
|
|
71
|
-
|
72
|
-
|
73
|
-
end
|
61
|
+
stub_request(:post, "https://api.getdrip.com/v2/12345/workflows/#{@id}/pause").
|
62
|
+
to_return(status: @response_status, body: @response_body, headers: {})
|
74
63
|
end
|
75
64
|
|
76
65
|
should "send the right request" do
|
@@ -89,11 +78,10 @@ class Drip::Client::WorkflowsTest < Drip::TestCase
|
|
89
78
|
@payload = { "subscribers" => [@data] }.to_json
|
90
79
|
|
91
80
|
@response_status = 204
|
92
|
-
@response_body =
|
81
|
+
@response_body = nil
|
93
82
|
|
94
|
-
|
95
|
-
|
96
|
-
end
|
83
|
+
stub_request(:post, "https://api.getdrip.com/v2/12345/workflows/#{@id}/subscribers").
|
84
|
+
to_return(status: @response_status, body: @response_body, headers: {})
|
97
85
|
end
|
98
86
|
|
99
87
|
should "send the right request" do
|
@@ -105,13 +93,12 @@ class Drip::Client::WorkflowsTest < Drip::TestCase
|
|
105
93
|
context "#remove_subscriber_workflow" do
|
106
94
|
setup do
|
107
95
|
@response_status = 200
|
108
|
-
@response_body = stub
|
96
|
+
@response_body = "stub"
|
109
97
|
@id = 1234
|
110
98
|
@email = "someone@example.com"
|
111
99
|
|
112
|
-
|
113
|
-
|
114
|
-
end
|
100
|
+
stub_request(:delete, "https://api.getdrip.com/v2/12345/workflows/#{@id}/subscribers/#{CGI.escape @email}").
|
101
|
+
to_return(status: @response_status, body: @response_body, headers: {})
|
115
102
|
end
|
116
103
|
|
117
104
|
should "send the right request" do
|
data/test/drip/client_test.rb
CHANGED
@@ -11,6 +11,19 @@ class Drip::ClientTest < Drip::TestCase
|
|
11
11
|
assert_equal "aaaa", client.api_key
|
12
12
|
end
|
13
13
|
|
14
|
+
should "accept url prefix" do
|
15
|
+
client = Drip::Client.new do |config|
|
16
|
+
config.url_prefix = "aaaa"
|
17
|
+
end
|
18
|
+
|
19
|
+
assert_equal "aaaa", client.url_prefix
|
20
|
+
end
|
21
|
+
|
22
|
+
should "have default url prefix" do
|
23
|
+
client = Drip::Client.new
|
24
|
+
assert_equal "https://api.getdrip.com/v2/", client.url_prefix
|
25
|
+
end
|
26
|
+
|
14
27
|
should "accept access token" do
|
15
28
|
client = Drip::Client.new do |config|
|
16
29
|
config.access_token = "aaaa"
|
@@ -61,8 +74,32 @@ class Drip::ClientTest < Drip::TestCase
|
|
61
74
|
end
|
62
75
|
|
63
76
|
should "use Basic authentication" do
|
64
|
-
|
65
|
-
|
77
|
+
stub_request(:get, "https://api.getdrip.com/v2/testpath").
|
78
|
+
to_return(status: 200, body: "", headers: {})
|
79
|
+
|
80
|
+
@client.get("testpath")
|
81
|
+
|
82
|
+
header = "Basic #{Base64.encode64(@key + ':')}".strip
|
83
|
+
assert_requested :get, "https://api.getdrip.com/v2/testpath", headers: { 'Authorization' => header }
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
context "given a different url prefix" do
|
88
|
+
setup do
|
89
|
+
@key = "aaaa"
|
90
|
+
@url_prefix = "https://api.example.com/v9001/"
|
91
|
+
@client = Drip::Client.new do |config|
|
92
|
+
config.api_key = @key
|
93
|
+
config.url_prefix = @url_prefix
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
should "connect to alternate prefix" do
|
98
|
+
stub_request(:get, "https://api.example.com/v9001/testpath").
|
99
|
+
to_return(status: 200, body: "", headers: {})
|
100
|
+
@client.get("testpath")
|
101
|
+
|
102
|
+
assert_requested :get, "https://api.example.com/v9001/testpath"
|
66
103
|
end
|
67
104
|
end
|
68
105
|
|
@@ -75,8 +112,38 @@ class Drip::ClientTest < Drip::TestCase
|
|
75
112
|
end
|
76
113
|
|
77
114
|
should "use Bearer token authentication" do
|
115
|
+
stub_request(:get, "https://api.getdrip.com/v2/testpath").
|
116
|
+
to_return(status: 200, body: "", headers: {})
|
117
|
+
@client.get("testpath")
|
78
118
|
header = "Bearer #{@key}"
|
79
|
-
|
119
|
+
assert_requested :get, "https://api.getdrip.com/v2/testpath", headers: { 'Authorization' => header }
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
123
|
+
context "given a redirecting url" do
|
124
|
+
setup do
|
125
|
+
@client = Drip::Client.new
|
126
|
+
end
|
127
|
+
|
128
|
+
should "follow redirect" do
|
129
|
+
stub_request(:get, "https://api.getdrip.com/v2/testpath").
|
130
|
+
to_return(status: 301, body: "", headers: { "Location" => "https://api.example.com/mytestpath" })
|
131
|
+
stub_request(:get, "https://api.example.com/mytestpath").
|
132
|
+
to_return(status: 200, body: "mybody")
|
133
|
+
response = @client.get("testpath")
|
134
|
+
assert_requested :get, "https://api.getdrip.com/v2/testpath"
|
135
|
+
assert_requested :get, "https://api.example.com/mytestpath"
|
136
|
+
assert_equal "mybody", response.body
|
137
|
+
end
|
138
|
+
|
139
|
+
should "not follow too many redirects" do
|
140
|
+
stub_request(:get, "https://api.getdrip.com/v2/testpath").
|
141
|
+
to_return(status: 301, body: "", headers: { "Location" => "https://api.example.com/mytestpath" })
|
142
|
+
stub_request(:get, "https://api.example.com/mytestpath").
|
143
|
+
to_return(status: 302, body: "", headers: { "Location" => "https://api.getdrip.com/v2/testpath" })
|
144
|
+
assert_raises(Drip::TooManyRedirectsError) { @client.get("testpath") }
|
145
|
+
assert_requested :get, "https://api.getdrip.com/v2/testpath", times: 5
|
146
|
+
assert_requested :get, "https://api.example.com/mytestpath", times: 5
|
80
147
|
end
|
81
148
|
end
|
82
149
|
end
|
data/test/test_helper.rb
CHANGED
@@ -4,14 +4,7 @@ require "drip"
|
|
4
4
|
require "minitest/autorun"
|
5
5
|
require "shoulda-context"
|
6
6
|
require "mocha/setup"
|
7
|
-
|
8
|
-
# require "vcr"
|
9
|
-
require "faraday"
|
10
|
-
|
11
|
-
# VCR.configure do |c|
|
12
|
-
# c.cassette_library_dir = 'test/cassettes'
|
13
|
-
# c.hook_into :webmock # or :fakeweb
|
14
|
-
# end
|
7
|
+
require "webmock/minitest"
|
15
8
|
|
16
9
|
class Drip::TestCase < Minitest::Test
|
17
10
|
def expand_fixture_path(path)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: drip-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 3.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Derrick Reimer
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-05-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -25,89 +25,89 @@ dependencies:
|
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '1.6'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
28
|
+
name: minitest
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
33
|
+
version: '5.0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
40
|
+
version: '5.0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
42
|
+
name: mocha
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '1.
|
47
|
+
version: '1.1'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '1.
|
54
|
+
version: '1.1'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
|
-
name:
|
56
|
+
name: rake
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: '
|
61
|
+
version: '10.0'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: '
|
68
|
+
version: '10.0'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
|
-
name:
|
70
|
+
name: rubocop
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
73
|
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version:
|
75
|
+
version: 0.56.0
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version:
|
82
|
+
version: 0.56.0
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
|
-
name:
|
84
|
+
name: shoulda-context
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
87
|
- - "~>"
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version: '0
|
90
|
-
type: :
|
89
|
+
version: '1.0'
|
90
|
+
type: :development
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
94
|
- - "~>"
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version: '0
|
96
|
+
version: '1.0'
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
|
-
name:
|
98
|
+
name: webmock
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
101
|
- - "~>"
|
102
102
|
- !ruby/object:Gem::Version
|
103
|
-
version: '
|
104
|
-
type: :
|
103
|
+
version: '3.4'
|
104
|
+
type: :development
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
108
|
- - "~>"
|
109
109
|
- !ruby/object:Gem::Version
|
110
|
-
version: '
|
110
|
+
version: '3.4'
|
111
111
|
description: A simple wrapper for the Drip API
|
112
112
|
email:
|
113
113
|
- derrickreimer@gmail.com
|
@@ -119,6 +119,7 @@ files:
|
|
119
119
|
- ".rubocop.yml"
|
120
120
|
- ".rubocop_todo.yml"
|
121
121
|
- ".travis.yml"
|
122
|
+
- CHANGELOG.md
|
122
123
|
- Gemfile
|
123
124
|
- LICENSE.txt
|
124
125
|
- README.md
|
@@ -135,7 +136,6 @@ files:
|
|
135
136
|
- lib/drip/client/events.rb
|
136
137
|
- lib/drip/client/forms.rb
|
137
138
|
- lib/drip/client/orders.rb
|
138
|
-
- lib/drip/client/purchases.rb
|
139
139
|
- lib/drip/client/subscribers.rb
|
140
140
|
- lib/drip/client/tags.rb
|
141
141
|
- lib/drip/client/webhooks.rb
|
@@ -155,6 +155,7 @@ files:
|
|
155
155
|
- lib/drip/collections/webhooks.rb
|
156
156
|
- lib/drip/collections/workflow_triggers.rb
|
157
157
|
- lib/drip/collections/workflows.rb
|
158
|
+
- lib/drip/errors.rb
|
158
159
|
- lib/drip/resource.rb
|
159
160
|
- lib/drip/resources.rb
|
160
161
|
- lib/drip/resources/account.rb
|
@@ -180,7 +181,6 @@ files:
|
|
180
181
|
- test/drip/client/events_test.rb
|
181
182
|
- test/drip/client/forms_test.rb
|
182
183
|
- test/drip/client/orders_test.rb
|
183
|
-
- test/drip/client/purchases_test.rb
|
184
184
|
- test/drip/client/subscribers_test.rb
|
185
185
|
- test/drip/client/tags_test.rb
|
186
186
|
- test/drip/client/webhooks_test.rb
|
@@ -210,7 +210,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
210
210
|
requirements:
|
211
211
|
- - ">="
|
212
212
|
- !ruby/object:Gem::Version
|
213
|
-
version: 1
|
213
|
+
version: '2.1'
|
214
214
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
215
215
|
requirements:
|
216
216
|
- - ">="
|
@@ -218,7 +218,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
218
218
|
version: '0'
|
219
219
|
requirements: []
|
220
220
|
rubyforge_project:
|
221
|
-
rubygems_version: 2.
|
221
|
+
rubygems_version: 2.5.2
|
222
222
|
signing_key:
|
223
223
|
specification_version: 4
|
224
224
|
summary: A Ruby gem for interacting with the Drip API
|
@@ -232,7 +232,6 @@ test_files:
|
|
232
232
|
- test/drip/client/events_test.rb
|
233
233
|
- test/drip/client/forms_test.rb
|
234
234
|
- test/drip/client/orders_test.rb
|
235
|
-
- test/drip/client/purchases_test.rb
|
236
235
|
- test/drip/client/subscribers_test.rb
|
237
236
|
- test/drip/client/tags_test.rb
|
238
237
|
- test/drip/client/webhooks_test.rb
|