iterable_rails 0.1.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 +7 -0
- data/.gitignore +15 -0
- data/.rspec +3 -0
- data/.rubocop.yml +1 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +112 -0
- data/LICENSE.txt +21 -0
- data/README.md +58 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/iterable_rails.gemspec +38 -0
- data/lib/iterable_rails.rb +28 -0
- data/lib/iterable_rails/delivery.rb +40 -0
- data/lib/iterable_rails/message.rb +189 -0
- data/lib/iterable_rails/railtie.rb +11 -0
- data/lib/iterable_rails/version.rb +3 -0
- metadata +161 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 3b9140d9770abf39d816bf808ce7719d79fb3825193335ea32d3971dfb92670c
|
|
4
|
+
data.tar.gz: fefc2547670803c316126f26d03258d243a46fcc75fa30fa720afe2e6bc74cc3
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 3955cafd74e2c016937d91aa0ed68dc3a5e3a097b5d8bf44574879e75bbd64b846181f88c7583836650390b11d55536c3a670f31fc65ee73315800b29f5b6f2e
|
|
7
|
+
data.tar.gz: bd060fa504ea2e59390651de60ccd2491a40c5513e1bc3bccd40ddc04b2b688cff0901f2a96575fa4094c41b546634b7b9c130c4be14eff3f08bd3846cecf249
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.rubocop.yml
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
inherit_from: https://raw.githubusercontent.com/BiggerPockets/patterns/master/ruby/.rubocop.yml
|
data/CODE_OF_CONDUCT.md
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
|
2
|
+
|
|
3
|
+
## Our Pledge
|
|
4
|
+
|
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
|
10
|
+
orientation.
|
|
11
|
+
|
|
12
|
+
## Our Standards
|
|
13
|
+
|
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
|
15
|
+
include:
|
|
16
|
+
|
|
17
|
+
* Using welcoming and inclusive language
|
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
|
19
|
+
* Gracefully accepting constructive criticism
|
|
20
|
+
* Focusing on what is best for the community
|
|
21
|
+
* Showing empathy towards other community members
|
|
22
|
+
|
|
23
|
+
Examples of unacceptable behavior by participants include:
|
|
24
|
+
|
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
|
26
|
+
advances
|
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
|
28
|
+
* Public or private harassment
|
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
|
30
|
+
address, without explicit permission
|
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
|
32
|
+
professional setting
|
|
33
|
+
|
|
34
|
+
## Our Responsibilities
|
|
35
|
+
|
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
|
38
|
+
response to any instances of unacceptable behavior.
|
|
39
|
+
|
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
|
44
|
+
threatening, offensive, or harmful.
|
|
45
|
+
|
|
46
|
+
## Scope
|
|
47
|
+
|
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
|
49
|
+
when an individual is representing the project or its community. Examples of
|
|
50
|
+
representing a project or community include using an official project e-mail
|
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
|
53
|
+
further defined and clarified by project maintainers.
|
|
54
|
+
|
|
55
|
+
## Enforcement
|
|
56
|
+
|
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
|
58
|
+
reported by contacting the project team at lewis@lewisbuckley.co.uk. All
|
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
|
63
|
+
|
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
|
66
|
+
members of the project's leadership.
|
|
67
|
+
|
|
68
|
+
## Attribution
|
|
69
|
+
|
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
|
71
|
+
available at [http://contributor-covenant.org/version/1/4][version]
|
|
72
|
+
|
|
73
|
+
[homepage]: http://contributor-covenant.org
|
|
74
|
+
[version]: http://contributor-covenant.org/version/1/4/
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
PATH
|
|
2
|
+
remote: .
|
|
3
|
+
specs:
|
|
4
|
+
iterable_rails (0.1.0)
|
|
5
|
+
actionmailer (>= 3.0.0)
|
|
6
|
+
iterable-api-client (~> 0.3)
|
|
7
|
+
|
|
8
|
+
GEM
|
|
9
|
+
remote: https://rubygems.org/
|
|
10
|
+
specs:
|
|
11
|
+
actionmailer (6.0.2.2)
|
|
12
|
+
actionpack (= 6.0.2.2)
|
|
13
|
+
actionview (= 6.0.2.2)
|
|
14
|
+
activejob (= 6.0.2.2)
|
|
15
|
+
mail (~> 2.5, >= 2.5.4)
|
|
16
|
+
rails-dom-testing (~> 2.0)
|
|
17
|
+
actionpack (6.0.2.2)
|
|
18
|
+
actionview (= 6.0.2.2)
|
|
19
|
+
activesupport (= 6.0.2.2)
|
|
20
|
+
rack (~> 2.0, >= 2.0.8)
|
|
21
|
+
rack-test (>= 0.6.3)
|
|
22
|
+
rails-dom-testing (~> 2.0)
|
|
23
|
+
rails-html-sanitizer (~> 1.0, >= 1.2.0)
|
|
24
|
+
actionview (6.0.2.2)
|
|
25
|
+
activesupport (= 6.0.2.2)
|
|
26
|
+
builder (~> 3.1)
|
|
27
|
+
erubi (~> 1.4)
|
|
28
|
+
rails-dom-testing (~> 2.0)
|
|
29
|
+
rails-html-sanitizer (~> 1.1, >= 1.2.0)
|
|
30
|
+
activejob (6.0.2.2)
|
|
31
|
+
activesupport (= 6.0.2.2)
|
|
32
|
+
globalid (>= 0.3.6)
|
|
33
|
+
activesupport (6.0.2.2)
|
|
34
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
|
35
|
+
i18n (>= 0.7, < 2)
|
|
36
|
+
minitest (~> 5.1)
|
|
37
|
+
tzinfo (~> 1.1)
|
|
38
|
+
zeitwerk (~> 2.2)
|
|
39
|
+
addressable (2.7.0)
|
|
40
|
+
public_suffix (>= 2.0.2, < 5.0)
|
|
41
|
+
builder (3.2.4)
|
|
42
|
+
byebug (11.1.3)
|
|
43
|
+
concurrent-ruby (1.1.6)
|
|
44
|
+
crack (0.4.3)
|
|
45
|
+
safe_yaml (~> 1.0.0)
|
|
46
|
+
crass (1.0.6)
|
|
47
|
+
diff-lcs (1.3)
|
|
48
|
+
erubi (1.9.0)
|
|
49
|
+
globalid (0.4.2)
|
|
50
|
+
activesupport (>= 4.2.0)
|
|
51
|
+
hashdiff (1.0.1)
|
|
52
|
+
i18n (1.8.3)
|
|
53
|
+
concurrent-ruby (~> 1.0)
|
|
54
|
+
iterable-api-client (0.3.1)
|
|
55
|
+
multi_json (>= 1.12.0)
|
|
56
|
+
loofah (2.5.0)
|
|
57
|
+
crass (~> 1.0.2)
|
|
58
|
+
nokogiri (>= 1.5.9)
|
|
59
|
+
mail (2.7.1)
|
|
60
|
+
mini_mime (>= 0.1.1)
|
|
61
|
+
mini_mime (1.0.2)
|
|
62
|
+
mini_portile2 (2.4.0)
|
|
63
|
+
minitest (5.14.1)
|
|
64
|
+
multi_json (1.14.1)
|
|
65
|
+
nokogiri (1.10.9)
|
|
66
|
+
mini_portile2 (~> 2.4.0)
|
|
67
|
+
public_suffix (4.0.5)
|
|
68
|
+
rack (2.2.3)
|
|
69
|
+
rack-test (1.1.0)
|
|
70
|
+
rack (>= 1.0, < 3)
|
|
71
|
+
rails-dom-testing (2.0.3)
|
|
72
|
+
activesupport (>= 4.2.0)
|
|
73
|
+
nokogiri (>= 1.6)
|
|
74
|
+
rails-html-sanitizer (1.3.0)
|
|
75
|
+
loofah (~> 2.3)
|
|
76
|
+
rake (10.5.0)
|
|
77
|
+
rspec (3.9.0)
|
|
78
|
+
rspec-core (~> 3.9.0)
|
|
79
|
+
rspec-expectations (~> 3.9.0)
|
|
80
|
+
rspec-mocks (~> 3.9.0)
|
|
81
|
+
rspec-core (3.9.2)
|
|
82
|
+
rspec-support (~> 3.9.3)
|
|
83
|
+
rspec-expectations (3.9.2)
|
|
84
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
|
85
|
+
rspec-support (~> 3.9.0)
|
|
86
|
+
rspec-mocks (3.9.1)
|
|
87
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
|
88
|
+
rspec-support (~> 3.9.0)
|
|
89
|
+
rspec-support (3.9.3)
|
|
90
|
+
safe_yaml (1.0.5)
|
|
91
|
+
thread_safe (0.3.6)
|
|
92
|
+
tzinfo (1.2.7)
|
|
93
|
+
thread_safe (~> 0.1)
|
|
94
|
+
webmock (2.3.2)
|
|
95
|
+
addressable (>= 2.3.6)
|
|
96
|
+
crack (>= 0.3.2)
|
|
97
|
+
hashdiff
|
|
98
|
+
zeitwerk (2.3.0)
|
|
99
|
+
|
|
100
|
+
PLATFORMS
|
|
101
|
+
ruby
|
|
102
|
+
|
|
103
|
+
DEPENDENCIES
|
|
104
|
+
bundler (~> 2.0)
|
|
105
|
+
byebug
|
|
106
|
+
iterable_rails!
|
|
107
|
+
rake (~> 10.0)
|
|
108
|
+
rspec (~> 3.0)
|
|
109
|
+
webmock (~> 2)
|
|
110
|
+
|
|
111
|
+
BUNDLED WITH
|
|
112
|
+
2.0.2
|
data/LICENSE.txt
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2020 Lewis Buckley
|
|
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.
|
data/README.md
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
# IterableRails
|
|
2
|
+
|
|
3
|
+
## Installation
|
|
4
|
+
|
|
5
|
+
Add this line to your application's Gemfile:
|
|
6
|
+
|
|
7
|
+
```ruby
|
|
8
|
+
gem 'iterable_rails'
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
And then execute:
|
|
12
|
+
|
|
13
|
+
$ bundle
|
|
14
|
+
|
|
15
|
+
Or install it yourself as:
|
|
16
|
+
|
|
17
|
+
$ gem install iterable_rails
|
|
18
|
+
|
|
19
|
+
## Usage
|
|
20
|
+
|
|
21
|
+
You'll need to set up a transactional email campaign and template within (Iterable)[https://app.iterable.com]. Note your campaign ID.
|
|
22
|
+
|
|
23
|
+
Within your Rails application or environment config add these lines:
|
|
24
|
+
|
|
25
|
+
```rb
|
|
26
|
+
config.action_mailer.delivery_method = :iterable
|
|
27
|
+
config.action_mailer.iterable_settings = {
|
|
28
|
+
api_key: ENV["ITERABLE_API_KEY"],
|
|
29
|
+
campaign_id: 12345678
|
|
30
|
+
}
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
Within Iterable you'll need to configure your template to use the following handlebars data:
|
|
34
|
+
|
|
35
|
+
- `{{ bcc_address }}`
|
|
36
|
+
- `{{ from_email }}`
|
|
37
|
+
- `{{ from_name }}`
|
|
38
|
+
- `{{ html }}`
|
|
39
|
+
- `{{ subject }}`
|
|
40
|
+
- `{{ text }}`
|
|
41
|
+
|
|
42
|
+
## Development
|
|
43
|
+
|
|
44
|
+
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.
|
|
45
|
+
|
|
46
|
+
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).
|
|
47
|
+
|
|
48
|
+
## Contributing
|
|
49
|
+
|
|
50
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/biggerpockets/iterable_rails. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
|
51
|
+
|
|
52
|
+
## License
|
|
53
|
+
|
|
54
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
|
55
|
+
|
|
56
|
+
## Code of Conduct
|
|
57
|
+
|
|
58
|
+
Everyone interacting in the IterableRails project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/biggerpockets/iterable_rails/blob/master/CODE_OF_CONDUCT.md).
|
data/Rakefile
ADDED
data/bin/console
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
|
|
3
|
+
require "bundler/setup"
|
|
4
|
+
require "iterable_rails"
|
|
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__)
|
data/bin/setup
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
lib = File.expand_path("lib", __dir__)
|
|
2
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
3
|
+
require "iterable_rails/version"
|
|
4
|
+
|
|
5
|
+
Gem::Specification.new do |spec|
|
|
6
|
+
spec.name = "iterable_rails"
|
|
7
|
+
spec.version = IterableRails::VERSION
|
|
8
|
+
spec.authors = ["Lewis Buckley"]
|
|
9
|
+
spec.email = ["lewis@lewisbuckley.co.uk"]
|
|
10
|
+
|
|
11
|
+
spec.summary = "Provides ActionMailer compatible delivery method for Iterable"
|
|
12
|
+
spec.description = "Provides ActionMailer compatible delivery method for Iterable"
|
|
13
|
+
spec.homepage = "https://www.github.com/biggerpockets/iterable_rails"
|
|
14
|
+
spec.license = "MIT"
|
|
15
|
+
|
|
16
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
|
17
|
+
spec.metadata["source_code_uri"] = "https://www.github.com/biggerpockets/iterable_rails"
|
|
18
|
+
spec.metadata["changelog_uri"] = "https://www.github.com/biggerpockets/iterable_rails/CHANGELOG.md"
|
|
19
|
+
|
|
20
|
+
# Specify which files should be added to the gem when it is released.
|
|
21
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
|
22
|
+
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
|
23
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
|
24
|
+
end
|
|
25
|
+
spec.bindir = "exe"
|
|
26
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
|
27
|
+
spec.require_paths = ["lib"]
|
|
28
|
+
|
|
29
|
+
spec.add_dependency("actionmailer", ">= 3.0.0")
|
|
30
|
+
|
|
31
|
+
spec.add_development_dependency "bundler", "~> 2.0"
|
|
32
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
|
33
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
|
34
|
+
spec.add_development_dependency "webmock", "~> 2"
|
|
35
|
+
spec.add_development_dependency "byebug"
|
|
36
|
+
|
|
37
|
+
spec.add_dependency "iterable-api-client", "~> 0.3"
|
|
38
|
+
end
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
require "action_mailer"
|
|
2
|
+
require "iterable"
|
|
3
|
+
|
|
4
|
+
require "iterable_rails/version"
|
|
5
|
+
require "iterable_rails/message"
|
|
6
|
+
require "iterable_rails/delivery"
|
|
7
|
+
|
|
8
|
+
module IterableRails
|
|
9
|
+
module ActionMailerExtensions
|
|
10
|
+
def metadata
|
|
11
|
+
@_message.metadata
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def metadata=(val)
|
|
15
|
+
@_message.metadata=(val)
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def self.install
|
|
20
|
+
ActionMailer::Base.add_delivery_method :iterable, IterableRails::Delivery
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
if defined?(Rails)
|
|
25
|
+
require "iterable_rails/railtie"
|
|
26
|
+
else
|
|
27
|
+
IterableRails.install
|
|
28
|
+
end
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module IterableRails
|
|
4
|
+
class Delivery
|
|
5
|
+
attr_accessor :settings
|
|
6
|
+
|
|
7
|
+
def initialize(settings)
|
|
8
|
+
self.settings = settings
|
|
9
|
+
configure_iterable_client
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def deliver!(mail)
|
|
13
|
+
message = Message.new(mail)
|
|
14
|
+
|
|
15
|
+
response = Iterable::Email.new.target(
|
|
16
|
+
message.to_email_address,
|
|
17
|
+
campaign_id,
|
|
18
|
+
attachments: message.attachments,
|
|
19
|
+
dataFields: message.data_fields,
|
|
20
|
+
metadata: message.metadata
|
|
21
|
+
)
|
|
22
|
+
|
|
23
|
+
unless response.success?
|
|
24
|
+
raise "Iterable API request failed: #{response.message}"
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
private
|
|
29
|
+
|
|
30
|
+
def configure_iterable_client
|
|
31
|
+
Iterable.configure do |config|
|
|
32
|
+
config.token = settings[:api_key]
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def campaign_id
|
|
37
|
+
settings[:campaign_id]
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
end
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module IterableRails
|
|
4
|
+
class Message
|
|
5
|
+
attr_reader :mail
|
|
6
|
+
|
|
7
|
+
def initialize(mail)
|
|
8
|
+
@mail = mail
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def attachments
|
|
12
|
+
mail.attachments.map do |attachment|
|
|
13
|
+
{
|
|
14
|
+
name: attachment.filename,
|
|
15
|
+
mimeType: attachment.mime_type,
|
|
16
|
+
content: Base64.encode64(attachment.body.decoded)
|
|
17
|
+
}
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def data_fields
|
|
22
|
+
{
|
|
23
|
+
bcc_address: bcc_address,
|
|
24
|
+
from_email: from_email,
|
|
25
|
+
from_name: from_name,
|
|
26
|
+
html: html,
|
|
27
|
+
subject: subject,
|
|
28
|
+
text: text,
|
|
29
|
+
}
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def metadata
|
|
33
|
+
get_value(:metadata) || {}
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def to_email_address
|
|
37
|
+
to.address
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
private
|
|
41
|
+
|
|
42
|
+
def bcc_address
|
|
43
|
+
return_string_value(:bcc_address)
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
def from_email
|
|
47
|
+
from.address
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
def from_name
|
|
51
|
+
from.display_name
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
def html
|
|
55
|
+
return mail.html_part.body.decoded if mail.html_part
|
|
56
|
+
return_decoded_body('text/html')
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
def template
|
|
60
|
+
return_string_value(:template)
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
def template_content
|
|
64
|
+
get_value(:template_content)
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
def important
|
|
68
|
+
mail[:important].to_s == 'true'
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
def inline_css
|
|
72
|
+
nil_true_false?(:inline_css)
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
def ip_pool
|
|
76
|
+
return_string_value(:ip_pool)
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
def preserve_recipients
|
|
80
|
+
nil_true_false?(:preserve_recipients)
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
def return_path_domain
|
|
84
|
+
return_string_value(:return_path_domain)
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
def send_at
|
|
88
|
+
value = get_value(:send_at)
|
|
89
|
+
value ? send_at_formatted_string(value) : nil
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
# mandrill expects `send_at` in UTC as `YYYY-MM-DD HH:MM:SS`
|
|
93
|
+
def send_at_formatted_string(obj)
|
|
94
|
+
return obj if obj.is_a?(String)
|
|
95
|
+
|
|
96
|
+
obj = obj.to_time if obj.is_a?(DateTime)
|
|
97
|
+
return obj.utc.strftime('%Y-%m-%d %H:%M:%S') if obj.is_a?(Time)
|
|
98
|
+
|
|
99
|
+
raise ArgumentError, 'send_at should be Time/DateTime or String'
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
def signing_domain
|
|
103
|
+
return_string_value(:signing_domain)
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
def subaccount
|
|
107
|
+
return_string_value(:subaccount)
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
def subject
|
|
111
|
+
mail.subject
|
|
112
|
+
end
|
|
113
|
+
|
|
114
|
+
def tags
|
|
115
|
+
collect_tags
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
def text
|
|
119
|
+
return mail.text_part.body.decoded if mail.text_part
|
|
120
|
+
return_decoded_body('text/plain')
|
|
121
|
+
end
|
|
122
|
+
|
|
123
|
+
def track_clicks
|
|
124
|
+
nil_true_false?(:track_clicks)
|
|
125
|
+
end
|
|
126
|
+
|
|
127
|
+
def track_opens
|
|
128
|
+
nil_true_false?(:track_opens)
|
|
129
|
+
end
|
|
130
|
+
|
|
131
|
+
def tracking_domain
|
|
132
|
+
return_string_value(:tracking_domain)
|
|
133
|
+
end
|
|
134
|
+
|
|
135
|
+
def url_strip_qs
|
|
136
|
+
nil_true_false?(:url_strip_qs)
|
|
137
|
+
end
|
|
138
|
+
|
|
139
|
+
def view_content_link
|
|
140
|
+
nil_true_false?(:view_content_link)
|
|
141
|
+
end
|
|
142
|
+
|
|
143
|
+
# Returns an array of tags
|
|
144
|
+
def collect_tags
|
|
145
|
+
mail[:tags].to_s.split(', ').map { |tag| tag }
|
|
146
|
+
end
|
|
147
|
+
|
|
148
|
+
def from
|
|
149
|
+
address = mail[:from].formatted
|
|
150
|
+
Mail::Address.new(address.first)
|
|
151
|
+
end
|
|
152
|
+
|
|
153
|
+
def to
|
|
154
|
+
address = mail[:to].formatted
|
|
155
|
+
Mail::Address.new(address.first)
|
|
156
|
+
end
|
|
157
|
+
|
|
158
|
+
def get_value(field)
|
|
159
|
+
if mail[field].respond_to?(:unparsed_value) # `mail` gem > 2.7.0
|
|
160
|
+
mail[field].unparsed_value
|
|
161
|
+
elsif mail[field].instance_variable_defined?('@unparsed_value') # `mail` gem = 2.7.0
|
|
162
|
+
mail[field].instance_variable_get('@unparsed_value')
|
|
163
|
+
elsif mail[field].instance_variable_defined?('@value') # `mail` gem < 2.7.0
|
|
164
|
+
mail[field].instance_variable_get('@value')
|
|
165
|
+
end
|
|
166
|
+
end
|
|
167
|
+
|
|
168
|
+
def attachments?
|
|
169
|
+
mail.attachments.any? { |a| !a.inline? }
|
|
170
|
+
end
|
|
171
|
+
|
|
172
|
+
def inline_attachments?
|
|
173
|
+
mail.attachments.any?(&:inline?)
|
|
174
|
+
end
|
|
175
|
+
|
|
176
|
+
def return_decoded_body(mime_type)
|
|
177
|
+
mail.mime_type == mime_type ? mail.body.decoded : nil
|
|
178
|
+
end
|
|
179
|
+
|
|
180
|
+
def return_string_value(field)
|
|
181
|
+
mail[field] ? mail[field].to_s : nil
|
|
182
|
+
end
|
|
183
|
+
|
|
184
|
+
def nil_true_false?(field)
|
|
185
|
+
return nil if mail[field].nil?
|
|
186
|
+
mail[field].to_s == 'true'
|
|
187
|
+
end
|
|
188
|
+
end
|
|
189
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: iterable_rails
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.1.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Lewis Buckley
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: exe
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2020-06-22 00:00:00.000000000 Z
|
|
12
|
+
dependencies:
|
|
13
|
+
- !ruby/object:Gem::Dependency
|
|
14
|
+
name: actionmailer
|
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
|
16
|
+
requirements:
|
|
17
|
+
- - ">="
|
|
18
|
+
- !ruby/object:Gem::Version
|
|
19
|
+
version: 3.0.0
|
|
20
|
+
type: :runtime
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
- - ">="
|
|
25
|
+
- !ruby/object:Gem::Version
|
|
26
|
+
version: 3.0.0
|
|
27
|
+
- !ruby/object:Gem::Dependency
|
|
28
|
+
name: bundler
|
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
|
30
|
+
requirements:
|
|
31
|
+
- - "~>"
|
|
32
|
+
- !ruby/object:Gem::Version
|
|
33
|
+
version: '2.0'
|
|
34
|
+
type: :development
|
|
35
|
+
prerelease: false
|
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
37
|
+
requirements:
|
|
38
|
+
- - "~>"
|
|
39
|
+
- !ruby/object:Gem::Version
|
|
40
|
+
version: '2.0'
|
|
41
|
+
- !ruby/object:Gem::Dependency
|
|
42
|
+
name: rake
|
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
|
44
|
+
requirements:
|
|
45
|
+
- - "~>"
|
|
46
|
+
- !ruby/object:Gem::Version
|
|
47
|
+
version: '10.0'
|
|
48
|
+
type: :development
|
|
49
|
+
prerelease: false
|
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
51
|
+
requirements:
|
|
52
|
+
- - "~>"
|
|
53
|
+
- !ruby/object:Gem::Version
|
|
54
|
+
version: '10.0'
|
|
55
|
+
- !ruby/object:Gem::Dependency
|
|
56
|
+
name: rspec
|
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
|
58
|
+
requirements:
|
|
59
|
+
- - "~>"
|
|
60
|
+
- !ruby/object:Gem::Version
|
|
61
|
+
version: '3.0'
|
|
62
|
+
type: :development
|
|
63
|
+
prerelease: false
|
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
65
|
+
requirements:
|
|
66
|
+
- - "~>"
|
|
67
|
+
- !ruby/object:Gem::Version
|
|
68
|
+
version: '3.0'
|
|
69
|
+
- !ruby/object:Gem::Dependency
|
|
70
|
+
name: webmock
|
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
|
72
|
+
requirements:
|
|
73
|
+
- - "~>"
|
|
74
|
+
- !ruby/object:Gem::Version
|
|
75
|
+
version: '2'
|
|
76
|
+
type: :development
|
|
77
|
+
prerelease: false
|
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
79
|
+
requirements:
|
|
80
|
+
- - "~>"
|
|
81
|
+
- !ruby/object:Gem::Version
|
|
82
|
+
version: '2'
|
|
83
|
+
- !ruby/object:Gem::Dependency
|
|
84
|
+
name: byebug
|
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
|
86
|
+
requirements:
|
|
87
|
+
- - ">="
|
|
88
|
+
- !ruby/object:Gem::Version
|
|
89
|
+
version: '0'
|
|
90
|
+
type: :development
|
|
91
|
+
prerelease: false
|
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
93
|
+
requirements:
|
|
94
|
+
- - ">="
|
|
95
|
+
- !ruby/object:Gem::Version
|
|
96
|
+
version: '0'
|
|
97
|
+
- !ruby/object:Gem::Dependency
|
|
98
|
+
name: iterable-api-client
|
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
|
100
|
+
requirements:
|
|
101
|
+
- - "~>"
|
|
102
|
+
- !ruby/object:Gem::Version
|
|
103
|
+
version: '0.3'
|
|
104
|
+
type: :runtime
|
|
105
|
+
prerelease: false
|
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
107
|
+
requirements:
|
|
108
|
+
- - "~>"
|
|
109
|
+
- !ruby/object:Gem::Version
|
|
110
|
+
version: '0.3'
|
|
111
|
+
description: Provides ActionMailer compatible delivery method for Iterable
|
|
112
|
+
email:
|
|
113
|
+
- lewis@lewisbuckley.co.uk
|
|
114
|
+
executables: []
|
|
115
|
+
extensions: []
|
|
116
|
+
extra_rdoc_files: []
|
|
117
|
+
files:
|
|
118
|
+
- ".gitignore"
|
|
119
|
+
- ".rspec"
|
|
120
|
+
- ".rubocop.yml"
|
|
121
|
+
- CODE_OF_CONDUCT.md
|
|
122
|
+
- Gemfile
|
|
123
|
+
- Gemfile.lock
|
|
124
|
+
- LICENSE.txt
|
|
125
|
+
- README.md
|
|
126
|
+
- Rakefile
|
|
127
|
+
- bin/console
|
|
128
|
+
- bin/setup
|
|
129
|
+
- iterable_rails.gemspec
|
|
130
|
+
- lib/iterable_rails.rb
|
|
131
|
+
- lib/iterable_rails/delivery.rb
|
|
132
|
+
- lib/iterable_rails/message.rb
|
|
133
|
+
- lib/iterable_rails/railtie.rb
|
|
134
|
+
- lib/iterable_rails/version.rb
|
|
135
|
+
homepage: https://www.github.com/biggerpockets/iterable_rails
|
|
136
|
+
licenses:
|
|
137
|
+
- MIT
|
|
138
|
+
metadata:
|
|
139
|
+
homepage_uri: https://www.github.com/biggerpockets/iterable_rails
|
|
140
|
+
source_code_uri: https://www.github.com/biggerpockets/iterable_rails
|
|
141
|
+
changelog_uri: https://www.github.com/biggerpockets/iterable_rails/CHANGELOG.md
|
|
142
|
+
post_install_message:
|
|
143
|
+
rdoc_options: []
|
|
144
|
+
require_paths:
|
|
145
|
+
- lib
|
|
146
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
147
|
+
requirements:
|
|
148
|
+
- - ">="
|
|
149
|
+
- !ruby/object:Gem::Version
|
|
150
|
+
version: '0'
|
|
151
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
152
|
+
requirements:
|
|
153
|
+
- - ">="
|
|
154
|
+
- !ruby/object:Gem::Version
|
|
155
|
+
version: '0'
|
|
156
|
+
requirements: []
|
|
157
|
+
rubygems_version: 3.0.3
|
|
158
|
+
signing_key:
|
|
159
|
+
specification_version: 4
|
|
160
|
+
summary: Provides ActionMailer compatible delivery method for Iterable
|
|
161
|
+
test_files: []
|