send_with_us 1.2.3 → 1.3.3
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +13 -0
- data/lib/send_with_us/api.rb +36 -25
- data/lib/send_with_us/version.rb +1 -1
- data/test/lib/send_with_us/api_request_test.rb +23 -17
- metadata +2 -2
data/README.md
CHANGED
@@ -146,6 +146,19 @@ rescue => e
|
|
146
146
|
end
|
147
147
|
```
|
148
148
|
|
149
|
+
### Customer conversion event
|
150
|
+
You can use the Conversion API to track conversion and revenue data events against your sent emails
|
151
|
+
|
152
|
+
**NOTE:** Revenue is in cents (eg. $100.50 = 10050)
|
153
|
+
|
154
|
+
```ruby
|
155
|
+
# With Revenue
|
156
|
+
obj.conversion_event('customer@example.com', 10050)
|
157
|
+
|
158
|
+
# Without Revenue
|
159
|
+
obj.conversion_event('customer@example.com')
|
160
|
+
```
|
161
|
+
|
149
162
|
### Rails
|
150
163
|
|
151
164
|
For a Rails app, create `send_with_us.rb` in `/config/initializers/`
|
data/lib/send_with_us/api.rb
CHANGED
@@ -30,7 +30,7 @@ module SendWithUs
|
|
30
30
|
end
|
31
31
|
|
32
32
|
payload = { email_id: email_id, recipient: to,
|
33
|
-
|
33
|
+
email_data: data }
|
34
34
|
|
35
35
|
if from.any?
|
36
36
|
payload[:sender] = from
|
@@ -90,45 +90,46 @@ module SendWithUs
|
|
90
90
|
end
|
91
91
|
|
92
92
|
def list_drip_campaigns()
|
93
|
-
|
93
|
+
SendWithUs::ApiRequest.new(@configuration).get(:drip_campaigns)
|
94
94
|
end
|
95
95
|
|
96
96
|
def start_on_drip_campaign(recipient_address, drip_campaign_id, email_data={})
|
97
97
|
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
98
|
+
if email_data.nil?
|
99
|
+
payload = {
|
100
|
+
recipient_address: recipient_address
|
101
|
+
}.to_json
|
102
|
+
else
|
103
|
+
payload = {
|
104
|
+
recipient_address: recipient_address,
|
105
|
+
email_data: email_data
|
106
|
+
}.to_json
|
107
|
+
end
|
108
|
+
|
109
|
+
SendWithUs::ApiRequest.new(@configuration).post("drip_campaigns/#{drip_campaign_id}/activate", payload)
|
110
110
|
end
|
111
111
|
|
112
112
|
def remove_from_drip_campaign(recipient_address, drip_campaign_id)
|
113
|
-
|
114
|
-
|
115
|
-
|
113
|
+
payload = {
|
114
|
+
recipient_address: recipient_address
|
115
|
+
}.to_json
|
116
116
|
|
117
|
-
|
117
|
+
SendWithUs::ApiRequest.new(@configuration).post("drip_campaigns/#{drip_campaign_id}/deactivate", payload)
|
118
118
|
end
|
119
119
|
|
120
120
|
def drip_campaign_details(drip_campaign_id)
|
121
|
-
|
121
|
+
SendWithUs::ApiRequest.new(@configuration).get("drip_campaigns/#{drip_campaign_id}")
|
122
122
|
end
|
123
|
-
|
123
|
+
|
124
124
|
def list_customers_on_campaign(drip_campaign_id)
|
125
|
-
|
125
|
+
SendWithUs::ApiRequest.new(@configuration).get("drip_campaigns/#{drip_campaign_id}/customers")
|
126
126
|
end
|
127
127
|
|
128
128
|
def list_customers_on_campaign_step(drip_campaign_id, drip_campaign_step_id)
|
129
|
-
|
129
|
+
SendWithUs::ApiRequest.new(@configuration).get("drip_campaigns/#{drip_campaign_id}/step/#{drip_campaign_step_id}/customers")
|
130
130
|
end
|
131
|
-
|
131
|
+
|
132
|
+
# DEPRECATED - use customer_conversion now
|
132
133
|
def add_customer_event(customer, event_name, revenue=nil)
|
133
134
|
|
134
135
|
if revenue.nil?
|
@@ -138,9 +139,19 @@ module SendWithUs
|
|
138
139
|
end
|
139
140
|
|
140
141
|
payload = payload.to_json
|
141
|
-
endpoint = 'customers/' + customer + '/
|
142
|
+
endpoint = 'customers/' + customer + '/conversions'
|
143
|
+
SendWithUs::ApiRequest.new(@configuration).post(endpoint, payload)
|
144
|
+
end
|
145
|
+
|
146
|
+
def customer_conversion(customer, revenue=nil)
|
147
|
+
payload = {}.to_json
|
148
|
+
|
149
|
+
if revenue
|
150
|
+
payload = { revenue: revenue }.to_json
|
151
|
+
end
|
152
|
+
|
153
|
+
endpoint = "customers/#{customer}/conversions"
|
142
154
|
SendWithUs::ApiRequest.new(@configuration).post(endpoint, payload)
|
143
155
|
end
|
144
156
|
end
|
145
157
|
end
|
146
|
-
|
data/lib/send_with_us/version.rb
CHANGED
@@ -20,13 +20,13 @@ class TestApiRequest < MiniTest::Unit::TestCase
|
|
20
20
|
build_objects
|
21
21
|
email_id = 'test_fixture_1'
|
22
22
|
result = @api.send_with(
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
23
|
+
email_id,
|
24
|
+
{name: 'Ruby Unit Test', address: 'matt@example.com'},
|
25
|
+
{name: 'sendwithus', address: 'matt@example.com'},
|
26
|
+
{},
|
27
|
+
[],
|
28
|
+
[],
|
29
|
+
['README.md']
|
30
30
|
)
|
31
31
|
assert_instance_of( Net::HTTPOK, result )
|
32
32
|
end
|
@@ -71,15 +71,15 @@ class TestApiRequest < MiniTest::Unit::TestCase
|
|
71
71
|
build_objects
|
72
72
|
email_id = 'tem_9YvYsaLW2Mw4tmPiLcVvpC'
|
73
73
|
result = @api.send_with(
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
74
|
+
email_id,
|
75
|
+
{name: 'Ruby Unit Test', address: 'matt@example.com'},
|
76
|
+
{name: 'sendwithus', address: 'matt@example.com'},
|
77
|
+
{},
|
78
|
+
[],
|
79
|
+
[],
|
80
|
+
[],
|
81
|
+
'',
|
82
|
+
'v2'
|
83
83
|
)
|
84
84
|
assert_instance_of( Net::HTTPOK, result )
|
85
85
|
end
|
@@ -134,7 +134,13 @@ class TestApiRequest < MiniTest::Unit::TestCase
|
|
134
134
|
def test_add_user_event()
|
135
135
|
build_objects
|
136
136
|
Net::HTTP.any_instance.stubs(:request).returns(Net::HTTPSuccess.new(1.0, 200, "OK"))
|
137
|
-
assert_instance_of( Net::HTTPSuccess, @request.post(:'customers/test@sendwithus.com/
|
137
|
+
assert_instance_of( Net::HTTPSuccess, @request.post(:'customers/test@sendwithus.com/conversions', @payload))
|
138
|
+
end
|
139
|
+
|
140
|
+
def test_conversion_event()
|
141
|
+
build_objects
|
142
|
+
Net::HTTP.any_instance.stubs(:request).returns(Net::HTTPSuccess.new(1.0, 200, "OK"))
|
143
|
+
assert_instance_of( Net::HTTPSuccess, @request.post(:'customers/test@sendwithus.com/conversions', @payload))
|
138
144
|
end
|
139
145
|
|
140
146
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: send_with_us
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.3.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2014-
|
14
|
+
date: 2014-11-12 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: rake
|