expresspigeon-ruby 0.0.6 → 0.0.7
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/lib/expresspigeon-ruby/messages.rb +13 -11
- data/lib/expresspigeon-ruby/version.rb +1 -1
- data/spec/messages_spec.rb +2 -1
- data/test/send_with_attachments.rb +1 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2aaf2cb7ae311969900e94bea9466d740495805e
|
4
|
+
data.tar.gz: e1f4506783ec702b655f0200b0abbf2e99a6dd5e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7a69e5d4cde9b3dab5f835eb5ff12228888aa0cf3b3837cf3f2a71360de7cc0e7e8ccbafcdb2f38dc52fe276f40d32621002ac5cd0966f585a6538c840346d69
|
7
|
+
data.tar.gz: 80c4ba1ef1dd860348e5d6db29e6897d1e6accf53b6a50f7b3f962d6d6ce364ef120e24b59c608b7a0deb0adaa83304fd21b159450d43ea204ebde0daaf3b896
|
@@ -17,13 +17,17 @@ module ExpressPigeon
|
|
17
17
|
# * +merge fields+ - hash with dynamic values to merge into a template
|
18
18
|
# * +view_online+ - generate "view online" link in the template
|
19
19
|
# * +click_tracking+ - enable/disable click tracking (and URL rewriting)
|
20
|
+
# * +suppress_address+ - enable/disable display of physical address at the bottom of newsletter.
|
20
21
|
# * +attachments+ - array of file paths to attach to email. Size limit: 1k per attachment, maximum 3 attachments.
|
21
|
-
def send_message(template_id, to, reply_to, from_name, subject, merge_fields = nil, view_online = false,
|
22
|
+
def send_message(template_id, to, reply_to, from_name, subject, merge_fields = nil, view_online = false,
|
23
|
+
click_tracking = true, suppress_address = false, attachments = nil)
|
22
24
|
if attachments
|
23
|
-
|
25
|
+
upload(template_id, to, reply_to, from_name, subject, merge_fields, view_online, click_tracking,
|
26
|
+
suppress_address, attachments)
|
24
27
|
else
|
25
|
-
post @endpoint, params = {template_id: template_id, :
|
26
|
-
:
|
28
|
+
post @endpoint, params = {template_id: template_id, to: to, reply_to: reply_to, from: from_name,
|
29
|
+
subject: subject, merge_fields: merge_fields, view_online: view_online,
|
30
|
+
click_tracking: click_tracking, suppress_address: suppress_address}
|
27
31
|
end
|
28
32
|
end
|
29
33
|
|
@@ -78,15 +82,12 @@ module ExpressPigeon
|
|
78
82
|
# * +merge fields+ - hash with dynamic values to merge into a template
|
79
83
|
# * +view_online+ - generate "view online" link in the template
|
80
84
|
# * +click_tracking+ - enable/disable click tracking (and URL rewriting)
|
85
|
+
# * +suppress_address+ - enable/disable display of physical address at the bottom of newsletter.
|
81
86
|
# * +attachments+ - array of file paths to attach to email. Size limit: 1k per attachment, maximum 3 attachments.
|
82
|
-
def upload(template_id, to, reply_to, from_name, subject, merge_fields, view_online, click_tracking, attachments)
|
83
|
-
|
87
|
+
def upload(template_id, to, reply_to, from_name, subject, merge_fields, view_online, click_tracking, suppress_address, attachments)
|
84
88
|
path = "#{@root ? @root : ROOT}/#{@endpoint}"
|
85
|
-
|
86
|
-
puts "sending to #{path}"
|
87
|
-
|
88
89
|
begin
|
89
|
-
payload = prepare_payload(template_id, to, reply_to, from_name, subject, merge_fields, view_online, click_tracking, attachments)
|
90
|
+
payload = prepare_payload(template_id, to, reply_to, from_name, subject, merge_fields, view_online, click_tracking, suppress_address, attachments)
|
90
91
|
request = RestClient::Request.new(
|
91
92
|
:method => :post,
|
92
93
|
:headers => {:'X-auth-key' => get_auth_key},
|
@@ -107,7 +108,7 @@ module ExpressPigeon
|
|
107
108
|
end
|
108
109
|
|
109
110
|
|
110
|
-
def prepare_payload(template_id, to, reply_to, from, subject, merge_fields, view_online, click_tracking, attachments)
|
111
|
+
def prepare_payload(template_id, to, reply_to, from, subject, merge_fields, view_online, click_tracking, suppress_address, attachments)
|
111
112
|
payload = { multipart: true }
|
112
113
|
payload[:template_id] = template_id
|
113
114
|
payload[:to] = to
|
@@ -117,6 +118,7 @@ module ExpressPigeon
|
|
117
118
|
payload[:merge_fields] = merge_fields
|
118
119
|
payload[:view_online] = view_online
|
119
120
|
payload[:click_tracking] = click_tracking
|
121
|
+
payload[:suppress_address] = suppress_address
|
120
122
|
|
121
123
|
attachments.each { |attachment|
|
122
124
|
if File.file?(attachment)
|
data/spec/messages_spec.rb
CHANGED
@@ -132,7 +132,7 @@ describe 'transactional messages integration test' do
|
|
132
132
|
'Jane Doe',
|
133
133
|
'Hello, Dolly!',
|
134
134
|
{eye_color: 'blue', body_shape:'pear'},
|
135
|
-
false, true,
|
135
|
+
false, true, false,
|
136
136
|
%w(spec/resources/attachment1.txt spec/resources/attachment2.txt))
|
137
137
|
|
138
138
|
payload[:multipart].should eq true
|
@@ -146,6 +146,7 @@ describe 'transactional messages integration test' do
|
|
146
146
|
payload[:merge_fields][:body_shape].should eq 'pear'
|
147
147
|
payload[:view_online].should eq false
|
148
148
|
payload[:click_tracking].should eq true
|
149
|
+
payload[:suppress_address].should eq false
|
149
150
|
payload['attachment1.txt'].class.should eq File
|
150
151
|
File.basename(payload['attachment1.txt']).should eq 'attachment1.txt'
|
151
152
|
File.basename(payload['attachment2.txt']).should eq 'attachment2.txt'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: expresspigeon-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ipolevoy
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-11-
|
11
|
+
date: 2016-11-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rest-client
|