send_with_us 2.0.0 → 3.1.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/CHANGELOG.md +2 -0
- data/README.md +3 -14
- data/lib/send_with_us/api.rb +3 -29
- data/lib/send_with_us/api_request.rb +1 -1
- data/lib/send_with_us/version.rb +1 -1
- data/test/lib/send_with_us/api_request_test.rb +34 -46
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d50c239efd64109971c40b8672b632ca5bfc3919
|
4
|
+
data.tar.gz: bfcf5cb515ac7b97a5c2f0437401970299356b12
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: aae51ef349b4cf4632ac6cfd6c944e54973eefe6ac982824c40542284c8a92d2fa164a214c425a32d54436dbce5edff2aa4a76c7f6a05ad3f53fb7f4126e286d
|
7
|
+
data.tar.gz: 9c926d10b52714d17a67e946dd3e18e8bf198d854cf2b0ad4128b73aa211b893c5061d6f734dd91c9db80883d136913bc21a554495cae015b6446220c236e12e
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
3.1.0 - Add `strict` option to the render call
|
2
|
+
3.0.0 - Deprecate and remove Conversions API calls
|
1
3
|
2.0.0 - Deprecate Customer Groups API
|
2
4
|
1.13.0 - Add support to get customer details
|
3
5
|
1.12.0 - Customer logs endpoint added and optional parameters for logs fixed when no options sent
|
data/README.md
CHANGED
@@ -192,6 +192,7 @@ end
|
|
192
192
|
- **version\_id** - *string* - Version ID to render (optional)
|
193
193
|
- **data** - *hash* - Email data to render the template with (optional)
|
194
194
|
- **data[:locale]** - *hash value* - This option specifies the locale to render (optional)
|
195
|
+
- **strict** - *bool* - This option enables strict mode and is disabled by default (optional)
|
195
196
|
|
196
197
|
```ruby
|
197
198
|
require 'rubygems'
|
@@ -204,6 +205,7 @@ begin
|
|
204
205
|
'template_id',
|
205
206
|
'version_id',
|
206
207
|
{ company_name: 'TestCo' },
|
208
|
+
strict=true)
|
207
209
|
|
208
210
|
puts result
|
209
211
|
rescue => e
|
@@ -274,7 +276,7 @@ customer = obj.customer_get("visha@example.com")
|
|
274
276
|
|
275
277
|
```ruby
|
276
278
|
customer_data = {:FirstName => "Visha"}
|
277
|
-
result = obj.customer_create("visha@example.com"
|
279
|
+
result = obj.customer_create("visha@example.com")
|
278
280
|
```
|
279
281
|
|
280
282
|
### Delete a Customer
|
@@ -296,19 +298,6 @@ Optional Arguments:
|
|
296
298
|
obj.customer_email_log('customer@example.com', count: 1)
|
297
299
|
```
|
298
300
|
|
299
|
-
### Customer Conversion Event
|
300
|
-
You can use the Conversion API to track conversion and revenue data events against your sent emails
|
301
|
-
|
302
|
-
**NOTE:** Revenue is in cents (eg. $100.50 = 10050)
|
303
|
-
|
304
|
-
```ruby
|
305
|
-
# With Revenue
|
306
|
-
obj.customer_conversion('customer@example.com', 10050)
|
307
|
-
|
308
|
-
# Without Revenue
|
309
|
-
obj.customer_conversion('customer@example.com')
|
310
|
-
```
|
311
|
-
|
312
301
|
## Templates
|
313
302
|
|
314
303
|
```ruby
|
data/lib/send_with_us/api.rb
CHANGED
@@ -151,12 +151,13 @@ module SendWithUs
|
|
151
151
|
|
152
152
|
alias list_templates emails
|
153
153
|
|
154
|
-
def render(template_id, version_id = nil, template_data = {})
|
154
|
+
def render(template_id, version_id = nil, template_data = {}, strict = false)
|
155
155
|
locale = template_data.delete(:locale)
|
156
156
|
|
157
157
|
payload = {
|
158
|
-
|
158
|
+
template: template_id,
|
159
159
|
template_data: template_data,
|
160
|
+
strict: strict,
|
160
161
|
}
|
161
162
|
|
162
163
|
payload[:version_id] = version_id if version_id
|
@@ -221,33 +222,6 @@ module SendWithUs
|
|
221
222
|
SendWithUs::ApiRequest.new(@configuration).get("drip_campaigns/#{drip_campaign_id}/step/#{drip_campaign_step_id}/customers")
|
222
223
|
end
|
223
224
|
|
224
|
-
# DEPRECATED: Please use 'customer_conversion' instead.
|
225
|
-
def add_customer_event(customer, event_name, revenue=nil)
|
226
|
-
warn "[DEPRECATED] 'add_customer_event' is deprecated. Please use 'customer_conversion' instead."
|
227
|
-
|
228
|
-
payload = {event_name: event_name}
|
229
|
-
|
230
|
-
if revenue
|
231
|
-
payload[:revenue] = revenue
|
232
|
-
end
|
233
|
-
|
234
|
-
payload = payload.to_json
|
235
|
-
endpoint = "customers/#{customer}/conversions"
|
236
|
-
SendWithUs::ApiRequest.new(@configuration).post(endpoint, payload)
|
237
|
-
end
|
238
|
-
|
239
|
-
def customer_conversion(customer, revenue=nil)
|
240
|
-
payload = {}
|
241
|
-
|
242
|
-
if revenue
|
243
|
-
payload[:revenue] = revenue
|
244
|
-
end
|
245
|
-
|
246
|
-
payload = payload.to_json
|
247
|
-
endpoint = "customers/#{customer}/conversions"
|
248
|
-
SendWithUs::ApiRequest.new(@configuration).post(endpoint, payload)
|
249
|
-
end
|
250
|
-
|
251
225
|
def customer_get(email)
|
252
226
|
SendWithUs::ApiRequest.new(@configuration).get("customers/#{email}")
|
253
227
|
end
|
@@ -42,7 +42,7 @@ module SendWithUs
|
|
42
42
|
end
|
43
43
|
|
44
44
|
def request(method_klass, path, payload=nil)
|
45
|
-
request = method_klass.new(path,
|
45
|
+
request = method_klass.new(path, {'Content-Type' =>'application/json'})
|
46
46
|
request.add_field('X-SWU-API-KEY', @configuration.api_key)
|
47
47
|
request.add_field('X-SWU-API-CLIENT', @configuration.client_stub)
|
48
48
|
|
data/lib/send_with_us/version.rb
CHANGED
@@ -17,7 +17,7 @@ class TestApiRequest < Minitest::Test
|
|
17
17
|
@template = {
|
18
18
|
:html => '<html><head></head><body>TEST</body></html>',
|
19
19
|
:subject => 'A test template',
|
20
|
-
:name => 'Test Template',
|
20
|
+
:name => 'Test Template '.concat(Random.new.rand(100000).to_s),
|
21
21
|
:id => 'test_fixture_1'
|
22
22
|
}
|
23
23
|
end
|
@@ -74,14 +74,14 @@ class TestApiRequest < Minitest::Test
|
|
74
74
|
|
75
75
|
def test_send_with_with_attachment
|
76
76
|
build_objects
|
77
|
-
result = @api.
|
77
|
+
result = @api.send_email(
|
78
78
|
@template[:id],
|
79
79
|
{name: 'Ruby Unit Test', address: 'matt@example.com'},
|
80
|
-
{data: 'I AM DATA'},
|
81
|
-
{name: 'sendwithus', address: 'matt@example.com'},
|
82
|
-
[],
|
83
|
-
[],
|
84
|
-
['README.md']
|
80
|
+
data: {data: 'I AM DATA'},
|
81
|
+
from: {name: 'sendwithus', address: 'matt@example.com'},
|
82
|
+
cc: [],
|
83
|
+
bcc: [],
|
84
|
+
files: ['README.md']
|
85
85
|
)
|
86
86
|
assert_instance_of( Net::HTTPOK, result )
|
87
87
|
end
|
@@ -89,16 +89,16 @@ class TestApiRequest < Minitest::Test
|
|
89
89
|
def test_send_with_with_version
|
90
90
|
build_objects
|
91
91
|
email_id = 'tem_9YvYsaLW2Mw4tmPiLcVvpC'
|
92
|
-
result = @api.
|
92
|
+
result = @api.send_email(
|
93
93
|
email_id,
|
94
94
|
{name: 'Ruby Unit Test', address: 'matt@example.com'},
|
95
|
-
{data: 'I AM DATA'},
|
96
|
-
{name: 'sendwithus', address: 'matt@example.com'},
|
97
|
-
[],
|
98
|
-
[],
|
99
|
-
[],
|
100
|
-
'',
|
101
|
-
'v2'
|
95
|
+
data: {data: 'I AM DATA'},
|
96
|
+
from: {name: 'sendwithus', address: 'matt@example.com'},
|
97
|
+
cc: [],
|
98
|
+
bcc: [],
|
99
|
+
files: [],
|
100
|
+
esp_account: '',
|
101
|
+
version_name: 'v2'
|
102
102
|
)
|
103
103
|
assert_instance_of( Net::HTTPOK, result )
|
104
104
|
end
|
@@ -106,17 +106,17 @@ class TestApiRequest < Minitest::Test
|
|
106
106
|
def test_send_with_with_headers
|
107
107
|
build_objects
|
108
108
|
email_id = 'tem_9YvYsaLW2Mw4tmPiLcVvpC'
|
109
|
-
result = @api.
|
109
|
+
result = @api.send_email(
|
110
110
|
email_id,
|
111
111
|
{name: 'Ruby Unit Test', address: 'matt@example.com'},
|
112
|
-
{data: 'I AM DATA'},
|
113
|
-
{name: 'sendwithus', address: 'matt@example.com'},
|
114
|
-
[],
|
115
|
-
[],
|
116
|
-
[],
|
117
|
-
'',
|
118
|
-
'v2',
|
119
|
-
{'X-MY-HEADER' => 'foo'}
|
112
|
+
data: {data: 'I AM DATA'},
|
113
|
+
from: {name: 'sendwithus', address: 'matt@example.com'},
|
114
|
+
cc: [],
|
115
|
+
bcc: [],
|
116
|
+
files: [],
|
117
|
+
esp_account: '',
|
118
|
+
version_name: 'v2',
|
119
|
+
headers: {'X-MY-HEADER' => 'foo'}
|
120
120
|
)
|
121
121
|
assert_instance_of( Net::HTTPOK, result )
|
122
122
|
end
|
@@ -124,18 +124,18 @@ class TestApiRequest < Minitest::Test
|
|
124
124
|
def test_send_with_with_tags
|
125
125
|
build_objects
|
126
126
|
email_id = 'tem_9YvYsaLW2Mw4tmPiLcVvpC'
|
127
|
-
result = @api.
|
127
|
+
result = @api.send_email(
|
128
128
|
email_id,
|
129
129
|
{name: 'Ruby Unit Test', address: 'matt@example.com'},
|
130
|
-
{data: 'I AM DATA'},
|
131
|
-
{name: 'sendwithus', address: 'matt@example.com'},
|
132
|
-
[],
|
133
|
-
[],
|
134
|
-
[],
|
135
|
-
'',
|
136
|
-
'v2',
|
137
|
-
{},
|
138
|
-
['tag1', 'tag2']
|
130
|
+
data: {data: 'I AM DATA'},
|
131
|
+
from: {name: 'sendwithus', address: 'matt@example.com'},
|
132
|
+
cc: [],
|
133
|
+
bcc: [],
|
134
|
+
files: [],
|
135
|
+
esp_account: '',
|
136
|
+
version_name: 'v2',
|
137
|
+
headers: {},
|
138
|
+
tags: ['tag1', 'tag2']
|
139
139
|
)
|
140
140
|
assert_instance_of( Net::HTTPOK, result )
|
141
141
|
end
|
@@ -301,18 +301,6 @@ class TestApiRequest < Minitest::Test
|
|
301
301
|
assert_equal( true, @request.send(:request_path, :send) == '/api/v1_0/send' )
|
302
302
|
end
|
303
303
|
|
304
|
-
def test_add_user_event
|
305
|
-
build_objects
|
306
|
-
Net::HTTP.any_instance.stubs(:request).returns(Net::HTTPSuccess.new(1.0, 200, "OK"))
|
307
|
-
assert_instance_of( Net::HTTPSuccess, @request.post(:'customers/test@sendwithus.com/conversions', @payload))
|
308
|
-
end
|
309
|
-
|
310
|
-
def test_conversion_event
|
311
|
-
build_objects
|
312
|
-
Net::HTTP.any_instance.stubs(:request).returns(Net::HTTPSuccess.new(1.0, 200, "OK"))
|
313
|
-
assert_instance_of( Net::HTTPSuccess, @request.post(:'customers/test@sendwithus.com/conversions', @payload))
|
314
|
-
end
|
315
|
-
|
316
304
|
def test_customer_create
|
317
305
|
build_objects
|
318
306
|
Net::HTTP.any_instance.stubs(:request).returns(Net::HTTPSuccess.new(1.0, 200, "OK"))
|
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:
|
4
|
+
version: 3.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matt Harris
|
@@ -12,7 +12,7 @@ authors:
|
|
12
12
|
autorequire:
|
13
13
|
bindir: bin
|
14
14
|
cert_chain: []
|
15
|
-
date: 2017-
|
15
|
+
date: 2017-07-13 00:00:00.000000000 Z
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|
18
18
|
name: rake
|
@@ -107,7 +107,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
107
107
|
version: '0'
|
108
108
|
requirements: []
|
109
109
|
rubyforge_project:
|
110
|
-
rubygems_version: 2.
|
110
|
+
rubygems_version: 2.6.11
|
111
111
|
signing_key:
|
112
112
|
specification_version: 4
|
113
113
|
summary: SendWithUs.com Ruby Client
|