marketingcloud-mailer 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/marketingcloud/mailer.rb +24 -3
- data/lib/marketingcloud/mailer/version.rb +1 -1
- data/marketingcloud-mailer.gemspec +2 -2
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fa998de934d9245bd307d5cd25905ca212148d65
|
4
|
+
data.tar.gz: d099472e82fb088176941a5dce51460f91f706ab
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cf0f973f8dd9d37c24685a88e3b87ab1e8b92f6df915403d70d0467a05361097850dccc0618a7e81cf9682f7bea19c523b6470dc77f39a711f31c7f9a44f1dcf
|
7
|
+
data.tar.gz: ad30d964d7638fcb3e2c05a157ba45e29ca01981c4bc172c310599845acc14deb608c68bb44e7c3d001071ed50f622d60e8c42a478881905f6e52a2c9f03d1ed
|
@@ -11,22 +11,43 @@ module Marketingcloud
|
|
11
11
|
@settings = {
|
12
12
|
client_id: nil,
|
13
13
|
client_secret: nil,
|
14
|
-
external_key: nil
|
14
|
+
external_key: nil,
|
15
|
+
debug: false
|
15
16
|
}.merge!(values)
|
17
|
+
if @settings[:debug] && !defined?(Faraday::DetailedLogger)
|
18
|
+
raise ArgumentError.new("Debug mode for marketingcloud-mailer requires gem: 'faraday-detailed_logger'")
|
19
|
+
end
|
16
20
|
@session = ::ExactTargetRest::Authorization.new(*credentials)
|
21
|
+
if @settings[:debug]
|
22
|
+
@session.setup_connection do |conn|
|
23
|
+
conn.response :detailed_logger
|
24
|
+
conn.adapter Faraday.default_adapter
|
25
|
+
end
|
26
|
+
end
|
17
27
|
end
|
18
28
|
|
19
29
|
def deliver!(mail)
|
20
30
|
ts = ::ExactTargetRest::TriggeredSend.new(@session, external_key)
|
31
|
+
if @settings[:debug]
|
32
|
+
ts.setup_connection do |conn|
|
33
|
+
conn.response :detailed_logger
|
34
|
+
conn.adapter Faraday.default_adapter
|
35
|
+
end
|
36
|
+
end
|
21
37
|
if mail.to.length != 1
|
22
38
|
raise ArgumentError.new('Marketingcloud::Mailer only accepts a single recipient')
|
23
39
|
end
|
24
40
|
html = if mail.body.raw_source.blank? && mail.body.parts.length >= 1
|
25
|
-
mail.body.parts.last.
|
41
|
+
mail.body.parts.last.decoded
|
26
42
|
else
|
27
43
|
mail.body.raw_source
|
28
44
|
end
|
29
|
-
|
45
|
+
from_name = begin
|
46
|
+
mail.header['From'].display_names.first || ''
|
47
|
+
rescue
|
48
|
+
''
|
49
|
+
end
|
50
|
+
ts.with_options(email_address: mail.to.first, subscriber_attributes: { 'HTML' => html, 'Subject' => mail.subject, 'FromName' => from_name }).deliver
|
30
51
|
end
|
31
52
|
|
32
53
|
private
|
@@ -28,8 +28,8 @@ Gem::Specification.new do |spec|
|
|
28
28
|
end
|
29
29
|
spec.require_paths = ["lib"]
|
30
30
|
|
31
|
-
spec.add_dependency "mail", "~> 2.6
|
32
|
-
spec.add_dependency "exact_target_rest", "~> 0.2
|
31
|
+
spec.add_dependency "mail", "~> 2.6"
|
32
|
+
spec.add_dependency "exact_target_rest", "~> 0.2"
|
33
33
|
spec.add_dependency "activesupport", ">= 5"
|
34
34
|
|
35
35
|
spec.add_development_dependency "actionmailer", ">= 5"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: marketingcloud-mailer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Justin Smestad
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-04-
|
11
|
+
date: 2017-04-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: mail
|
@@ -16,28 +16,28 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 2.6
|
19
|
+
version: '2.6'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 2.6
|
26
|
+
version: '2.6'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: exact_target_rest
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 0.2
|
33
|
+
version: '0.2'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 0.2
|
40
|
+
version: '0.2'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: activesupport
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|