lob 1.9.1 → 2.5.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 +4 -4
- data/.gitignore +0 -2
- data/.travis.yml +3 -6
- data/CHANGELOG.md +46 -0
- data/README.md +125 -596
- data/Rakefile +0 -19
- data/examples/README.md +27 -0
- data/examples/checks.rb +22 -23
- data/examples/csv_postcards/create_postcards.rb +46 -0
- data/examples/csv_postcards/input.csv +7 -0
- data/examples/csv_postcards/postcard_back.html +38 -0
- data/examples/csv_postcards/postcard_front.html +25 -0
- data/examples/jobs.rb +65 -21
- data/examples/letters.rb +73 -0
- data/examples/postcards.rb +64 -12
- data/examples/verify/input.txt +7 -0
- data/examples/verify/verify.rb +38 -0
- data/lib/lob/errors/lob_error.rb +9 -6
- data/lib/lob/v1/address.rb +3 -4
- data/lib/lob/v1/area.rb +1 -1
- data/lib/lob/v1/bank_account.rb +5 -9
- data/lib/lob/v1/check.rb +1 -5
- data/lib/lob/v1/country.rb +1 -1
- data/lib/lob/v1/job.rb +1 -9
- data/lib/lob/v1/letter.rb +29 -0
- data/lib/lob/v1/object.rb +1 -1
- data/lib/lob/v1/postcard.rb +1 -9
- data/lib/lob/v1/resource.rb +4 -24
- data/lib/lob/v1/route.rb +9 -1
- data/lib/lob/v1/setting.rb +1 -1
- data/lib/lob/v1/state.rb +1 -1
- data/lib/lob/version.rb +1 -1
- data/lib/lob.rb +37 -16
- data/lob.gemspec +5 -7
- data/spec/lob/errors/lob_error_spec.rb +4 -2
- data/spec/lob/v1/address_spec.rb +24 -34
- data/spec/lob/v1/area_spec.rb +16 -38
- data/spec/lob/v1/bank_account_spec.rb +25 -79
- data/spec/lob/v1/check_spec.rb +38 -65
- data/spec/lob/v1/country_spec.rb +2 -4
- data/spec/lob/v1/job_spec.rb +116 -162
- data/spec/lob/v1/letter_spec.rb +75 -0
- data/spec/lob/v1/object_spec.rb +32 -50
- data/spec/lob/v1/postcard_spec.rb +66 -90
- data/spec/lob/v1/resource_spec.rb +0 -9
- data/spec/lob/v1/route_spec.rb +28 -6
- data/spec/lob/v1/setting_spec.rb +4 -12
- data/spec/lob/v1/state_spec.rb +2 -4
- data/spec/lob_spec.rb +25 -6
- data/spec/samples/8.5x11.pdf +0 -0
- data/spec/samples/postcardback.pdf +2288 -1
- data/spec/samples/postcardfront.pdf +1550 -0
- data/spec/spec_helper.rb +0 -6
- metadata +58 -62
- data/examples/create_pdf.rb +0 -25
- data/lib/lob/v1/packaging.rb +0 -21
- data/lib/lob/v1/service.rb +0 -21
- data/spec/lob/v1/packaging_spec.rb +0 -16
- data/spec/lob/v1/service_spec.rb +0 -16
data/spec/lob/v1/check_spec.rb
CHANGED
|
@@ -3,20 +3,23 @@ require "spec_helper"
|
|
|
3
3
|
describe Lob::V1::Check do
|
|
4
4
|
|
|
5
5
|
before :each do
|
|
6
|
+
|
|
6
7
|
@sample_address_params = {
|
|
7
8
|
name: "TestAddress",
|
|
8
9
|
email: "test@test.com",
|
|
9
10
|
address_line1: "123 Test Street",
|
|
10
11
|
address_line2: "Unit 199",
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
address_city: "Mountain View",
|
|
13
|
+
address_state: "CA",
|
|
14
|
+
address_country: "US",
|
|
15
|
+
address_zip: 94085
|
|
15
16
|
}
|
|
16
17
|
|
|
17
18
|
@sample_bank_account_params = {
|
|
18
19
|
routing_number: "122100024",
|
|
19
|
-
account_number: "123456789"
|
|
20
|
+
account_number: "123456789",
|
|
21
|
+
account_type: "company",
|
|
22
|
+
signatory: "John Doe"
|
|
20
23
|
}
|
|
21
24
|
end
|
|
22
25
|
|
|
@@ -24,77 +27,47 @@ describe Lob::V1::Check do
|
|
|
24
27
|
|
|
25
28
|
describe "list" do
|
|
26
29
|
it "should list checks" do
|
|
27
|
-
|
|
28
|
-
new_address = subject.addresses.create @sample_address_params
|
|
29
|
-
|
|
30
|
-
new_bank_account = subject.bank_accounts.create(
|
|
31
|
-
routing_number: @sample_bank_account_params[:routing_number],
|
|
32
|
-
bank_address: @sample_address_params,
|
|
33
|
-
account_number: @sample_bank_account_params[:account_number],
|
|
34
|
-
account_address: @sample_address_params,
|
|
35
|
-
signatory: "John Doe"
|
|
36
|
-
)
|
|
37
|
-
|
|
38
|
-
new_check = subject.checks.create(
|
|
39
|
-
bank_account: new_bank_account["id"],
|
|
40
|
-
to: @sample_address_params,
|
|
41
|
-
amount: 2000
|
|
42
|
-
)
|
|
43
|
-
|
|
44
|
-
list_result = subject.checks.list
|
|
45
|
-
assert /#{new_check["id"]}/i =~ list_result.to_s
|
|
46
|
-
end
|
|
30
|
+
assert subject.checks.list["object"] == "list"
|
|
47
31
|
end
|
|
48
32
|
end
|
|
49
33
|
|
|
50
|
-
|
|
51
34
|
describe "create" do
|
|
52
35
|
it "should create a check with bank account id" do
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
amount: "2000"
|
|
68
|
-
)
|
|
69
|
-
|
|
70
|
-
result["amount"].to_s.must_equal("2000.00")
|
|
71
|
-
end
|
|
36
|
+
new_address = subject.addresses.create @sample_address_params
|
|
37
|
+
|
|
38
|
+
new_bank_account = subject.bank_accounts.create(@sample_bank_account_params)
|
|
39
|
+
|
|
40
|
+
subject.bank_accounts.verify(new_bank_account["id"], amounts: [1, 2])
|
|
41
|
+
|
|
42
|
+
result = subject.checks.create(
|
|
43
|
+
bank_account: new_bank_account["id"],
|
|
44
|
+
to: new_address["id"],
|
|
45
|
+
from: new_address["id"],
|
|
46
|
+
amount: "2000.12"
|
|
47
|
+
)
|
|
48
|
+
|
|
49
|
+
result["amount"].to_s.must_equal("2000.12")
|
|
72
50
|
end
|
|
73
51
|
end
|
|
74
52
|
|
|
75
53
|
|
|
76
54
|
describe "find" do
|
|
77
55
|
it "should find a check" do
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
)
|
|
94
|
-
|
|
95
|
-
result = subject.checks.find(new_check["id"])
|
|
96
|
-
result["id"].must_equal(new_check["id"])
|
|
97
|
-
end
|
|
56
|
+
new_address = subject.addresses.create @sample_address_params
|
|
57
|
+
|
|
58
|
+
new_bank_account = subject.bank_accounts.create(@sample_bank_account_params)
|
|
59
|
+
|
|
60
|
+
subject.bank_accounts.verify(new_bank_account["id"], amounts: [1, 2])
|
|
61
|
+
|
|
62
|
+
new_check = subject.checks.create(
|
|
63
|
+
bank_account: new_bank_account["id"],
|
|
64
|
+
to: new_address["id"],
|
|
65
|
+
from: new_address["id"],
|
|
66
|
+
amount: 2000
|
|
67
|
+
)
|
|
68
|
+
|
|
69
|
+
result = subject.checks.find(new_check["id"])
|
|
70
|
+
result["id"].must_equal(new_check["id"])
|
|
98
71
|
end
|
|
99
72
|
end
|
|
100
73
|
|
data/spec/lob/v1/country_spec.rb
CHANGED
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
require "spec_helper"
|
|
2
2
|
|
|
3
3
|
describe Lob::V1::Country do
|
|
4
|
+
|
|
4
5
|
subject { Lob(api_key: ENV["LOB_API_KEY"]) }
|
|
5
6
|
|
|
6
7
|
describe "list" do
|
|
7
8
|
it "should list countries" do
|
|
8
|
-
|
|
9
|
-
result = subject.countries.list
|
|
10
|
-
result.length.must_be :>, 0
|
|
11
|
-
end
|
|
9
|
+
assert subject.countries.list["object"] == "list"
|
|
12
10
|
end
|
|
13
11
|
end
|
|
14
12
|
end
|
data/spec/lob/v1/job_spec.rb
CHANGED
|
@@ -8,199 +8,153 @@ describe Lob::V1::Job do
|
|
|
8
8
|
email: "test@test.com",
|
|
9
9
|
address_line1: "123 Test Street",
|
|
10
10
|
address_line2: "Unit 199",
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
11
|
+
address_city: "Mountain View",
|
|
12
|
+
address_state: "CA",
|
|
13
|
+
address_country: "US",
|
|
14
|
+
address_zip: 94085
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
@sample_job_params = {
|
|
18
|
-
@sample_object_params = {
|
|
17
|
+
@sample_job_params = { description: "TestJob" }
|
|
18
|
+
@sample_object_params = { description: "TestObject" }
|
|
19
19
|
@test_setting_id = 201
|
|
20
20
|
end
|
|
21
21
|
|
|
22
22
|
subject { Lob(api_key: ENV["LOB_API_KEY"]) }
|
|
23
23
|
|
|
24
|
-
|
|
25
24
|
describe "list" do
|
|
26
25
|
it "should list jobs" do
|
|
27
|
-
|
|
28
|
-
new_address = subject.addresses.create @sample_address_params
|
|
29
|
-
settings_list = subject.settings.list
|
|
30
|
-
new_object = subject.objects.create(
|
|
31
|
-
name: @sample_object_params[:name],
|
|
32
|
-
file: "https://s3-us-west-2.amazonaws.com/lob-assets/test.pdf",
|
|
33
|
-
setting: @test_setting_id
|
|
34
|
-
)
|
|
35
|
-
|
|
36
|
-
new_job = subject.jobs.create(
|
|
37
|
-
name: @sample_job_params[:name],
|
|
38
|
-
from: new_address["id"],
|
|
39
|
-
to: new_address["id"],
|
|
40
|
-
objects: new_object["id"]
|
|
41
|
-
)
|
|
42
|
-
|
|
43
|
-
list_result = subject.jobs.list
|
|
44
|
-
assert /#{new_job["name"]}/ =~ list_result.to_s
|
|
45
|
-
end
|
|
26
|
+
assert subject.jobs.list["object"] == "list"
|
|
46
27
|
end
|
|
47
28
|
end
|
|
48
29
|
|
|
49
|
-
|
|
50
30
|
describe "create" do
|
|
51
31
|
it "should create a job with address_id" do
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
result["name"].must_equal(@sample_job_params[:name])
|
|
69
|
-
end
|
|
32
|
+
new_address = subject.addresses.create @sample_address_params
|
|
33
|
+
|
|
34
|
+
settings_list = subject.settings.list
|
|
35
|
+
new_object = subject.objects.create(
|
|
36
|
+
description: @sample_object_params[:description],
|
|
37
|
+
file: "https://lob.com/postcardfront.pdf",
|
|
38
|
+
setting: @test_setting_id
|
|
39
|
+
)
|
|
40
|
+
|
|
41
|
+
result = subject.jobs.create(
|
|
42
|
+
description: @sample_job_params[:description],
|
|
43
|
+
from: new_address["id"],
|
|
44
|
+
to: new_address["id"],
|
|
45
|
+
objects: new_object["id"]
|
|
46
|
+
)
|
|
47
|
+
result["description"].must_equal(@sample_job_params[:description])
|
|
70
48
|
end
|
|
71
49
|
|
|
72
|
-
|
|
73
50
|
it "should be able to create multiple jobs" do
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
result["name"].must_equal(@sample_job_params[:name])
|
|
99
|
-
end
|
|
51
|
+
new_address = subject.addresses.create @sample_address_params
|
|
52
|
+
|
|
53
|
+
settings_list = subject.settings.list
|
|
54
|
+
|
|
55
|
+
new_object_params = {
|
|
56
|
+
description: @sample_object_params[:description],
|
|
57
|
+
file: "https://lob.com/postcardfront.pdf",
|
|
58
|
+
setting: 500
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
another_object_params = {
|
|
62
|
+
description: "Another #{@sample_object_params[:description]}",
|
|
63
|
+
file: "https://lob.com/postcardfront.pdf",
|
|
64
|
+
setting: 500
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
result = subject.jobs.create(
|
|
68
|
+
description: @sample_job_params[:description],
|
|
69
|
+
from: new_address["id"],
|
|
70
|
+
to: new_address["id"],
|
|
71
|
+
objects: [new_object_params, another_object_params]
|
|
72
|
+
)
|
|
73
|
+
|
|
74
|
+
result["description"].must_equal(@sample_job_params[:description])
|
|
100
75
|
end
|
|
101
76
|
|
|
102
|
-
|
|
103
|
-
|
|
104
77
|
it "should be able to create jobs from a mix of remote and local files" do
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
# result = subject.jobs.create(
|
|
128
|
-
# name: @sample_job_params[:name],
|
|
129
|
-
# from: new_address["id"],
|
|
130
|
-
# to: new_address["id"],
|
|
131
|
-
# objects: [new_object_params]
|
|
132
|
-
# )
|
|
133
|
-
|
|
134
|
-
result["name"].must_equal(@sample_job_params[:name])
|
|
135
|
-
end
|
|
78
|
+
new_address = subject.addresses.create @sample_address_params
|
|
79
|
+
|
|
80
|
+
new_object_params = {
|
|
81
|
+
description: @sample_object_params[:description],
|
|
82
|
+
file: File.new(File.expand_path("../../../samples/postcardfront.pdf", __FILE__)),
|
|
83
|
+
setting: 500
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
another_object_params = {
|
|
87
|
+
description: "Another #{@sample_object_params[:description]}",
|
|
88
|
+
file: "https://lob.com/postcardfront.pdf",
|
|
89
|
+
setting: 500
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
result = subject.jobs.create(
|
|
93
|
+
description: @sample_job_params[:description],
|
|
94
|
+
from: new_address["id"],
|
|
95
|
+
to: new_address["id"],
|
|
96
|
+
objects: [new_object_params, another_object_params]
|
|
97
|
+
)
|
|
98
|
+
|
|
99
|
+
result["description"].must_equal(@sample_job_params[:description])
|
|
136
100
|
end
|
|
137
101
|
|
|
138
|
-
|
|
139
|
-
|
|
140
102
|
it "should create a job with address params" do
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
result["name"].must_equal(@sample_job_params[:name])
|
|
156
|
-
end
|
|
103
|
+
settings_list = subject.settings.list
|
|
104
|
+
new_object = subject.objects.create(
|
|
105
|
+
description: @sample_object_params[:description],
|
|
106
|
+
file: "https://lob.com/postcardfront.pdf",
|
|
107
|
+
setting: @test_setting_id
|
|
108
|
+
)
|
|
109
|
+
|
|
110
|
+
result = subject.jobs.create(
|
|
111
|
+
description: @sample_job_params[:description],
|
|
112
|
+
from: @sample_address_params,
|
|
113
|
+
to: @sample_address_params,
|
|
114
|
+
objects: new_object["id"]
|
|
115
|
+
)
|
|
116
|
+
result["description"].must_equal(@sample_job_params[:description])
|
|
157
117
|
end
|
|
158
118
|
|
|
159
|
-
|
|
160
119
|
it "should create a job with object params" do
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
result["name"].must_equal(@sample_job_params[:name])
|
|
177
|
-
end
|
|
120
|
+
new_address = subject.addresses.create @sample_address_params
|
|
121
|
+
settings_list = subject.settings.list
|
|
122
|
+
new_object_params = {
|
|
123
|
+
description: @sample_object_params[:description],
|
|
124
|
+
file: "https://lob.com/postcardfront.pdf",
|
|
125
|
+
setting: @test_setting_id
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
result = subject.jobs.create(
|
|
129
|
+
description: @sample_job_params[:description],
|
|
130
|
+
from: new_address["id"],
|
|
131
|
+
to: new_address["id"],
|
|
132
|
+
objects: new_object_params
|
|
133
|
+
)
|
|
134
|
+
result["description"].must_equal(@sample_job_params[:description])
|
|
178
135
|
end
|
|
179
136
|
end
|
|
180
137
|
|
|
181
|
-
|
|
182
138
|
describe "find" do
|
|
183
139
|
it "should find a job" do
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
result["name"].must_equal(@sample_job_params[:name])
|
|
203
|
-
end
|
|
140
|
+
new_address = subject.addresses.create @sample_address_params
|
|
141
|
+
|
|
142
|
+
settings_list = subject.settings.list
|
|
143
|
+
new_object = subject.objects.create(
|
|
144
|
+
description: @sample_object_params[:description],
|
|
145
|
+
file: "https://lob.com/postcardfront.pdf",
|
|
146
|
+
setting: @test_setting_id
|
|
147
|
+
)
|
|
148
|
+
|
|
149
|
+
new_job = subject.jobs.create(
|
|
150
|
+
description: @sample_job_params[:description],
|
|
151
|
+
from: new_address["id"],
|
|
152
|
+
to: new_address["id"],
|
|
153
|
+
objects: new_object["id"]
|
|
154
|
+
)
|
|
155
|
+
|
|
156
|
+
result = subject.jobs.find(new_job["id"])
|
|
157
|
+
result["description"].must_equal(@sample_job_params[:description])
|
|
204
158
|
end
|
|
205
159
|
end
|
|
206
160
|
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
require "spec_helper"
|
|
2
|
+
|
|
3
|
+
describe Lob::V1::Letter 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
|
+
end
|
|
17
|
+
|
|
18
|
+
subject { Lob(api_key: ENV["LOB_API_KEY"]) }
|
|
19
|
+
|
|
20
|
+
describe "list" do
|
|
21
|
+
it "should list letter" do
|
|
22
|
+
assert subject.letters.list["object"] == "list"
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
describe "create" do
|
|
28
|
+
it "should create a letter with address_id" do
|
|
29
|
+
new_address = subject.addresses.create @sample_address_params
|
|
30
|
+
|
|
31
|
+
new_letter = subject.letters.create(
|
|
32
|
+
description: "TestLetter",
|
|
33
|
+
color: true,
|
|
34
|
+
file: "https://s3-us-west-2.amazonaws.com/lob-assets/letter-goblue.pdf",
|
|
35
|
+
to: new_address["id"],
|
|
36
|
+
from: @sample_address_params
|
|
37
|
+
)
|
|
38
|
+
|
|
39
|
+
new_letter["description"].must_equal("TestLetter")
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
it "should create a letter with a local file" do
|
|
43
|
+
new_address = subject.addresses.create @sample_address_params
|
|
44
|
+
|
|
45
|
+
new_letter = subject.letters.create(
|
|
46
|
+
description: "TestLetter",
|
|
47
|
+
color: true,
|
|
48
|
+
file: File.new(File.expand_path("../../../samples/8.5x11.pdf", __FILE__)),
|
|
49
|
+
to: new_address["id"],
|
|
50
|
+
from: @sample_address_params
|
|
51
|
+
)
|
|
52
|
+
|
|
53
|
+
new_letter["description"].must_equal("TestLetter")
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
describe "find" do
|
|
59
|
+
it "should find a letter" do
|
|
60
|
+
new_address = subject.addresses.create @sample_address_params
|
|
61
|
+
|
|
62
|
+
new_letter = subject.letters.create(
|
|
63
|
+
description: "TestLetter",
|
|
64
|
+
color: true,
|
|
65
|
+
file: "https://s3-us-west-2.amazonaws.com/lob-assets/letter-goblue.pdf",
|
|
66
|
+
to: new_address["id"],
|
|
67
|
+
from: new_address["id"]
|
|
68
|
+
)
|
|
69
|
+
|
|
70
|
+
result = subject.letters.find(new_letter["id"])
|
|
71
|
+
assert /#{new_letter["description"]}/ =~ result.to_s
|
|
72
|
+
end
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
end
|
data/spec/lob/v1/object_spec.rb
CHANGED
|
@@ -4,7 +4,7 @@ describe Lob::V1::Object do
|
|
|
4
4
|
|
|
5
5
|
before :each do
|
|
6
6
|
@sample_params = {
|
|
7
|
-
|
|
7
|
+
description: "TestObject",
|
|
8
8
|
}
|
|
9
9
|
@test_setting_id = 201
|
|
10
10
|
end
|
|
@@ -13,77 +13,59 @@ describe Lob::V1::Object do
|
|
|
13
13
|
|
|
14
14
|
describe "list" do
|
|
15
15
|
it "should list objects" do
|
|
16
|
-
|
|
17
|
-
settings_list = subject.settings.list
|
|
18
|
-
new_object = subject.objects.create(
|
|
19
|
-
name: @sample_params[:name],
|
|
20
|
-
file: "https://s3-us-west-2.amazonaws.com/lob-assets/test.pdf",
|
|
21
|
-
setting: @test_setting_id
|
|
22
|
-
)
|
|
23
|
-
|
|
24
|
-
list_result = subject.objects.list
|
|
25
|
-
assert /#{new_object["name"]}/ =~ list_result.to_s
|
|
26
|
-
end
|
|
16
|
+
assert subject.objects.list["object"] == "list"
|
|
27
17
|
end
|
|
28
18
|
end
|
|
29
19
|
|
|
30
20
|
describe "create" do
|
|
31
21
|
it "should create an object with file url" do
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
)
|
|
22
|
+
settings_list = subject.settings.list
|
|
23
|
+
result = subject.objects.create(
|
|
24
|
+
description: @sample_params[:description],
|
|
25
|
+
file: "https://lob.com/postcardfront.pdf",
|
|
26
|
+
setting: @test_setting_id
|
|
27
|
+
)
|
|
39
28
|
|
|
40
|
-
|
|
41
|
-
end
|
|
29
|
+
result["description"].must_equal(@sample_params[:description])
|
|
42
30
|
end
|
|
43
31
|
|
|
44
32
|
it "should create an object with file" do
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
)
|
|
33
|
+
settings_list = subject.settings.list
|
|
34
|
+
result = subject.objects.create(
|
|
35
|
+
description: @sample_params[:description],
|
|
36
|
+
file: File.new(File.expand_path("../../../samples/postcardfront.pdf", __FILE__), "rb"),
|
|
37
|
+
setting: @test_setting_id
|
|
38
|
+
)
|
|
52
39
|
|
|
53
|
-
|
|
54
|
-
end
|
|
40
|
+
result["description"].must_equal(@sample_params[:description])
|
|
55
41
|
end
|
|
56
42
|
end
|
|
57
43
|
|
|
58
44
|
describe "find" do
|
|
59
45
|
it "should find an object" do
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
)
|
|
46
|
+
settings_list = subject.settings.list
|
|
47
|
+
new_object = subject.objects.create(
|
|
48
|
+
description: @sample_params[:description],
|
|
49
|
+
file: "https://lob.com/postcardfront.pdf",
|
|
50
|
+
setting: @test_setting_id
|
|
51
|
+
)
|
|
67
52
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
end
|
|
53
|
+
find_result = subject.objects.find(new_object["id"])
|
|
54
|
+
find_result["description"].must_equal(@sample_params[:description])
|
|
71
55
|
end
|
|
72
56
|
end
|
|
73
57
|
|
|
74
58
|
describe "destroy" do
|
|
75
59
|
it "should delete an object" do
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
)
|
|
60
|
+
settings_list = subject.settings.list
|
|
61
|
+
new_object = subject.objects.create(
|
|
62
|
+
description: @sample_params[:description],
|
|
63
|
+
file: "https://lob.com/postcardfront.pdf",
|
|
64
|
+
setting: @test_setting_id
|
|
65
|
+
)
|
|
83
66
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
end
|
|
67
|
+
delete_result = subject.objects.destroy(new_object["id"])
|
|
68
|
+
assert_equal(new_object["id"], delete_result["id"])
|
|
87
69
|
end
|
|
88
70
|
end
|
|
89
71
|
|