lob 1.4 → 1.5
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 +2 -1
- data/README.md +32 -13
- data/examples/addresses.rb +16 -0
- data/examples/checks.rb +17 -0
- data/examples/create_pdf.rb +25 -0
- data/examples/jobs.rb +46 -0
- data/examples/postcards.rb +57 -0
- data/examples/verification.rb +14 -0
- data/lib/lob/v1/bank_account.rb +3 -0
- data/lob.gemspec +4 -2
- data/spec/lob/v1/address_spec.rb +5 -6
- data/spec/lob/v1/bank_account_spec.rb +16 -1
- data/spec/lob/v1/check_spec.rb +1 -1
- metadata +22 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: da1de55d24c191d96b977778bc662314c4a6523d
|
4
|
+
data.tar.gz: 1a6bf843e2f9730735a0aa6ad5c89b228eb77c75
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 22cddc118df4adee9bad8bc045a98138e82353b9d4783a9912dec8e75e87dede1183ba0f59c5715b8c91b416111b6cba38a96ac6175b201259cbe29547835504
|
7
|
+
data.tar.gz: 151991770ed6e72b43710473c35b9d5f34c09f2c66aaf72d5bbda99aab89955161261fddfe9bc0dd7c44f3d2bf4953947cd5746f9b5f8a14678f43d94fa14556
|
data/.gitignore
CHANGED
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# lob-ruby
|
2
2
|
|
3
|
-
[](https://travis-ci.org/lob/lob-ruby) [](http://badge.fury.io/rb/lob) [](https://gemnasium.com/lob/lob-ruby) [](https://coveralls.io/r/lob/lob-ruby?branch=master) 
|
3
|
+
[](https://travis-ci.org/lob/lob-ruby) [](http://badge.fury.io/rb/lob) [](https://gemnasium.com/lob/lob-ruby) [](https://coveralls.io/r/lob/lob-ruby?branch=master) [](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
|
|
@@ -33,18 +33,23 @@ When using zip codes with zero-prefixes, always quote them. For example when spe
|
|
33
33
|
|
34
34
|
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
35
|
|
36
|
-
|
36
|
+
Supported Image Types
|
37
|
+
--------
|
38
|
+
The lob.com API supports the following image types:
|
37
39
|
|
38
|
-
|
39
|
-
|
40
|
-
|
40
|
+
- PDF
|
41
|
+
- PNG
|
42
|
+
- JPEG
|
41
43
|
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
44
|
+
For more information on prepping the images please see the [Lob documentation](https://lob.com/docs#prepping)
|
45
|
+
|
46
|
+
Creating a PDF
|
47
|
+
-------
|
48
|
+
|
49
|
+
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)
|
46
50
|
|
47
|
-
|
51
|
+
Initialization and configuration
|
52
|
+
------
|
48
53
|
|
49
54
|
```ruby
|
50
55
|
# To initialize a Lob object
|
@@ -66,6 +71,20 @@ Lob.configure do |config|
|
|
66
71
|
end
|
67
72
|
```
|
68
73
|
|
74
|
+
### Settings
|
75
|
+
|
76
|
+
#### List settings
|
77
|
+
```ruby
|
78
|
+
# returns an array of settings
|
79
|
+
@lob.settings.list
|
80
|
+
```
|
81
|
+
|
82
|
+
#### Find a setting
|
83
|
+
```ruby
|
84
|
+
# returns a setting object
|
85
|
+
@lob.settings.find("setting_id")
|
86
|
+
```
|
87
|
+
|
69
88
|
### Addresses
|
70
89
|
|
71
90
|
#### To create an address
|
@@ -409,10 +428,10 @@ zip_codes and routes can be a string or an array of strings
|
|
409
428
|
|
410
429
|
#### List areas
|
411
430
|
```ruby
|
412
|
-
|
431
|
+
@lob.areas.list
|
413
432
|
|
414
|
-
|
415
|
-
|
433
|
+
# you can also pass count and offset
|
434
|
+
@lob.areas.list(count: 10, offset: 3)
|
416
435
|
```
|
417
436
|
|
418
437
|
|
@@ -0,0 +1,16 @@
|
|
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/checks.rb
ADDED
@@ -0,0 +1,17 @@
|
|
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
|
+
# send a $1000 check using an already created bank and address
|
9
|
+
puts @lob.checks.create(
|
10
|
+
name: 'Test Check',
|
11
|
+
check_number: '10000',
|
12
|
+
bank_account: 'bank_3e64d9904356b20',
|
13
|
+
to: 'adr_0e418aa8d1eb41fb',
|
14
|
+
amount: 100,
|
15
|
+
memo: 'This is my first Check',
|
16
|
+
message: 'This check is for laundry'
|
17
|
+
)
|
@@ -0,0 +1,25 @@
|
|
1
|
+
$:.unshift File.expand_path("../lib", File.dirname(__FILE__))
|
2
|
+
require 'open-uri'
|
3
|
+
require 'prawn'
|
4
|
+
require 'lob'
|
5
|
+
|
6
|
+
# initialize Lob object
|
7
|
+
Lob.api_key = 'test_0dc8d51e0acffcb1880e0f19c79b2f5b0cc'
|
8
|
+
@lob = Lob.load
|
9
|
+
|
10
|
+
POINTS_PER_INCH = 72 # 72 PostScript Points per Inch
|
11
|
+
|
12
|
+
pdf = Prawn::Document.new(:page_size => [4.25 * POINTS_PER_INCH, 6.25 * POINTS_PER_INCH])
|
13
|
+
pdf.image open('https://www.lob.com/assets/images/printing_icon.png'), :position => :center
|
14
|
+
pdf.text 'Print with Lob!', :align => :center, :size => 32
|
15
|
+
|
16
|
+
pdf.render_file 'sample.pdf'
|
17
|
+
|
18
|
+
object = @lob.objects.create(
|
19
|
+
name: 'Test Object',
|
20
|
+
file: File.new('sample.pdf'),
|
21
|
+
setting_id: 201,
|
22
|
+
full_bleed: 1
|
23
|
+
)
|
24
|
+
|
25
|
+
puts 'You can view your created PDF here: ' + object['url']
|
data/examples/jobs.rb
ADDED
@@ -0,0 +1,46 @@
|
|
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
|
+
# find the setting_id for the object you want to create
|
9
|
+
settings = @lob.settings.list
|
10
|
+
setting_index = settings.find_index { |setting| setting["type"] === "documents" }
|
11
|
+
setting_id = settings[setting_index]["id"]
|
12
|
+
|
13
|
+
# create a file object to user laterA
|
14
|
+
michigan_logo = @lob.objects.create(
|
15
|
+
name: "Michigan Logo Document",
|
16
|
+
)
|
17
|
+
|
18
|
+
|
19
|
+
@lob.jobs.create(
|
20
|
+
name: "Michigan Logo to Harry",
|
21
|
+
from: {
|
22
|
+
name: "Leore Avidar",
|
23
|
+
email: "test@test.com",
|
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
|
+
}
|
46
|
+
)
|
@@ -0,0 +1,57 @@
|
|
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 a postcard with in-line addresses
|
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
|
+
|
33
|
+
to_address = @lob.addresses.create(
|
34
|
+
name: "ToAddress",
|
35
|
+
address_line1: "120, 6th Ave",
|
36
|
+
city: "Boston",
|
37
|
+
state: "MA",
|
38
|
+
country: "US",
|
39
|
+
zip: 12345
|
40
|
+
)
|
41
|
+
|
42
|
+
from_address = @lob.addresses.create(
|
43
|
+
name: "FromAddress",
|
44
|
+
address_line1: "120, 6th Ave",
|
45
|
+
city: "Boston",
|
46
|
+
state: "MA",
|
47
|
+
country: "US",
|
48
|
+
zip: 12345
|
49
|
+
)
|
50
|
+
|
51
|
+
puts @lob.postcards.create(
|
52
|
+
name: "John Joe",
|
53
|
+
to: to_address["id"],
|
54
|
+
from: from_address["id"],
|
55
|
+
front: "https://www.lob.com/postcardfront.pdf",
|
56
|
+
back: File.new("../spec/samples/postcardback.pdf")
|
57
|
+
)
|
@@ -0,0 +1,14 @@
|
|
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
|
+
)
|
data/lib/lob/v1/bank_account.rb
CHANGED
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.5"
|
9
9
|
spec.authors = ["Lob"]
|
10
10
|
spec.email = ["support@lob.com"]
|
11
11
|
spec.description = %q{Lob API Ruby wrapper}
|
@@ -18,7 +18,9 @@ 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", "
|
21
|
+
spec.add_dependency "rest-client", "~> 1.7.0"
|
22
|
+
|
23
|
+
spec.add_dependency "prawn", ">= 0"
|
22
24
|
|
23
25
|
spec.add_development_dependency "bundler", "~> 1.3"
|
24
26
|
spec.add_development_dependency "rake", "~> 10.3.2"
|
data/spec/lob/v1/address_spec.rb
CHANGED
@@ -4,13 +4,12 @@ describe Lob::V1::Address do
|
|
4
4
|
|
5
5
|
let(:sample_params) {
|
6
6
|
{
|
7
|
-
name:
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
state: "MA",
|
7
|
+
name: "John Doe",
|
8
|
+
address_line1: "325 Berry Street",
|
9
|
+
city: "San Francisco",
|
10
|
+
state: "CA",
|
12
11
|
country: "US",
|
13
|
-
zip:
|
12
|
+
zip: 94158
|
14
13
|
}
|
15
14
|
}
|
16
15
|
|
@@ -15,7 +15,7 @@ describe Lob::V1::BankAccount do
|
|
15
15
|
}
|
16
16
|
|
17
17
|
@sample_bank_account_params = {
|
18
|
-
routing_number: "
|
18
|
+
routing_number: "122100024",
|
19
19
|
account_number: "123456789"
|
20
20
|
}
|
21
21
|
end
|
@@ -91,4 +91,19 @@ describe Lob::V1::BankAccount do
|
|
91
91
|
end
|
92
92
|
end
|
93
93
|
|
94
|
+
describe "destroy" do
|
95
|
+
it "should delete a bank_account" do
|
96
|
+
VCR.use_cassette('delete_bank_account') do
|
97
|
+
new_bank_account = subject.bank_accounts.create(
|
98
|
+
routing_number: @sample_bank_account_params[:routing_number],
|
99
|
+
bank_address: @sample_address_params.clone,
|
100
|
+
account_number: @sample_bank_account_params[:account_number],
|
101
|
+
account_address: @sample_address_params.clone
|
102
|
+
)
|
103
|
+
|
104
|
+
delete_result = subject.bank_accounts.destroy(new_bank_account["id"])
|
105
|
+
assert_equal(new_bank_account["id"], delete_result["id"])
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|
94
109
|
end
|
data/spec/lob/v1/check_spec.rb
CHANGED
metadata
CHANGED
@@ -1,17 +1,31 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lob
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '1.
|
4
|
+
version: '1.5'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Lob
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-10-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rest-client
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 1.7.0
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 1.7.0
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: prawn
|
15
29
|
requirement: !ruby/object:Gem::Requirement
|
16
30
|
requirements:
|
17
31
|
- - '>='
|
@@ -149,6 +163,12 @@ files:
|
|
149
163
|
- LICENSE.txt
|
150
164
|
- README.md
|
151
165
|
- Rakefile
|
166
|
+
- examples/addresses.rb
|
167
|
+
- examples/checks.rb
|
168
|
+
- examples/create_pdf.rb
|
169
|
+
- examples/jobs.rb
|
170
|
+
- examples/postcards.rb
|
171
|
+
- examples/verification.rb
|
152
172
|
- lib/lob.rb
|
153
173
|
- lib/lob/lob_error.rb
|
154
174
|
- lib/lob/v1/address.rb
|