drip-ruby 3.1.0 → 3.1.1
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/CHANGELOG.md +14 -0
- data/lib/drip/client.rb +3 -1
- data/lib/drip/version.rb +1 -1
- data/test/drip/client/accounts_test.rb +4 -4
- data/test/drip/client/broadcasts_test.rb +4 -4
- data/test/drip/client/campaign_subscriptions_test.rb +2 -2
- data/test/drip/client/campaigns_test.rb +6 -6
- data/test/drip/client/conversions_test.rb +4 -4
- data/test/drip/client/custom_fields_test.rb +2 -2
- data/test/drip/client/events_test.rb +8 -8
- data/test/drip/client/forms_test.rb +4 -4
- data/test/drip/client/orders_test.rb +6 -6
- data/test/drip/client/subscribers_test.rb +18 -18
- data/test/drip/client/tags_test.rb +4 -4
- data/test/drip/client/webhooks_test.rb +8 -8
- data/test/drip/client/workflow_triggers_test.rb +6 -6
- data/test/drip/client/workflows_test.rb +6 -6
- data/test/drip/client_test.rb +29 -7
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 34ab6a491e2d7b0bdf33b525a11c7d5499bd0e2f
|
4
|
+
data.tar.gz: d5b703ea0a8f113be93b5c19bbf13849f7fbb6b7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ffb4cacb8da55651f34b33c9377de84104fa5913eb520f7437a2b0cf045eba8da1743043538c10ee00be64b562697128d22e35225307d5f4dee1c318c5022bdc
|
7
|
+
data.tar.gz: 3bce36166a411416f7258939b2283c403ec35903b882144538f95b893f56a61bd7bb3f90503ae61f7c318a834356ca073b594555fbc62f6185f4d8d6fa29908c
|
data/CHANGELOG.md
CHANGED
@@ -4,6 +4,20 @@ All notable changes to this project will be documented in this file.
|
|
4
4
|
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
|
5
5
|
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
|
6
6
|
|
7
|
+
## [Unreleased]
|
8
|
+
|
9
|
+
[master]: https://github.com/DripEmail/drip-ruby/compare/v3.0.0...HEAD
|
10
|
+
|
11
|
+
- Your contribution here!
|
12
|
+
|
13
|
+
## [3.1.1] - 2018-06-06
|
14
|
+
|
15
|
+
[3.1.1]: https://github.com/DripEmail/drip-ruby/compare/v3.1.0...v3.1.1
|
16
|
+
|
17
|
+
### Fixed
|
18
|
+
|
19
|
+
- [#48](https://github.com/DripEmail/drip-ruby/issues/48): Repair json parsing to work correctly
|
20
|
+
|
7
21
|
## [3.1.0] - 2018-06-05
|
8
22
|
|
9
23
|
[3.1.0]: https://github.com/DripEmail/drip-ruby/compare/v3.0.0...v3.1.0
|
data/lib/drip/client.rb
CHANGED
@@ -116,7 +116,9 @@ module Drip
|
|
116
116
|
|
117
117
|
def build_response(&block)
|
118
118
|
response = yield
|
119
|
-
Drip::Response.new(response.code.to_i, response.body)
|
119
|
+
Drip::Response.new(response.code.to_i, response.body || response.body == "" ? JSON.parse(response.body) : nil)
|
120
|
+
rescue JSON::ParserError
|
121
|
+
Drip::Response.new(response.code.to_i, nil)
|
120
122
|
end
|
121
123
|
|
122
124
|
def connection_options(uri_scheme)
|
data/lib/drip/version.rb
CHANGED
@@ -8,14 +8,14 @@ class Drip::Client::AccountsTest < Drip::TestCase
|
|
8
8
|
context "#accounts" do
|
9
9
|
setup do
|
10
10
|
@response_status = 200
|
11
|
-
@response_body = "
|
11
|
+
@response_body = "{}"
|
12
12
|
|
13
13
|
stub_request(:get, "https://api.getdrip.com/v2/accounts").
|
14
14
|
to_return(status: @response_status, body: @response_body, headers: {})
|
15
15
|
end
|
16
16
|
|
17
17
|
should "send the right request" do
|
18
|
-
expected = Drip::Response.new(@response_status, @response_body)
|
18
|
+
expected = Drip::Response.new(@response_status, JSON.parse(@response_body))
|
19
19
|
assert_equal expected, @client.accounts
|
20
20
|
end
|
21
21
|
end
|
@@ -23,7 +23,7 @@ class Drip::Client::AccountsTest < Drip::TestCase
|
|
23
23
|
context "#account" do
|
24
24
|
setup do
|
25
25
|
@response_status = 200
|
26
|
-
@response_body = "
|
26
|
+
@response_body = "{}"
|
27
27
|
@id = 9999999
|
28
28
|
|
29
29
|
stub_request(:get, "https://api.getdrip.com/v2/accounts/#{@id}").
|
@@ -31,7 +31,7 @@ class Drip::Client::AccountsTest < Drip::TestCase
|
|
31
31
|
end
|
32
32
|
|
33
33
|
should "send the right request" do
|
34
|
-
expected = Drip::Response.new(@response_status, @response_body)
|
34
|
+
expected = Drip::Response.new(@response_status, JSON.parse(@response_body))
|
35
35
|
assert_equal expected, @client.account(@id)
|
36
36
|
end
|
37
37
|
end
|
@@ -8,14 +8,14 @@ class Drip::Client::BroadcastsTest < Drip::TestCase
|
|
8
8
|
context "#broadcasts" do
|
9
9
|
setup do
|
10
10
|
@response_status = 200
|
11
|
-
@response_body = "
|
11
|
+
@response_body = "{}"
|
12
12
|
|
13
13
|
stub_request(:get, "https://api.getdrip.com/v2/12345/broadcasts").
|
14
14
|
to_return(status: @response_status, body: @response_body, headers: {})
|
15
15
|
end
|
16
16
|
|
17
17
|
should "send the correct request" do
|
18
|
-
expected = Drip::Response.new(@response_status, @response_body)
|
18
|
+
expected = Drip::Response.new(@response_status, JSON.parse(@response_body))
|
19
19
|
assert_equal expected, @client.broadcasts
|
20
20
|
end
|
21
21
|
end
|
@@ -23,7 +23,7 @@ class Drip::Client::BroadcastsTest < Drip::TestCase
|
|
23
23
|
context "#broadcast" do
|
24
24
|
setup do
|
25
25
|
@response_status = 200
|
26
|
-
@response_body = "
|
26
|
+
@response_body = "{}"
|
27
27
|
@id = 99999
|
28
28
|
|
29
29
|
stub_request(:get, "https://api.getdrip.com/v2/12345/broadcasts/#{@id}").
|
@@ -31,7 +31,7 @@ class Drip::Client::BroadcastsTest < Drip::TestCase
|
|
31
31
|
end
|
32
32
|
|
33
33
|
should "send the correct request" do
|
34
|
-
expected = Drip::Response.new(@response_status, @response_body)
|
34
|
+
expected = Drip::Response.new(@response_status, JSON.parse(@response_body))
|
35
35
|
assert_equal expected, @client.broadcast(@id)
|
36
36
|
end
|
37
37
|
end
|
@@ -8,7 +8,7 @@ class Drip::Client::CampaignSubscriptionsTest < Drip::TestCase
|
|
8
8
|
context "#campaign_subscriptions" do
|
9
9
|
setup do
|
10
10
|
@response_status = 200
|
11
|
-
@response_body = "
|
11
|
+
@response_body = "{}"
|
12
12
|
@subscriber_id = "abc123"
|
13
13
|
|
14
14
|
stub_request(:get, "https://api.getdrip.com/v2/12345/subscribers/#{@subscriber_id}/campaign_subscriptions").
|
@@ -16,7 +16,7 @@ class Drip::Client::CampaignSubscriptionsTest < Drip::TestCase
|
|
16
16
|
end
|
17
17
|
|
18
18
|
should "send the right request" do
|
19
|
-
expected = Drip::Response.new(@response_status, @response_body)
|
19
|
+
expected = Drip::Response.new(@response_status, JSON.parse(@response_body))
|
20
20
|
assert_equal expected, @client.campaign_subscriptions(@subscriber_id)
|
21
21
|
end
|
22
22
|
end
|
@@ -8,14 +8,14 @@ class Drip::Client::CampaignsTest < Drip::TestCase
|
|
8
8
|
context "#campaigns" do
|
9
9
|
setup do
|
10
10
|
@response_status = 200
|
11
|
-
@response_body = "
|
11
|
+
@response_body = "{}"
|
12
12
|
|
13
13
|
stub_request(:get, "https://api.getdrip.com/v2/12345/campaigns").
|
14
14
|
to_return(status: @response_status, body: @response_body, headers: {})
|
15
15
|
end
|
16
16
|
|
17
17
|
should "send the right request" do
|
18
|
-
expected = Drip::Response.new(@response_status, @response_body)
|
18
|
+
expected = Drip::Response.new(@response_status, JSON.parse(@response_body))
|
19
19
|
assert_equal expected, @client.campaigns
|
20
20
|
end
|
21
21
|
end
|
@@ -23,7 +23,7 @@ class Drip::Client::CampaignsTest < Drip::TestCase
|
|
23
23
|
context "#campaign" do
|
24
24
|
setup do
|
25
25
|
@response_status = 200
|
26
|
-
@response_body = "
|
26
|
+
@response_body = "{}"
|
27
27
|
@id = 9999999
|
28
28
|
|
29
29
|
stub_request(:get, "https://api.getdrip.com/v2/12345/campaigns/#{@id}").
|
@@ -31,7 +31,7 @@ class Drip::Client::CampaignsTest < Drip::TestCase
|
|
31
31
|
end
|
32
32
|
|
33
33
|
should "send the right request" do
|
34
|
-
expected = Drip::Response.new(@response_status, @response_body)
|
34
|
+
expected = Drip::Response.new(@response_status, JSON.parse(@response_body))
|
35
35
|
assert_equal expected, @client.campaign(@id)
|
36
36
|
end
|
37
37
|
end
|
@@ -71,7 +71,7 @@ class Drip::Client::CampaignsTest < Drip::TestCase
|
|
71
71
|
context "#campaign_subscribers" do
|
72
72
|
setup do
|
73
73
|
@response_status = 200
|
74
|
-
@response_body = "
|
74
|
+
@response_body = "{}"
|
75
75
|
@id = 9999999
|
76
76
|
|
77
77
|
stub_request(:get, "https://api.getdrip.com/v2/12345/campaigns/#{@id}/subscribers").
|
@@ -79,7 +79,7 @@ class Drip::Client::CampaignsTest < Drip::TestCase
|
|
79
79
|
end
|
80
80
|
|
81
81
|
should "send the right request" do
|
82
|
-
expected = Drip::Response.new(@response_status, @response_body)
|
82
|
+
expected = Drip::Response.new(@response_status, JSON.parse(@response_body))
|
83
83
|
assert_equal expected, @client.campaign_subscribers(@id)
|
84
84
|
end
|
85
85
|
end
|
@@ -8,14 +8,14 @@ class Drip::Client::ConversionsTest < Drip::TestCase
|
|
8
8
|
context "#conversions" do
|
9
9
|
setup do
|
10
10
|
@response_status = 200
|
11
|
-
@response_body = "
|
11
|
+
@response_body = "{}"
|
12
12
|
|
13
13
|
stub_request(:get, "https://api.getdrip.com/v2/12345/goals").
|
14
14
|
to_return(status: @response_status, body: @response_body, headers: {})
|
15
15
|
end
|
16
16
|
|
17
17
|
should "send the right request" do
|
18
|
-
expected = Drip::Response.new(@response_status, @response_body)
|
18
|
+
expected = Drip::Response.new(@response_status, JSON.parse(@response_body))
|
19
19
|
assert_equal expected, @client.conversions
|
20
20
|
end
|
21
21
|
end
|
@@ -23,7 +23,7 @@ class Drip::Client::ConversionsTest < Drip::TestCase
|
|
23
23
|
context "#conversion" do
|
24
24
|
setup do
|
25
25
|
@response_status = 200
|
26
|
-
@response_body = "
|
26
|
+
@response_body = "{}"
|
27
27
|
@id = 9999999
|
28
28
|
|
29
29
|
stub_request(:get, "https://api.getdrip.com/v2/12345/goals/#{@id}").
|
@@ -31,7 +31,7 @@ class Drip::Client::ConversionsTest < Drip::TestCase
|
|
31
31
|
end
|
32
32
|
|
33
33
|
should "send the right request" do
|
34
|
-
expected = Drip::Response.new(@response_status, @response_body)
|
34
|
+
expected = Drip::Response.new(@response_status, JSON.parse(@response_body))
|
35
35
|
assert_equal expected, @client.conversion(@id)
|
36
36
|
end
|
37
37
|
end
|
@@ -8,14 +8,14 @@ class Drip::Client::CustomFieldsTest < Drip::TestCase
|
|
8
8
|
context "#custom_fields" do
|
9
9
|
setup do
|
10
10
|
@response_status = 200
|
11
|
-
@response_body = "
|
11
|
+
@response_body = "{}"
|
12
12
|
|
13
13
|
stub_request(:get, "https://api.getdrip.com/v2/12345/custom_field_identifiers").
|
14
14
|
to_return(status: @response_status, body: @response_body, headers: {})
|
15
15
|
end
|
16
16
|
|
17
17
|
should "send the right request" do
|
18
|
-
expected = Drip::Response.new(@response_status, @response_body)
|
18
|
+
expected = Drip::Response.new(@response_status, JSON.parse(@response_body))
|
19
19
|
assert_equal expected, @client.custom_fields
|
20
20
|
end
|
21
21
|
end
|
@@ -23,14 +23,14 @@ class Drip::Client::EventsTest < Drip::TestCase
|
|
23
23
|
}.to_json
|
24
24
|
|
25
25
|
@response_status = 201
|
26
|
-
@response_body = "
|
26
|
+
@response_body = "{}"
|
27
27
|
|
28
28
|
stub_request(:post, "https://api.getdrip.com/v2/12345/events").
|
29
29
|
to_return(status: @response_status, body: @response_body, headers: {})
|
30
30
|
end
|
31
31
|
|
32
32
|
should "send the right request" do
|
33
|
-
expected = Drip::Response.new(@response_status, @response_body)
|
33
|
+
expected = Drip::Response.new(@response_status, JSON.parse(@response_body))
|
34
34
|
assert_equal expected, @client.track_event(@email, @action, @properties)
|
35
35
|
end
|
36
36
|
end
|
@@ -50,14 +50,14 @@ class Drip::Client::EventsTest < Drip::TestCase
|
|
50
50
|
}.to_json
|
51
51
|
|
52
52
|
@response_status = 201
|
53
|
-
@response_body = "
|
53
|
+
@response_body = "{}"
|
54
54
|
|
55
55
|
stub_request(:post, "https://api.getdrip.com/v2/12345/events").
|
56
56
|
to_return(status: @response_status, body: @response_body, headers: {})
|
57
57
|
end
|
58
58
|
|
59
59
|
should "send the right request" do
|
60
|
-
expected = Drip::Response.new(@response_status, @response_body)
|
60
|
+
expected = Drip::Response.new(@response_status, JSON.parse(@response_body))
|
61
61
|
assert_equal expected, @client.track_event(@email, @action, @properties, @options)
|
62
62
|
end
|
63
63
|
end
|
@@ -78,14 +78,14 @@ class Drip::Client::EventsTest < Drip::TestCase
|
|
78
78
|
|
79
79
|
@payload = { "batches" => [{ "events" => @events }] }.to_json
|
80
80
|
@response_status = 201
|
81
|
-
@response_body = "
|
81
|
+
@response_body = "{}"
|
82
82
|
|
83
83
|
stub_request(:post, "https://api.getdrip.com/v2/12345/events/batches").
|
84
84
|
to_return(status: @response_status, body: @response_body, headers: {})
|
85
85
|
end
|
86
86
|
|
87
87
|
should "send the right request" do
|
88
|
-
expected = Drip::Response.new(@response_status, @response_body)
|
88
|
+
expected = Drip::Response.new(@response_status, JSON.parse(@response_body))
|
89
89
|
assert_equal expected, @client.track_events(@events)
|
90
90
|
end
|
91
91
|
end
|
@@ -93,14 +93,14 @@ class Drip::Client::EventsTest < Drip::TestCase
|
|
93
93
|
context "#event_actions" do
|
94
94
|
setup do
|
95
95
|
@response_status = 200
|
96
|
-
@response_body = "
|
96
|
+
@response_body = "{}"
|
97
97
|
|
98
98
|
stub_request(:get, "https://api.getdrip.com/v2/12345/event_actions").
|
99
99
|
to_return(status: @response_status, body: @response_body, headers: {})
|
100
100
|
end
|
101
101
|
|
102
102
|
should "send the right request" do
|
103
|
-
expected = Drip::Response.new(@response_status, @response_body)
|
103
|
+
expected = Drip::Response.new(@response_status, JSON.parse(@response_body))
|
104
104
|
assert_equal expected, @client.event_actions
|
105
105
|
end
|
106
106
|
end
|
@@ -8,14 +8,14 @@ class Drip::Client::FormsTest < Drip::TestCase
|
|
8
8
|
context "#forms" do
|
9
9
|
setup do
|
10
10
|
@response_status = 200
|
11
|
-
@response_body = "
|
11
|
+
@response_body = "{}"
|
12
12
|
|
13
13
|
stub_request(:get, "https://api.getdrip.com/v2/12345/forms").
|
14
14
|
to_return(status: @response_status, body: @response_body, headers: {})
|
15
15
|
end
|
16
16
|
|
17
17
|
should "send the right request" do
|
18
|
-
expected = Drip::Response.new(@response_status, @response_body)
|
18
|
+
expected = Drip::Response.new(@response_status, JSON.parse(@response_body))
|
19
19
|
assert_equal expected, @client.forms
|
20
20
|
end
|
21
21
|
end
|
@@ -23,7 +23,7 @@ class Drip::Client::FormsTest < Drip::TestCase
|
|
23
23
|
context "#form" do
|
24
24
|
setup do
|
25
25
|
@response_status = 200
|
26
|
-
@response_body = "
|
26
|
+
@response_body = "{}"
|
27
27
|
@id = 9999999
|
28
28
|
|
29
29
|
stub_request(:get, "https://api.getdrip.com/v2/12345/forms/#{@id}").
|
@@ -31,7 +31,7 @@ class Drip::Client::FormsTest < Drip::TestCase
|
|
31
31
|
end
|
32
32
|
|
33
33
|
should "send the right request" do
|
34
|
-
expected = Drip::Response.new(@response_status, @response_body)
|
34
|
+
expected = Drip::Response.new(@response_status, JSON.parse(@response_body))
|
35
35
|
assert_equal expected, @client.form(@id)
|
36
36
|
end
|
37
37
|
end
|
@@ -24,14 +24,14 @@ class Drip::Client::OrdersTest < Drip::TestCase
|
|
24
24
|
}
|
25
25
|
@payload = { "orders" => [@options] }.to_json
|
26
26
|
@response_status = 202
|
27
|
-
@response_body = "
|
27
|
+
@response_body = "{}"
|
28
28
|
|
29
29
|
stub_request(:post, "https://api.getdrip.com/v2/12345/orders").
|
30
30
|
to_return(status: @response_status, body: @response_body, headers: {})
|
31
31
|
end
|
32
32
|
|
33
33
|
should "send the correct request" do
|
34
|
-
expected = Drip::Response.new(@response_status, @response_body)
|
34
|
+
expected = Drip::Response.new(@response_status, JSON.parse(@response_body))
|
35
35
|
assert_equal expected, @client.create_or_update_order(@email, @options)
|
36
36
|
end
|
37
37
|
end
|
@@ -71,14 +71,14 @@ class Drip::Client::OrdersTest < Drip::TestCase
|
|
71
71
|
|
72
72
|
@payload = { "batches" => [{ "orders" => @orders }] }.to_json
|
73
73
|
@response_status = 202
|
74
|
-
@response_body = "
|
74
|
+
@response_body = "{}"
|
75
75
|
|
76
76
|
stub_request(:post, "https://api.getdrip.com/v2/12345/orders/batches").
|
77
77
|
to_return(status: @response_status, body: @response_body, headers: {})
|
78
78
|
end
|
79
79
|
|
80
80
|
should "send the correct request" do
|
81
|
-
expected = Drip::Response.new(@response_status, @response_body)
|
81
|
+
expected = Drip::Response.new(@response_status, JSON.parse(@response_body))
|
82
82
|
assert_equal expected, @client.create_or_update_orders(@orders)
|
83
83
|
end
|
84
84
|
end
|
@@ -96,14 +96,14 @@ class Drip::Client::OrdersTest < Drip::TestCase
|
|
96
96
|
|
97
97
|
@payload = { "refunds" => [@options] }.to_json
|
98
98
|
@response_status = 202
|
99
|
-
@response_body = "
|
99
|
+
@response_body = "{}"
|
100
100
|
|
101
101
|
stub_request(:post, "https://api.getdrip.com/v2/12345/refunds").
|
102
102
|
to_return(status: @response_status, body: @response_body, headers: {})
|
103
103
|
end
|
104
104
|
|
105
105
|
should "send the correct request" do
|
106
|
-
expected = Drip::Response.new(@response_status, @response_body)
|
106
|
+
expected = Drip::Response.new(@response_status, JSON.parse(@response_body))
|
107
107
|
assert_equal expected, @client.create_or_update_refund(@options)
|
108
108
|
end
|
109
109
|
end
|
@@ -8,14 +8,14 @@ class Drip::Client::SubscribersTest < Drip::TestCase
|
|
8
8
|
context "#subscribers" do
|
9
9
|
setup do
|
10
10
|
@response_status = 200
|
11
|
-
@response_body = "
|
11
|
+
@response_body = "{}"
|
12
12
|
|
13
13
|
stub_request(:get, "https://api.getdrip.com/v2/12345/subscribers").
|
14
14
|
to_return(status: @response_status, body: @response_body, headers: {})
|
15
15
|
end
|
16
16
|
|
17
17
|
should "send the right request" do
|
18
|
-
expected = Drip::Response.new(@response_status, @response_body)
|
18
|
+
expected = Drip::Response.new(@response_status, JSON.parse(@response_body))
|
19
19
|
assert_equal expected, @client.subscribers
|
20
20
|
end
|
21
21
|
end
|
@@ -24,14 +24,14 @@ class Drip::Client::SubscribersTest < Drip::TestCase
|
|
24
24
|
setup do
|
25
25
|
@id = "derrick@getdrip.com"
|
26
26
|
@response_status = 201
|
27
|
-
@response_body = "
|
27
|
+
@response_body = "{}"
|
28
28
|
|
29
29
|
stub_request(:get, "https://api.getdrip.com/v2/12345/subscribers/#{CGI.escape @id}").
|
30
30
|
to_return(status: @response_status, body: @response_body, headers: {})
|
31
31
|
end
|
32
32
|
|
33
33
|
should "send the right request" do
|
34
|
-
expected = Drip::Response.new(@response_status, @response_body)
|
34
|
+
expected = Drip::Response.new(@response_status, JSON.parse(@response_body))
|
35
35
|
assert_equal expected, @client.subscriber(@id)
|
36
36
|
end
|
37
37
|
end
|
@@ -59,14 +59,14 @@ class Drip::Client::SubscribersTest < Drip::TestCase
|
|
59
59
|
@payload = { "subscribers" => [@data.merge(email: @email)] }.to_json
|
60
60
|
|
61
61
|
@response_status = 201
|
62
|
-
@response_body = "
|
62
|
+
@response_body = "{}"
|
63
63
|
|
64
64
|
stub_request(:post, "https://api.getdrip.com/v2/12345/subscribers").
|
65
65
|
to_return(status: @response_status, body: @response_body, headers: {})
|
66
66
|
end
|
67
67
|
|
68
68
|
should "send the right request" do
|
69
|
-
expected = Drip::Response.new(@response_status, @response_body)
|
69
|
+
expected = Drip::Response.new(@response_status, JSON.parse(@response_body))
|
70
70
|
assert_equal expected, @client.create_or_update_subscriber(@email, @data)
|
71
71
|
end
|
72
72
|
end
|
@@ -86,14 +86,14 @@ class Drip::Client::SubscribersTest < Drip::TestCase
|
|
86
86
|
|
87
87
|
@payload = { "batches" => [{ "subscribers" => @subscribers }] }.to_json
|
88
88
|
@response_status = 201
|
89
|
-
@response_body = "
|
89
|
+
@response_body = "{}"
|
90
90
|
|
91
91
|
stub_request(:post, "https://api.getdrip.com/v2/12345/subscribers/batches").
|
92
92
|
to_return(status: @response_status, body: @response_body, headers: {})
|
93
93
|
end
|
94
94
|
|
95
95
|
should "send the right request" do
|
96
|
-
expected = Drip::Response.new(@response_status, @response_body)
|
96
|
+
expected = Drip::Response.new(@response_status, JSON.parse(@response_body))
|
97
97
|
assert_equal expected, @client.create_or_update_subscribers(@subscribers)
|
98
98
|
end
|
99
99
|
end
|
@@ -131,14 +131,14 @@ class Drip::Client::SubscribersTest < Drip::TestCase
|
|
131
131
|
@payload = { "subscribers" => [@data.merge(email: @email)] }.to_json
|
132
132
|
|
133
133
|
@response_status = 201
|
134
|
-
@response_body = "
|
134
|
+
@response_body = "{}"
|
135
135
|
|
136
136
|
stub_request(:post, "https://api.getdrip.com/v2/12345/campaigns/#{@campaign_id}/subscribers").
|
137
137
|
to_return(status: @response_status, body: @response_body, headers: {})
|
138
138
|
end
|
139
139
|
|
140
140
|
should "send the right request" do
|
141
|
-
expected = Drip::Response.new(@response_status, @response_body)
|
141
|
+
expected = Drip::Response.new(@response_status, JSON.parse(@response_body))
|
142
142
|
assert_equal expected, @client.subscribe(@email, @campaign_id, @data)
|
143
143
|
end
|
144
144
|
end
|
@@ -149,14 +149,14 @@ class Drip::Client::SubscribersTest < Drip::TestCase
|
|
149
149
|
@id = "derrick@getdrip.com"
|
150
150
|
|
151
151
|
@response_status = 201
|
152
|
-
@response_body = "
|
152
|
+
@response_body = "{}"
|
153
153
|
|
154
154
|
stub_request(:post, "https://api.getdrip.com/v2/12345/subscribers/#{CGI.escape @id}/remove").
|
155
155
|
to_return(status: @response_status, body: @response_body, headers: {})
|
156
156
|
end
|
157
157
|
|
158
158
|
should "send the right request" do
|
159
|
-
expected = Drip::Response.new(@response_status, @response_body)
|
159
|
+
expected = Drip::Response.new(@response_status, JSON.parse(@response_body))
|
160
160
|
assert_equal expected, @client.unsubscribe(@id)
|
161
161
|
end
|
162
162
|
end
|
@@ -167,14 +167,14 @@ class Drip::Client::SubscribersTest < Drip::TestCase
|
|
167
167
|
@campaign = "12345"
|
168
168
|
|
169
169
|
@response_status = 201
|
170
|
-
@response_body = "
|
170
|
+
@response_body = "{}"
|
171
171
|
|
172
172
|
stub_request(:post, "https://api.getdrip.com/v2/12345/subscribers/#{CGI.escape @id}/remove?campaign_id=#{@campaign}").
|
173
173
|
to_return(status: @response_status, body: @response_body, headers: {})
|
174
174
|
end
|
175
175
|
|
176
176
|
should "send the right request" do
|
177
|
-
expected = Drip::Response.new(@response_status, @response_body)
|
177
|
+
expected = Drip::Response.new(@response_status, JSON.parse(@response_body))
|
178
178
|
assert_equal expected, @client.unsubscribe(@id, campaign_id: @campaign)
|
179
179
|
end
|
180
180
|
end
|
@@ -184,14 +184,14 @@ class Drip::Client::SubscribersTest < Drip::TestCase
|
|
184
184
|
setup do
|
185
185
|
@id = "derrick@getdrip.com"
|
186
186
|
@response_status = 200
|
187
|
-
@response_body = "
|
187
|
+
@response_body = "{}"
|
188
188
|
|
189
189
|
stub_request(:post, "https://api.getdrip.com/v2/12345/subscribers/#{CGI.escape @id}/unsubscribe_all").
|
190
190
|
to_return(status: @response_status, body: @response_body, headers: {})
|
191
191
|
end
|
192
192
|
|
193
193
|
should "send the right request" do
|
194
|
-
expected = Drip::Response.new(@response_status, @response_body)
|
194
|
+
expected = Drip::Response.new(@response_status, JSON.parse(@response_body))
|
195
195
|
assert_equal expected, @client.unsubscribe_from_all(@id)
|
196
196
|
end
|
197
197
|
end
|
@@ -203,14 +203,14 @@ class Drip::Client::SubscribersTest < Drip::TestCase
|
|
203
203
|
@payload = { "tags" => [{ "email" => @email, "tag" => @tag }] }.to_json
|
204
204
|
|
205
205
|
@response_status = 201
|
206
|
-
@response_body = "
|
206
|
+
@response_body = "{}"
|
207
207
|
|
208
208
|
stub_request(:post, "https://api.getdrip.com/v2/12345/tags").
|
209
209
|
to_return(status: @response_status, body: @response_body, headers: {})
|
210
210
|
end
|
211
211
|
|
212
212
|
should "send the right request" do
|
213
|
-
expected = Drip::Response.new(@response_status, @response_body)
|
213
|
+
expected = Drip::Response.new(@response_status, JSON.parse(@response_body))
|
214
214
|
assert_equal expected, @client.apply_tag(@email, @tag)
|
215
215
|
end
|
216
216
|
end
|
@@ -8,14 +8,14 @@ class Drip::Client::TagsTest < Drip::TestCase
|
|
8
8
|
context "#tags" do
|
9
9
|
setup do
|
10
10
|
@response_status = 200
|
11
|
-
@response_body = "
|
11
|
+
@response_body = "{}"
|
12
12
|
|
13
13
|
stub_request(:get, "https://api.getdrip.com/v2/12345/tags").
|
14
14
|
to_return(status: @response_status, body: @response_body, headers: {})
|
15
15
|
end
|
16
16
|
|
17
17
|
should "send the right request" do
|
18
|
-
expected = Drip::Response.new(@response_status, @response_body)
|
18
|
+
expected = Drip::Response.new(@response_status, JSON.parse(@response_body))
|
19
19
|
assert_equal expected, @client.tags
|
20
20
|
end
|
21
21
|
end
|
@@ -27,14 +27,14 @@ class Drip::Client::TagsTest < Drip::TestCase
|
|
27
27
|
@payload = { "tags" => [{ "email" => @email, "tag" => @tag }] }.to_json
|
28
28
|
|
29
29
|
@response_status = 201
|
30
|
-
@response_body = "
|
30
|
+
@response_body = "{}"
|
31
31
|
|
32
32
|
stub_request(:post, "https://api.getdrip.com/v2/12345/tags").
|
33
33
|
to_return(status: @response_status, body: @response_body, headers: {})
|
34
34
|
end
|
35
35
|
|
36
36
|
should "send the right request" do
|
37
|
-
expected = Drip::Response.new(@response_status, @response_body)
|
37
|
+
expected = Drip::Response.new(@response_status, JSON.parse(@response_body))
|
38
38
|
assert_equal expected, @client.apply_tag(@email, @tag)
|
39
39
|
end
|
40
40
|
end
|
@@ -8,14 +8,14 @@ class Drip::Client::WebhooksTest < Drip::TestCase
|
|
8
8
|
context "#webhooks" do
|
9
9
|
setup do
|
10
10
|
@response_status = 200
|
11
|
-
@response_body = "
|
11
|
+
@response_body = "{}"
|
12
12
|
|
13
13
|
stub_request(:get, "https://api.getdrip.com/v2/12345/webhooks").
|
14
14
|
to_return(status: @response_status, body: @response_body, headers: {})
|
15
15
|
end
|
16
16
|
|
17
17
|
should "send the right request" do
|
18
|
-
expected = Drip::Response.new(@response_status, @response_body)
|
18
|
+
expected = Drip::Response.new(@response_status, JSON.parse(@response_body))
|
19
19
|
assert_equal expected, @client.webhooks
|
20
20
|
end
|
21
21
|
end
|
@@ -23,7 +23,7 @@ class Drip::Client::WebhooksTest < Drip::TestCase
|
|
23
23
|
context "#webhook" do
|
24
24
|
setup do
|
25
25
|
@response_status = 200
|
26
|
-
@response_body = "
|
26
|
+
@response_body = "{}"
|
27
27
|
@id = 1234
|
28
28
|
|
29
29
|
stub_request(:get, "https://api.getdrip.com/v2/12345/webhooks/#{@id}").
|
@@ -31,7 +31,7 @@ class Drip::Client::WebhooksTest < Drip::TestCase
|
|
31
31
|
end
|
32
32
|
|
33
33
|
should "send the right request" do
|
34
|
-
expected = Drip::Response.new(@response_status, @response_body)
|
34
|
+
expected = Drip::Response.new(@response_status, JSON.parse(@response_body))
|
35
35
|
assert_equal expected, @client.webhook(@id)
|
36
36
|
end
|
37
37
|
end
|
@@ -50,14 +50,14 @@ class Drip::Client::WebhooksTest < Drip::TestCase
|
|
50
50
|
|
51
51
|
@payload = { "webhooks" => [@options] }.to_json
|
52
52
|
@response_status = 201
|
53
|
-
@response_body = "
|
53
|
+
@response_body = "{}"
|
54
54
|
|
55
55
|
stub_request(:post, "https://api.getdrip.com/v2/12345/webhooks").
|
56
56
|
to_return(status: @response_status, body: @response_body, headers: {})
|
57
57
|
end
|
58
58
|
|
59
59
|
should "send the right request" do
|
60
|
-
expected = Drip::Response.new(@response_status, @response_body)
|
60
|
+
expected = Drip::Response.new(@response_status, JSON.parse(@response_body))
|
61
61
|
assert_equal expected, @client.create_webhook(@post_url, @include_received_email, @events)
|
62
62
|
end
|
63
63
|
end
|
@@ -65,7 +65,7 @@ class Drip::Client::WebhooksTest < Drip::TestCase
|
|
65
65
|
context "#delete_webhook" do
|
66
66
|
setup do
|
67
67
|
@response_status = 200
|
68
|
-
@response_body = "
|
68
|
+
@response_body = "{}"
|
69
69
|
@id = 1234
|
70
70
|
|
71
71
|
stub_request(:delete, "https://api.getdrip.com/v2/12345/webhooks/#{@id}").
|
@@ -73,7 +73,7 @@ class Drip::Client::WebhooksTest < Drip::TestCase
|
|
73
73
|
end
|
74
74
|
|
75
75
|
should "send the right request" do
|
76
|
-
expected = Drip::Response.new(@response_status, @response_body)
|
76
|
+
expected = Drip::Response.new(@response_status, JSON.parse(@response_body))
|
77
77
|
assert_equal expected, @client.delete_webhook(@id)
|
78
78
|
end
|
79
79
|
end
|
@@ -9,14 +9,14 @@ class Drip::Client::WorkflowTriggersTest < Drip::TestCase
|
|
9
9
|
setup do
|
10
10
|
@id = 9999999
|
11
11
|
@response_status = 200
|
12
|
-
@response_body = "
|
12
|
+
@response_body = "{}"
|
13
13
|
|
14
14
|
stub_request(:get, "https://api.getdrip.com/v2/12345/workflows/#{@id}/triggers").
|
15
15
|
to_return(status: @response_status, body: @response_body, headers: {})
|
16
16
|
end
|
17
17
|
|
18
18
|
should "send the right request" do
|
19
|
-
expected = Drip::Response.new(@response_status, @response_body)
|
19
|
+
expected = Drip::Response.new(@response_status, JSON.parse(@response_body))
|
20
20
|
assert_equal expected, @client.workflow_triggers(@id)
|
21
21
|
end
|
22
22
|
end
|
@@ -35,14 +35,14 @@ class Drip::Client::WorkflowTriggersTest < Drip::TestCase
|
|
35
35
|
@payload = { "triggers" => [@data] }.to_json
|
36
36
|
|
37
37
|
@response_status = 200
|
38
|
-
@response_body = "
|
38
|
+
@response_body = "{}"
|
39
39
|
|
40
40
|
stub_request(:post, "https://api.getdrip.com/v2/12345/workflows/#{@id}/triggers").
|
41
41
|
to_return(status: @response_status, body: @response_body, headers: {})
|
42
42
|
end
|
43
43
|
|
44
44
|
should "send the right request" do
|
45
|
-
expected = Drip::Response.new(@response_status, @response_body)
|
45
|
+
expected = Drip::Response.new(@response_status, JSON.parse(@response_body))
|
46
46
|
assert_equal expected, @client.create_workflow_trigger(@id, @data)
|
47
47
|
end
|
48
48
|
end
|
@@ -61,14 +61,14 @@ class Drip::Client::WorkflowTriggersTest < Drip::TestCase
|
|
61
61
|
@payload = { "triggers" => [@data] }.to_json
|
62
62
|
|
63
63
|
@response_status = 200
|
64
|
-
@response_body = "
|
64
|
+
@response_body = "{}"
|
65
65
|
|
66
66
|
stub_request(:put, "https://api.getdrip.com/v2/12345/workflows/#{@id}/triggers").
|
67
67
|
to_return(status: @response_status, body: @response_body, headers: {})
|
68
68
|
end
|
69
69
|
|
70
70
|
should "send the right request" do
|
71
|
-
expected = Drip::Response.new(@response_status, @response_body)
|
71
|
+
expected = Drip::Response.new(@response_status, JSON.parse(@response_body))
|
72
72
|
assert_equal expected, @client.update_workflow_trigger(@id, @data)
|
73
73
|
end
|
74
74
|
end
|
@@ -8,14 +8,14 @@ class Drip::Client::WorkflowsTest < Drip::TestCase
|
|
8
8
|
context "#workflows" do
|
9
9
|
setup do
|
10
10
|
@response_status = 200
|
11
|
-
@response_body = "
|
11
|
+
@response_body = "{}"
|
12
12
|
|
13
13
|
stub_request(:get, "https://api.getdrip.com/v2/12345/workflows").
|
14
14
|
to_return(status: @response_status, body: @response_body, headers: {})
|
15
15
|
end
|
16
16
|
|
17
17
|
should "send the right request" do
|
18
|
-
expected = Drip::Response.new(@response_status, @response_body)
|
18
|
+
expected = Drip::Response.new(@response_status, JSON.parse(@response_body))
|
19
19
|
assert_equal expected, @client.workflows
|
20
20
|
end
|
21
21
|
end
|
@@ -23,7 +23,7 @@ class Drip::Client::WorkflowsTest < Drip::TestCase
|
|
23
23
|
context "#workflow" do
|
24
24
|
setup do
|
25
25
|
@response_status = 200
|
26
|
-
@response_body = "
|
26
|
+
@response_body = "{}"
|
27
27
|
@id = 1234
|
28
28
|
|
29
29
|
stub_request(:get, "https://api.getdrip.com/v2/12345/workflows/#{@id}").
|
@@ -31,7 +31,7 @@ class Drip::Client::WorkflowsTest < Drip::TestCase
|
|
31
31
|
end
|
32
32
|
|
33
33
|
should "send the right request" do
|
34
|
-
expected = Drip::Response.new(@response_status, @response_body)
|
34
|
+
expected = Drip::Response.new(@response_status, JSON.parse(@response_body))
|
35
35
|
assert_equal expected, @client.workflow(@id)
|
36
36
|
end
|
37
37
|
end
|
@@ -93,7 +93,7 @@ class Drip::Client::WorkflowsTest < Drip::TestCase
|
|
93
93
|
context "#remove_subscriber_workflow" do
|
94
94
|
setup do
|
95
95
|
@response_status = 200
|
96
|
-
@response_body = "
|
96
|
+
@response_body = "{}"
|
97
97
|
@id = 1234
|
98
98
|
@email = "someone@example.com"
|
99
99
|
|
@@ -102,7 +102,7 @@ class Drip::Client::WorkflowsTest < Drip::TestCase
|
|
102
102
|
end
|
103
103
|
|
104
104
|
should "send the right request" do
|
105
|
-
expected = Drip::Response.new(@response_status, @response_body)
|
105
|
+
expected = Drip::Response.new(@response_status, JSON.parse(@response_body))
|
106
106
|
assert_equal expected, @client.remove_subscriber_workflow(@id, @email)
|
107
107
|
end
|
108
108
|
end
|
data/test/drip/client_test.rb
CHANGED
@@ -88,6 +88,31 @@ class Drip::ClientTest < Drip::TestCase
|
|
88
88
|
end
|
89
89
|
end
|
90
90
|
|
91
|
+
context "given a basic request" do
|
92
|
+
setup do
|
93
|
+
@client = Drip::Client.new do |config|
|
94
|
+
config.api_key = "Hello world"
|
95
|
+
config.account_id = 12345
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
should "return objects" do
|
100
|
+
stub_request(:get, "https://api.getdrip.com/v2/12345/subscribers/jdoe%40example.com").
|
101
|
+
to_return(status: 200, body: "{\"links\":{\"subscribers.account\":\"https://api.getdrip.com/v2/accounts/{subscribers.account}\"},\"subscribers\":[{\"id\":\"randomid\",\"href\":\"https://api.getdrip.com/v2/1234/subscribers/randomid\",\"status\":\"active\",\"email\":\"jdoe@example.com\",\"time_zone\":null,\"utc_offset\":0,\"visitor_uuid\":null,\"custom_fields\":{\"first_name\":\"John\"},\"tags\":[\"customer\"],\"created_at\":\"2018-06-04T21:29:49Z\",\"ip_address\":null,\"user_agent\":null,\"lifetime_value\":null,\"original_referrer\":null,\"landing_url\":null,\"prospect\":null,\"base_lead_score\":null,\"eu_consent\":\"unknown\",\"lead_score\":null,\"user_id\":\"123\",\"links\":{\"account\":\"1234\"}}]}")
|
102
|
+
|
103
|
+
response = @client.subscriber('jdoe@example.com')
|
104
|
+
assert_equal('randomid', response.subscribers.first.id)
|
105
|
+
end
|
106
|
+
|
107
|
+
should "handle empty string" do
|
108
|
+
stub_request(:get, "https://api.getdrip.com/v2/12345/subscribers/jdoe%40example.com").
|
109
|
+
to_return(status: 200, body: "")
|
110
|
+
|
111
|
+
response = @client.subscriber('jdoe@example.com')
|
112
|
+
assert_nil(response.body)
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
91
116
|
context "given a different url prefix" do
|
92
117
|
setup do
|
93
118
|
@key = "aaaa"
|
@@ -133,11 +158,11 @@ class Drip::ClientTest < Drip::TestCase
|
|
133
158
|
stub_request(:get, "https://api.getdrip.com/v2/testpath").
|
134
159
|
to_return(status: 301, body: "", headers: { "Location" => "https://api.example.com/mytestpath" })
|
135
160
|
stub_request(:get, "https://api.example.com/mytestpath").
|
136
|
-
to_return(status: 200, body: "
|
161
|
+
to_return(status: 200, body: "{}")
|
137
162
|
response = @client.get("testpath")
|
138
163
|
assert_requested :get, "https://api.getdrip.com/v2/testpath"
|
139
164
|
assert_requested :get, "https://api.example.com/mytestpath"
|
140
|
-
assert_equal
|
165
|
+
assert_equal({}, response.body)
|
141
166
|
end
|
142
167
|
|
143
168
|
should "not follow too many redirects" do
|
@@ -156,7 +181,7 @@ class Drip::ClientTest < Drip::TestCase
|
|
156
181
|
@client = Drip::Client.new
|
157
182
|
@response = mock
|
158
183
|
@response.stubs(:code).returns('200')
|
159
|
-
@response.stubs(:body).returns('
|
184
|
+
@response.stubs(:body).returns('{}')
|
160
185
|
|
161
186
|
@http = mock
|
162
187
|
@http.expects(:request).returns(@response)
|
@@ -167,9 +192,6 @@ class Drip::ClientTest < Drip::TestCase
|
|
167
192
|
end
|
168
193
|
|
169
194
|
should "encode query and not set body" do
|
170
|
-
stub_request(:get, "https://api.getdrip.com/v2/testpath").
|
171
|
-
to_return(status: 200, body: "mybody")
|
172
|
-
|
173
195
|
Net::HTTP::Get.expects(:new).returns(@request)
|
174
196
|
Net::HTTP.expects(:start).yields(@http).returns(@response)
|
175
197
|
|
@@ -177,7 +199,7 @@ class Drip::ClientTest < Drip::TestCase
|
|
177
199
|
URI.expects(:encode_www_form).once
|
178
200
|
|
179
201
|
response = @client.get("testpath")
|
180
|
-
assert_equal
|
202
|
+
assert_equal({}, response.body)
|
181
203
|
end
|
182
204
|
end
|
183
205
|
end
|
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: 3.1.
|
4
|
+
version: 3.1.1
|
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-06-
|
11
|
+
date: 2018-06-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|