drip-ruby 2.0.0 → 3.0.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 +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
data/lib/drip/client/orders.rb
CHANGED
@@ -27,12 +27,12 @@ module Drip
|
|
27
27
|
# Public: Create or update a refund.
|
28
28
|
#
|
29
29
|
# options - Required. A Hash of refund properties
|
30
|
-
# amount
|
30
|
+
# amount - Required. The amount of the refund.
|
31
31
|
# provider - Required. The provider for the Order being refunded.
|
32
32
|
# order_upstream_id - Required. The upstream_id for the Order being refunded.
|
33
|
-
# upstream_id
|
34
|
-
# note
|
35
|
-
# processed_at - The String time at which the refund was processed in
|
33
|
+
# upstream_id - The unique id of refund in the order management system.
|
34
|
+
# note - A note about the refund.
|
35
|
+
# processed_at - The String time at which the refund was processed in
|
36
36
|
# ISO-8601 format.
|
37
37
|
#
|
38
38
|
# Returns a Drip::Response.
|
data/lib/drip/errors.rb
ADDED
data/lib/drip/response.rb
CHANGED
@@ -51,10 +51,10 @@ module Drip
|
|
51
51
|
if body.is_a?(Hash)
|
52
52
|
body.each do |key, value|
|
53
53
|
klass = if value.is_a?(Array)
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
54
|
+
Drip::Collections.find_class(key)
|
55
|
+
else
|
56
|
+
Drip::Resources.find_class(key)
|
57
|
+
end
|
58
58
|
|
59
59
|
members[key] = klass.new(value)
|
60
60
|
end
|
@@ -65,7 +65,7 @@ module Drip
|
|
65
65
|
|
66
66
|
def member_map
|
67
67
|
@member_map ||= {}.tap do |map|
|
68
|
-
members.each { |key,
|
68
|
+
members.each { |key, _value| map[key.to_sym] = key }
|
69
69
|
end
|
70
70
|
end
|
71
71
|
end
|
data/lib/drip/version.rb
CHANGED
@@ -2,24 +2,16 @@ require File.dirname(__FILE__) + '/../../test_helper.rb'
|
|
2
2
|
|
3
3
|
class Drip::Client::AccountsTest < 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
|
12
|
-
@client.expects(:connection).at_least_once.returns(@connection)
|
13
6
|
end
|
14
7
|
|
15
8
|
context "#accounts" 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/accounts").
|
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::AccountsTest < Drip::TestCase
|
|
31
23
|
context "#account" do
|
32
24
|
setup do
|
33
25
|
@response_status = 200
|
34
|
-
@response_body = stub
|
26
|
+
@response_body = "stub"
|
35
27
|
@id = 9999999
|
36
28
|
|
37
|
-
|
38
|
-
|
39
|
-
end
|
29
|
+
stub_request(:get, "https://api.getdrip.com/v2/accounts/#{@id}").
|
30
|
+
to_return(status: @response_status, body: @response_body, headers: {})
|
40
31
|
end
|
41
32
|
|
42
33
|
should "send the right request" do
|
@@ -2,24 +2,16 @@ require File.dirname(__FILE__) + '/../../test_helper.rb'
|
|
2
2
|
|
3
3
|
class Drip::Client::BroadcastsTest < 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 "#broadcasts" 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/broadcasts").
|
14
|
+
to_return(status: @response_status, body: @response_body, headers: {})
|
23
15
|
end
|
24
16
|
|
25
17
|
should "send the correct request" do
|
@@ -31,12 +23,11 @@ class Drip::Client::BroadcastsTest < Drip::TestCase
|
|
31
23
|
context "#broadcast" do
|
32
24
|
setup do
|
33
25
|
@response_status = 200
|
34
|
-
@response_body = stub
|
26
|
+
@response_body = "stub"
|
35
27
|
@id = 99999
|
36
28
|
|
37
|
-
|
38
|
-
|
39
|
-
end
|
29
|
+
stub_request(:get, "https://api.getdrip.com/v2/12345/broadcasts/#{@id}").
|
30
|
+
to_return(status: @response_status, body: @response_body, headers: {})
|
40
31
|
end
|
41
32
|
|
42
33
|
should "send the correct request" do
|
@@ -2,25 +2,17 @@ require File.dirname(__FILE__) + '/../../test_helper.rb'
|
|
2
2
|
|
3
3
|
class Drip::Client::CampaignSubscriptionsTest < 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 "#campaign_subscriptions" do
|
16
9
|
setup do
|
17
10
|
@response_status = 200
|
18
|
-
@response_body = stub
|
11
|
+
@response_body = "stub"
|
19
12
|
@subscriber_id = "abc123"
|
20
13
|
|
21
|
-
|
22
|
-
|
23
|
-
end
|
14
|
+
stub_request(:get, "https://api.getdrip.com/v2/12345/subscribers/#{@subscriber_id}/campaign_subscriptions").
|
15
|
+
to_return(status: @response_status, body: @response_body, headers: {})
|
24
16
|
end
|
25
17
|
|
26
18
|
should "send the right request" do
|
@@ -2,24 +2,16 @@ require File.dirname(__FILE__) + '/../../test_helper.rb'
|
|
2
2
|
|
3
3
|
class Drip::Client::CampaignsTest < 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 "#campaigns" 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/campaigns").
|
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::CampaignsTest < Drip::TestCase
|
|
31
23
|
context "#campaign" do
|
32
24
|
setup do
|
33
25
|
@response_status = 200
|
34
|
-
@response_body = stub
|
26
|
+
@response_body = "stub"
|
35
27
|
@id = 9999999
|
36
28
|
|
37
|
-
|
38
|
-
|
39
|
-
end
|
29
|
+
stub_request(:get, "https://api.getdrip.com/v2/12345/campaigns/#{@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::CampaignsTest < Drip::TestCase
|
|
48
39
|
context "#activate_campaign" do
|
49
40
|
setup do
|
50
41
|
@response_status = 204
|
51
|
-
@response_body =
|
42
|
+
@response_body = nil
|
52
43
|
@id = 9999999
|
53
44
|
|
54
|
-
|
55
|
-
|
56
|
-
end
|
45
|
+
stub_request(:post, "https://api.getdrip.com/v2/12345/campaigns/#{@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::CampaignsTest < Drip::TestCase
|
|
65
55
|
context "#pause_campaign" do
|
66
56
|
setup do
|
67
57
|
@response_status = 204
|
68
|
-
@response_body =
|
58
|
+
@response_body = nil
|
69
59
|
@id = 9999999
|
70
60
|
|
71
|
-
|
72
|
-
|
73
|
-
end
|
61
|
+
stub_request(:post, "https://api.getdrip.com/v2/12345/campaigns/#{@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
|
@@ -82,12 +71,11 @@ class Drip::Client::CampaignsTest < Drip::TestCase
|
|
82
71
|
context "#campaign_subscribers" do
|
83
72
|
setup do
|
84
73
|
@response_status = 200
|
85
|
-
@response_body = stub
|
74
|
+
@response_body = "stub"
|
86
75
|
@id = 9999999
|
87
76
|
|
88
|
-
|
89
|
-
|
90
|
-
end
|
77
|
+
stub_request(:get, "https://api.getdrip.com/v2/12345/campaigns/#{@id}/subscribers").
|
78
|
+
to_return(status: @response_status, body: @response_body, headers: {})
|
91
79
|
end
|
92
80
|
|
93
81
|
should "send the right request" do
|
@@ -2,24 +2,16 @@ require File.dirname(__FILE__) + '/../../test_helper.rb'
|
|
2
2
|
|
3
3
|
class Drip::Client::ConversionsTest < 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 "#conversions" 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/goals").
|
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::ConversionsTest < Drip::TestCase
|
|
31
23
|
context "#conversion" do
|
32
24
|
setup do
|
33
25
|
@response_status = 200
|
34
|
-
@response_body = stub
|
26
|
+
@response_body = "stub"
|
35
27
|
@id = 9999999
|
36
28
|
|
37
|
-
|
38
|
-
|
39
|
-
end
|
29
|
+
stub_request(:get, "https://api.getdrip.com/v2/12345/goals/#{@id}").
|
30
|
+
to_return(status: @response_status, body: @response_body, headers: {})
|
40
31
|
end
|
41
32
|
|
42
33
|
should "send the right request" do
|
@@ -2,24 +2,16 @@ require File.dirname(__FILE__) + '/../../test_helper.rb'
|
|
2
2
|
|
3
3
|
class Drip::Client::CustomFieldsTest < 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 "#custom_fields" 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/custom_field_identifiers").
|
14
|
+
to_return(status: @response_status, body: @response_body, headers: {})
|
23
15
|
end
|
24
16
|
|
25
17
|
should "send the right request" do
|
@@ -2,14 +2,7 @@ require File.dirname(__FILE__) + '/../../test_helper.rb'
|
|
2
2
|
|
3
3
|
class Drip::Client::EventsTest < 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 "#track_event" do
|
@@ -30,11 +23,10 @@ class Drip::Client::EventsTest < Drip::TestCase
|
|
30
23
|
}.to_json
|
31
24
|
|
32
25
|
@response_status = 201
|
33
|
-
@response_body = stub
|
26
|
+
@response_body = "stub"
|
34
27
|
|
35
|
-
|
36
|
-
|
37
|
-
end
|
28
|
+
stub_request(:post, "https://api.getdrip.com/v2/12345/events").
|
29
|
+
to_return(status: @response_status, body: @response_body, headers: {})
|
38
30
|
end
|
39
31
|
|
40
32
|
should "send the right request" do
|
@@ -58,11 +50,10 @@ class Drip::Client::EventsTest < Drip::TestCase
|
|
58
50
|
}.to_json
|
59
51
|
|
60
52
|
@response_status = 201
|
61
|
-
@response_body = stub
|
53
|
+
@response_body = "stub"
|
62
54
|
|
63
|
-
|
64
|
-
|
65
|
-
end
|
55
|
+
stub_request(:post, "https://api.getdrip.com/v2/12345/events").
|
56
|
+
to_return(status: @response_status, body: @response_body, headers: {})
|
66
57
|
end
|
67
58
|
|
68
59
|
should "send the right request" do
|
@@ -87,11 +78,10 @@ class Drip::Client::EventsTest < Drip::TestCase
|
|
87
78
|
|
88
79
|
@payload = { "batches" => [{ "events" => @events }] }.to_json
|
89
80
|
@response_status = 201
|
90
|
-
@response_body = stub
|
81
|
+
@response_body = "stub"
|
91
82
|
|
92
|
-
|
93
|
-
|
94
|
-
end
|
83
|
+
stub_request(:post, "https://api.getdrip.com/v2/12345/events/batches").
|
84
|
+
to_return(status: @response_status, body: @response_body, headers: {})
|
95
85
|
end
|
96
86
|
|
97
87
|
should "send the right request" do
|
@@ -103,11 +93,10 @@ class Drip::Client::EventsTest < Drip::TestCase
|
|
103
93
|
context "#event_actions" do
|
104
94
|
setup do
|
105
95
|
@response_status = 200
|
106
|
-
@response_body = stub
|
96
|
+
@response_body = "stub"
|
107
97
|
|
108
|
-
|
109
|
-
|
110
|
-
end
|
98
|
+
stub_request(:get, "https://api.getdrip.com/v2/12345/event_actions").
|
99
|
+
to_return(status: @response_status, body: @response_body, headers: {})
|
111
100
|
end
|
112
101
|
|
113
102
|
should "send the right request" do
|
@@ -2,24 +2,16 @@ require File.dirname(__FILE__) + '/../../test_helper.rb'
|
|
2
2
|
|
3
3
|
class Drip::Client::FormsTest < 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 "#forms" 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/forms").
|
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::FormsTest < Drip::TestCase
|
|
31
23
|
context "#form" do
|
32
24
|
setup do
|
33
25
|
@response_status = 200
|
34
|
-
@response_body = stub
|
26
|
+
@response_body = "stub"
|
35
27
|
@id = 9999999
|
36
28
|
|
37
|
-
|
38
|
-
|
39
|
-
end
|
29
|
+
stub_request(:get, "https://api.getdrip.com/v2/12345/forms/#{@id}").
|
30
|
+
to_return(status: @response_status, body: @response_body, headers: {})
|
40
31
|
end
|
41
32
|
|
42
33
|
should "send the right request" do
|