mailjet-micro 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/MIT-LICENSE +42 -0
- data/README.md +5 -0
- data/Rakefile +17 -0
- data/lib/mailjet-micro.rb +1 -0
- data/lib/mailjet.rb +17 -0
- data/lib/mailjet/configuration.rb +8 -0
- data/lib/mailjet/mailer.rb +17 -0
- data/lib/mailjet/rack/endpoint.rb +23 -0
- data/lib/mailjet/version.rb +3 -0
- data/spec/mailjet/configuration_spec.rb +10 -0
- data/spec/mailjet/rack/endpoint_spec.rb +30 -0
- data/spec/mailjet_test.rb +15 -0
- data/spec/spec_helper.rb +11 -0
- metadata +177 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 783cc552772e7391156aee8adc24aad6507f8a3d
|
4
|
+
data.tar.gz: 9c1d01cd1e3f65cfdac215763ea64b2dc53d30be
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: b285bfc41c5032bef297f1f1352dcb9c955cb2b3b41d748f7d27eabfeae6f10db2670ef7e0199355c9ceba50eaa56c5288e77eceb5715a0af7b8d3a8dc4dc451
|
7
|
+
data.tar.gz: cefa3cc3c701e20f89ea4368acf0c09cc950db1640a23bd50b28293c360d1eab9a48fe07b017c0ea580dcf9721ba5194903650c3627b525e2d0b62f3c68d45f0
|
data/MIT-LICENSE
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
Copyright 2012 Benezech
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
21
|
+
|
22
|
+
|
23
|
+
Copyright (c) 2011 Holinnn
|
24
|
+
|
25
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
26
|
+
a copy of this software and associated documentation files (the
|
27
|
+
"Software"), to deal in the Software without restriction, including
|
28
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
29
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
30
|
+
permit persons to whom the Software is furnished to do so, subject to
|
31
|
+
the following conditions:
|
32
|
+
|
33
|
+
The above copyright notice and this permission notice shall be
|
34
|
+
included in all copies or substantial portions of the Software.
|
35
|
+
|
36
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
37
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
38
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
39
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
40
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
41
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
42
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
data/Rakefile
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
#!/usr/bin/env rake
|
2
|
+
require 'rake/testtask'
|
3
|
+
require 'bundler'
|
4
|
+
Bundler::GemHelper.install_tasks
|
5
|
+
|
6
|
+
$:.push File.expand_path("../lib", __FILE__)
|
7
|
+
|
8
|
+
Rake::TestTask.new(:spec) do |t|
|
9
|
+
t.libs << 'lib'
|
10
|
+
t.libs << 'spec'
|
11
|
+
# t.pattern = 'spec/**/*_spec.rb'
|
12
|
+
t.verbose = true
|
13
|
+
t.test_files = Dir['spec/**/*_spec.rb']
|
14
|
+
end
|
15
|
+
|
16
|
+
|
17
|
+
task :default => :spec
|
@@ -0,0 +1 @@
|
|
1
|
+
require 'mailjet'
|
data/lib/mailjet.rb
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'mailjet/configuration'
|
2
|
+
module Mailjet
|
3
|
+
def self.configure
|
4
|
+
yield Mailjet::Configuration
|
5
|
+
end
|
6
|
+
|
7
|
+
def self.config
|
8
|
+
Mailjet::Configuration
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
if defined?(ActionMailer)
|
13
|
+
require 'action_mailer/version'
|
14
|
+
require 'mailjet/mailer' if ActionMailer::Base.respond_to?(:add_delivery_method)
|
15
|
+
end
|
16
|
+
|
17
|
+
require 'mailjet/rack/endpoint'
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'action_mailer'
|
2
|
+
require 'mail'
|
3
|
+
|
4
|
+
class Mailjet::Mailer < ::Mail::SMTP
|
5
|
+
def initialize(options = {})
|
6
|
+
super({
|
7
|
+
:address => "in-v3.mailjet.com",
|
8
|
+
:port => 587,
|
9
|
+
:authentication => 'plain',
|
10
|
+
:user_name => Mailjet.config.api_key,
|
11
|
+
:password => Mailjet.config.secret_key,
|
12
|
+
:enable_starttls_auto => true
|
13
|
+
}.merge(options))
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
ActionMailer::Base.add_delivery_method :mailjet, Mailjet::Mailer
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'active_support'
|
2
|
+
require 'rack/request'
|
3
|
+
|
4
|
+
module Mailjet
|
5
|
+
module Rack
|
6
|
+
class Endpoint
|
7
|
+
def initialize(app, path, &block)
|
8
|
+
@app = app
|
9
|
+
@path = path
|
10
|
+
@block = block
|
11
|
+
end
|
12
|
+
|
13
|
+
def call(env)
|
14
|
+
if env['PATH_INFO'] == @path && (content = env['rack.input'].read)
|
15
|
+
@block.call(ActiveSupport::JSON.decode(content))
|
16
|
+
[200, { 'Content-Type' => 'text/html', 'Content-Length' => '0' }, []]
|
17
|
+
else
|
18
|
+
@app.call(env)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'rack/mock'
|
3
|
+
|
4
|
+
SAMPLE_MAILJET_PAYLOAD = "{\"event\":\"open\",\"time\":1331581827,\"email\":\"benoit.benezech+1634@gmail.com\",\"mj_campaign_id\":\"105881975\",\"mj_contact_id\":\"116408391\",\"customcampaign\":null,\"ip\":\"88.164.20.58\",\"geo\":\"FR\",\"agent\":\"Mozilla\\/5.0 (Macintosh; Intel Mac OS X 10_7_2) AppleWebKit\\/535.11 (KHTML, like Gecko) Chrome\\/17.0.963.79 Safari\\/535.11\"}"
|
5
|
+
SAMPLE_MAILJET_PARAMS = {"event"=>"open", "time"=>1331581827, "email"=>"benoit.benezech+1634@gmail.com", "mj_campaign_id"=>"105881975", "mj_contact_id"=>"116408391", "customcampaign"=>nil, "ip"=>"88.164.20.58", "geo"=>"FR", "agent"=>"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_2) AppleWebKit/535.11 (KHTML, like Gecko) Chrome/17.0.963.79 Safari/535.11"}
|
6
|
+
|
7
|
+
|
8
|
+
describe Mailjet::Rack::Endpoint do
|
9
|
+
it "should decipher Mailjet's posted events and pass them to the block" do
|
10
|
+
# mock should receive :find with "benoit.benezech+1634@gmail.com" and will return true
|
11
|
+
$user_class_mock = MiniTest::Mock.new.expect(:find, true, ["benoit.benezech+1634@gmail.com"])
|
12
|
+
|
13
|
+
app = Rack::Builder.new do
|
14
|
+
use Rack::Lint
|
15
|
+
use Mailjet::Rack::Endpoint, '/callback' do |params|
|
16
|
+
$user_class_mock.find(params['email'])#.do_smtg_with_the_user....
|
17
|
+
end
|
18
|
+
run lambda { |env|
|
19
|
+
[200, {'Content-Type' => 'text/plain'}, ['passed through your endpoint, haha']]
|
20
|
+
}
|
21
|
+
end
|
22
|
+
|
23
|
+
response = Rack::MockRequest.new(app).get('/not_callback')
|
24
|
+
response.body.must_equal('passed through your endpoint, haha')
|
25
|
+
|
26
|
+
response = Rack::MockRequest.new(app).post('/callback', :input => SAMPLE_MAILJET_PAYLOAD)
|
27
|
+
response.body.must_equal('')
|
28
|
+
$user_class_mock.verify
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Mailjet do
|
4
|
+
describe "#configure" do
|
5
|
+
it "should permit to set api keys and remember them" do
|
6
|
+
Mailjet.configure do |config|
|
7
|
+
config.api_key = "1234"
|
8
|
+
config.secret_key = "5678"
|
9
|
+
end
|
10
|
+
|
11
|
+
Mailjet.config.api_key.must_equal "1234"
|
12
|
+
Mailjet.config.secret_key.must_equal "5678"
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,177 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: mailjet-micro
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Tyler Nappy
|
8
|
+
- Jean-Baptiste Escoyez
|
9
|
+
- Aurélien AMILIN
|
10
|
+
- Benoit Bénézech
|
11
|
+
autorequire:
|
12
|
+
bindir: bin
|
13
|
+
cert_chain: []
|
14
|
+
date: 2016-09-13 00:00:00.000000000 Z
|
15
|
+
dependencies:
|
16
|
+
- !ruby/object:Gem::Dependency
|
17
|
+
name: activesupport
|
18
|
+
requirement: !ruby/object:Gem::Requirement
|
19
|
+
requirements:
|
20
|
+
- - ">="
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: 3.1.0
|
23
|
+
type: :runtime
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
requirements:
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 3.1.0
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: rack
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
requirements:
|
34
|
+
- - ">="
|
35
|
+
- !ruby/object:Gem::Version
|
36
|
+
version: 1.4.0
|
37
|
+
type: :runtime
|
38
|
+
prerelease: false
|
39
|
+
version_requirements: !ruby/object:Gem::Requirement
|
40
|
+
requirements:
|
41
|
+
- - ">="
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: 1.4.0
|
44
|
+
- !ruby/object:Gem::Dependency
|
45
|
+
name: actionmailer
|
46
|
+
requirement: !ruby/object:Gem::Requirement
|
47
|
+
requirements:
|
48
|
+
- - ">="
|
49
|
+
- !ruby/object:Gem::Version
|
50
|
+
version: 3.0.9
|
51
|
+
type: :development
|
52
|
+
prerelease: false
|
53
|
+
version_requirements: !ruby/object:Gem::Requirement
|
54
|
+
requirements:
|
55
|
+
- - ">="
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
version: 3.0.9
|
58
|
+
- !ruby/object:Gem::Dependency
|
59
|
+
name: minitest
|
60
|
+
requirement: !ruby/object:Gem::Requirement
|
61
|
+
requirements:
|
62
|
+
- - ">="
|
63
|
+
- !ruby/object:Gem::Version
|
64
|
+
version: '0'
|
65
|
+
type: :development
|
66
|
+
prerelease: false
|
67
|
+
version_requirements: !ruby/object:Gem::Requirement
|
68
|
+
requirements:
|
69
|
+
- - ">="
|
70
|
+
- !ruby/object:Gem::Version
|
71
|
+
version: '0'
|
72
|
+
- !ruby/object:Gem::Dependency
|
73
|
+
name: minitest-matchers
|
74
|
+
requirement: !ruby/object:Gem::Requirement
|
75
|
+
requirements:
|
76
|
+
- - ">="
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
version: '0'
|
79
|
+
type: :development
|
80
|
+
prerelease: false
|
81
|
+
version_requirements: !ruby/object:Gem::Requirement
|
82
|
+
requirements:
|
83
|
+
- - ">="
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '0'
|
86
|
+
- !ruby/object:Gem::Dependency
|
87
|
+
name: rake
|
88
|
+
requirement: !ruby/object:Gem::Requirement
|
89
|
+
requirements:
|
90
|
+
- - ">="
|
91
|
+
- !ruby/object:Gem::Version
|
92
|
+
version: '0'
|
93
|
+
type: :development
|
94
|
+
prerelease: false
|
95
|
+
version_requirements: !ruby/object:Gem::Requirement
|
96
|
+
requirements:
|
97
|
+
- - ">="
|
98
|
+
- !ruby/object:Gem::Version
|
99
|
+
version: '0'
|
100
|
+
- !ruby/object:Gem::Dependency
|
101
|
+
name: json
|
102
|
+
requirement: !ruby/object:Gem::Requirement
|
103
|
+
requirements:
|
104
|
+
- - ">="
|
105
|
+
- !ruby/object:Gem::Version
|
106
|
+
version: '0'
|
107
|
+
type: :development
|
108
|
+
prerelease: false
|
109
|
+
version_requirements: !ruby/object:Gem::Requirement
|
110
|
+
requirements:
|
111
|
+
- - ">="
|
112
|
+
- !ruby/object:Gem::Version
|
113
|
+
version: '0'
|
114
|
+
- !ruby/object:Gem::Dependency
|
115
|
+
name: mocha
|
116
|
+
requirement: !ruby/object:Gem::Requirement
|
117
|
+
requirements:
|
118
|
+
- - ">="
|
119
|
+
- !ruby/object:Gem::Version
|
120
|
+
version: '0'
|
121
|
+
type: :development
|
122
|
+
prerelease: false
|
123
|
+
version_requirements: !ruby/object:Gem::Requirement
|
124
|
+
requirements:
|
125
|
+
- - ">="
|
126
|
+
- !ruby/object:Gem::Version
|
127
|
+
version: '0'
|
128
|
+
description: Basic Mailjet ActionMailer support
|
129
|
+
email:
|
130
|
+
- tyler@mailjet.com
|
131
|
+
- devrel-team@mailjet.com
|
132
|
+
- jbescoyez@gmail.com
|
133
|
+
executables: []
|
134
|
+
extensions: []
|
135
|
+
extra_rdoc_files: []
|
136
|
+
files:
|
137
|
+
- MIT-LICENSE
|
138
|
+
- README.md
|
139
|
+
- Rakefile
|
140
|
+
- lib/mailjet-micro.rb
|
141
|
+
- lib/mailjet.rb
|
142
|
+
- lib/mailjet/configuration.rb
|
143
|
+
- lib/mailjet/mailer.rb
|
144
|
+
- lib/mailjet/rack/endpoint.rb
|
145
|
+
- lib/mailjet/version.rb
|
146
|
+
- spec/mailjet/configuration_spec.rb
|
147
|
+
- spec/mailjet/rack/endpoint_spec.rb
|
148
|
+
- spec/mailjet_test.rb
|
149
|
+
- spec/spec_helper.rb
|
150
|
+
homepage: http://www.mailjet.com
|
151
|
+
licenses: []
|
152
|
+
metadata: {}
|
153
|
+
post_install_message:
|
154
|
+
rdoc_options: []
|
155
|
+
require_paths:
|
156
|
+
- lib
|
157
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
158
|
+
requirements:
|
159
|
+
- - ">="
|
160
|
+
- !ruby/object:Gem::Version
|
161
|
+
version: '0'
|
162
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
163
|
+
requirements:
|
164
|
+
- - ">="
|
165
|
+
- !ruby/object:Gem::Version
|
166
|
+
version: '0'
|
167
|
+
requirements: []
|
168
|
+
rubyforge_project:
|
169
|
+
rubygems_version: 2.6.4
|
170
|
+
signing_key:
|
171
|
+
specification_version: 4
|
172
|
+
summary: Basic Mailjet ActionMailer support
|
173
|
+
test_files:
|
174
|
+
- spec/mailjet/configuration_spec.rb
|
175
|
+
- spec/mailjet/rack/endpoint_spec.rb
|
176
|
+
- spec/mailjet_test.rb
|
177
|
+
- spec/spec_helper.rb
|