send_with_us 4.2.1 → 4.4.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 +7 -1
- data/lib/send_with_us/api.rb +14 -8
- data/lib/send_with_us/version.rb +1 -1
- data/test/lib/send_with_us/api_request_test.rb +38 -3
- data/test/lib/send_with_us/api_test.rb +22 -0
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f67c0ceffafb13f25e0f582159853931f7ad80cb021c49839d42f3fe950057f9
|
4
|
+
data.tar.gz: fc33de35c98767fef56a58837cd00d80c8a9490e37fb90c7a7ad241854377585
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 247e986c2ed5785fd6c5a719448a57da298056a00ac6a41eb4f44813931456c749856e1ff0b026ad12225483ba4c3a70a8bfb20f7e9cd8209a1bba340919e60f
|
7
|
+
data.tar.gz: 1ea7ae022f32cae2ceb89da6828d3978540218f9a9a02fce7faa7fe5752ac54fa6c0ff8e6cd5977c65cb2408a9a700b319b09cd7ef7684150712fe10d6fa204c
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,11 @@
|
|
1
|
+
## 4.4.0
|
2
|
+
- **[#88](https://github.com/sendwithus/sendwithus_ruby/pull/88) Fix problematic `render` implementation.** `template_data` serves two purposes, defining template data and specifying the optional API parameter for `locale`. Previously, `locale` would be stripped out of `template_data` in the API request, preventing users from specifying variables named `locale` in their own template data.
|
3
|
+
|
4
|
+
## 4.3.0
|
5
|
+
- Add optional `preheader` and `amp_html` fields to template calls
|
6
|
+
|
1
7
|
## 4.2.1
|
2
|
-
- Bump `rake` version due to vulnerability
|
8
|
+
- Bump `rake` version due to vulnerability
|
3
9
|
|
4
10
|
## 4.2.0
|
5
11
|
- add a `log_events` method to get the events list on a Sendwithus log
|
data/lib/send_with_us/api.rb
CHANGED
@@ -145,7 +145,7 @@ module SendWithUs
|
|
145
145
|
alias list_templates emails
|
146
146
|
|
147
147
|
def render(template_id, version_id = nil, template_data = {}, strict = false)
|
148
|
-
locale = template_data
|
148
|
+
locale = template_data[:locale]
|
149
149
|
|
150
150
|
payload = {
|
151
151
|
template: template_id,
|
@@ -160,12 +160,14 @@ module SendWithUs
|
|
160
160
|
SendWithUs::ApiRequest.new(@configuration).post(:'render', payload)
|
161
161
|
end
|
162
162
|
|
163
|
-
def create_template(name, subject, html, text)
|
163
|
+
def create_template(name, subject, html, text, preheader='', amp_html='')
|
164
164
|
payload = {
|
165
165
|
name: name,
|
166
166
|
subject: subject,
|
167
167
|
html: html,
|
168
|
-
text: text
|
168
|
+
text: text,
|
169
|
+
preheader: preheader,
|
170
|
+
amp_html: amp_html
|
169
171
|
}
|
170
172
|
|
171
173
|
payload = payload.to_json
|
@@ -254,7 +256,7 @@ module SendWithUs
|
|
254
256
|
|
255
257
|
SendWithUs::ApiRequest.new(@configuration).get(endpoint)
|
256
258
|
end
|
257
|
-
|
259
|
+
|
258
260
|
def delete_template(template_id)
|
259
261
|
endpoint = "templates/#{template_id}"
|
260
262
|
SendWithUs::ApiRequest.new(@configuration).delete(endpoint)
|
@@ -270,24 +272,28 @@ module SendWithUs
|
|
270
272
|
SendWithUs::ApiRequest.new(@configuration).get(endpoint)
|
271
273
|
end
|
272
274
|
|
273
|
-
def update_template_version(template_id, version_id, name, subject, html, text)
|
275
|
+
def update_template_version(template_id, version_id, name, subject, html, text, preheader='', amp_html='')
|
274
276
|
payload = {
|
275
277
|
name: name,
|
276
278
|
subject: subject,
|
277
279
|
html: html,
|
278
|
-
text: text
|
280
|
+
text: text,
|
281
|
+
preheader: preheader,
|
282
|
+
amp_html: amp_html
|
279
283
|
}
|
280
284
|
|
281
285
|
endpoint = "templates/#{template_id}/versions/#{version_id}"
|
282
286
|
SendWithUs::ApiRequest.new(@configuration).put(endpoint, payload.to_json)
|
283
287
|
end
|
284
288
|
|
285
|
-
def create_template_version(template_id, name, subject, html, text)
|
289
|
+
def create_template_version(template_id, name, subject, html, text, preheader='', amp_html='')
|
286
290
|
payload = {
|
287
291
|
name: name,
|
288
292
|
subject: subject,
|
289
293
|
html: html,
|
290
|
-
text: text
|
294
|
+
text: text,
|
295
|
+
preheader: preheader,
|
296
|
+
amp_html: amp_html
|
291
297
|
}
|
292
298
|
|
293
299
|
endpoint = "templates/#{template_id}/versions"
|
data/lib/send_with_us/version.rb
CHANGED
@@ -19,7 +19,9 @@ class TestApiRequest < Minitest::Test
|
|
19
19
|
:html => '<html><head></head><body>TEST</body></html>',
|
20
20
|
:subject => 'A test template',
|
21
21
|
:name => 'Test Template '.concat(Random.new.rand(100000).to_s),
|
22
|
-
:id => 'test_fixture_1'
|
22
|
+
:id => 'test_fixture_1',
|
23
|
+
:preheader => 'Test preheader',
|
24
|
+
:amp_html => '<html><head></head><body>AMP HTML</body></html>'
|
23
25
|
}
|
24
26
|
end
|
25
27
|
|
@@ -78,7 +80,7 @@ class TestApiRequest < Minitest::Test
|
|
78
80
|
invalid_payload = {
|
79
81
|
template_id: @template[:id],
|
80
82
|
recipient: {name: 'Ruby Unit Test', address: 'stéve@sendwithus.com'}
|
81
|
-
}.to_json
|
83
|
+
}.to_json
|
82
84
|
assert_raises( SendWithUs::ApiBadRequest) { @request.post(:send, invalid_payload) }
|
83
85
|
end
|
84
86
|
|
@@ -93,7 +95,7 @@ class TestApiRequest < Minitest::Test
|
|
93
95
|
bcc: [],
|
94
96
|
files: ['README.md']
|
95
97
|
)
|
96
|
-
assert_instance_of( Net::HTTPOK, result )
|
98
|
+
assert_instance_of( Net::HTTPOK, result )
|
97
99
|
end
|
98
100
|
|
99
101
|
def test_send_email_with_file
|
@@ -247,6 +249,24 @@ class TestApiRequest < Minitest::Test
|
|
247
249
|
assert_instance_of( Net::HTTPOK, result )
|
248
250
|
end
|
249
251
|
|
252
|
+
def test_update_template_version_with_optional_fields
|
253
|
+
build_objects
|
254
|
+
version_id = get_first_template_version_id(@template[:id])
|
255
|
+
|
256
|
+
result = @api.update_template_version(
|
257
|
+
@template[:id],
|
258
|
+
version_id,
|
259
|
+
@template[:name],
|
260
|
+
@template[:subject],
|
261
|
+
@template[:html],
|
262
|
+
'sample text payload',
|
263
|
+
preheader=@template[:preheader],
|
264
|
+
amp_html=@template[:amp_html]
|
265
|
+
)
|
266
|
+
|
267
|
+
assert_instance_of( Net::HTTPOK, result )
|
268
|
+
end
|
269
|
+
|
250
270
|
def test_create_template_version
|
251
271
|
build_objects
|
252
272
|
result = @api.create_template_version(
|
@@ -260,6 +280,21 @@ class TestApiRequest < Minitest::Test
|
|
260
280
|
assert_instance_of( Net::HTTPOK, result )
|
261
281
|
end
|
262
282
|
|
283
|
+
def test_create_template_version_with_optional_fields
|
284
|
+
build_objects
|
285
|
+
result = @api.create_template_version(
|
286
|
+
@template[:id],
|
287
|
+
@template[:name],
|
288
|
+
@template[:subject],
|
289
|
+
@template[:html],
|
290
|
+
'sample text payload',
|
291
|
+
preheader=@template[:preheader],
|
292
|
+
amp_html=@template[:amp_html]
|
293
|
+
)
|
294
|
+
|
295
|
+
assert_instance_of( Net::HTTPOK, result )
|
296
|
+
end
|
297
|
+
|
263
298
|
def test_delete_template
|
264
299
|
build_objects
|
265
300
|
template = JSON.parse @api.create_template(
|
@@ -99,4 +99,26 @@ describe SendWithUs::Api do
|
|
99
99
|
|
100
100
|
it { subject.customer_get(email) }
|
101
101
|
end
|
102
|
+
|
103
|
+
describe '#render' do
|
104
|
+
let(:locale) { 'fr-CA' }
|
105
|
+
let(:template_id) { 'template-id' }
|
106
|
+
let(:template_data) { { foo: 'bar', locale: locale } }
|
107
|
+
let(:strict) { true }
|
108
|
+
let(:version_id) { 'some-version-id' }
|
109
|
+
|
110
|
+
let(:payload) do
|
111
|
+
{
|
112
|
+
template: template_id,
|
113
|
+
template_data: template_data,
|
114
|
+
strict: strict,
|
115
|
+
version_id: version_id,
|
116
|
+
locale: locale,
|
117
|
+
}
|
118
|
+
end
|
119
|
+
|
120
|
+
before { SendWithUs::ApiRequest.any_instance.expects(:post).with(:render, payload.to_json) }
|
121
|
+
|
122
|
+
it { subject.render(template_id, version_id, template_data, strict) }
|
123
|
+
end
|
102
124
|
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: 4.
|
4
|
+
version: 4.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matt Harris
|
@@ -9,10 +9,10 @@ authors:
|
|
9
9
|
- Nicholas Rempel
|
10
10
|
- Gregory Schier
|
11
11
|
- Brad Van Vugt
|
12
|
-
autorequire:
|
12
|
+
autorequire:
|
13
13
|
bindir: bin
|
14
14
|
cert_chain: []
|
15
|
-
date:
|
15
|
+
date: 1980-01-01 00:00:00.000000000 Z
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|
18
18
|
name: rake
|
@@ -94,7 +94,7 @@ homepage: https://github.com/sendwithus/sendwithus_ruby
|
|
94
94
|
licenses:
|
95
95
|
- Apache-2.0
|
96
96
|
metadata: {}
|
97
|
-
post_install_message:
|
97
|
+
post_install_message:
|
98
98
|
rdoc_options: []
|
99
99
|
require_paths:
|
100
100
|
- lib
|
@@ -109,8 +109,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: '0'
|
111
111
|
requirements: []
|
112
|
-
rubygems_version: 3.
|
113
|
-
signing_key:
|
112
|
+
rubygems_version: 3.2.26
|
113
|
+
signing_key:
|
114
114
|
specification_version: 4
|
115
115
|
summary: SendWithUs.com Ruby Client
|
116
116
|
test_files:
|