lob 4.3.0 → 5.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +4 -10
- data/CHANGELOG.md +30 -0
- data/README.md +15 -20
- data/examples/README.md +4 -0
- data/examples/checks.rb +1 -1
- data/examples/csv_checks/create_checks.rb +1 -1
- data/examples/csv_letters/create_letters.rb +1 -1
- data/examples/csv_letters/letter_template.html +1 -1
- data/examples/csv_postcards/create_postcards.rb +1 -1
- data/examples/csv_postcards/input.csv +7 -7
- data/examples/csv_postcards/postcard_back.html +1 -1
- data/examples/csv_verify/verify.rb +1 -1
- data/examples/letters.rb +2 -2
- data/examples/postcards.rb +3 -3
- data/examples/self_mailers.rb +37 -0
- data/lib/lob/client.rb +13 -8
- data/lib/lob/resources/{area.rb → group.rb} +2 -4
- data/lib/lob/resources/groups_member.rb +66 -0
- data/lib/lob/resources/resource_base.rb +8 -5
- data/lib/lob/resources/self_mailer.rb +14 -0
- data/lib/lob/version.rb +1 -1
- data/lob.gemspec +4 -7
- data/spec/lob/resources/check_spec.rb +21 -0
- data/spec/lob/resources/group_spec.rb +50 -0
- data/spec/lob/resources/intl_verifications_spec.rb +4 -7
- data/spec/lob/resources/letter_spec.rb +24 -4
- data/spec/lob/resources/member_spec.rb +65 -0
- data/spec/lob/resources/postcard_spec.rb +30 -5
- data/spec/lob/resources/resource_base_spec.rb +4 -16
- data/spec/lob/resources/self_mailer_spec.rb +177 -0
- data/spec/samples/sfm-12x9-inside.pdf +0 -0
- data/spec/samples/sfm-12x9-outside.pdf +0 -0
- data/spec/samples/sfm-6x18-inside.pdf +0 -0
- data/spec/samples/sfm-6x18-outside.pdf +0 -0
- data/spec/spec_helper.rb +3 -3
- metadata +29 -60
- data/lib/lob/resources/route.rb +0 -33
- data/spec/lob/resources/area_spec.rb +0 -59
- data/spec/lob/resources/route_spec.rb +0 -39
@@ -19,7 +19,7 @@ module Lob
|
|
19
19
|
query: query
|
20
20
|
}
|
21
21
|
|
22
|
-
submit
|
22
|
+
submit(request)
|
23
23
|
end
|
24
24
|
|
25
25
|
def find(resource_id)
|
@@ -28,7 +28,7 @@ module Lob
|
|
28
28
|
url: resource_url(resource_id)
|
29
29
|
}
|
30
30
|
|
31
|
-
submit
|
31
|
+
submit(request)
|
32
32
|
end
|
33
33
|
|
34
34
|
def create(body={}, headers={}, query={})
|
@@ -40,7 +40,7 @@ module Lob
|
|
40
40
|
query: query
|
41
41
|
}
|
42
42
|
|
43
|
-
submit
|
43
|
+
submit(request)
|
44
44
|
end
|
45
45
|
|
46
46
|
def destroy(resource_id)
|
@@ -49,7 +49,7 @@ module Lob
|
|
49
49
|
url: resource_url(resource_id)
|
50
50
|
}
|
51
51
|
|
52
|
-
submit
|
52
|
+
submit(request)
|
53
53
|
end
|
54
54
|
|
55
55
|
private
|
@@ -71,11 +71,14 @@ module Lob
|
|
71
71
|
if query != {}
|
72
72
|
url = "#{url}?#{build_nested_query(query)}"
|
73
73
|
end
|
74
|
-
|
74
|
+
|
75
75
|
begin
|
76
76
|
if method == :get || method == :delete
|
77
77
|
response = RestClient.send(method, url, headers)
|
78
78
|
else
|
79
|
+
if body[:merge_variables] and body[:merge_variables].class == Hash
|
80
|
+
body[:merge_variables] = body[:merge_variables].to_json()
|
81
|
+
end
|
79
82
|
response = RestClient.send(method, url, body, headers)
|
80
83
|
end
|
81
84
|
|
data/lib/lob/version.rb
CHANGED
data/lob.gemspec
CHANGED
@@ -18,14 +18,11 @@ Gem::Specification.new do |spec|
|
|
18
18
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
19
|
spec.require_paths = ["lib"]
|
20
20
|
|
21
|
-
spec.add_dependency "rest-client", ">= 1
|
21
|
+
spec.add_dependency "rest-client", ">= 2.0.1", "< 3.0"
|
22
22
|
|
23
|
-
spec.add_development_dependency "
|
24
|
-
spec.add_development_dependency "rake", "~> 10.4.2"
|
23
|
+
spec.add_development_dependency "rake", "~> 12.3.3"
|
25
24
|
spec.add_development_dependency "minitest", "~> 5.6.1"
|
26
25
|
spec.add_development_dependency "webmock", "~> 1.2"
|
27
|
-
spec.add_development_dependency "
|
28
|
-
spec.add_development_dependency "
|
29
|
-
spec.add_development_dependency "simplecov", "~> 0.10.0"
|
30
|
-
spec.add_development_dependency "pry", "~> 0.10.0"
|
26
|
+
spec.add_development_dependency "coveralls", "~> 0.8.13"
|
27
|
+
spec.add_development_dependency "simplecov", "~> 0.11.0"
|
31
28
|
end
|
@@ -50,6 +50,27 @@ describe Lob::Resources::Check do
|
|
50
50
|
|
51
51
|
result["amount"].to_s.must_equal("2000.12")
|
52
52
|
end
|
53
|
+
|
54
|
+
it "should create a check with a merge variable conditional" do
|
55
|
+
new_address = subject.addresses.create @sample_address_params
|
56
|
+
|
57
|
+
new_bank_account = subject.bank_accounts.create(@sample_bank_account_params)
|
58
|
+
|
59
|
+
subject.bank_accounts.verify(new_bank_account["id"], amounts: [1, 2])
|
60
|
+
|
61
|
+
result = subject.checks.create(
|
62
|
+
bank_account: new_bank_account["id"],
|
63
|
+
to: new_address["id"],
|
64
|
+
from: new_address["id"],
|
65
|
+
amount: "2000.12",
|
66
|
+
attachment: "<html>{{#is_awesome}}You are awesome!{{/is_awesome}}</html>",
|
67
|
+
merge_variables: {
|
68
|
+
is_awesome: false
|
69
|
+
}
|
70
|
+
)
|
71
|
+
|
72
|
+
result["merge_variables"]["is_awesome"].must_equal(false)
|
73
|
+
end
|
53
74
|
end
|
54
75
|
|
55
76
|
|
@@ -0,0 +1,50 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe Lob::Resources::Group do
|
4
|
+
|
5
|
+
before :each do
|
6
|
+
@sample_params = {
|
7
|
+
description: "Unsubscribe group",
|
8
|
+
metadata: {
|
9
|
+
test: 'stuff'
|
10
|
+
}
|
11
|
+
}
|
12
|
+
end
|
13
|
+
|
14
|
+
subject { Lob::Client.new(api_key: API_KEY) }
|
15
|
+
|
16
|
+
describe "list" do
|
17
|
+
it "should list groups" do
|
18
|
+
assert subject.groups.list["object"] == "list"
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
|
23
|
+
describe "create" do
|
24
|
+
it "should create a group" do
|
25
|
+
result = subject.groups.create @sample_params
|
26
|
+
|
27
|
+
result["description"].must_equal(@sample_params[:description])
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
|
32
|
+
describe "find" do
|
33
|
+
it "should find a group" do
|
34
|
+
new_group = subject.groups.create @sample_params
|
35
|
+
|
36
|
+
find_result = subject.groups.find(new_group["id"])
|
37
|
+
find_result["description"].must_equal(@sample_params[:description])
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
|
42
|
+
describe "destroy" do
|
43
|
+
it "should delete a group" do
|
44
|
+
new_group = subject.groups.create @sample_params
|
45
|
+
|
46
|
+
delete_result = subject.groups.destroy(new_group["id"])
|
47
|
+
assert_equal(new_group["id"], delete_result["id"])
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -15,13 +15,10 @@ describe Lob::Resources::IntlVerifications do
|
|
15
15
|
subject { Lob::Client.new(api_key: API_KEY) }
|
16
16
|
|
17
17
|
describe "verify" do
|
18
|
-
it "should
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
assert e.http_status == 403
|
23
|
-
assert e._response.headers.include?(:content_type)
|
24
|
-
end
|
18
|
+
it "should verify an international address" do
|
19
|
+
result = subject.intl_verifications.verify @sample_params
|
20
|
+
|
21
|
+
result["recipient"].must_equal("TEST KEYS DO NOT VERIFY ADDRESSES")
|
25
22
|
end
|
26
23
|
end
|
27
24
|
|
@@ -31,7 +31,7 @@ describe Lob::Resources::Letter do
|
|
31
31
|
new_letter = subject.letters.create(
|
32
32
|
description: "TestLetter",
|
33
33
|
color: true,
|
34
|
-
file: "https://s3-us-west-2.amazonaws.com/lob
|
34
|
+
file: "https://s3-us-west-2.amazonaws.com/public.lob.com/assets/us_letter_1pg.pdf",
|
35
35
|
to: new_address["id"],
|
36
36
|
from: @sample_address_params
|
37
37
|
)
|
@@ -52,6 +52,26 @@ describe Lob::Resources::Letter do
|
|
52
52
|
|
53
53
|
new_letter["description"].must_equal("TestLetter")
|
54
54
|
end
|
55
|
+
|
56
|
+
it "should create a letter with a merge variable object" do
|
57
|
+
new_address = subject.addresses.create @sample_address_params
|
58
|
+
|
59
|
+
new_letter = subject.letters.create(
|
60
|
+
description: "TestLetter",
|
61
|
+
color: true,
|
62
|
+
file: "<html>{{data.name}}</html>",
|
63
|
+
to: new_address["id"],
|
64
|
+
from: @sample_address_params,
|
65
|
+
merge_variables: {
|
66
|
+
data: {
|
67
|
+
name: "Kobe"
|
68
|
+
}
|
69
|
+
}
|
70
|
+
)
|
71
|
+
|
72
|
+
new_letter["description"].must_equal("TestLetter")
|
73
|
+
new_letter["merge_variables"]["data"]["name"].must_equal("Kobe")
|
74
|
+
end
|
55
75
|
end
|
56
76
|
|
57
77
|
|
@@ -62,13 +82,13 @@ describe Lob::Resources::Letter do
|
|
62
82
|
new_letter = subject.letters.create(
|
63
83
|
description: "TestLetter",
|
64
84
|
color: true,
|
65
|
-
file: "https://s3-us-west-2.amazonaws.com/lob
|
85
|
+
file: "https://s3-us-west-2.amazonaws.com/public.lob.com/assets/us_letter_1pg.pdf",
|
66
86
|
to: new_address["id"],
|
67
87
|
from: new_address["id"]
|
68
88
|
)
|
69
89
|
|
70
90
|
result = subject.letters.find(new_letter["id"])
|
71
|
-
assert
|
91
|
+
assert %r{#{new_letter["description"]}} =~ result.to_s
|
72
92
|
end
|
73
93
|
end
|
74
94
|
|
@@ -80,7 +100,7 @@ describe Lob::Resources::Letter do
|
|
80
100
|
new_letter = subject.letters.create(
|
81
101
|
description: "TestLetter",
|
82
102
|
color: true,
|
83
|
-
file: "https://s3-us-west-2.amazonaws.com/lob
|
103
|
+
file: "https://s3-us-west-2.amazonaws.com/public.lob.com/assets/us_letter_1pg.pdf",
|
84
104
|
to: new_address["id"],
|
85
105
|
from: new_address["id"]
|
86
106
|
)
|
@@ -0,0 +1,65 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe Lob::Resources::GroupsMember do
|
4
|
+
|
5
|
+
before :each do
|
6
|
+
@sample_group_params = {
|
7
|
+
description: "Unsubscribe group",
|
8
|
+
metadata: {
|
9
|
+
test: 'stuff'
|
10
|
+
}
|
11
|
+
}
|
12
|
+
@sample_member_params = {
|
13
|
+
recipient: {
|
14
|
+
name: 'Sophie',
|
15
|
+
address_line1: '185 Berry St',
|
16
|
+
address_line2: '6100',
|
17
|
+
address_city: 'San Francisco',
|
18
|
+
address_state: 'CA',
|
19
|
+
address_zip: '94107'
|
20
|
+
},
|
21
|
+
description: "Some Member",
|
22
|
+
metadata: {
|
23
|
+
test: 'stuff'
|
24
|
+
}
|
25
|
+
}
|
26
|
+
@new_group = subject.groups.create @sample_group_params
|
27
|
+
end
|
28
|
+
|
29
|
+
subject { Lob::Client.new(api_key: API_KEY) }
|
30
|
+
|
31
|
+
describe "list" do
|
32
|
+
it "should list members in a group" do
|
33
|
+
assert subject.groups_members.list(@new_group["id"])["object"] == "list"
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
|
38
|
+
describe "create" do
|
39
|
+
it "should create a member" do
|
40
|
+
result = subject.groups_members.create(@new_group["id"], @sample_member_params)
|
41
|
+
|
42
|
+
result["description"].must_equal(@sample_member_params[:description])
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
|
47
|
+
describe "find" do
|
48
|
+
it "should find a member" do
|
49
|
+
new_member = subject.groups_members.create(@new_group["id"], @sample_member_params)
|
50
|
+
|
51
|
+
find_result = subject.groups_members.find(@new_group["id"], new_member["id"])
|
52
|
+
find_result["description"].must_equal(@sample_member_params[:description])
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
|
57
|
+
describe "destroy" do
|
58
|
+
it "should delete a member" do
|
59
|
+
new_member = subject.groups_members.create(@new_group["id"], @sample_member_params)
|
60
|
+
|
61
|
+
delete_result = subject.groups_members.destroy(@new_group["id"], new_member["id"])
|
62
|
+
assert_equal(new_member["id"], delete_result["id"])
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
@@ -37,7 +37,7 @@ describe Lob::Resources::Postcard do
|
|
37
37
|
description: @sample_postcard_params[:description],
|
38
38
|
to: new_address["id"],
|
39
39
|
back: @sample_postcard_params[:back],
|
40
|
-
front: "https://lob.com/
|
40
|
+
front: "https://s3-us-west-2.amazonaws.com/public.lob.com/assets/pc_4x6_front.pdf"
|
41
41
|
)
|
42
42
|
|
43
43
|
result["description"].must_equal(@sample_postcard_params[:description])
|
@@ -48,7 +48,7 @@ describe Lob::Resources::Postcard do
|
|
48
48
|
description: @sample_postcard_params[:description],
|
49
49
|
to: @sample_address_params,
|
50
50
|
back: @sample_postcard_params[:back],
|
51
|
-
front: "https://lob.com/
|
51
|
+
front: "https://s3-us-west-2.amazonaws.com/public.lob.com/assets/pc_4x6_front.pdf"
|
52
52
|
)
|
53
53
|
|
54
54
|
result["description"].must_equal(@sample_postcard_params[:description])
|
@@ -62,7 +62,7 @@ describe Lob::Resources::Postcard do
|
|
62
62
|
to: new_address["id"],
|
63
63
|
from: @sample_address_params,
|
64
64
|
back: @sample_postcard_params[:back],
|
65
|
-
front: "https://lob.com/
|
65
|
+
front: "https://s3-us-west-2.amazonaws.com/public.lob.com/assets/pc_4x6_front.pdf"
|
66
66
|
)
|
67
67
|
|
68
68
|
result["description"].must_equal(@sample_postcard_params[:description])
|
@@ -74,8 +74,8 @@ describe Lob::Resources::Postcard do
|
|
74
74
|
result = subject.postcards.create(
|
75
75
|
description: @sample_postcard_params[:description],
|
76
76
|
to: new_address["id"],
|
77
|
-
front: "https://lob.com/
|
78
|
-
back: "https://lob.com/
|
77
|
+
front: "https://s3-us-west-2.amazonaws.com/public.lob.com/assets/pc_4x6_front.pdf",
|
78
|
+
back: "https://s3-us-west-2.amazonaws.com/public.lob.com/assets/pc_4x6_back.pdf"
|
79
79
|
)
|
80
80
|
|
81
81
|
result["description"].must_equal(@sample_postcard_params[:description])
|
@@ -95,6 +95,31 @@ describe Lob::Resources::Postcard do
|
|
95
95
|
result["description"].must_equal(@sample_postcard_params[:description])
|
96
96
|
end
|
97
97
|
|
98
|
+
it "should create a postcard with a merge variable list" do
|
99
|
+
new_address = subject.addresses.create @sample_address_params
|
100
|
+
merge_variables = {
|
101
|
+
list: [
|
102
|
+
{
|
103
|
+
name: "Larissa"
|
104
|
+
},
|
105
|
+
{
|
106
|
+
name: "Larry"
|
107
|
+
}
|
108
|
+
]
|
109
|
+
}
|
110
|
+
|
111
|
+
result = subject.postcards.create(
|
112
|
+
description: @sample_postcard_params[:description],
|
113
|
+
to: new_address["id"],
|
114
|
+
back: "<html>{{#list}} {{name}} {{/list}}</html>",
|
115
|
+
front: "https://s3-us-west-2.amazonaws.com/public.lob.com/assets/pc_4x6_front.pdf",
|
116
|
+
merge_variables: merge_variables
|
117
|
+
)
|
118
|
+
|
119
|
+
result["description"].must_equal(@sample_postcard_params[:description])
|
120
|
+
result["merge_variables"]["list"][0]["name"].must_equal("Larissa")
|
121
|
+
result["merge_variables"]["list"][1]["name"].must_equal("Larry")
|
122
|
+
end
|
98
123
|
end
|
99
124
|
|
100
125
|
|
@@ -2,22 +2,14 @@ require "spec_helper"
|
|
2
2
|
|
3
3
|
describe Lob::Resources::ResourceBase do
|
4
4
|
|
5
|
-
|
6
|
-
@api_key = API_KEY
|
7
|
-
end
|
8
|
-
|
9
|
-
subject { Lob::Client.new(api_key: @api_key) }
|
5
|
+
subject { Lob::Client.new(api_key: API_KEY) }
|
10
6
|
|
11
7
|
describe "when Lob is initialized" do
|
12
8
|
it "should have API key in config" do
|
13
|
-
subject.config[:api_key].must_equal
|
9
|
+
subject.config[:api_key].must_equal API_KEY
|
14
10
|
end
|
15
11
|
end
|
16
12
|
|
17
|
-
it "should return areas resource" do
|
18
|
-
subject.areas.must_be_kind_of(Lob::Resources::Area)
|
19
|
-
end
|
20
|
-
|
21
13
|
it "should return addresses resource" do
|
22
14
|
subject.addresses.must_be_kind_of(Lob::Resources::Address)
|
23
15
|
end
|
@@ -38,10 +30,6 @@ describe Lob::Resources::ResourceBase do
|
|
38
30
|
subject.postcards.must_be_kind_of(Lob::Resources::Postcard)
|
39
31
|
end
|
40
32
|
|
41
|
-
it "should return routes resource" do
|
42
|
-
subject.routes.must_be_kind_of(Lob::Resources::Route)
|
43
|
-
end
|
44
|
-
|
45
33
|
it "should accept an idempotency_key" do
|
46
34
|
sample_address_params = {
|
47
35
|
name: "TestAddress",
|
@@ -67,7 +55,7 @@ describe Lob::Resources::ResourceBase do
|
|
67
55
|
description: sample_postcard_params[:description],
|
68
56
|
to: new_address["id"],
|
69
57
|
back: sample_postcard_params[:back],
|
70
|
-
front: "https://lob.com/
|
58
|
+
front: "https://s3-us-west-2.amazonaws.com/public.lob.com/assets/pc_4x6_front.pdf"
|
71
59
|
}, {
|
72
60
|
"Idempotency-Key" => idempotency_key
|
73
61
|
})
|
@@ -76,7 +64,7 @@ describe Lob::Resources::ResourceBase do
|
|
76
64
|
description: sample_postcard_params[:description],
|
77
65
|
to: new_address["id"],
|
78
66
|
back: sample_postcard_params[:back],
|
79
|
-
front: "https://lob.com/
|
67
|
+
front: "https://s3-us-west-2.amazonaws.com/public.lob.com/assets/pc_4x6_front.pdf"
|
80
68
|
}, {
|
81
69
|
"Idempotency-Key" => idempotency_key
|
82
70
|
})
|
@@ -0,0 +1,177 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe Lob::Resources::SelfMailer do
|
4
|
+
|
5
|
+
before :each do
|
6
|
+
@sample_address_params = {
|
7
|
+
name: "TestAddress",
|
8
|
+
email: "test@test.com",
|
9
|
+
address_line1: "123 Test Street",
|
10
|
+
address_line2: "Unit 199",
|
11
|
+
address_city: "Mountain View",
|
12
|
+
address_state: "CA",
|
13
|
+
address_country: "US",
|
14
|
+
address_zip: 94085
|
15
|
+
}
|
16
|
+
|
17
|
+
@sample_self_mailer_params = {
|
18
|
+
description: "Test Self Mailer",
|
19
|
+
outside: "<h1>Sample Self Mailer Outside</h1>",
|
20
|
+
inside: "https://s3-us-west-2.amazonaws.com/public.lob.com/assets/templates/self_mailers/6x18_sfm_inside.pdf",
|
21
|
+
}
|
22
|
+
end
|
23
|
+
|
24
|
+
subject { Lob::Client.new(api_key: API_KEY) }
|
25
|
+
|
26
|
+
describe "list" do
|
27
|
+
it "should list self mailers" do
|
28
|
+
self_mailers = subject.self_mailers.list()
|
29
|
+
assert self_mailers["object"] == "list"
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
|
34
|
+
describe "create" do
|
35
|
+
it "should create a self mailer with address_id" do
|
36
|
+
new_address = subject.addresses.create @sample_address_params
|
37
|
+
|
38
|
+
result = subject.self_mailers.create(
|
39
|
+
description: @sample_self_mailer_params[:description],
|
40
|
+
to: new_address["id"],
|
41
|
+
outside: @sample_self_mailer_params[:outside],
|
42
|
+
inside: @sample_self_mailer_params[:inside],
|
43
|
+
)
|
44
|
+
|
45
|
+
result["description"].must_equal(@sample_self_mailer_params[:description])
|
46
|
+
end
|
47
|
+
|
48
|
+
it "should create a self mailer with to address params" do
|
49
|
+
result = subject.self_mailers.create(
|
50
|
+
description: @sample_self_mailer_params[:description],
|
51
|
+
to: @sample_address_params,
|
52
|
+
outside: @sample_self_mailer_params[:outside],
|
53
|
+
inside: "https://s3-us-west-2.amazonaws.com/public.lob.com/assets/templates/self_mailers/6x18_sfm_inside.pdf"
|
54
|
+
)
|
55
|
+
|
56
|
+
result["description"].must_equal(@sample_self_mailer_params[:description])
|
57
|
+
end
|
58
|
+
|
59
|
+
it "should create a self mailer with from address params" do
|
60
|
+
new_address = subject.addresses.create @sample_address_params
|
61
|
+
|
62
|
+
result = subject.self_mailers.create(
|
63
|
+
description: @sample_self_mailer_params[:description],
|
64
|
+
to: new_address["id"],
|
65
|
+
from: @sample_address_params,
|
66
|
+
outside: @sample_self_mailer_params[:outside],
|
67
|
+
inside: "https://s3-us-west-2.amazonaws.com/public.lob.com/assets/templates/self_mailers/6x18_sfm_inside.pdf"
|
68
|
+
)
|
69
|
+
|
70
|
+
result["description"].must_equal(@sample_self_mailer_params[:description])
|
71
|
+
end
|
72
|
+
|
73
|
+
it "should create a self mailer with front and back as urls" do
|
74
|
+
new_address = subject.addresses.create @sample_address_params
|
75
|
+
|
76
|
+
result = subject.self_mailers.create(
|
77
|
+
description: @sample_self_mailer_params[:description],
|
78
|
+
to: new_address["id"],
|
79
|
+
outside: "https://s3-us-west-2.amazonaws.com/public.lob.com/assets/templates/self_mailers/6x18_sfm_outside.pdf",
|
80
|
+
inside: "https://s3-us-west-2.amazonaws.com/public.lob.com/assets/templates/self_mailers/6x18_sfm_inside.pdf"
|
81
|
+
)
|
82
|
+
|
83
|
+
result["description"].must_equal(@sample_self_mailer_params[:description])
|
84
|
+
end
|
85
|
+
|
86
|
+
|
87
|
+
it "should create a self mailer with front and back as PDFs" do
|
88
|
+
new_address = subject.addresses.create @sample_address_params
|
89
|
+
|
90
|
+
result = subject.self_mailers.create(
|
91
|
+
description: @sample_self_mailer_params[:description],
|
92
|
+
to: new_address["id"],
|
93
|
+
outside: File.new(File.expand_path("../../../samples/sfm-6x18-outside.pdf", __FILE__)),
|
94
|
+
inside: File.new(File.expand_path("../../../samples/sfm-6x18-inside.pdf", __FILE__))
|
95
|
+
)
|
96
|
+
|
97
|
+
result["description"].must_equal(@sample_self_mailer_params[:description])
|
98
|
+
end
|
99
|
+
|
100
|
+
it "should create a self mailer with front and back as 12x9 PDFs" do
|
101
|
+
new_address = subject.addresses.create @sample_address_params
|
102
|
+
|
103
|
+
result = subject.self_mailers.create(
|
104
|
+
description: @sample_self_mailer_params[:description],
|
105
|
+
to: new_address["id"],
|
106
|
+
size: "12x9_bifold",
|
107
|
+
outside: File.new(File.expand_path("../../../samples/sfm-12x9-outside.pdf", __FILE__)),
|
108
|
+
inside: File.new(File.expand_path("../../../samples/sfm-12x9-inside.pdf", __FILE__))
|
109
|
+
)
|
110
|
+
|
111
|
+
result["description"].must_equal(@sample_self_mailer_params[:description])
|
112
|
+
end
|
113
|
+
|
114
|
+
|
115
|
+
it "should create a self mailer with a merge variable list" do
|
116
|
+
new_address = subject.addresses.create @sample_address_params
|
117
|
+
merge_variables = {
|
118
|
+
list: [
|
119
|
+
{
|
120
|
+
name: "Larissa"
|
121
|
+
},
|
122
|
+
{
|
123
|
+
name: "Larry"
|
124
|
+
}
|
125
|
+
]
|
126
|
+
}
|
127
|
+
|
128
|
+
result = subject.self_mailers.create(
|
129
|
+
description: @sample_self_mailer_params[:description],
|
130
|
+
to: new_address["id"],
|
131
|
+
outside: "https://s3-us-west-2.amazonaws.com/public.lob.com/assets/templates/self_mailers/6x18_sfm_inside.pdf",
|
132
|
+
inside: "<html>{{#list}} {{name}} {{/list}}</html>",
|
133
|
+
merge_variables: merge_variables
|
134
|
+
)
|
135
|
+
|
136
|
+
result["description"].must_equal(@sample_self_mailer_params[:description])
|
137
|
+
result["merge_variables"]["list"][0]["name"].must_equal("Larissa")
|
138
|
+
result["merge_variables"]["list"][1]["name"].must_equal("Larry")
|
139
|
+
end
|
140
|
+
end
|
141
|
+
|
142
|
+
|
143
|
+
describe "find" do
|
144
|
+
it "should find a self mailer" do
|
145
|
+
new_address = subject.addresses.create @sample_address_params
|
146
|
+
|
147
|
+
new_self_mailer = subject.self_mailers.create(
|
148
|
+
description: @sample_self_mailer_params[:description],
|
149
|
+
to: new_address["id"],
|
150
|
+
outside: @sample_self_mailer_params[:outside],
|
151
|
+
inside: @sample_self_mailer_params[:inside]
|
152
|
+
)
|
153
|
+
|
154
|
+
result = subject.self_mailers.find(new_self_mailer["id"])
|
155
|
+
result["description"].must_equal(@sample_self_mailer_params[:description])
|
156
|
+
end
|
157
|
+
end
|
158
|
+
|
159
|
+
|
160
|
+
describe "destroy" do
|
161
|
+
it "should destroy a self mailer" do
|
162
|
+
new_address = subject.addresses.create @sample_address_params
|
163
|
+
|
164
|
+
new_self_mailer = subject.self_mailers.create(
|
165
|
+
description: @sample_self_mailer_params[:description],
|
166
|
+
to: new_address["id"],
|
167
|
+
outside: @sample_self_mailer_params[:outside],
|
168
|
+
inside: @sample_self_mailer_params[:inside]
|
169
|
+
)
|
170
|
+
|
171
|
+
result = subject.self_mailers.destroy(new_self_mailer["id"])
|
172
|
+
result["id"].must_equal(new_self_mailer["id"])
|
173
|
+
result["deleted"].must_equal(true)
|
174
|
+
end
|
175
|
+
end
|
176
|
+
|
177
|
+
end
|