mailstro 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/mailstro/delivery.rb +5 -5
- data/lib/mailstro/list_delivery.rb +5 -5
- data/lib/mailstro/test.rb +4 -4
- data/lib/mailstro/version.rb +1 -1
- data/lib/mailstro.rb +4 -4
- data/spec/integration/delivery_spec.rb +4 -4
- data/spec/integration/list_delivery_spec.rb +3 -3
- data/spec/mailstro_spec.rb +3 -3
- metadata +2 -2
data/lib/mailstro/delivery.rb
CHANGED
@@ -1,21 +1,21 @@
|
|
1
1
|
module Mailstro
|
2
2
|
class Delivery < Resource
|
3
|
-
def self.deliver(template_name, contact_email,
|
4
|
-
new(template_name, contact_email,
|
3
|
+
def self.deliver(template_name, contact_email, data)
|
4
|
+
new(template_name, contact_email, data).deliver
|
5
5
|
end
|
6
6
|
|
7
7
|
attr_reader :contact_email, :template_name
|
8
8
|
|
9
|
-
def initialize(template_name, contact_email,
|
9
|
+
def initialize(template_name, contact_email, data)
|
10
10
|
@template_name = template_name
|
11
11
|
@contact_email = contact_email
|
12
|
-
@
|
12
|
+
@data = data
|
13
13
|
end
|
14
14
|
|
15
15
|
def deliver
|
16
16
|
post("deliveries", :template_name => @template_name,
|
17
17
|
:contact_email => @contact_email,
|
18
|
-
:
|
18
|
+
:data => @data)
|
19
19
|
end
|
20
20
|
end
|
21
21
|
end
|
@@ -1,21 +1,21 @@
|
|
1
1
|
module Mailstro
|
2
2
|
class ListDelivery < Resource
|
3
|
-
def self.deliver(template_name, list_name,
|
4
|
-
new(template_name, list_name,
|
3
|
+
def self.deliver(template_name, list_name, data)
|
4
|
+
new(template_name, list_name, data).deliver
|
5
5
|
end
|
6
6
|
|
7
7
|
attr_reader :list_name, :template_name
|
8
8
|
|
9
|
-
def initialize(template_name, list_name,
|
9
|
+
def initialize(template_name, list_name, data)
|
10
10
|
@template_name = template_name
|
11
11
|
@list_name = list_name
|
12
|
-
@
|
12
|
+
@data = data
|
13
13
|
end
|
14
14
|
|
15
15
|
def deliver
|
16
16
|
post("lists/deliveries", :template_name => @template_name,
|
17
17
|
:list_name => @list_name,
|
18
|
-
:
|
18
|
+
:data => @data)
|
19
19
|
end
|
20
20
|
end
|
21
21
|
end
|
data/lib/mailstro/test.rb
CHANGED
@@ -12,8 +12,8 @@ module Mailstro
|
|
12
12
|
end
|
13
13
|
|
14
14
|
def self.enable
|
15
|
-
def Mailstro.deliver(template_name, contact_email,
|
16
|
-
Mailstro::Test.deliveries << Mailstro::Delivery.new(template_name, contact_email,
|
15
|
+
def Mailstro.deliver(template_name, contact_email, data = {})
|
16
|
+
Mailstro::Test.deliveries << Mailstro::Delivery.new(template_name, contact_email, data)
|
17
17
|
true # insert response here
|
18
18
|
end
|
19
19
|
|
@@ -25,8 +25,8 @@ module Mailstro
|
|
25
25
|
end
|
26
26
|
|
27
27
|
def self.disable
|
28
|
-
def Mailstro.deliver(template_name, contact_email,
|
29
|
-
Mailstro::Delivery.deliver(template_name, contact_email,
|
28
|
+
def Mailstro.deliver(template_name, contact_email, data = {})
|
29
|
+
Mailstro::Delivery.deliver(template_name, contact_email, data)
|
30
30
|
end
|
31
31
|
|
32
32
|
@@enabled = false
|
data/lib/mailstro/version.rb
CHANGED
data/lib/mailstro.rb
CHANGED
@@ -18,12 +18,12 @@ module Mailstro
|
|
18
18
|
configuration.validate!
|
19
19
|
end
|
20
20
|
|
21
|
-
def self.deliver(template_name, contact_email,
|
22
|
-
Delivery.deliver(template_name, contact_email,
|
21
|
+
def self.deliver(template_name, contact_email, data = {})
|
22
|
+
Delivery.deliver(template_name, contact_email, data)
|
23
23
|
end
|
24
24
|
|
25
|
-
def self.list_deliver(template_name, list,
|
26
|
-
ListDelivery.deliver(template_name, list,
|
25
|
+
def self.list_deliver(template_name, list, data = {})
|
26
|
+
ListDelivery.deliver(template_name, list, data)
|
27
27
|
end
|
28
28
|
|
29
29
|
def self.list_subscribe(list_name, contact_email)
|
@@ -3,7 +3,7 @@ require 'spec_helper'
|
|
3
3
|
describe 'posting a delivery', :integration do
|
4
4
|
let(:template_name) { :test }
|
5
5
|
let(:contact_email) { "test@example.com" }
|
6
|
-
let(:
|
6
|
+
let(:data) { { :greeting => "Gday!" } }
|
7
7
|
|
8
8
|
before do
|
9
9
|
Mailstro.configure do |config|
|
@@ -15,14 +15,14 @@ describe 'posting a delivery', :integration do
|
|
15
15
|
"api_key" => "lolapi",
|
16
16
|
"template_name" => "test",
|
17
17
|
"contact_email" => "test@example.com",
|
18
|
-
"
|
18
|
+
"data" => { "greeting" => "Gday!" }
|
19
19
|
}}
|
20
20
|
|
21
21
|
it "succesfully submits a delivery to mailstro" do
|
22
22
|
stub_request(:post, "https://api.mailstroapp.com/v1/deliveries").
|
23
23
|
with(:body => expected_body).to_return(:status => 200, :body => fixture("response.json"))
|
24
24
|
|
25
|
-
response = Mailstro.deliver(template_name, contact_email,
|
25
|
+
response = Mailstro.deliver(template_name, contact_email, data)
|
26
26
|
response['success'].should == true
|
27
27
|
end
|
28
28
|
|
@@ -31,7 +31,7 @@ describe 'posting a delivery', :integration do
|
|
31
31
|
to_return(:status => 401)
|
32
32
|
|
33
33
|
expect do
|
34
|
-
Mailstro.deliver(template_name, contact_email,
|
34
|
+
Mailstro.deliver(template_name, contact_email, data)
|
35
35
|
end.to raise_error(Mailstro::Error::AuthorisationError, "api_key not authorised")
|
36
36
|
end
|
37
37
|
end
|
@@ -3,7 +3,7 @@ require 'spec_helper'
|
|
3
3
|
describe 'posting a list delivery', :integration do
|
4
4
|
let(:template_name) { :test }
|
5
5
|
let(:list_name) { :customers }
|
6
|
-
let(:
|
6
|
+
let(:data) { { :message => "Are you ok?" } }
|
7
7
|
|
8
8
|
before do
|
9
9
|
Mailstro.configure do |config|
|
@@ -15,14 +15,14 @@ describe 'posting a list delivery', :integration do
|
|
15
15
|
"api_key" => "lolapi",
|
16
16
|
"template_name" => "test",
|
17
17
|
"list_name" => "customers",
|
18
|
-
"
|
18
|
+
"data" => { "message" => "Are you ok?" }
|
19
19
|
}}
|
20
20
|
|
21
21
|
it "succesfully submits a list delivery to mailstro" do
|
22
22
|
stub_request(:post, "https://api.mailstroapp.com/v1/lists/deliveries").
|
23
23
|
with(:body => expected_body).to_return(:status => 200, :body => fixture("response.json"))
|
24
24
|
|
25
|
-
response = Mailstro.list_deliver(template_name, list_name,
|
25
|
+
response = Mailstro.list_deliver(template_name, list_name, data)
|
26
26
|
|
27
27
|
response[:success].should == true
|
28
28
|
end
|
data/spec/mailstro_spec.rb
CHANGED
@@ -20,12 +20,12 @@ describe Mailstro do
|
|
20
20
|
describe ".delivery" do
|
21
21
|
let(:template) { "name" }
|
22
22
|
let(:contact) { { :email => "foo@bar.com" } }
|
23
|
-
let(:
|
23
|
+
let(:data) { { :data => "here" } }
|
24
24
|
|
25
25
|
it "creates a delivery object and delivers it" do
|
26
|
-
Mailstro::Delivery.should_receive(:deliver).with(template, contact,
|
26
|
+
Mailstro::Delivery.should_receive(:deliver).with(template, contact, data)
|
27
27
|
|
28
|
-
Mailstro.deliver(template, contact,
|
28
|
+
Mailstro.deliver(template, contact, data)
|
29
29
|
end
|
30
30
|
end
|
31
31
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mailstro
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-09-
|
12
|
+
date: 2013-09-08 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: faraday
|