Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(examples): adds csv checks and csv letters examples
- Loading branch information
Pallavi Shankar
committed
Aug 16, 2016
1 parent
b6ff1c0
commit 4419be9
Showing
8 changed files
with
162 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
$:.unshift File.expand_path("../../lib", File.dirname(__FILE__)) | ||
require 'lob' | ||
require 'csv' | ||
|
||
# Initialize Lob object | ||
Lob.api_key = 'test_799ff27291c166d10ba191902ad02fb059c' | ||
@lob = Lob.load | ||
|
||
# Create a bank account | ||
bank_account = @lob.bank_accounts.create( | ||
routing_number: "322271627", | ||
account_number: "123456789", | ||
account_type: "company", | ||
signatory: "John Doe" | ||
) | ||
|
||
puts bank_account | ||
|
||
# Verify bank account | ||
@lob.bank_accounts.verify(bank_account['id'], amounts: [23, 12]) | ||
|
||
# Parse the CSV and create the checks | ||
CSV.foreach(File.expand_path('../input.csv', __FILE__)) do |row| | ||
check = @lob.checks.create( | ||
description: 'CSV Test', | ||
bank_account: bank_account["id"], | ||
to: { | ||
name: row[0], | ||
address_line1: row[1], | ||
address_line2: row[2], | ||
address_city: row[3], | ||
address_state: row[4], | ||
address_zip: row[5], | ||
address_country: row[6] | ||
}, | ||
from: { | ||
name: 'Lob', | ||
address_line1: '123 Main Street', | ||
address_city: 'San Francisco', | ||
address_state: 'CA', | ||
address_zip: '94185', | ||
address_country: 'US' | ||
}, | ||
amount: row[7], | ||
memo: "For travel reimbursement" | ||
) | ||
puts check['url'] | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
Pallavi,353 King Street,Apt. 432,San Francisco,CA,94158,US,600.00 | ||
Dom,456 Oak Street,Apt. 102,San Francisco,CA,94185,US,500.00 | ||
Kyle,123 Test Street,Apt. 101,San Francisco,CA,94105,US,400.00 | ||
Kienan,789 Elm Street,Apt. 101,San Francisco,CA,94107,US,300.00 | ||
Sid,111 Washington Street,Apt. 101,San Francisco,CA,94112,US,200.00 | ||
Will,888 Jefferson Street,Apt. 101,San Francisco,CA,94197,US,100.00 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
$:.unshift File.expand_path("../../lib", File.dirname(__FILE__)) | ||
require 'lob' | ||
require 'csv' | ||
|
||
# Initialize Lob object | ||
Lob.api_key = 'test_799ff27291c166d10ba191902ad02fb059c' | ||
@lob = Lob.load | ||
|
||
# Load the HTML from letter_template.html | ||
letter_html = File.open(File.expand_path('../letter_template.html', __FILE__)).read | ||
|
||
# Parse the CSV and create the letters. | ||
CSV.foreach(File.expand_path('../input.csv', __FILE__)) do |row| | ||
letter = @lob.letters.create( | ||
description: 'CSV Test', | ||
to: { | ||
name: row[0], | ||
address_line1: row[1], | ||
address_line2: row[2], | ||
address_city: row[3], | ||
address_state: row[4], | ||
address_zip: row[5], | ||
address_country: row[6] | ||
}, | ||
from: { | ||
name: 'Lob', | ||
address_line1: '123 Main Street', | ||
address_city: 'San Francisco', | ||
address_state: 'CA', | ||
address_zip: '94185', | ||
address_country: 'US' | ||
}, | ||
file: letter_html, | ||
data: { | ||
name: row[0], | ||
city: row[3] | ||
}, | ||
color: false | ||
) | ||
puts letter['url'] | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
Pallavi,353 King Street,Apt. 432,San Francisco,CA,94158,US | ||
Dom,456 Oak Street ,Apt. 102,San Francisco,CA,94185,US | ||
Kyle,123 Test Street,Apt. 101,San Francisco,CA,94105,US | ||
Kienan,789 Elm Street,Apt. 101,San Francisco,CA,94107,US | ||
Sid,111 Washington Street,Apt. 101,San Francisco,CA,94112,US | ||
Will,888 Jefferson Street,Apt. 101,San Francisco,CA,94197,US |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<html> | ||
<head> | ||
<style> | ||
*, *:before, *:after { | ||
-webkit-box-sizing: border-box; | ||
-moz-box-sizing: border-box; | ||
box-sizing: border-box; | ||
} | ||
|
||
@font-face { | ||
font-family: 'Loved by the King'; | ||
font-style: normal; | ||
font-weight: 400; | ||
src: url('https://s3-us-west-2.amazonaws.com/lob-assets/LovedbytheKing.ttf') format('truetype'); | ||
} | ||
|
||
.text { | ||
margin-left: 75px; | ||
padding-top: 250px; | ||
width: 400px; | ||
font-family: 'Loved by the King'; | ||
font-size: 50px; | ||
font-weight: 700; | ||
color: black; | ||
} | ||
</style> | ||
</head> | ||
|
||
<body> | ||
<p class="text">Hello {{name}}!<br/><br/>Join us for this year's summer celebration in {{city}}!</p> | ||
</body> | ||
|
||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters