lob 4.3.0 → 5.4.6
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 +4 -4
- data/.github/workflows/forked_tests_job.yml +36 -0
- data/.github/workflows/run_tests_job.yml +32 -0
- data/.github/workflows/update_gem.yml +27 -0
- data/.gitignore +1 -0
- data/CHANGELOG.md +47 -0
- data/README.md +16 -85
- data/examples/README.md +95 -9
- data/examples/cards.rb +51 -0
- data/examples/checks.rb +4 -3
- data/examples/csv_checks/create_checks.rb +3 -2
- data/examples/csv_letters/create_letters.rb +3 -2
- data/examples/csv_letters/letter_template.html +1 -1
- data/examples/csv_postcards/create_postcards.rb +3 -2
- data/examples/csv_postcards/input.csv +7 -7
- data/examples/csv_postcards/postcard_back.html +1 -1
- data/examples/csv_verify/verify.rb +3 -2
- data/examples/letters.rb +4 -3
- data/examples/list_postcards_metadata.rb +94 -0
- data/examples/postcards.rb +6 -5
- data/examples/postcards_idempotent.rb +92 -0
- data/examples/postcards_intl.rb +87 -0
- data/examples/postcards_remote.rb +87 -0
- data/examples/postcards_send_date.rb +97 -0
- data/examples/postcards_template.rb +98 -0
- data/examples/self_mailers.rb +38 -0
- data/lib/lob/client.rb +33 -8
- data/lib/lob/resources/bulk_intl_verifications.rb +27 -0
- data/lib/lob/resources/bulk_us_verifications.rb +28 -0
- data/lib/lob/resources/card.rb +46 -0
- 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 +20 -9
- data/lib/lob/resources/self_mailer.rb +14 -0
- data/lib/lob/resources/us_reverse_geocode_lookups.rb +26 -0
- data/lib/lob/version.rb +1 -1
- data/lob.gemspec +7 -7
- data/spec/lob/resources/bulk_intl_verifications_spec.rb +39 -0
- data/spec/lob/resources/bulk_us_verifications_spec.rb +51 -0
- data/spec/lob/resources/card_spec.rb +145 -0
- 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/lob/resources/us_reverse_geocode_lookups_spec.rb +22 -0
- data/spec/samples/card.pdf +744 -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 +7 -5
- metadata +73 -39
- data/.travis.yml +0 -19
- 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
data/examples/letters.rb
CHANGED
@@ -1,8 +1,9 @@
|
|
1
1
|
$:.unshift File.expand_path("../lib", File.dirname(__FILE__))
|
2
2
|
require 'lob'
|
3
|
+
require 'pp'
|
3
4
|
|
4
5
|
# initialize Lob object
|
5
|
-
lob = Lob::Client.new(api_key: '
|
6
|
+
lob = Lob::Client.new(api_key: 'YOUR_API_KEY')
|
6
7
|
|
7
8
|
html = %{
|
8
9
|
<html>
|
@@ -18,7 +19,7 @@ html = %{
|
|
18
19
|
font-family: 'Loved by the King';
|
19
20
|
font-style: normal;
|
20
21
|
font-weight: 400;
|
21
|
-
src: url('https://s3-us-west-2.amazonaws.com/lob
|
22
|
+
src: url('https://s3-us-west-2.amazonaws.com/public.lob.com/fonts/lovedByTheKing/LovedbytheKing.ttf') format('truetype');
|
22
23
|
}
|
23
24
|
|
24
25
|
.text {
|
@@ -61,7 +62,7 @@ from_address = lob.addresses.create(
|
|
61
62
|
)
|
62
63
|
|
63
64
|
# send the letter
|
64
|
-
|
65
|
+
pp lob.letters.create(
|
65
66
|
description: "Test letter",
|
66
67
|
to: to_address["id"],
|
67
68
|
from: from_address["id"],
|
@@ -0,0 +1,94 @@
|
|
1
|
+
$:.unshift File.expand_path("../lib", File.dirname(__FILE__))
|
2
|
+
require 'lob.rb'
|
3
|
+
require 'pp'
|
4
|
+
|
5
|
+
# initialize Lob object
|
6
|
+
lob = Lob::Client.new(api_key: 'YOUR_API_KEY')
|
7
|
+
|
8
|
+
# HTML to send to the server
|
9
|
+
html = %{
|
10
|
+
<html>
|
11
|
+
<head>
|
12
|
+
<title>Lob.com Sample 4x6 Postcard Front</title>
|
13
|
+
<style>
|
14
|
+
*, *:before, *:after {
|
15
|
+
-webkit-box-sizing: border-box;
|
16
|
+
-moz-box-sizing: border-box;
|
17
|
+
box-sizing: border-box;
|
18
|
+
}
|
19
|
+
|
20
|
+
@font-face {
|
21
|
+
font-family: 'Loved by the King';
|
22
|
+
font-style: normal;
|
23
|
+
font-weight: 400;
|
24
|
+
src: url('https://s3-us-west-2.amazonaws.com/public.lob.com/fonts/lovedByTheKing/LovedbytheKing.ttf') format('truetype');
|
25
|
+
}
|
26
|
+
|
27
|
+
body {
|
28
|
+
width: 6.25in;
|
29
|
+
height: 4.25in;
|
30
|
+
margin: 0;
|
31
|
+
padding: 0;
|
32
|
+
/* If using an image, the background image should have dimensions of 1875x1275 pixels. */
|
33
|
+
background-image: url('https://s3-us-west-2.amazonaws.com/public.lob.com/assets/beach.jpg');
|
34
|
+
background-size: 6.25in 4.25in;
|
35
|
+
background-repeat: no-repeat;
|
36
|
+
}
|
37
|
+
|
38
|
+
.text {
|
39
|
+
margin: 50px;
|
40
|
+
width: 400px;
|
41
|
+
font-family: 'Loved by the King';
|
42
|
+
font-size: 50px;
|
43
|
+
font-weight: 700;
|
44
|
+
color: white;
|
45
|
+
text-shadow: 3px 3px black;
|
46
|
+
}
|
47
|
+
</style>
|
48
|
+
</head>
|
49
|
+
|
50
|
+
<body>
|
51
|
+
<h1 class="text">Hello {{name}}!</h1>
|
52
|
+
<p class="text">Join us for the {{event}}!</p>
|
53
|
+
</body>
|
54
|
+
|
55
|
+
</html>
|
56
|
+
}
|
57
|
+
|
58
|
+
# create a to address
|
59
|
+
to_address = lob.addresses.create(
|
60
|
+
name: "ToAddress",
|
61
|
+
address_line1: "120 6th Ave",
|
62
|
+
address_city: "Boston",
|
63
|
+
address_state: "MA",
|
64
|
+
address_country: "US",
|
65
|
+
address_zip: 12345
|
66
|
+
)
|
67
|
+
|
68
|
+
# create a from address
|
69
|
+
from_address = lob.addresses.create(
|
70
|
+
name: "FromAddress",
|
71
|
+
address_line1: "120 6th Ave",
|
72
|
+
address_city: "Boston",
|
73
|
+
address_state: "MA",
|
74
|
+
address_country: "US",
|
75
|
+
address_zip: 12345
|
76
|
+
)
|
77
|
+
|
78
|
+
# send a postcard
|
79
|
+
pp lob.postcards.create(
|
80
|
+
description: "Beach Postcard",
|
81
|
+
to: to_address["id"],
|
82
|
+
from: from_address["id"],
|
83
|
+
metadata: { campaign: "Summer 2015 Beach" },
|
84
|
+
merge_variables: { name: "Albert", event: "Summer 2015 Beach-athon" },
|
85
|
+
front: html,
|
86
|
+
back: "<h1>Please RSVP as soon as possible to reserve your lounge chair.</h1>"
|
87
|
+
)
|
88
|
+
|
89
|
+
pp lob.postcards.list(
|
90
|
+
metadata: {
|
91
|
+
campaign: 'Summer 2015 Beach'
|
92
|
+
},
|
93
|
+
limit: 1
|
94
|
+
)
|
data/examples/postcards.rb
CHANGED
@@ -1,8 +1,9 @@
|
|
1
1
|
$:.unshift File.expand_path("../lib", File.dirname(__FILE__))
|
2
|
-
require 'lob'
|
2
|
+
require 'lob.rb'
|
3
|
+
require 'pp'
|
3
4
|
|
4
5
|
# initialize Lob object
|
5
|
-
lob = Lob::Client.new(api_key: '
|
6
|
+
lob = Lob::Client.new(api_key: 'YOUR_API_KEY')
|
6
7
|
|
7
8
|
# HTML to send to the server
|
8
9
|
html = %{
|
@@ -20,7 +21,7 @@ html = %{
|
|
20
21
|
font-family: 'Loved by the King';
|
21
22
|
font-style: normal;
|
22
23
|
font-weight: 400;
|
23
|
-
src: url('https://s3-us-west-2.amazonaws.com/lob
|
24
|
+
src: url('https://s3-us-west-2.amazonaws.com/public.lob.com/fonts/lovedByTheKing/LovedbytheKing.ttf') format('truetype');
|
24
25
|
}
|
25
26
|
|
26
27
|
body {
|
@@ -29,7 +30,7 @@ html = %{
|
|
29
30
|
margin: 0;
|
30
31
|
padding: 0;
|
31
32
|
/* If using an image, the background image should have dimensions of 1875x1275 pixels. */
|
32
|
-
background-image: url(https://s3-us-west-2.amazonaws.com/lob
|
33
|
+
background-image: url('https://s3-us-west-2.amazonaws.com/public.lob.com/assets/beach.jpg');
|
33
34
|
background-size: 6.25in 4.25in;
|
34
35
|
background-repeat: no-repeat;
|
35
36
|
}
|
@@ -75,7 +76,7 @@ from_address = lob.addresses.create(
|
|
75
76
|
)
|
76
77
|
|
77
78
|
# send a postcard
|
78
|
-
|
79
|
+
pp lob.postcards.create(
|
79
80
|
description: "Beach Postcard",
|
80
81
|
to: to_address["id"],
|
81
82
|
from: from_address["id"],
|
@@ -0,0 +1,92 @@
|
|
1
|
+
$:.unshift File.expand_path("../lib", File.dirname(__FILE__))
|
2
|
+
require 'lob.rb'
|
3
|
+
require 'pp'
|
4
|
+
|
5
|
+
# initialize Lob object
|
6
|
+
lob = Lob::Client.new(api_key: 'YOUR_API_KEY')
|
7
|
+
|
8
|
+
# HTML to send to the server
|
9
|
+
html = %{
|
10
|
+
<html>
|
11
|
+
<head>
|
12
|
+
<title>Lob.com Sample 4x6 Postcard Front</title>
|
13
|
+
<style>
|
14
|
+
*, *:before, *:after {
|
15
|
+
-webkit-box-sizing: border-box;
|
16
|
+
-moz-box-sizing: border-box;
|
17
|
+
box-sizing: border-box;
|
18
|
+
}
|
19
|
+
|
20
|
+
@font-face {
|
21
|
+
font-family: 'Loved by the King';
|
22
|
+
font-style: normal;
|
23
|
+
font-weight: 400;
|
24
|
+
src: url('https://s3-us-west-2.amazonaws.com/public.lob.com/fonts/lovedByTheKing/LovedbytheKing.ttf') format('truetype');
|
25
|
+
}
|
26
|
+
|
27
|
+
body {
|
28
|
+
width: 6.25in;
|
29
|
+
height: 4.25in;
|
30
|
+
margin: 0;
|
31
|
+
padding: 0;
|
32
|
+
/* If using an image, the background image should have dimensions of 1875x1275 pixels. */
|
33
|
+
background-image: url('https://s3-us-west-2.amazonaws.com/public.lob.com/assets/beach.jpg');
|
34
|
+
background-size: 6.25in 4.25in;
|
35
|
+
background-repeat: no-repeat;
|
36
|
+
}
|
37
|
+
|
38
|
+
.text {
|
39
|
+
margin: 50px;
|
40
|
+
width: 400px;
|
41
|
+
font-family: 'Loved by the King';
|
42
|
+
font-size: 50px;
|
43
|
+
font-weight: 700;
|
44
|
+
color: white;
|
45
|
+
text-shadow: 3px 3px black;
|
46
|
+
}
|
47
|
+
</style>
|
48
|
+
</head>
|
49
|
+
|
50
|
+
<body>
|
51
|
+
<h1 class="text">Hello {{name}}!</h1>
|
52
|
+
<p class="text">Join us for the {{event}}!</p>
|
53
|
+
</body>
|
54
|
+
|
55
|
+
</html>
|
56
|
+
}
|
57
|
+
|
58
|
+
# create a to address
|
59
|
+
to_address = lob.addresses.create(
|
60
|
+
name: "ToAddress",
|
61
|
+
address_line1: "120 6th Ave",
|
62
|
+
address_city: "Boston",
|
63
|
+
address_state: "MA",
|
64
|
+
address_country: "US",
|
65
|
+
address_zip: 12345
|
66
|
+
)
|
67
|
+
|
68
|
+
# create a from address
|
69
|
+
from_address = lob.addresses.create(
|
70
|
+
name: "FromAddress",
|
71
|
+
address_line1: "120 6th Ave",
|
72
|
+
address_city: "Boston",
|
73
|
+
address_state: "MA",
|
74
|
+
address_country: "US",
|
75
|
+
address_zip: 12345
|
76
|
+
)
|
77
|
+
|
78
|
+
# send a postcard
|
79
|
+
pp lob.postcards.create(
|
80
|
+
{
|
81
|
+
description: "Beach Postcard",
|
82
|
+
to: to_address["id"],
|
83
|
+
from: from_address["id"],
|
84
|
+
metadata: { campaign: "Summer 2015 Beach" },
|
85
|
+
merge_variables: { name: "Albert", event: "Summer 2015 Beach-athon" },
|
86
|
+
front: html,
|
87
|
+
back: "<h1>Please RSVP as soon as possible to reserve your lounge chair.</h1>"
|
88
|
+
},
|
89
|
+
{
|
90
|
+
'Idempotency-Key': '026e7634-24d7-486c-a0bb-4a17fd0eebc5'
|
91
|
+
}
|
92
|
+
)
|
@@ -0,0 +1,87 @@
|
|
1
|
+
$:.unshift File.expand_path("../lib", File.dirname(__FILE__))
|
2
|
+
require 'lob'
|
3
|
+
require 'pp'
|
4
|
+
|
5
|
+
# initialize Lob object
|
6
|
+
lob = Lob::Client.new(api_key: 'YOUR_API_KEY')
|
7
|
+
|
8
|
+
# HTML to send to the server
|
9
|
+
html = %{
|
10
|
+
<html>
|
11
|
+
<head>
|
12
|
+
<title>Lob.com Sample 4x6 Postcard Front</title>
|
13
|
+
<style>
|
14
|
+
*, *:before, *:after {
|
15
|
+
-webkit-box-sizing: border-box;
|
16
|
+
-moz-box-sizing: border-box;
|
17
|
+
box-sizing: border-box;
|
18
|
+
}
|
19
|
+
|
20
|
+
@font-face {
|
21
|
+
font-family: 'Loved by the King';
|
22
|
+
font-style: normal;
|
23
|
+
font-weight: 400;
|
24
|
+
src: url('https://s3-us-west-2.amazonaws.com/public.lob.com/fonts/lovedByTheKing/LovedbytheKing.ttf') format('truetype');
|
25
|
+
}
|
26
|
+
|
27
|
+
body {
|
28
|
+
width: 6.25in;
|
29
|
+
height: 4.25in;
|
30
|
+
margin: 0;
|
31
|
+
padding: 0;
|
32
|
+
/* If using an image, the background image should have dimensions of 1875x1275 pixels. */
|
33
|
+
background-image: url('https://s3-us-west-2.amazonaws.com/public.lob.com/assets/beach.jpg');
|
34
|
+
background-size: 6.25in 4.25in;
|
35
|
+
background-repeat: no-repeat;
|
36
|
+
}
|
37
|
+
|
38
|
+
.text {
|
39
|
+
margin: 50px;
|
40
|
+
width: 400px;
|
41
|
+
font-family: 'Loved by the King';
|
42
|
+
font-size: 50px;
|
43
|
+
font-weight: 700;
|
44
|
+
color: white;
|
45
|
+
text-shadow: 3px 3px black;
|
46
|
+
}
|
47
|
+
</style>
|
48
|
+
</head>
|
49
|
+
|
50
|
+
<body>
|
51
|
+
<h1 class="text">Hello {{name}}!</h1>
|
52
|
+
<p class="text">Join us for the {{event}}!</p>
|
53
|
+
</body>
|
54
|
+
|
55
|
+
</html>
|
56
|
+
}
|
57
|
+
|
58
|
+
# create a to address
|
59
|
+
to_address = lob.addresses.create(
|
60
|
+
name: "ToAddress",
|
61
|
+
address_line1: "370 Water St",
|
62
|
+
address_city: "Summerside",
|
63
|
+
address_state: "Prince Edward Island",
|
64
|
+
address_country: "CA",
|
65
|
+
address_zip: "C1N 1C4"
|
66
|
+
)
|
67
|
+
|
68
|
+
# create a from address
|
69
|
+
from_address = lob.addresses.create(
|
70
|
+
name: "FromAddress",
|
71
|
+
address_line1: "120 6th Ave",
|
72
|
+
address_city: "Boston",
|
73
|
+
address_state: "MA",
|
74
|
+
address_country: "US",
|
75
|
+
address_zip: 12345
|
76
|
+
)
|
77
|
+
|
78
|
+
# send a postcard
|
79
|
+
pp lob.postcards.create(
|
80
|
+
description: "Beach Postcard",
|
81
|
+
to: to_address["id"],
|
82
|
+
from: from_address["id"],
|
83
|
+
metadata: { campaign: "Summer 2015 Beach" },
|
84
|
+
merge_variables: { name: "Albert", event: "Summer 2015 Beach-athon" },
|
85
|
+
front: html,
|
86
|
+
back: "<h1>Please RSVP as soon as possible to reserve your lounge chair.</h1>"
|
87
|
+
)
|
@@ -0,0 +1,87 @@
|
|
1
|
+
$:.unshift File.expand_path("../lib", File.dirname(__FILE__))
|
2
|
+
require 'lob.rb'
|
3
|
+
require 'pp'
|
4
|
+
|
5
|
+
# initialize Lob object
|
6
|
+
lob = Lob::Client.new(api_key: 'YOUR_API_KEY')
|
7
|
+
|
8
|
+
# HTML to send to the server
|
9
|
+
html = %{
|
10
|
+
<html>
|
11
|
+
<head>
|
12
|
+
<title>Lob.com Sample 4x6 Postcard Front</title>
|
13
|
+
<style>
|
14
|
+
*, *:before, *:after {
|
15
|
+
-webkit-box-sizing: border-box;
|
16
|
+
-moz-box-sizing: border-box;
|
17
|
+
box-sizing: border-box;
|
18
|
+
}
|
19
|
+
|
20
|
+
@font-face {
|
21
|
+
font-family: 'Loved by the King';
|
22
|
+
font-style: normal;
|
23
|
+
font-weight: 400;
|
24
|
+
src: url('https://s3-us-west-2.amazonaws.com/public.lob.com/fonts/lovedByTheKing/LovedbytheKing.ttf') format('truetype');
|
25
|
+
}
|
26
|
+
|
27
|
+
body {
|
28
|
+
width: 6.25in;
|
29
|
+
height: 4.25in;
|
30
|
+
margin: 0;
|
31
|
+
padding: 0;
|
32
|
+
/* If using an image, the background image should have dimensions of 1875x1275 pixels. */
|
33
|
+
background-image: url('https://s3-us-west-2.amazonaws.com/public.lob.com/assets/beach.jpg');
|
34
|
+
background-size: 6.25in 4.25in;
|
35
|
+
background-repeat: no-repeat;
|
36
|
+
}
|
37
|
+
|
38
|
+
.text {
|
39
|
+
margin: 50px;
|
40
|
+
width: 400px;
|
41
|
+
font-family: 'Loved by the King';
|
42
|
+
font-size: 50px;
|
43
|
+
font-weight: 700;
|
44
|
+
color: white;
|
45
|
+
text-shadow: 3px 3px black;
|
46
|
+
}
|
47
|
+
</style>
|
48
|
+
</head>
|
49
|
+
|
50
|
+
<body>
|
51
|
+
<h1 class="text">Hello {{name}}!</h1>
|
52
|
+
<p class="text">Join us for the {{event}}!</p>
|
53
|
+
</body>
|
54
|
+
|
55
|
+
</html>
|
56
|
+
}
|
57
|
+
|
58
|
+
# create a to address
|
59
|
+
to_address = lob.addresses.create(
|
60
|
+
name: "ToAddress",
|
61
|
+
address_line1: "120 6th Ave",
|
62
|
+
address_city: "Boston",
|
63
|
+
address_state: "MA",
|
64
|
+
address_country: "US",
|
65
|
+
address_zip: 12345
|
66
|
+
)
|
67
|
+
|
68
|
+
# create a from address
|
69
|
+
from_address = lob.addresses.create(
|
70
|
+
name: "FromAddress",
|
71
|
+
address_line1: "120 6th Ave",
|
72
|
+
address_city: "Boston",
|
73
|
+
address_state: "MA",
|
74
|
+
address_country: "US",
|
75
|
+
address_zip: 12345
|
76
|
+
)
|
77
|
+
|
78
|
+
# send a postcard
|
79
|
+
pp lob.postcards.create(
|
80
|
+
description: "Beach Postcard",
|
81
|
+
to: to_address["id"],
|
82
|
+
from: from_address["id"],
|
83
|
+
metadata: { campaign: "Summer 2015 Beach" },
|
84
|
+
merge_variables: { name: "Albert", event: "Summer 2015 Beach-athon" },
|
85
|
+
front: 'https://s3-us-west-2.amazonaws.com/public.lob.com/assets/templates/4x6_pc_template.pdf',
|
86
|
+
back: 'https://s3-us-west-2.amazonaws.com/public.lob.com/assets/templates/4x6_pc_template.pdf'
|
87
|
+
)
|
@@ -0,0 +1,97 @@
|
|
1
|
+
$:.unshift File.expand_path("../lib", File.dirname(__FILE__))
|
2
|
+
require 'lob.rb'
|
3
|
+
require 'pp'
|
4
|
+
require 'date'
|
5
|
+
|
6
|
+
# initialize Lob object
|
7
|
+
lob = Lob::Client.new(api_key: 'YOUR_API_KEY')
|
8
|
+
|
9
|
+
# HTML to send to the server
|
10
|
+
html = %{
|
11
|
+
<html>
|
12
|
+
<head>
|
13
|
+
<title>Lob.com Sample 4x6 Postcard Front</title>
|
14
|
+
<style>
|
15
|
+
*, *:before, *:after {
|
16
|
+
-webkit-box-sizing: border-box;
|
17
|
+
-moz-box-sizing: border-box;
|
18
|
+
box-sizing: border-box;
|
19
|
+
}
|
20
|
+
|
21
|
+
@font-face {
|
22
|
+
font-family: 'Loved by the King';
|
23
|
+
font-style: normal;
|
24
|
+
font-weight: 400;
|
25
|
+
src: url('https://s3-us-west-2.amazonaws.com/public.lob.com/fonts/lovedByTheKing/LovedbytheKing.ttf') format('truetype');
|
26
|
+
}
|
27
|
+
|
28
|
+
body {
|
29
|
+
width: 6.25in;
|
30
|
+
height: 4.25in;
|
31
|
+
margin: 0;
|
32
|
+
padding: 0;
|
33
|
+
/* If using an image, the background image should have dimensions of 1875x1275 pixels. */
|
34
|
+
background-image: url('https://s3-us-west-2.amazonaws.com/public.lob.com/assets/beach.jpg');
|
35
|
+
background-size: 6.25in 4.25in;
|
36
|
+
background-repeat: no-repeat;
|
37
|
+
}
|
38
|
+
|
39
|
+
.text {
|
40
|
+
margin: 50px;
|
41
|
+
width: 400px;
|
42
|
+
font-family: 'Loved by the King';
|
43
|
+
font-size: 50px;
|
44
|
+
font-weight: 700;
|
45
|
+
color: white;
|
46
|
+
text-shadow: 3px 3px black;
|
47
|
+
}
|
48
|
+
</style>
|
49
|
+
</head>
|
50
|
+
|
51
|
+
<body>
|
52
|
+
<h1 class="text">Hello {{name}}!</h1>
|
53
|
+
<p class="text">Join us for the {{event}}!</p>
|
54
|
+
</body>
|
55
|
+
|
56
|
+
</html>
|
57
|
+
}
|
58
|
+
|
59
|
+
# create a to address
|
60
|
+
to_address = lob.addresses.create(
|
61
|
+
name: "ToAddress",
|
62
|
+
address_line1: "120 6th Ave",
|
63
|
+
address_city: "Boston",
|
64
|
+
address_state: "MA",
|
65
|
+
address_country: "US",
|
66
|
+
address_zip: 12345
|
67
|
+
)
|
68
|
+
|
69
|
+
# create a from address
|
70
|
+
from_address = lob.addresses.create(
|
71
|
+
name: "FromAddress",
|
72
|
+
address_line1: "120 6th Ave",
|
73
|
+
address_city: "Boston",
|
74
|
+
address_state: "MA",
|
75
|
+
address_country: "US",
|
76
|
+
address_zip: 12345
|
77
|
+
)
|
78
|
+
|
79
|
+
def get_date()
|
80
|
+
time = Time.new
|
81
|
+
if time.month == 12
|
82
|
+
return "#{time.year + 1}-01-#{time.day}"
|
83
|
+
else
|
84
|
+
return "#{time.year}-#{time.month + 1}-#{time.day}"
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
pp lob.postcards.create(
|
89
|
+
description: "Beach Postcard",
|
90
|
+
to: to_address["id"],
|
91
|
+
from: from_address["id"],
|
92
|
+
metadata: { campaign: "Summer 2015 Beach" },
|
93
|
+
merge_variables: { name: "Albert", event: "Summer 2015 Beach-athon" },
|
94
|
+
front: html,
|
95
|
+
back: "<h1>Please RSVP as soon as possible to reserve your lounge chair.</h1>",
|
96
|
+
send_date: get_date()
|
97
|
+
)
|
@@ -0,0 +1,98 @@
|
|
1
|
+
$:.unshift File.expand_path("../lib", File.dirname(__FILE__))
|
2
|
+
require 'lob.rb'
|
3
|
+
require 'pp'
|
4
|
+
|
5
|
+
# initialize Lob object
|
6
|
+
# this key is publicly available in the legacy docs, so it's hardcoded
|
7
|
+
# since the templates are associated with this dummy account
|
8
|
+
# you can replace this key with your own, and the IDs below with any
|
9
|
+
# saved templates you have
|
10
|
+
lob = Lob::Client.new(api_key: 'test_0dc8d51e0acffcb1880e0f19c79b2f5b0cc')
|
11
|
+
|
12
|
+
# HTML to send to the server
|
13
|
+
html = %{
|
14
|
+
<html>
|
15
|
+
<head>
|
16
|
+
<title>Lob.com Sample 4x6 Postcard Front</title>
|
17
|
+
<style>
|
18
|
+
*, *:before, *:after {
|
19
|
+
-webkit-box-sizing: border-box;
|
20
|
+
-moz-box-sizing: border-box;
|
21
|
+
box-sizing: border-box;
|
22
|
+
}
|
23
|
+
|
24
|
+
@font-face {
|
25
|
+
font-family: 'Loved by the King';
|
26
|
+
font-style: normal;
|
27
|
+
font-weight: 400;
|
28
|
+
src: url('https://s3-us-west-2.amazonaws.com/public.lob.com/fonts/lovedByTheKing/LovedbytheKing.ttf') format('truetype');
|
29
|
+
}
|
30
|
+
|
31
|
+
body {
|
32
|
+
width: 6.25in;
|
33
|
+
height: 4.25in;
|
34
|
+
margin: 0;
|
35
|
+
padding: 0;
|
36
|
+
/* If using an image, the background image should have dimensions of 1875x1275 pixels. */
|
37
|
+
background-image: url('https://s3-us-west-2.amazonaws.com/public.lob.com/assets/beach.jpg');
|
38
|
+
background-size: 6.25in 4.25in;
|
39
|
+
background-repeat: no-repeat;
|
40
|
+
}
|
41
|
+
|
42
|
+
.text {
|
43
|
+
margin: 50px;
|
44
|
+
width: 400px;
|
45
|
+
font-family: 'Loved by the King';
|
46
|
+
font-size: 50px;
|
47
|
+
font-weight: 700;
|
48
|
+
color: white;
|
49
|
+
text-shadow: 3px 3px black;
|
50
|
+
}
|
51
|
+
</style>
|
52
|
+
</head>
|
53
|
+
|
54
|
+
<body>
|
55
|
+
<h1 class="text">Hello {{name}}!</h1>
|
56
|
+
<p class="text">Join us for the {{event}}!</p>
|
57
|
+
</body>
|
58
|
+
|
59
|
+
</html>
|
60
|
+
}
|
61
|
+
|
62
|
+
# create a to address
|
63
|
+
to_address = lob.addresses.create(
|
64
|
+
{
|
65
|
+
"name": "ToAddress",
|
66
|
+
"address_line1": "120 6th Ave",
|
67
|
+
"address_city": "Boston",
|
68
|
+
"address_state": "MA",
|
69
|
+
"address_country": "US",
|
70
|
+
"address_zip": 12345
|
71
|
+
}
|
72
|
+
)
|
73
|
+
|
74
|
+
# create a from address
|
75
|
+
from_address = lob.addresses.create(
|
76
|
+
{
|
77
|
+
"name": "FromAddress",
|
78
|
+
"address_line1": "120 6th Ave",
|
79
|
+
"address_city": "Boston",
|
80
|
+
"address_state": "MA",
|
81
|
+
"address_country": "US",
|
82
|
+
"address_zip": 12345
|
83
|
+
}
|
84
|
+
)
|
85
|
+
|
86
|
+
# send a postcard
|
87
|
+
pp lob.postcards.create(
|
88
|
+
{
|
89
|
+
"description": "Beach Postcard",
|
90
|
+
"to": to_address["id"],
|
91
|
+
"from": from_address["id"],
|
92
|
+
"metadata": { campaign: "Summer 2015 Beach" },
|
93
|
+
"merge_variables": { name: "Albert", event: "Summer 2015 Beach-athon" },
|
94
|
+
# you can replace these template IDs
|
95
|
+
"front": 'tmpl_b846a20859ae11a',
|
96
|
+
"back": 'tmpl_01b0d396a10c268'
|
97
|
+
}
|
98
|
+
)
|
@@ -0,0 +1,38 @@
|
|
1
|
+
$:.unshift File.expand_path("../lib", File.dirname(__FILE__))
|
2
|
+
require 'lob'
|
3
|
+
require 'pp'
|
4
|
+
|
5
|
+
# initialize Lob object
|
6
|
+
lob = Lob::Client.new(api_key: 'YOUR_API_KEY')
|
7
|
+
|
8
|
+
# create a to address
|
9
|
+
to_address = lob.addresses.create(
|
10
|
+
name: "ToAddress",
|
11
|
+
address_line1: "120 6th Ave",
|
12
|
+
address_city: "Boston",
|
13
|
+
address_state: "MA",
|
14
|
+
address_country: "US",
|
15
|
+
address_zip: 12345
|
16
|
+
)
|
17
|
+
|
18
|
+
# create a from address
|
19
|
+
from_address = lob.addresses.create(
|
20
|
+
name: "FromAddress",
|
21
|
+
address_line1: "120 6th Ave",
|
22
|
+
address_city: "Boston",
|
23
|
+
address_state: "MA",
|
24
|
+
address_country: "US",
|
25
|
+
address_zip: 12345
|
26
|
+
)
|
27
|
+
|
28
|
+
|
29
|
+
# send a self mailer
|
30
|
+
pp lob.self_mailers.create(
|
31
|
+
description: "Beach Postcard",
|
32
|
+
to: to_address["id"],
|
33
|
+
from: from_address["id"],
|
34
|
+
metadata: { campaign: "Summer 2021 Beach" },
|
35
|
+
merge_variables: { name: "Albert" },
|
36
|
+
outside: "https://s3-us-west-2.amazonaws.com/public.lob.com/assets/templates/self_mailers/6x18_sfm_outside.pdf",
|
37
|
+
inside: "<h1>Hi {{name}}, please RSVP as soon as possible to reserve your lounge chair.</h1>"
|
38
|
+
)
|