lob 5.1.2 → 5.2.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 13cf985be48a2293b60d39581618b3ec1d6dd55627060e4276e0219839707dda
4
- data.tar.gz: 0d157d5f90ab10bfae3a58959be1478adcac54606e37dbecaf8c8b8fabf6dacb
3
+ metadata.gz: 58d9c6ae15fcc102d200e7f5658c0ec7ffabe144a5c1c7a5dad4b3d73c7a446c
4
+ data.tar.gz: b52642eddc9ccad70128c13d9c4a2686216117592e8aa65132742d42dbc5d782
5
5
  SHA512:
6
- metadata.gz: 910a721a953d8bf7a714b71e8ab47dfecd7ab294055cd57b1736f2f84aa3d71ed8b54693a9f09112c0b991f6489b23437005dc4ae146a0aff9ecb38cd2121ffc
7
- data.tar.gz: 922c3a7b56174b13a390e7294dd3421ec9eb1305eadbdeccddf007e544ac000e8844b82d5183c5f7c9832dd8c8a4b72b735b0b141f831a95ff0280af81b3bffa
6
+ metadata.gz: 0704b2ada68338190157031692d209082b261a0701208eb9dbdcac0145a4a014d0a86e13e5b6215e2a57f04f4a26dc253b3bd8113fbdea827fb11f48dfe26c57
7
+ data.tar.gz: 503e570a1803fc459ce45ba4fb7fc7dd99fae7c0a848d8946db9cbabda744cff5d01edbee6eed88ab207130e0689b6288c751c1c9be27204b4c59311408bf45d
data/CHANGELOG.md CHANGED
@@ -1,9 +1,11 @@
1
- #### 5.1.2 (2021-02-18)
1
+ ## [**5.2.0**](https://github.com/lob/lob-ruby/releases/tag/v5.2.0) (2021-05-03)
2
+ - [**188**](https://github.com/lob/lob-ruby/pull/188) Adds support for Self Mailers
3
+ ## 5.1.2 (2021-02-18)
2
4
 
3
5
  ##### Chores and Bug Fixes
4
6
 
5
- -[**185**](https://github.com/lob/lob-ruby/pull/185) Bumps rake to 12.3.3, adds Ruby 2.7, update example asset links, other cleanup.
6
- #### 5.1.1 (2020-05-21)
7
+ - [**185**](https://github.com/lob/lob-ruby/pull/185) Bumps rake to 12.3.3, adds Ruby 2.7, update example asset links, other cleanup.
8
+ ## 5.1.1 (2020-05-21)
7
9
 
8
10
  ##### Chores
9
11
 
data/README.md CHANGED
@@ -146,6 +146,13 @@ There are simple scripts to demonstrate how to create all the core Lob objects (
146
146
  - [Retrieve a Postcard](https://lob.com/docs/ruby#postcards_retrieve)
147
147
  - [Cancel a Postcard](https://lob.com/docs/ruby#postcards_delete)
148
148
  - [List all Postcards](https://lob.com/docs/ruby#postcards_list)
149
+ - **Self Mailers API**
150
+ - [Self Mailers](https://lob.com/docs/ruby#self_mailers)
151
+ - [The Self Mailer Object](https://lob.com/docs/ruby#self_mailers_object)
152
+ - [Create a Self Mailer](https://lob.com/docs/ruby#self_mailers_create)
153
+ - [Retrieve a Self Mailer](https://lob.com/docs/ruby#self_mailers_retrieve)
154
+ - [Cancel a Self Mailer](https://lob.com/docs/ruby#self_mailers_delete)
155
+ - [List all Self Mailers](https://lob.com/docs/ruby#self_mailers_list)
149
156
  - **Letters API**
150
157
  - [Letters](https://lob.com/docs/ruby#letters)
151
158
  - [The Letter Object](https://lob.com/docs/ruby#letters_object)
data/examples/README.md CHANGED
@@ -31,3 +31,7 @@ An example showing how to create a letter using Lob's [Letters API](https://lob.
31
31
  ## /postcards.rb
32
32
 
33
33
  An example showing how to create a postcard using Lob's [Postcards API](https://lob.com/services/postcards).
34
+
35
+ ## /self_mailers.rb
36
+
37
+ An example showing how to create a self mailer using Lob's Self Mailers API.
@@ -0,0 +1,37 @@
1
+ $:.unshift File.expand_path("../lib", File.dirname(__FILE__))
2
+ require 'lob'
3
+
4
+ # initialize Lob object
5
+ lob = Lob::Client.new(api_key: 'YOUR_API_KEY_HERE')
6
+
7
+ # create a to address
8
+ to_address = lob.addresses.create(
9
+ name: "ToAddress",
10
+ address_line1: "120 6th Ave",
11
+ address_city: "Boston",
12
+ address_state: "MA",
13
+ address_country: "US",
14
+ address_zip: 12345
15
+ )
16
+
17
+ # create a from address
18
+ from_address = lob.addresses.create(
19
+ name: "FromAddress",
20
+ address_line1: "120 6th Ave",
21
+ address_city: "Boston",
22
+ address_state: "MA",
23
+ address_country: "US",
24
+ address_zip: 12345
25
+ )
26
+
27
+
28
+ # send a self mailer
29
+ puts lob.self_mailers.create(
30
+ description: "Beach Postcard",
31
+ to: to_address["id"],
32
+ from: from_address["id"],
33
+ metadata: { campaign: "Summer 2021 Beach" },
34
+ merge_variables: { name: "Albert" },
35
+ outside: "https://s3-us-west-2.amazonaws.com/public.lob.com/assets/templates/self_mailers/6x18_sfm_outside.pdf",
36
+ inside: "<h1>Hi {{name}}, please RSVP as soon as possible to reserve your lounge chair.</h1>"
37
+ )
data/lib/lob/client.rb CHANGED
@@ -6,6 +6,7 @@ require "lob/resources/groups_member"
6
6
  require "lob/resources/intl_verifications"
7
7
  require "lob/resources/letter"
8
8
  require "lob/resources/postcard"
9
+ require "lob/resources/self_mailer"
9
10
  require "lob/resources/us_autocompletions"
10
11
  require "lob/resources/us_verifications"
11
12
  require "lob/resources/us_zip_lookups"
@@ -55,6 +56,10 @@ module Lob
55
56
  Lob::Resources::Postcard.new(config)
56
57
  end
57
58
 
59
+ def self_mailers
60
+ Lob::Resources::SelfMailer.new(config)
61
+ end
62
+
58
63
  def us_autocompletions
59
64
  Lob::Resources::USAutocompletions.new(config)
60
65
  end
@@ -0,0 +1,14 @@
1
+ require "lob/resources/resource_base"
2
+
3
+ module Lob
4
+ module Resources
5
+ class SelfMailer < Lob::Resources::ResourceBase
6
+
7
+ def initialize(config)
8
+ super(config)
9
+ @endpoint = "self_mailers"
10
+ end
11
+
12
+ end
13
+ end
14
+ end
data/lib/lob/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Lob
2
- VERSION = "5.1.2"
2
+ VERSION = "5.2.0"
3
3
  end
@@ -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
Binary file
Binary file
Binary file
Binary file
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lob
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.1.2
4
+ version: 5.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lob
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-02-18 00:00:00.000000000 Z
11
+ date: 2021-05-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rest-client
@@ -130,6 +130,7 @@ files:
130
130
  - examples/csv_verify/verify.rb
131
131
  - examples/letters.rb
132
132
  - examples/postcards.rb
133
+ - examples/self_mailers.rb
133
134
  - lib/lob.rb
134
135
  - lib/lob/client.rb
135
136
  - lib/lob/errors/invalid_request_error.rb
@@ -143,6 +144,7 @@ files:
143
144
  - lib/lob/resources/letter.rb
144
145
  - lib/lob/resources/postcard.rb
145
146
  - lib/lob/resources/resource_base.rb
147
+ - lib/lob/resources/self_mailer.rb
146
148
  - lib/lob/resources/us_autocompletions.rb
147
149
  - lib/lob/resources/us_verifications.rb
148
150
  - lib/lob/resources/us_zip_lookups.rb
@@ -158,6 +160,7 @@ files:
158
160
  - spec/lob/resources/member_spec.rb
159
161
  - spec/lob/resources/postcard_spec.rb
160
162
  - spec/lob/resources/resource_base_spec.rb
163
+ - spec/lob/resources/self_mailer_spec.rb
161
164
  - spec/lob/resources/us_autocompletions_spec.rb
162
165
  - spec/lob/resources/us_verifications_spec.rb
163
166
  - spec/lob/resources/us_zip_lookups_spec.rb
@@ -165,6 +168,10 @@ files:
165
168
  - spec/samples/8.5x11.pdf
166
169
  - spec/samples/postcardback.pdf
167
170
  - spec/samples/postcardfront.pdf
171
+ - spec/samples/sfm-12x9-inside.pdf
172
+ - spec/samples/sfm-12x9-outside.pdf
173
+ - spec/samples/sfm-6x18-inside.pdf
174
+ - spec/samples/sfm-6x18-outside.pdf
168
175
  - spec/spec_helper.rb
169
176
  homepage: https://github.com/lob/lob-ruby
170
177
  licenses:
@@ -200,6 +207,7 @@ test_files:
200
207
  - spec/lob/resources/member_spec.rb
201
208
  - spec/lob/resources/postcard_spec.rb
202
209
  - spec/lob/resources/resource_base_spec.rb
210
+ - spec/lob/resources/self_mailer_spec.rb
203
211
  - spec/lob/resources/us_autocompletions_spec.rb
204
212
  - spec/lob/resources/us_verifications_spec.rb
205
213
  - spec/lob/resources/us_zip_lookups_spec.rb
@@ -207,4 +215,8 @@ test_files:
207
215
  - spec/samples/8.5x11.pdf
208
216
  - spec/samples/postcardback.pdf
209
217
  - spec/samples/postcardfront.pdf
218
+ - spec/samples/sfm-12x9-inside.pdf
219
+ - spec/samples/sfm-12x9-outside.pdf
220
+ - spec/samples/sfm-6x18-inside.pdf
221
+ - spec/samples/sfm-6x18-outside.pdf
210
222
  - spec/spec_helper.rb