marketingcloud-mailer 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 13889f6bd857910ef405ec97b49dcd48770e26ce
4
+ data.tar.gz: 25e88a3a9686c7e8e795175d52a21a52556ae03b
5
+ SHA512:
6
+ metadata.gz: b75f1bf09abbaec708756b7733ab6fa9d2ed567d27f74ddda97252fea99894485ce23efc0bf164d81d788c7d82c4333b193a1eeedbd1f11380d6efcee66c3b2d
7
+ data.tar.gz: a618b3ef49716b5b7cd6c256a3cb18e4009b34c7d26709ea9cb72bad169a2cfa77f2f9798a45ec29e7198a877ef70348286f5883030cec93c32444d2fc9a9033
@@ -0,0 +1,12 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+
11
+ # rspec failure tracking
12
+ .rspec_status
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in marketingcloud-mailer.gemspec
4
+ gemspec
5
+
6
+ gem 'pry'
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2017 Justin Smestad
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,42 @@
1
+ # Marketingcloud::Mailer
2
+
3
+ [![CircleCI](https://circleci.com/gh/homebotapp/marketingcloud-mailer/tree/master.svg?style=svg&circle-token=4a89731421c209376ecafe2bdc64b1e965cd45d6)](https://circleci.com/gh/homebotapp/marketingcloud-mailer/tree/master)
4
+
5
+ Extends the [Mail](https://github.com/mikel/mail) gem used by Rails' ActionMailer to provide a delivery
6
+ mechanism to Salesforce Marketingcloud (previously known as Exact Target).
7
+
8
+ ## Installation
9
+
10
+ Add this line to your application's Gemfile:
11
+
12
+ ```ruby
13
+ gem 'marketingcloud-mailer'
14
+ ```
15
+
16
+ And then execute:
17
+
18
+ $ bundle
19
+
20
+ Or install it yourself as:
21
+
22
+ $ gem install marketingcloud-mailer
23
+
24
+ ## Usage
25
+
26
+ TODO: Write usage instructions here
27
+
28
+ ## Development
29
+
30
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
31
+
32
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
33
+
34
+ ## Contributing
35
+
36
+ Bug reports and pull requests are welcome on GitHub at https://github.com/homebotapp/marketingcloud-mailer.
37
+
38
+
39
+ ## License
40
+
41
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
42
+
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "marketingcloud/mailer"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,42 @@
1
+ require "exact_target_rest"
2
+ require "active_support/core_ext/object/blank"
3
+
4
+ require "marketingcloud/mailer/version"
5
+
6
+ module Marketingcloud
7
+ class Mailer
8
+ attr_accessor :settings
9
+
10
+ def initialize(values)
11
+ @settings = {
12
+ client_id: nil,
13
+ client_secret: nil,
14
+ external_key: nil
15
+ }.merge!(values)
16
+ @session = ::ExactTargetRest::Authorization.new(*credentials)
17
+ end
18
+
19
+ def deliver!(mail)
20
+ # key = mail['external_key'] || external_key
21
+ ts = ::ExactTargetRest::TriggeredSend.new(@session, external_key)
22
+ if mail.to.length != 1
23
+ raise ArgumentError.new('Marketingcloud::Mailer only accepts a single recipient')
24
+ end
25
+ ts.send_one(email_address: mail.to.first, subscriber_attributes: { 'HTML' => mail.body.raw_source, 'Subject' => mail.subject, 'Preheader' => ''})
26
+ end
27
+
28
+ private
29
+
30
+ def credentials
31
+ if @settings[:client_id].blank? || @settings[:client_secret].blank?
32
+ raise ArgumentError.new('Marketingcloud::Mailer requires a `client_id` and `client_secret` to be set')
33
+ else
34
+ [@settings[:client_id], @settings[:client_secret]]
35
+ end
36
+ end
37
+
38
+ def external_key
39
+ @settings[:external_key]
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,5 @@
1
+ module Marketingcloud
2
+ class Mailer
3
+ VERSION = "0.1.0"
4
+ end
5
+ end
@@ -0,0 +1,39 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'marketingcloud/mailer/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "marketingcloud-mailer"
8
+ spec.version = Marketingcloud::Mailer::VERSION
9
+ spec.authors = ["Justin Smestad"]
10
+ spec.email = ["justin@homebot.ai", "justin.smestad@gmail.com"]
11
+
12
+ spec.summary = %q{Provides a custom delivery method for Salesforce Marketingcloud}
13
+ spec.description = %q{Depends on the 'mail' gem, sends emails through Salesforce Marketingcloud, previously known as ExactTarget}
14
+ spec.homepage = "https://github.com/homebotapp/marketingcloud-mailer"
15
+ spec.license = "MIT"
16
+
17
+ # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
18
+ # to allow pushing to a single host or delete this section to allow pushing to any host.
19
+ # if spec.respond_to?(:metadata)
20
+ # spec.metadata['allowed_push_host'] = ""
21
+ # else
22
+ # raise "RubyGems 2.0 or newer is required to protect against " \
23
+ # "public gem pushes."
24
+ # end
25
+
26
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
27
+ f.match(%r{^(test|spec|features)/})
28
+ end
29
+ spec.require_paths = ["lib"]
30
+
31
+ spec.add_dependency "mail", "~> 2.6.0"
32
+ spec.add_dependency "exact_target_rest", "~> 0.2.6"
33
+ spec.add_dependency "activesupport", ">= 5"
34
+
35
+ spec.add_development_dependency "actionmailer", ">= 5"
36
+ spec.add_development_dependency "bundler", "~> 1.14"
37
+ spec.add_development_dependency "rake", "~> 10.0"
38
+ spec.add_development_dependency "rspec", "~> 3.5"
39
+ end
metadata ADDED
@@ -0,0 +1,155 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: marketingcloud-mailer
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Justin Smestad
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2017-04-18 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: mail
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 2.6.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 2.6.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: exact_target_rest
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: 0.2.6
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: 0.2.6
41
+ - !ruby/object:Gem::Dependency
42
+ name: activesupport
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '5'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '5'
55
+ - !ruby/object:Gem::Dependency
56
+ name: actionmailer
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '5'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '5'
69
+ - !ruby/object:Gem::Dependency
70
+ name: bundler
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '1.14'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '1.14'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rake
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '10.0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '10.0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: rspec
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '3.5'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '3.5'
111
+ description: Depends on the 'mail' gem, sends emails through Salesforce Marketingcloud,
112
+ previously known as ExactTarget
113
+ email:
114
+ - justin@homebot.ai
115
+ - justin.smestad@gmail.com
116
+ executables: []
117
+ extensions: []
118
+ extra_rdoc_files: []
119
+ files:
120
+ - ".gitignore"
121
+ - ".rspec"
122
+ - Gemfile
123
+ - LICENSE.txt
124
+ - README.md
125
+ - Rakefile
126
+ - bin/console
127
+ - bin/setup
128
+ - lib/marketingcloud/mailer.rb
129
+ - lib/marketingcloud/mailer/version.rb
130
+ - marketingcloud-mailer.gemspec
131
+ homepage: https://github.com/homebotapp/marketingcloud-mailer
132
+ licenses:
133
+ - MIT
134
+ metadata: {}
135
+ post_install_message:
136
+ rdoc_options: []
137
+ require_paths:
138
+ - lib
139
+ required_ruby_version: !ruby/object:Gem::Requirement
140
+ requirements:
141
+ - - ">="
142
+ - !ruby/object:Gem::Version
143
+ version: '0'
144
+ required_rubygems_version: !ruby/object:Gem::Requirement
145
+ requirements:
146
+ - - ">="
147
+ - !ruby/object:Gem::Version
148
+ version: '0'
149
+ requirements: []
150
+ rubyforge_project:
151
+ rubygems_version: 2.6.11
152
+ signing_key:
153
+ specification_version: 4
154
+ summary: Provides a custom delivery method for Salesforce Marketingcloud
155
+ test_files: []