lob 1.5 → 1.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +276 -180
- data/examples/checks.rb +38 -6
- data/examples/jobs.rb +28 -27
- data/examples/postcards.rb +6 -28
- data/lib/lob.rb +12 -3
- data/lib/lob/v1/resource.rb +14 -11
- data/lib/lob/v1/state.rb +21 -0
- data/lob.gemspec +1 -1
- data/spec/lob/v1/country_spec.rb +0 -2
- data/spec/lob/v1/state_spec.rb +14 -0
- metadata +5 -4
- data/examples/addresses.rb +0 -16
- data/examples/verification.rb +0 -14
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1b67da6c7e2938a86f2c5884a070c81a366b410d
|
4
|
+
data.tar.gz: 1166c4df4106f04b383b56514189745646b17e2f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e70dba9281e47906d648e12b0367ef3687d2d99f4bd764e714711f7ea8c1f59b99c755d9e75068a00891803e9c7c28468a1e71707d45e86311ca7ee27fd91443
|
7
|
+
data.tar.gz: a05e6868b870375aad6d889063b0fd13a97b36e8d05451190023f162bed5c717c79b31f33f92179c224459638aa30b5ee8eabd420fe9d8141236e6f4e0b2cb62
|
data/README.md
CHANGED
@@ -1,11 +1,22 @@
|
|
1
1
|
# lob-ruby
|
2
2
|
|
3
|
-
[![Build Status](https://travis-ci.org/lob/lob-ruby.svg?branch=master)](https://travis-ci.org/lob/lob-ruby) [![Gem Version](https://badge.fury.io/rb/lob.svg)](http://badge.fury.io/rb/lob) [![Dependency Status](https://gemnasium.com/lob/lob-ruby.svg)](https://gemnasium.com/lob/lob-ruby) [![Coverage Status](https://img.shields.io/coveralls/lob/lob-ruby.svg)](https://coveralls.io/r/lob/lob-ruby?branch=master) [![Downloads](http://ruby-gem-downloads-badge.herokuapp.com/lob?color=green)](https://rubygems.org/gems/lob)
|
3
|
+
[![Build Status](https://travis-ci.org/lob/lob-ruby.svg?branch=master)](https://travis-ci.org/lob/lob-ruby) [![Gem Version](https://badge.fury.io/rb/lob.svg)](http://badge.fury.io/rb/lob) [![Dependency Status](https://gemnasium.com/lob/lob-ruby.svg)](https://gemnasium.com/lob/lob-ruby) [![Coverage Status](https://img.shields.io/coveralls/lob/lob-ruby.svg)](https://coveralls.io/r/lob/lob-ruby?branch=master) [![Downloads](http://ruby-gem-downloads-badge.herokuapp.com/lob?color=green&type=total)](https://rubygems.org/gems/lob)
|
4
4
|
|
5
5
|
Ruby wrapper for the [Lob.com](http://lob.com) API. This gem gives you an ActiveRecord-style syntax to use the Lob.com API.
|
6
6
|
|
7
7
|
Supports Ruby 1.9.3 and greater.
|
8
8
|
|
9
|
+
## Table of Contents
|
10
|
+
|
11
|
+
- [Installation](#installation)
|
12
|
+
- [Usage](#usage)
|
13
|
+
- [Supported Image Types](#supported-image-types)
|
14
|
+
- [Initialization and Configuration](#initialization-and-configuration)
|
15
|
+
- [API Reference](#api-reference)
|
16
|
+
- [Developing](#developing)
|
17
|
+
- [Testing](#testing)
|
18
|
+
- [Contributing](#contributing)
|
19
|
+
|
9
20
|
## Installation
|
10
21
|
|
11
22
|
Add this line to your application's `Gemfile`:
|
@@ -16,14 +27,14 @@ And then execute:
|
|
16
27
|
|
17
28
|
$ bundle
|
18
29
|
|
19
|
-
Or install it yourself
|
30
|
+
Or manually install it yourself:
|
20
31
|
|
21
32
|
$ gem install lob
|
22
33
|
|
23
34
|
## Usage
|
24
35
|
|
25
36
|
The library uses an ActiveRecord-style interface. You'll feel right at home.
|
26
|
-
You'll need a Lob.com API key. It's free and you can get yours [here](https://
|
37
|
+
You'll need a Lob.com API key. It's free and you can get yours [here](https://dashboard.lob.com/account).
|
27
38
|
|
28
39
|
For optional parameters and other details, refer the docs here - <https://lob.com/docs>
|
29
40
|
|
@@ -33,8 +44,8 @@ When using zip codes with zero-prefixes, always quote them. For example when spe
|
|
33
44
|
|
34
45
|
The Ruby interpreter assumes it's not of base-10 and tries to convert it to base-10 number. So that might result in an entirely different zip-code than intended.
|
35
46
|
|
36
|
-
Supported Image Types
|
37
|
-
|
47
|
+
## Supported Image Types
|
48
|
+
|
38
49
|
The lob.com API supports the following image types:
|
39
50
|
|
40
51
|
- PDF
|
@@ -43,13 +54,11 @@ The lob.com API supports the following image types:
|
|
43
54
|
|
44
55
|
For more information on prepping the images please see the [Lob documentation](https://lob.com/docs#prepping)
|
45
56
|
|
46
|
-
Creating a PDF
|
47
|
-
-------
|
57
|
+
#### Creating a PDF
|
48
58
|
|
49
59
|
If you need to generate your own PDF programmatically we recommend using [prawn](https://github.com/prawnpdf/prawn). There is an example provided in the examples folder [here](examples/create_pdf.rb)
|
50
60
|
|
51
|
-
Initialization and
|
52
|
-
------
|
61
|
+
## Initialization and Configuration
|
53
62
|
|
54
63
|
```ruby
|
55
64
|
# To initialize a Lob object
|
@@ -71,87 +80,63 @@ Lob.configure do |config|
|
|
71
80
|
end
|
72
81
|
```
|
73
82
|
|
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
|
-
|
99
|
-
|
100
|
-
|
101
|
-
)
|
102
|
-
|
103
|
-
#
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
)
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
#
|
120
|
-
|
121
|
-
|
122
|
-
#
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
```
|
132
|
-
|
133
|
-
#### Deletes a specific address
|
134
|
-
|
135
|
-
```ruby
|
136
|
-
# deletes the address with the corresponding ID
|
137
|
-
@lob.addresses.destroy("some-address-id")
|
138
|
-
```
|
139
|
-
|
140
|
-
### Address verification
|
141
|
-
|
142
|
-
```ruby
|
143
|
-
# verifies and returns an address with more details
|
144
|
-
@lob.addresses.verify(
|
145
|
-
address_line1: "220 WILLIAM T MORRISSEY BLVD",
|
146
|
-
city: "Boston",
|
147
|
-
state: "MA",
|
148
|
-
zip: "02125"
|
149
|
-
)
|
150
|
-
```
|
151
|
-
|
152
|
-
### Jobs
|
153
|
-
|
154
|
-
#### Create jobs
|
83
|
+
## API Reference
|
84
|
+
|
85
|
+
- [Simple Print Service](#simple-print-service)
|
86
|
+
- [lob.jobs](#lobjobs)
|
87
|
+
- [lob.jobs.create](#lobjobscreate)
|
88
|
+
- [lob.jobs.list](#lobjobslist)
|
89
|
+
- [lob.jobs.find](#lobjobsfind)
|
90
|
+
- [lob.addresses](#lobaddresses)
|
91
|
+
- [lob.addresses.create](#lobaddressescreate)
|
92
|
+
- [lob.addresses.list](#lobaddresseslist)
|
93
|
+
- [lob.addresses.find](#lobaddressesfind)
|
94
|
+
- [lob.addresses.destroy](#lobaddressesdestroy)
|
95
|
+
- [lob.addresses.verify](#lobaddressesverify)
|
96
|
+
- [lob.objects](#lobobjects)
|
97
|
+
- [lob.objects.create](#lobobjectscreate)
|
98
|
+
- [lob.objects.list](#lobobjectslist)
|
99
|
+
- [lob.objects.find](#lobobjectsfind)
|
100
|
+
- [lob.objects.destroy](#lobobjectsdestroy)
|
101
|
+
- [lob.settings](#lobsettings)
|
102
|
+
- [lob.settings.list](#lobsettingslist)
|
103
|
+
- [lob.settings.find](#lobsettingsfind)
|
104
|
+
- [lob.packagings](#lobpackagings)
|
105
|
+
- [lob.packagings.list](#lobpackagingslist)
|
106
|
+
- [lob.services](#lobservices)
|
107
|
+
- [lob.services.list](#lobserviceslist)
|
108
|
+
- [Simple Postcard Service](#simple-postcard-service)
|
109
|
+
- [lob.postcards](#lobpostcards)
|
110
|
+
- [lob.postcards.create](#lobpostcardscreate)
|
111
|
+
- [lob.postcards.list](#lobpostcardslist)
|
112
|
+
- [lob.postcards.find](#lobpostcardsfind)
|
113
|
+
- [Simple Check Service](#simple-check-service)
|
114
|
+
- [lob.checks](#lobchecks)
|
115
|
+
- [lob.checks.create](#lobcheckscreate)
|
116
|
+
- [lob.checks.list](#lobcheckslist)
|
117
|
+
- [lob.checks.find](#lobchecksfind)
|
118
|
+
- [lob.bank_accounts](#lobbank_accounts)
|
119
|
+
- [lob.bank_accounts.create](#lobbank_accountscreate)
|
120
|
+
- [lob.bank_accounts.list](#lobbank_accountslist)
|
121
|
+
- [lob.bank_accounts.find](#lobbank_accountsfind)
|
122
|
+
- [Simple Area Mail](#simple-area-mail)
|
123
|
+
- [lob.areas](#lobareas)
|
124
|
+
- [lob.areas.create](#lobareascreate)
|
125
|
+
- [lob.areas.list](#lobareaslist)
|
126
|
+
- [lob.areas.find](#lobareasfind)
|
127
|
+
- [lob.routes](#lobroutes)
|
128
|
+
- [lob.routes.find](#lobroutesfind)
|
129
|
+
- [Resources](#lobresources)
|
130
|
+
- [lob.countries](#lobcountries)
|
131
|
+
- [lob.countries.list](#lobcountrieslist)
|
132
|
+
- [lob.states](#lobstates)
|
133
|
+
- [lob.states.list](#lobstateslist)
|
134
|
+
|
135
|
+
## Simple Print Service
|
136
|
+
|
137
|
+
### lob.jobs
|
138
|
+
|
139
|
+
#### lob.jobs.create
|
155
140
|
|
156
141
|
```ruby
|
157
142
|
|
@@ -181,7 +166,7 @@ end
|
|
181
166
|
},
|
182
167
|
objects: {
|
183
168
|
name: "Local File Object",
|
184
|
-
file:
|
169
|
+
file: File.new("/path/to/file.pdf"),
|
185
170
|
setting_id: 100
|
186
171
|
})
|
187
172
|
|
@@ -244,7 +229,7 @@ end
|
|
244
229
|
|
245
230
|
```
|
246
231
|
|
247
|
-
####
|
232
|
+
#### lob.jobs.list
|
248
233
|
|
249
234
|
```ruby
|
250
235
|
# returns an array of jobs
|
@@ -254,16 +239,70 @@ end
|
|
254
239
|
@lob.jobs.list(count: 10, offset: 3)
|
255
240
|
```
|
256
241
|
|
257
|
-
####
|
242
|
+
#### lob.jobs.find
|
258
243
|
|
259
244
|
```ruby
|
260
245
|
# returns the job with the corresponding ID
|
261
246
|
@lob.jobs.find("some-job-id")
|
262
247
|
```
|
263
248
|
|
264
|
-
###
|
249
|
+
### lob.addresses
|
250
|
+
|
251
|
+
#### lob.addresses.create
|
252
|
+
|
253
|
+
```ruby
|
254
|
+
# name, address, city, state, country and zip are required parameters
|
255
|
+
@lob.addresses.create(
|
256
|
+
name: "John Doe",
|
257
|
+
email: "test@test.com", # optional
|
258
|
+
address_line1: "104, Printing Boulevard",
|
259
|
+
address_line2: "Sunset Town", # optional
|
260
|
+
city: "Boston",
|
261
|
+
state: "MA",
|
262
|
+
country: "US",
|
263
|
+
zip: 12345
|
264
|
+
)
|
265
|
+
```
|
266
|
+
|
267
|
+
#### lob.addresses.list
|
268
|
+
|
269
|
+
```ruby
|
270
|
+
# returns an array of addresses
|
271
|
+
@lob.addresses.list
|
272
|
+
|
273
|
+
#you can also pass count and offset
|
274
|
+
@lob.addresses.list(count: 10, offset: 3)
|
275
|
+
```
|
276
|
+
|
277
|
+
#### lob.addresses.find
|
278
|
+
|
279
|
+
```ruby
|
280
|
+
# returns the address with the corresponding ID
|
281
|
+
@lob.addresses.find("some-address-id")
|
282
|
+
```
|
265
283
|
|
266
|
-
####
|
284
|
+
#### lob.addresses.destroy
|
285
|
+
|
286
|
+
```ruby
|
287
|
+
# deletes the address with the corresponding ID
|
288
|
+
@lob.addresses.destroy("some-address-id")
|
289
|
+
```
|
290
|
+
|
291
|
+
#### lob.addresses.verify
|
292
|
+
|
293
|
+
```ruby
|
294
|
+
# verifies and returns an address with more details
|
295
|
+
@lob.addresses.verify(
|
296
|
+
address_line1: "220 WILLIAM T MORRISSEY BLVD",
|
297
|
+
city: "Boston",
|
298
|
+
state: "MA",
|
299
|
+
zip: "02125"
|
300
|
+
)
|
301
|
+
```
|
302
|
+
|
303
|
+
### lob.objects
|
304
|
+
|
305
|
+
#### lob.objects.create
|
267
306
|
|
268
307
|
```ruby
|
269
308
|
# You can create an onject by passing the name, file url and setting ID, quantity is defaulted to 1
|
@@ -283,7 +322,7 @@ end
|
|
283
322
|
)
|
284
323
|
```
|
285
324
|
|
286
|
-
####
|
325
|
+
#### lob.objects.list
|
287
326
|
|
288
327
|
```ruby
|
289
328
|
# returns an array of objects
|
@@ -293,32 +332,57 @@ end
|
|
293
332
|
@lob.objects.list(count: 10, offset: 3)
|
294
333
|
```
|
295
334
|
|
296
|
-
####
|
335
|
+
#### lob.objects.find
|
297
336
|
|
298
337
|
```ruby
|
299
338
|
# returns the object with the corresponding ID
|
300
339
|
@lob.objects.find("some-object-id")
|
301
340
|
```
|
302
341
|
|
303
|
-
####
|
342
|
+
#### lob.objects.destroy
|
304
343
|
|
305
344
|
```ruby
|
306
345
|
# deletes the object with the corresponding ID
|
307
346
|
@lob.objects.destroy("some-object-id")
|
308
347
|
```
|
309
348
|
|
310
|
-
###
|
349
|
+
### lob.settings
|
350
|
+
|
351
|
+
#### lob.settings.list
|
352
|
+
```ruby
|
353
|
+
# returns an array of settings
|
354
|
+
@lob.settings.list
|
355
|
+
```
|
356
|
+
|
357
|
+
#### lob.settings.find
|
358
|
+
```ruby
|
359
|
+
# returns a setting object
|
360
|
+
@lob.settings.find("setting_id")
|
361
|
+
```
|
311
362
|
|
312
|
-
|
363
|
+
### lob.packagings
|
364
|
+
|
365
|
+
#### lob.packagings.list
|
313
366
|
|
314
367
|
```ruby
|
315
368
|
# returns a list of packagings
|
316
369
|
@lob.packagings.list
|
317
370
|
```
|
318
371
|
|
319
|
-
###
|
372
|
+
### lob.services
|
320
373
|
|
321
|
-
####
|
374
|
+
#### lob.services.list
|
375
|
+
|
376
|
+
```ruby
|
377
|
+
# returns a list of services
|
378
|
+
@lob.services.list
|
379
|
+
```
|
380
|
+
|
381
|
+
## Simple Postcard Service
|
382
|
+
|
383
|
+
### lob.postcards
|
384
|
+
|
385
|
+
#### lob.postcards.create
|
322
386
|
|
323
387
|
You'll have to specify either the `message` option or the `back` option.
|
324
388
|
|
@@ -381,7 +445,7 @@ You'll have to specify either the `message` option or the `back` option.
|
|
381
445
|
)
|
382
446
|
```
|
383
447
|
|
384
|
-
####
|
448
|
+
#### lob.postcards.list
|
385
449
|
|
386
450
|
```ruby
|
387
451
|
@lob.postcards.list
|
@@ -390,21 +454,111 @@ You'll have to specify either the `message` option or the `back` option.
|
|
390
454
|
@lob.postcards.list(count: 10, offset: 3)
|
391
455
|
```
|
392
456
|
|
393
|
-
####
|
457
|
+
#### lob.postcards.find
|
394
458
|
|
395
459
|
```ruby
|
396
460
|
@lob.postcards.find("post-card-id")
|
397
461
|
```
|
398
462
|
|
399
|
-
|
463
|
+
## Simple Check Service
|
400
464
|
|
401
|
-
|
465
|
+
### lob.checks
|
466
|
+
|
467
|
+
#### lob.checks.create
|
468
|
+
|
469
|
+
```ruby
|
470
|
+
# For the "to" address, you can pass params
|
471
|
+
# Transfer $5000 to a bank account.
|
472
|
+
@lob.checks.create(
|
473
|
+
bank_account: "bank-account-id",
|
474
|
+
to: {
|
475
|
+
name: "FromAddress",
|
476
|
+
address_line1: "120, 6th Ave",
|
477
|
+
city: "Boston",
|
478
|
+
state: "MA",
|
479
|
+
country: "US",
|
480
|
+
zip: 12345
|
481
|
+
},
|
482
|
+
amount: 5000
|
483
|
+
)
|
484
|
+
|
485
|
+
# or an address ID
|
486
|
+
@lob.checks.create(
|
487
|
+
bank_account: "bank-account-id",
|
488
|
+
to: "to-address-ID",
|
489
|
+
amount: 5000
|
490
|
+
)
|
491
|
+
|
492
|
+
# You can also specify an optional 4th argument, with other options.
|
493
|
+
```
|
494
|
+
|
495
|
+
#### lob.checks.list
|
496
|
+
|
497
|
+
```ruby
|
498
|
+
@lob.checks.list
|
499
|
+
```
|
500
|
+
|
501
|
+
#### lob.checks.find
|
502
|
+
|
503
|
+
```ruby
|
504
|
+
@lob.checks.find("check-id")
|
505
|
+
```
|
506
|
+
|
507
|
+
### lob.bank_accounts
|
508
|
+
|
509
|
+
#### lob.bank_accounts.create
|
510
|
+
|
511
|
+
```ruby
|
512
|
+
bank_address =
|
513
|
+
|
514
|
+
account_address =
|
515
|
+
|
516
|
+
# Pass address params or address IDs
|
517
|
+
# The 5th argument is the options argument and is optional
|
518
|
+
@lob.bank_accounts.create(
|
519
|
+
routing_number: "routing_number",
|
520
|
+
account_number: "account_number",
|
521
|
+
bank_address: {
|
522
|
+
name: "ToAddress",
|
523
|
+
address_line1: "120 6th Ave",
|
524
|
+
city: "Boston",
|
525
|
+
country: "US",
|
526
|
+
zip: 12345
|
527
|
+
},
|
528
|
+
account_address: {
|
529
|
+
name: "ToAddress",
|
530
|
+
address_line1: "120 6th Ave",
|
531
|
+
city: "Boston",
|
532
|
+
country: "US",
|
533
|
+
zip: 12345
|
534
|
+
}
|
535
|
+
)
|
536
|
+
```
|
537
|
+
|
538
|
+
#### lob.bank_accounts.list
|
539
|
+
|
540
|
+
```ruby
|
541
|
+
# returns a list of accounts
|
542
|
+
@lob.bank_accounts.list
|
543
|
+
```
|
544
|
+
|
545
|
+
#### lob.bank_accounts.find
|
546
|
+
|
547
|
+
```ruby
|
548
|
+
@lob.bank_accounts.find("bank-account-id")
|
549
|
+
```
|
550
|
+
|
551
|
+
## Simple Area Mail
|
552
|
+
|
553
|
+
### lob.areas
|
554
|
+
|
555
|
+
#### lob.areas.create
|
402
556
|
|
403
557
|
You'll have to specify front, back, and either zip_codes or routes
|
404
558
|
|
405
559
|
```ruby
|
406
560
|
# create an area request with routes
|
407
|
-
@lob.
|
561
|
+
@lob.areas.create(
|
408
562
|
name: "My Area",
|
409
563
|
front: "https://www.lob.com/areafront.pdf",
|
410
564
|
back: "https://www.lob.com/areaback.pdf",
|
@@ -414,7 +568,7 @@ You'll have to specify front, back, and either zip_codes or routes
|
|
414
568
|
)
|
415
569
|
|
416
570
|
# create an area request with zip_codes
|
417
|
-
@lob.
|
571
|
+
@lob.areas.create(
|
418
572
|
name: "My Area",
|
419
573
|
front: "https://www.lob.com/areafront.pdf",
|
420
574
|
back: "https://www.lob.com/areaback.pdf",
|
@@ -426,7 +580,7 @@ You'll have to specify front, back, and either zip_codes or routes
|
|
426
580
|
|
427
581
|
zip_codes and routes can be a string or an array of strings
|
428
582
|
|
429
|
-
####
|
583
|
+
#### lob.areas.list
|
430
584
|
```ruby
|
431
585
|
@lob.areas.list
|
432
586
|
|
@@ -434,17 +588,16 @@ zip_codes and routes can be a string or an array of strings
|
|
434
588
|
@lob.areas.list(count: 10, offset: 3)
|
435
589
|
```
|
436
590
|
|
437
|
-
|
438
|
-
#### Find an area
|
591
|
+
#### lob.areas.find
|
439
592
|
```ruby
|
440
593
|
@lob.areas.find("area_id")
|
441
594
|
```
|
442
595
|
|
443
|
-
###
|
596
|
+
### lob.routes
|
444
597
|
|
445
598
|
You'll have to specify zip_codes
|
446
599
|
|
447
|
-
####
|
600
|
+
#### lob.routes.find
|
448
601
|
|
449
602
|
```ruby
|
450
603
|
@lob.routes.find(
|
@@ -454,81 +607,24 @@ You'll have to specify zip_codes
|
|
454
607
|
|
455
608
|
zip_codes can be a string or an array of strings
|
456
609
|
|
457
|
-
|
458
|
-
|
459
|
-
#### List services
|
460
|
-
|
461
|
-
```ruby
|
462
|
-
# returns a list of services
|
463
|
-
@lob.services.list
|
464
|
-
```
|
465
|
-
|
466
|
-
### Bank accounts
|
467
|
-
|
468
|
-
#### List bank accounts
|
469
|
-
|
470
|
-
```ruby
|
471
|
-
# returns a list of accounts
|
472
|
-
@lob.bank_accounts.list
|
473
|
-
```
|
474
|
-
|
475
|
-
#### Add a bank account
|
476
|
-
|
477
|
-
```ruby
|
478
|
-
bank_address = {name: "ToAddress", address_line1: "120, 6th Ave", city: "Boston", country: "US", zip: 12345}
|
479
|
-
account_address = {name: "ToAddress", address_line1: "120, 6th Ave", city: "Boston", country: "US", zip: 12345}
|
480
|
-
|
481
|
-
# Pass address params or address IDs
|
482
|
-
# The 5th argument is the options argument and is optional
|
483
|
-
@lob.bank_accounts.create(
|
484
|
-
routing_number: "routing_number",
|
485
|
-
bank_address: bank_address,
|
486
|
-
account_number: "account_number",
|
487
|
-
account_address: account_address
|
488
|
-
)
|
489
|
-
```
|
490
|
-
|
491
|
-
#### Find a bank account
|
492
|
-
|
493
|
-
```ruby
|
494
|
-
@lob.bank_accounts.find("bank-account-id")
|
495
|
-
```
|
496
|
-
|
497
|
-
### Checks
|
498
|
-
|
499
|
-
#### Create a check
|
500
|
-
|
501
|
-
```ruby
|
502
|
-
# Transfer $5000 to a bank account.
|
503
|
-
@lob.checks.create(
|
504
|
-
bank_account: "bank-account-id",
|
505
|
-
to: "to-address-ID",
|
506
|
-
amount: 5000
|
507
|
-
)
|
508
|
-
|
509
|
-
# For the "to" address, you can pass params or an address ID
|
510
|
-
# You can also specify an optional 4th argument, with other options.
|
511
|
-
```
|
512
|
-
|
513
|
-
#### List checks
|
610
|
+
## Resources
|
514
611
|
|
515
|
-
|
516
|
-
@lob.checks.list
|
517
|
-
```
|
612
|
+
### lob.countries
|
518
613
|
|
519
|
-
####
|
614
|
+
#### lob.countries.list
|
520
615
|
|
521
616
|
```ruby
|
522
|
-
|
617
|
+
# returns a list of countries
|
618
|
+
@lob.countries.list
|
523
619
|
```
|
524
620
|
|
525
|
-
###
|
621
|
+
### lob.states
|
526
622
|
|
527
|
-
####
|
623
|
+
#### lob.states.list
|
528
624
|
|
529
625
|
```ruby
|
530
|
-
# returns a list of
|
531
|
-
@lob.
|
626
|
+
# returns a list of states
|
627
|
+
@lob.states.list
|
532
628
|
```
|
533
629
|
|
534
630
|
## Developing
|
@@ -541,7 +637,7 @@ Make sure you have Ruby 2.0 installed. Copy and paste the following commands in
|
|
541
637
|
|
542
638
|
You are powered up and ready to roll ~!
|
543
639
|
|
544
|
-
##
|
640
|
+
## Testing
|
545
641
|
|
546
642
|
To run the tests, download the required sample files by running the following command:
|
547
643
|
|
data/examples/checks.rb
CHANGED
@@ -5,13 +5,45 @@ require 'lob'
|
|
5
5
|
Lob.api_key = 'test_0dc8d51e0acffcb1880e0f19c79b2f5b0cc'
|
6
6
|
@lob = Lob.load
|
7
7
|
|
8
|
+
# create an address
|
9
|
+
to_address = @lob.addresses.create(
|
10
|
+
name: "John Doe",
|
11
|
+
address_line1: "104 Printing Boulevard",
|
12
|
+
city: "Boston",
|
13
|
+
state: "MA",
|
14
|
+
country: "US",
|
15
|
+
zip: 12345
|
16
|
+
)
|
17
|
+
|
18
|
+
# create a bank account
|
19
|
+
bank_account = @lob.bank_accounts.create(
|
20
|
+
routing_number: "322271627",
|
21
|
+
account_number: "123456789",
|
22
|
+
bank_address: {
|
23
|
+
name: "Bank Address",
|
24
|
+
address_line1: "120 6th Ave",
|
25
|
+
city: "Boston",
|
26
|
+
state: "MA",
|
27
|
+
country: "US",
|
28
|
+
zip: 12345
|
29
|
+
},
|
30
|
+
account_address: {
|
31
|
+
name: "Account Address",
|
32
|
+
address_line1: "120 6th Ave",
|
33
|
+
city: "Boston",
|
34
|
+
state: "MA",
|
35
|
+
country: "US",
|
36
|
+
zip: 12345
|
37
|
+
}
|
38
|
+
)
|
39
|
+
|
8
40
|
# send a $1000 check using an already created bank and address
|
9
41
|
puts @lob.checks.create(
|
10
|
-
name:
|
11
|
-
check_number:
|
12
|
-
bank_account:
|
13
|
-
to:
|
42
|
+
name: "Test Check",
|
43
|
+
check_number: "10000",
|
44
|
+
bank_account: bank_account["id"],
|
45
|
+
to: to_address["id"],
|
14
46
|
amount: 100,
|
15
|
-
memo:
|
16
|
-
message:
|
47
|
+
memo: "This is my first Check",
|
48
|
+
message: "This check is for laundry"
|
17
49
|
)
|
data/examples/jobs.rb
CHANGED
@@ -10,37 +10,38 @@ settings = @lob.settings.list
|
|
10
10
|
setting_index = settings.find_index { |setting| setting["type"] === "documents" }
|
11
11
|
setting_id = settings[setting_index]["id"]
|
12
12
|
|
13
|
-
# create a file object to user
|
13
|
+
# create a file object to user later
|
14
14
|
michigan_logo = @lob.objects.create(
|
15
15
|
name: "Michigan Logo Document",
|
16
|
+
file: "https://www.lob.com/goblue.pdf",
|
17
|
+
setting_id: setting_id
|
18
|
+
)
|
19
|
+
|
20
|
+
# create a to address
|
21
|
+
to_address = @lob.addresses.create(
|
22
|
+
name: "ToAddress",
|
23
|
+
address_line1: "120 6th Ave",
|
24
|
+
city: "Boston",
|
25
|
+
state: "MA",
|
26
|
+
country: "US",
|
27
|
+
zip: 12345
|
28
|
+
)
|
29
|
+
|
30
|
+
# create a from address
|
31
|
+
from_address = @lob.addresses.create(
|
32
|
+
name: "FromAddress",
|
33
|
+
address_line1: "120 6th Ave",
|
34
|
+
city: "Boston",
|
35
|
+
state: "MA",
|
36
|
+
country: "US",
|
37
|
+
zip: 12345
|
16
38
|
)
|
17
39
|
|
18
40
|
|
19
|
-
|
41
|
+
# send the object you created
|
42
|
+
puts @lob.jobs.create(
|
20
43
|
name: "Michigan Logo to Harry",
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
address_line1: "123 Test Street",
|
25
|
-
address_line2: "Unit 199",
|
26
|
-
city: "Mountain View",
|
27
|
-
state: "CA",
|
28
|
-
country: "US",
|
29
|
-
zip: 94085
|
30
|
-
},
|
31
|
-
to: {
|
32
|
-
name: "Harry Avidar",
|
33
|
-
email: "test@test.com",
|
34
|
-
address_line1: "123 Test Street",
|
35
|
-
address_line2: "Unit 199",
|
36
|
-
city: "Mountain View",
|
37
|
-
state: "CA",
|
38
|
-
country: "US",
|
39
|
-
zip: 94085
|
40
|
-
},
|
41
|
-
objects: {
|
42
|
-
name: "Michigan Logo",
|
43
|
-
file: "https://www.lob.com/goblue.pdf",
|
44
|
-
setting_id: setting_id
|
45
|
-
}
|
44
|
+
to: to_address["id"],
|
45
|
+
from: from_address["id"],
|
46
|
+
objects: michigan_logo["id"]
|
46
47
|
)
|
data/examples/postcards.rb
CHANGED
@@ -5,53 +5,31 @@ require 'lob'
|
|
5
5
|
Lob.api_key = 'test_0dc8d51e0acffcb1880e0f19c79b2f5b0cc'
|
6
6
|
@lob = Lob.load
|
7
7
|
|
8
|
-
# create a
|
9
|
-
puts @lob.postcards.create(
|
10
|
-
name: "John Joe",
|
11
|
-
to: {
|
12
|
-
name: "ToAddress",
|
13
|
-
address_line1: "120, 6th Ave",
|
14
|
-
city: "Boston",
|
15
|
-
state: "MA",
|
16
|
-
country: "US",
|
17
|
-
zip: 12345
|
18
|
-
},
|
19
|
-
from: {
|
20
|
-
name: "FromAddress",
|
21
|
-
address_line1: "120, 6th Ave",
|
22
|
-
city: "Boston",
|
23
|
-
state: "MA",
|
24
|
-
country: "US",
|
25
|
-
zip: 12345
|
26
|
-
},
|
27
|
-
front: "https://www.lob.com/postcardfront.pdf",
|
28
|
-
back: File.new("../spec/samples/postcardback.pdf")
|
29
|
-
)
|
30
|
-
|
31
|
-
# create a postcard with stored addresses
|
32
|
-
|
8
|
+
# create a to address
|
33
9
|
to_address = @lob.addresses.create(
|
34
10
|
name: "ToAddress",
|
35
|
-
address_line1: "120
|
11
|
+
address_line1: "120 6th Ave",
|
36
12
|
city: "Boston",
|
37
13
|
state: "MA",
|
38
14
|
country: "US",
|
39
15
|
zip: 12345
|
40
16
|
)
|
41
17
|
|
18
|
+
# create a from address
|
42
19
|
from_address = @lob.addresses.create(
|
43
20
|
name: "FromAddress",
|
44
|
-
address_line1: "120
|
21
|
+
address_line1: "120 6th Ave",
|
45
22
|
city: "Boston",
|
46
23
|
state: "MA",
|
47
24
|
country: "US",
|
48
25
|
zip: 12345
|
49
26
|
)
|
50
27
|
|
28
|
+
# send a postcard
|
51
29
|
puts @lob.postcards.create(
|
52
30
|
name: "John Joe",
|
53
31
|
to: to_address["id"],
|
54
32
|
from: from_address["id"],
|
55
33
|
front: "https://www.lob.com/postcardfront.pdf",
|
56
|
-
back:
|
34
|
+
back: "https://www.lob.com/postcardback.pdf"
|
57
35
|
)
|
data/lib/lob.rb
CHANGED
@@ -6,7 +6,6 @@ require "lob/lob_error"
|
|
6
6
|
Dir[File.join(File.dirname(__FILE__), 'lob', 'v*', '*.rb')].each {|file| require file }
|
7
7
|
|
8
8
|
module Lob
|
9
|
-
|
10
9
|
class << self
|
11
10
|
attr_accessor :api_key,
|
12
11
|
:api_version,
|
@@ -29,8 +28,18 @@ module Lob
|
|
29
28
|
|
30
29
|
|
31
30
|
def self.submit(method, url, parameters={})
|
32
|
-
|
33
|
-
|
31
|
+
clientVersion = Gem.latest_spec_for('lob').version.to_s
|
32
|
+
|
33
|
+
if method == :get || method == :delete
|
34
|
+
JSON(RestClient.send(method, url, {
|
35
|
+
user_agent: 'Lob/v1 RubyBindings/' + clientVersion,
|
36
|
+
params: parameters
|
37
|
+
}))
|
38
|
+
else
|
39
|
+
JSON(RestClient.send(method, url, parameters, {
|
40
|
+
user_agent: 'Lob/v1 RubyBindings/' + clientVersion
|
41
|
+
}))
|
42
|
+
end
|
34
43
|
# :nocov:
|
35
44
|
rescue => e
|
36
45
|
begin
|
data/lib/lob/v1/resource.rb
CHANGED
@@ -16,6 +16,18 @@ module Lob
|
|
16
16
|
Lob::V1::Address.new(self)
|
17
17
|
end
|
18
18
|
|
19
|
+
def bank_accounts
|
20
|
+
Lob::V1::BankAccount.new(self)
|
21
|
+
end
|
22
|
+
|
23
|
+
def checks
|
24
|
+
Lob::V1::Check.new(self)
|
25
|
+
end
|
26
|
+
|
27
|
+
def countries
|
28
|
+
Lob::V1::Country.new(self)
|
29
|
+
end
|
30
|
+
|
19
31
|
def jobs
|
20
32
|
Lob::V1::Job.new(self)
|
21
33
|
end
|
@@ -44,19 +56,10 @@ module Lob
|
|
44
56
|
Lob::V1::Setting.new(self)
|
45
57
|
end
|
46
58
|
|
47
|
-
def
|
48
|
-
Lob::V1::
|
49
|
-
end
|
50
|
-
|
51
|
-
def checks
|
52
|
-
Lob::V1::Check.new(self)
|
59
|
+
def states
|
60
|
+
Lob::V1::State.new(self)
|
53
61
|
end
|
54
62
|
|
55
|
-
def bank_accounts
|
56
|
-
Lob::V1::BankAccount.new(self)
|
57
|
-
end
|
58
|
-
|
59
|
-
|
60
63
|
def base_url
|
61
64
|
"#{@options[:protocol]}://#{@options[:api_key]}:@#{@options[:api_host]}/v1"
|
62
65
|
end
|
data/lib/lob/v1/state.rb
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
module Lob
|
2
|
+
module V1
|
3
|
+
class State
|
4
|
+
|
5
|
+
def initialize(resource)
|
6
|
+
@resource = resource
|
7
|
+
end
|
8
|
+
|
9
|
+
def list(options={})
|
10
|
+
Lob.submit(:get, state_url, options)["data"] || []
|
11
|
+
end
|
12
|
+
|
13
|
+
private
|
14
|
+
|
15
|
+
def state_url
|
16
|
+
@resource.construct_url("states")
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
data/lob.gemspec
CHANGED
@@ -5,7 +5,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |spec|
|
7
7
|
spec.name = "lob"
|
8
|
-
spec.version = "1.
|
8
|
+
spec.version = "1.6"
|
9
9
|
spec.authors = ["Lob"]
|
10
10
|
spec.email = ["support@lob.com"]
|
11
11
|
spec.description = %q{Lob API Ruby wrapper}
|
data/spec/lob/v1/country_spec.rb
CHANGED
@@ -0,0 +1,14 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe Lob::V1::State do
|
4
|
+
subject { Lob(api_key: ENV["LOB_API_KEY"], api_version: "v1") }
|
5
|
+
|
6
|
+
describe "list" do
|
7
|
+
it "should list states" do
|
8
|
+
VCR.use_cassette('list_states') do
|
9
|
+
result = subject.states.list
|
10
|
+
result.length.must_be :>, 0
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
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: '1.
|
4
|
+
version: '1.6'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Lob
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-10-
|
11
|
+
date: 2014-10-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rest-client
|
@@ -163,12 +163,10 @@ files:
|
|
163
163
|
- LICENSE.txt
|
164
164
|
- README.md
|
165
165
|
- Rakefile
|
166
|
-
- examples/addresses.rb
|
167
166
|
- examples/checks.rb
|
168
167
|
- examples/create_pdf.rb
|
169
168
|
- examples/jobs.rb
|
170
169
|
- examples/postcards.rb
|
171
|
-
- examples/verification.rb
|
172
170
|
- lib/lob.rb
|
173
171
|
- lib/lob/lob_error.rb
|
174
172
|
- lib/lob/v1/address.rb
|
@@ -184,6 +182,7 @@ files:
|
|
184
182
|
- lib/lob/v1/route.rb
|
185
183
|
- lib/lob/v1/service.rb
|
186
184
|
- lib/lob/v1/setting.rb
|
185
|
+
- lib/lob/v1/state.rb
|
187
186
|
- lob.gemspec
|
188
187
|
- spec/lob/v1/address_spec.rb
|
189
188
|
- spec/lob/v1/area_spec.rb
|
@@ -198,6 +197,7 @@ files:
|
|
198
197
|
- spec/lob/v1/route_spec.rb
|
199
198
|
- spec/lob/v1/service_spec.rb
|
200
199
|
- spec/lob/v1/setting_spec.rb
|
200
|
+
- spec/lob/v1/state_spec.rb
|
201
201
|
- spec/lob_spec.rb
|
202
202
|
- spec/spec_helper.rb
|
203
203
|
homepage: https://github.com/lob/lob-ruby
|
@@ -238,5 +238,6 @@ test_files:
|
|
238
238
|
- spec/lob/v1/route_spec.rb
|
239
239
|
- spec/lob/v1/service_spec.rb
|
240
240
|
- spec/lob/v1/setting_spec.rb
|
241
|
+
- spec/lob/v1/state_spec.rb
|
241
242
|
- spec/lob_spec.rb
|
242
243
|
- spec/spec_helper.rb
|
data/examples/addresses.rb
DELETED
@@ -1,16 +0,0 @@
|
|
1
|
-
$:.unshift File.expand_path("../lib", File.dirname(__FILE__))
|
2
|
-
require 'lob'
|
3
|
-
|
4
|
-
# initialize Lob object
|
5
|
-
Lob.api_key = 'test_0dc8d51e0acffcb1880e0f19c79b2f5b0cc'
|
6
|
-
@lob = Lob.load
|
7
|
-
|
8
|
-
# create an address
|
9
|
-
puts @lob.addresses.create(
|
10
|
-
name: "John Doe",
|
11
|
-
address_line1: "104, Printing Boulevard",
|
12
|
-
city: "Boston",
|
13
|
-
state: "MA",
|
14
|
-
country: "US",
|
15
|
-
zip: 12345
|
16
|
-
)
|
data/examples/verification.rb
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
$:.unshift File.expand_path("../lib", File.dirname(__FILE__))
|
2
|
-
require 'lob'
|
3
|
-
|
4
|
-
# initialize Lob object
|
5
|
-
Lob.api_key = 'test_0dc8d51e0acffcb1880e0f19c79b2f5b0cc'
|
6
|
-
@lob = Lob.load
|
7
|
-
|
8
|
-
# verify an address
|
9
|
-
puts @lob.addresses.verify(
|
10
|
-
address_line1: "220 WILLIAM T MORRISSEY BLVD",
|
11
|
-
city: "Boston",
|
12
|
-
state: "MA",
|
13
|
-
zip: "02125"
|
14
|
-
)
|