drip-ruby 0.0.12 → 1.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 +4 -4
- data/.rubocop.yml +17 -0
- data/.rubocop_todo.yml +134 -0
- data/README.md +107 -13
- data/Rakefile +1 -1
- data/drip-ruby.gemspec +2 -2
- data/lib/drip/client.rb +23 -7
- data/lib/drip/client/accounts.rb +10 -0
- data/lib/drip/client/broadcasts.rb +29 -0
- data/lib/drip/client/campaign_subscriptions.rb +15 -0
- data/lib/drip/client/campaigns.rb +54 -0
- data/lib/drip/client/conversions.rb +27 -0
- data/lib/drip/client/custom_fields.rb +13 -0
- data/lib/drip/client/events.rb +13 -0
- data/lib/drip/client/forms.rb +23 -0
- data/lib/drip/client/purchases.rb +1 -1
- data/lib/drip/client/subscribers.rb +28 -6
- data/lib/drip/client/webhooks.rb +59 -0
- data/lib/drip/client/workflow_triggers.rb +44 -0
- data/lib/drip/client/workflows.rb +80 -0
- data/lib/drip/collections.rb +17 -5
- data/lib/drip/collections/broadcasts.rb +13 -0
- data/lib/drip/collections/campaign_subscriptions.rb +13 -0
- data/lib/drip/collections/campaigns.rb +13 -0
- data/lib/drip/collections/webhooks.rb +13 -0
- data/lib/drip/collections/workflow_triggers.rb +13 -0
- data/lib/drip/collections/workflows.rb +13 -0
- data/lib/drip/resources.rb +17 -5
- data/lib/drip/resources/broadcast.rb +9 -0
- data/lib/drip/resources/campaign.rb +9 -0
- data/lib/drip/resources/campaign_subscription.rb +9 -0
- data/lib/drip/resources/webhook.rb +9 -0
- data/lib/drip/resources/workflow.rb +9 -0
- data/lib/drip/resources/workflow_trigger.rb +9 -0
- data/lib/drip/response.rb +1 -1
- data/lib/drip/version.rb +1 -1
- data/test/drip/client/accounts_test.rb +17 -0
- data/test/drip/client/broadcasts_test.rb +47 -0
- data/test/drip/client/campaign_subscriptions_test.rb +31 -0
- data/test/drip/client/campaigns_test.rb +68 -0
- data/test/drip/client/conversions_test.rb +47 -0
- data/test/drip/client/custom_fields_test.rb +30 -0
- data/test/drip/client/events_test.rb +21 -5
- data/test/drip/client/forms_test.rb +47 -0
- data/test/drip/client/purchases_test.rb +0 -1
- data/test/drip/client/subscribers_test.rb +52 -9
- data/test/drip/client/webhooks_test.rb +91 -0
- data/test/drip/client/workflow_triggers_test.rb +85 -0
- data/test/drip/client/workflows_test.rb +122 -0
- data/test/drip/collection_test.rb +1 -1
- data/test/drip/collections_test.rb +8 -1
- data/test/drip/resources_test.rb +8 -1
- data/test/drip/response_test.rb +2 -2
- data/test/test_helper.rb +1 -1
- metadata +40 -2
data/lib/drip/resources.rb
CHANGED
|
@@ -1,23 +1,35 @@
|
|
|
1
1
|
require "drip/resources/account"
|
|
2
|
-
require "drip/resources/
|
|
3
|
-
require "drip/resources/
|
|
2
|
+
require "drip/resources/broadcast"
|
|
3
|
+
require "drip/resources/campaign"
|
|
4
|
+
require "drip/resources/campaign_subscription"
|
|
4
5
|
require "drip/resources/error"
|
|
5
6
|
require "drip/resources/purchase"
|
|
7
|
+
require "drip/resources/subscriber"
|
|
8
|
+
require "drip/resources/tag"
|
|
9
|
+
require "drip/resources/webhook"
|
|
10
|
+
require "drip/resources/workflow"
|
|
11
|
+
require "drip/resources/workflow_trigger"
|
|
6
12
|
|
|
7
13
|
module Drip
|
|
8
14
|
module Resources
|
|
9
15
|
def self.classes
|
|
10
16
|
[
|
|
11
17
|
Drip::Account,
|
|
12
|
-
Drip::
|
|
18
|
+
Drip::Broadcast,
|
|
19
|
+
Drip::Campaign,
|
|
20
|
+
Drip::CampaignSubscription,
|
|
13
21
|
Drip::Error,
|
|
22
|
+
Drip::Purchase,
|
|
23
|
+
Drip::Subscriber,
|
|
14
24
|
Drip::Tag,
|
|
15
|
-
Drip::
|
|
25
|
+
Drip::Webhook,
|
|
26
|
+
Drip::Workflow,
|
|
27
|
+
Drip::WorkflowTrigger
|
|
16
28
|
]
|
|
17
29
|
end
|
|
18
30
|
|
|
19
31
|
def self.find_class(name)
|
|
20
|
-
|
|
32
|
+
classes.find { |c| c.resource_name == name } || Drip::Resource
|
|
21
33
|
end
|
|
22
34
|
end
|
|
23
35
|
end
|
data/lib/drip/response.rb
CHANGED
data/lib/drip/version.rb
CHANGED
|
@@ -27,4 +27,21 @@ class Drip::Client::AccountsTest < Drip::TestCase
|
|
|
27
27
|
assert_equal expected, @client.accounts
|
|
28
28
|
end
|
|
29
29
|
end
|
|
30
|
+
|
|
31
|
+
context "#account" do
|
|
32
|
+
setup do
|
|
33
|
+
@response_status = 200
|
|
34
|
+
@response_body = stub
|
|
35
|
+
@id = 9999999
|
|
36
|
+
|
|
37
|
+
@stubs.get "accounts/#{@id}" do
|
|
38
|
+
[@response_status, {}, @response_body]
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
should "send the right request" do
|
|
43
|
+
expected = Drip::Response.new(@response_status, @response_body)
|
|
44
|
+
assert_equal expected, @client.account(@id)
|
|
45
|
+
end
|
|
46
|
+
end
|
|
30
47
|
end
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
require File.dirname(__FILE__) + '/../../test_helper.rb'
|
|
2
|
+
|
|
3
|
+
class Drip::Client::BroadcastsTest < Drip::TestCase
|
|
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
|
+
@client = Drip::Client.new { |c| c.account_id = "12345" }
|
|
12
|
+
@client.expects(:connection).at_least_once.returns(@connection)
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
context "#broadcasts" do
|
|
16
|
+
setup do
|
|
17
|
+
@response_status = 200
|
|
18
|
+
@response_body = stub
|
|
19
|
+
|
|
20
|
+
@stubs.get "12345/broadcasts" do
|
|
21
|
+
[@response_status, {}, @response_body]
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
should "send the correct request" do
|
|
26
|
+
expected = Drip::Response.new(@response_status, @response_body)
|
|
27
|
+
assert_equal expected, @client.broadcasts
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
context "#broadcast" do
|
|
32
|
+
setup do
|
|
33
|
+
@response_status = 200
|
|
34
|
+
@response_body = stub
|
|
35
|
+
@id = 99999
|
|
36
|
+
|
|
37
|
+
@stubs.get "12345/broadcasts/#{@id}" do
|
|
38
|
+
[@response_status, {}, @response_body]
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
should "send the correct request" do
|
|
43
|
+
expected = Drip::Response.new(@response_status, @response_body)
|
|
44
|
+
assert_equal expected, @client.broadcast(@id)
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
end
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
require File.dirname(__FILE__) + '/../../test_helper.rb'
|
|
2
|
+
|
|
3
|
+
class Drip::Client::CampaignSubscriptionsTest < Drip::TestCase
|
|
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
|
+
@client = Drip::Client.new { |c| c.account_id = "12345" }
|
|
12
|
+
@client.expects(:connection).at_least_once.returns(@connection)
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
context "#campaign_subscriptions" do
|
|
16
|
+
setup do
|
|
17
|
+
@response_status = 200
|
|
18
|
+
@response_body = stub
|
|
19
|
+
@subscriber_id = "abc123"
|
|
20
|
+
|
|
21
|
+
@stubs.get "12345/subscribers/#{@subscriber_id}/campaign_subscriptions" do
|
|
22
|
+
[@response_status, {}, @response_body]
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
should "send the right request" do
|
|
27
|
+
expected = Drip::Response.new(@response_status, @response_body)
|
|
28
|
+
assert_equal expected, @client.campaign_subscriptions(@subscriber_id)
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
@@ -27,4 +27,72 @@ class Drip::Client::CampaignsTest < Drip::TestCase
|
|
|
27
27
|
assert_equal expected, @client.campaigns
|
|
28
28
|
end
|
|
29
29
|
end
|
|
30
|
+
|
|
31
|
+
context "#campaign" do
|
|
32
|
+
setup do
|
|
33
|
+
@response_status = 200
|
|
34
|
+
@response_body = stub
|
|
35
|
+
@id = 9999999
|
|
36
|
+
|
|
37
|
+
@stubs.get "12345/campaigns/#{@id}" do
|
|
38
|
+
[@response_status, {}, @response_body]
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
should "send the right request" do
|
|
43
|
+
expected = Drip::Response.new(@response_status, @response_body)
|
|
44
|
+
assert_equal expected, @client.campaign(@id)
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
context "#activate_campaign" do
|
|
49
|
+
setup do
|
|
50
|
+
@response_status = 204
|
|
51
|
+
@response_body = stub
|
|
52
|
+
@id = 9999999
|
|
53
|
+
|
|
54
|
+
@stubs.post "12345/campaigns/#{@id}/activate" do
|
|
55
|
+
[@response_status, {}, @response_body]
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
should "send the right request" do
|
|
60
|
+
expected = Drip::Response.new(@response_status, @response_body)
|
|
61
|
+
assert_equal expected, @client.activate_campaign(@id)
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
context "#pause_campaign" do
|
|
66
|
+
setup do
|
|
67
|
+
@response_status = 204
|
|
68
|
+
@response_body = stub
|
|
69
|
+
@id = 9999999
|
|
70
|
+
|
|
71
|
+
@stubs.post "12345/campaigns/#{@id}/pause" do
|
|
72
|
+
[@response_status, {}, @response_body]
|
|
73
|
+
end
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
should "send the right request" do
|
|
77
|
+
expected = Drip::Response.new(@response_status, @response_body)
|
|
78
|
+
assert_equal expected, @client.pause_campaign(@id)
|
|
79
|
+
end
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
context "#campaign_subscribers" do
|
|
83
|
+
setup do
|
|
84
|
+
@response_status = 200
|
|
85
|
+
@response_body = stub
|
|
86
|
+
@id = 9999999
|
|
87
|
+
|
|
88
|
+
@stubs.get "12345/campaigns/#{@id}/subscribers" do
|
|
89
|
+
[@response_status, {}, @response_body]
|
|
90
|
+
end
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
should "send the right request" do
|
|
94
|
+
expected = Drip::Response.new(@response_status, @response_body)
|
|
95
|
+
assert_equal expected, @client.campaign_subscribers(@id)
|
|
96
|
+
end
|
|
97
|
+
end
|
|
30
98
|
end
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
require File.dirname(__FILE__) + '/../../test_helper.rb'
|
|
2
|
+
|
|
3
|
+
class Drip::Client::ConversionsTest < Drip::TestCase
|
|
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
|
+
@client = Drip::Client.new { |c| c.account_id = "12345" }
|
|
12
|
+
@client.expects(:connection).at_least_once.returns(@connection)
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
context "#conversions" do
|
|
16
|
+
setup do
|
|
17
|
+
@response_status = 200
|
|
18
|
+
@response_body = stub
|
|
19
|
+
|
|
20
|
+
@stubs.get "12345/goals" do
|
|
21
|
+
[@response_status, {}, @response_body]
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
should "send the right request" do
|
|
26
|
+
expected = Drip::Response.new(@response_status, @response_body)
|
|
27
|
+
assert_equal expected, @client.conversions
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
context "#conversion" do
|
|
32
|
+
setup do
|
|
33
|
+
@response_status = 200
|
|
34
|
+
@response_body = stub
|
|
35
|
+
@id = 9999999
|
|
36
|
+
|
|
37
|
+
@stubs.get "12345/goals/#{@id}" do
|
|
38
|
+
[@response_status, {}, @response_body]
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
should "send the right request" do
|
|
43
|
+
expected = Drip::Response.new(@response_status, @response_body)
|
|
44
|
+
assert_equal expected, @client.conversion(@id)
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
end
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
require File.dirname(__FILE__) + '/../../test_helper.rb'
|
|
2
|
+
|
|
3
|
+
class Drip::Client::CustomFieldsTest < Drip::TestCase
|
|
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
|
+
@client = Drip::Client.new { |c| c.account_id = "12345" }
|
|
12
|
+
@client.expects(:connection).at_least_once.returns(@connection)
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
context "#custom_fields" do
|
|
16
|
+
setup do
|
|
17
|
+
@response_status = 200
|
|
18
|
+
@response_body = stub
|
|
19
|
+
|
|
20
|
+
@stubs.get "12345/custom_field_identifiers" do
|
|
21
|
+
[@response_status, {}, @response_body]
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
should "send the right request" do
|
|
26
|
+
expected = Drip::Response.new(@response_status, @response_body)
|
|
27
|
+
assert_equal expected, @client.custom_fields
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|