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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c43df6df704ba5d094a67bbdac8f951864556015
4
- data.tar.gz: 6ce53d834407e6252a53521c73a0b22d719a70f9
3
+ metadata.gz: fa998de934d9245bd307d5cd25905ca212148d65
4
+ data.tar.gz: d099472e82fb088176941a5dce51460f91f706ab
5
5
  SHA512:
6
- metadata.gz: c4e809e212a75a7eb053546380f15ba42ccf313b382c4f3faeb3660140274a5615a7f3fa1d14135564fa408a56fe2bd02660a03b3f46d01c4624f5a941a0a05f
7
- data.tar.gz: 26116f746340f35c3e3885c8e10628fa3227abe2a839fc249bdbb742dd32c9bec2d5ca28ff8081a15f9586b84aa2190dd6dd87735ee7380bfc5bcea5167f3d5c
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.to_s
41
+ mail.body.parts.last.decoded
26
42
  else
27
43
  mail.body.raw_source
28
44
  end
29
- ts.send_one(email_address: mail.to.first, subscriber_attributes: { 'HTML' => html, 'Subject' => mail.subject, 'Preheader' => ''})
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
@@ -1,5 +1,5 @@
1
1
  module Marketingcloud
2
2
  class Mailer
3
- VERSION = "0.2.0"
3
+ VERSION = "0.3.0"
4
4
  end
5
5
  end
@@ -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.0"
32
- spec.add_dependency "exact_target_rest", "~> 0.2.6"
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.2.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-21 00:00:00.000000000 Z
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.0
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.0
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.6
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.6
40
+ version: '0.2'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: activesupport
43
43
  requirement: !ruby/object:Gem::Requirement