lob 2.5.1 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +2 -2
- data/CHANGELOG.md +9 -0
- data/CONTRIBUTING.md +19 -0
- data/Gemfile +0 -2
- data/README.md +19 -36
- data/examples/README.md +14 -6
- data/examples/checks.rb +6 -7
- data/examples/csv_checks/create_checks.rb +47 -0
- data/examples/csv_checks/input.csv +6 -0
- data/examples/csv_letters/create_letters.rb +40 -0
- data/examples/csv_letters/input.csv +6 -0
- data/examples/csv_letters/letter_template.html +33 -0
- data/examples/csv_postcards/create_postcards.rb +2 -3
- data/examples/letters.rb +4 -5
- data/examples/postcards.rb +4 -5
- data/examples/verify/verify.rb +3 -4
- data/lib/lob.rb +1 -91
- data/lib/lob/client.rb +61 -0
- data/lib/lob/resources/address.rb +24 -0
- data/lib/lob/resources/area.rb +16 -0
- data/lib/lob/resources/bank_account.rb +24 -0
- data/lib/lob/resources/check.rb +14 -0
- data/lib/lob/resources/country.rb +16 -0
- data/lib/lob/resources/letter.rb +14 -0
- data/lib/lob/resources/postcard.rb +14 -0
- data/lib/lob/resources/resource_base.rb +108 -0
- data/lib/lob/resources/route.rb +24 -0
- data/lib/lob/resources/state.rb +16 -0
- data/lib/lob/version.rb +1 -1
- data/spec/lob/{v1 → resources}/address_spec.rb +15 -14
- data/spec/lob/{v1 → resources}/area_spec.rb +2 -2
- data/spec/lob/{v1 → resources}/bank_account_spec.rb +2 -2
- data/spec/lob/{v1 → resources}/check_spec.rb +3 -2
- data/spec/lob/{v1 → resources}/country_spec.rb +2 -2
- data/spec/lob/{v1 → resources}/letter_spec.rb +2 -2
- data/spec/lob/{v1 → resources}/postcard_spec.rb +2 -2
- data/spec/lob/resources/resource_base_spec.rb +53 -0
- data/spec/lob/{v1 → resources}/route_spec.rb +2 -2
- data/spec/lob/{v1 → resources}/state_spec.rb +2 -2
- data/spec/lob_spec.rb +12 -45
- data/spec/spec_helper.rb +2 -0
- metadata +86 -89
- data/examples/jobs.rb +0 -91
- data/lib/lob/v1/address.rb +0 -41
- data/lib/lob/v1/area.rb +0 -27
- data/lib/lob/v1/bank_account.rb +0 -37
- data/lib/lob/v1/check.rb +0 -33
- data/lib/lob/v1/country.rb +0 -21
- data/lib/lob/v1/job.rb +0 -39
- data/lib/lob/v1/letter.rb +0 -33
- data/lib/lob/v1/object.rb +0 -33
- data/lib/lob/v1/postcard.rb +0 -33
- data/lib/lob/v1/resource.rb +0 -69
- data/lib/lob/v1/route.rb +0 -27
- data/lib/lob/v1/setting.rb +0 -25
- data/lib/lob/v1/state.rb +0 -21
- data/spec/lob/v1/job_spec.rb +0 -161
- data/spec/lob/v1/object_spec.rb +0 -72
- data/spec/lob/v1/resource_spec.rb +0 -41
- data/spec/lob/v1/setting_spec.rb +0 -21
data/examples/jobs.rb
DELETED
@@ -1,91 +0,0 @@
|
|
1
|
-
$:.unshift File.expand_path("../lib", File.dirname(__FILE__))
|
2
|
-
require 'open-uri'
|
3
|
-
require 'lob'
|
4
|
-
|
5
|
-
# initialize Lob object
|
6
|
-
Lob.api_key = 'test_799ff27291c166d10ba191902ad02fb059c'
|
7
|
-
@lob = Lob.load
|
8
|
-
|
9
|
-
html = %{
|
10
|
-
<html>
|
11
|
-
<head>
|
12
|
-
<title>Lob.com Sample Photo</title>
|
13
|
-
<style>
|
14
|
-
*, *:before, *:after {
|
15
|
-
-webkit-box-sizing: border-box;
|
16
|
-
-moz-box-sizing: border-box;
|
17
|
-
box-sizing: border-box;
|
18
|
-
}
|
19
|
-
|
20
|
-
@font-face {
|
21
|
-
font-family: 'Loved by the King';
|
22
|
-
font-style: normal;
|
23
|
-
font-weight: 400;
|
24
|
-
src: url('https://s3-us-west-2.amazonaws.com/lob-assets/LovedbytheKing.ttf') format('truetype');
|
25
|
-
}
|
26
|
-
|
27
|
-
body {
|
28
|
-
width: 6.25in;
|
29
|
-
height: 4.25in;
|
30
|
-
margin: 0;
|
31
|
-
padding: 0;
|
32
|
-
/* If using an image, the background image should have dimensions of 1875x1275 pixels. */
|
33
|
-
background-image: url(https://s3-us-west-2.amazonaws.com/lob-assets/beach.jpg);
|
34
|
-
background-size: 6.25in 4.25in;
|
35
|
-
background-repeat: no-repeat;
|
36
|
-
}
|
37
|
-
|
38
|
-
.text {
|
39
|
-
margin: 50px;
|
40
|
-
width: 400px;
|
41
|
-
font-family: 'Loved by the King';
|
42
|
-
font-size: 50px;
|
43
|
-
font-weight: 700;
|
44
|
-
color: white;
|
45
|
-
text-shadow: 3px 3px black;
|
46
|
-
}
|
47
|
-
</style>
|
48
|
-
</head>
|
49
|
-
|
50
|
-
<body>
|
51
|
-
<h1 class="text">Hello {{name}}!</h1>
|
52
|
-
<p class="text">Join us for the {{event}}!</p>
|
53
|
-
</body>
|
54
|
-
|
55
|
-
</html>
|
56
|
-
}
|
57
|
-
|
58
|
-
object = @lob.objects.create(
|
59
|
-
description: 'Test Object',
|
60
|
-
file: html,
|
61
|
-
data: { name: "Albert", event: "Summer 2015 Beach-athon" },
|
62
|
-
setting: 201
|
63
|
-
)
|
64
|
-
|
65
|
-
# create a to address
|
66
|
-
to_address = @lob.addresses.create(
|
67
|
-
name: "ToAddress",
|
68
|
-
address_line1: "120 6th Ave",
|
69
|
-
address_city: "Boston",
|
70
|
-
address_state: "MA",
|
71
|
-
address_country: "US",
|
72
|
-
address_zip: 12345
|
73
|
-
)
|
74
|
-
|
75
|
-
# create a from address
|
76
|
-
from_address = @lob.addresses.create(
|
77
|
-
name: "FromAddress",
|
78
|
-
address_line1: "120 6th Ave",
|
79
|
-
address_city: "Boston",
|
80
|
-
address_state: "MA",
|
81
|
-
address_country: "US",
|
82
|
-
address_zip: 12345
|
83
|
-
)
|
84
|
-
|
85
|
-
# send the object you created
|
86
|
-
puts @lob.jobs.create(
|
87
|
-
description: "Michigan Logo to Harry",
|
88
|
-
to: to_address["id"],
|
89
|
-
from: from_address["id"],
|
90
|
-
objects: object["id"]
|
91
|
-
)
|
data/lib/lob/v1/address.rb
DELETED
@@ -1,41 +0,0 @@
|
|
1
|
-
module Lob
|
2
|
-
module V1
|
3
|
-
class Address
|
4
|
-
|
5
|
-
def initialize(resource)
|
6
|
-
@resource = resource
|
7
|
-
end
|
8
|
-
|
9
|
-
def verify(options={})
|
10
|
-
Lob.submit(:post, address_verify_url, options)
|
11
|
-
end
|
12
|
-
|
13
|
-
def list(options={})
|
14
|
-
Lob.submit(:get, address_url, options)
|
15
|
-
end
|
16
|
-
|
17
|
-
def find(address_id)
|
18
|
-
Lob.submit :get, address_url(address_id)
|
19
|
-
end
|
20
|
-
|
21
|
-
def create(options = {})
|
22
|
-
Lob.submit :post, address_url, options
|
23
|
-
end
|
24
|
-
|
25
|
-
def destroy(address_id)
|
26
|
-
Lob.submit :delete, address_url(address_id)
|
27
|
-
end
|
28
|
-
|
29
|
-
private
|
30
|
-
|
31
|
-
def address_url(address_id = nil)
|
32
|
-
@resource.construct_url("addresses", address_id)
|
33
|
-
end
|
34
|
-
|
35
|
-
def address_verify_url
|
36
|
-
@resource.construct_url("verify")
|
37
|
-
end
|
38
|
-
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|
data/lib/lob/v1/area.rb
DELETED
@@ -1,27 +0,0 @@
|
|
1
|
-
module Lob
|
2
|
-
module V1
|
3
|
-
class Area
|
4
|
-
def initialize(resource)
|
5
|
-
@resource = resource
|
6
|
-
end
|
7
|
-
|
8
|
-
def list(options = {})
|
9
|
-
Lob.submit(:get, area_url, options)
|
10
|
-
end
|
11
|
-
|
12
|
-
def find(lob_object_id)
|
13
|
-
Lob.submit :get, area_url(lob_object_id)
|
14
|
-
end
|
15
|
-
|
16
|
-
def create(options = {})
|
17
|
-
Lob.submit :post, area_url, options
|
18
|
-
end
|
19
|
-
|
20
|
-
private
|
21
|
-
|
22
|
-
def area_url(area_id = nil)
|
23
|
-
@resource.construct_url("areas", area_id)
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
data/lib/lob/v1/bank_account.rb
DELETED
@@ -1,37 +0,0 @@
|
|
1
|
-
module Lob
|
2
|
-
module V1
|
3
|
-
class BankAccount
|
4
|
-
|
5
|
-
def initialize(resource)
|
6
|
-
@resource = resource
|
7
|
-
end
|
8
|
-
|
9
|
-
def list(options={})
|
10
|
-
Lob.submit(:get, bank_account_url, options)
|
11
|
-
end
|
12
|
-
|
13
|
-
def find(bank_account_id)
|
14
|
-
Lob.submit :get, bank_account_url(bank_account_id)
|
15
|
-
end
|
16
|
-
|
17
|
-
def create(options = {})
|
18
|
-
Lob.submit :post, bank_account_url, options
|
19
|
-
end
|
20
|
-
|
21
|
-
def destroy(bank_account_id)
|
22
|
-
Lob.submit :delete, bank_account_url(bank_account_id)
|
23
|
-
end
|
24
|
-
|
25
|
-
def verify(bank_account_id, options = {})
|
26
|
-
Lob.submit :post, "#{bank_account_url(bank_account_id)}/verify", options
|
27
|
-
end
|
28
|
-
|
29
|
-
private
|
30
|
-
|
31
|
-
def bank_account_url(bank_account_id = nil)
|
32
|
-
@resource.construct_url("bank_accounts", bank_account_id)
|
33
|
-
end
|
34
|
-
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
data/lib/lob/v1/check.rb
DELETED
@@ -1,33 +0,0 @@
|
|
1
|
-
module Lob
|
2
|
-
module V1
|
3
|
-
class Check
|
4
|
-
|
5
|
-
def initialize(resource)
|
6
|
-
@resource = resource
|
7
|
-
end
|
8
|
-
|
9
|
-
def list(options={})
|
10
|
-
Lob.submit(:get, check_url, options)
|
11
|
-
end
|
12
|
-
|
13
|
-
def find(check_id)
|
14
|
-
Lob.submit :get, check_url(check_id)
|
15
|
-
end
|
16
|
-
|
17
|
-
def create(options = {})
|
18
|
-
Lob.submit :post, check_url, options
|
19
|
-
end
|
20
|
-
|
21
|
-
def destroy(check_id)
|
22
|
-
Lob.submit :delete, check_url(check_id)
|
23
|
-
end
|
24
|
-
|
25
|
-
private
|
26
|
-
|
27
|
-
def check_url(check_id = nil)
|
28
|
-
@resource.construct_url("checks", check_id)
|
29
|
-
end
|
30
|
-
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
data/lib/lob/v1/country.rb
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
module Lob
|
2
|
-
module V1
|
3
|
-
class Country
|
4
|
-
|
5
|
-
def initialize(resource)
|
6
|
-
@resource = resource
|
7
|
-
end
|
8
|
-
|
9
|
-
def list(options={})
|
10
|
-
Lob.submit(:get, country_url, options)
|
11
|
-
end
|
12
|
-
|
13
|
-
private
|
14
|
-
|
15
|
-
def country_url
|
16
|
-
@resource.construct_url("countries")
|
17
|
-
end
|
18
|
-
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
data/lib/lob/v1/job.rb
DELETED
@@ -1,39 +0,0 @@
|
|
1
|
-
module Lob
|
2
|
-
module V1
|
3
|
-
class Job
|
4
|
-
|
5
|
-
def initialize(resource)
|
6
|
-
@resource = resource
|
7
|
-
end
|
8
|
-
|
9
|
-
def list(options={})
|
10
|
-
Lob.submit(:get, job_url, options)
|
11
|
-
end
|
12
|
-
|
13
|
-
def find(job_id)
|
14
|
-
Lob.submit :get, job_url(job_id)
|
15
|
-
end
|
16
|
-
|
17
|
-
def create(options = {})
|
18
|
-
if options[:objects].is_a?(Array)
|
19
|
-
options[:objects].each_with_index do |object, index|
|
20
|
-
options["object#{index+1}"] = object
|
21
|
-
end
|
22
|
-
else
|
23
|
-
options["object1"] = options[:objects]
|
24
|
-
end
|
25
|
-
options.delete(:objects)
|
26
|
-
|
27
|
-
Lob.submit :post, job_url, options
|
28
|
-
end
|
29
|
-
|
30
|
-
|
31
|
-
private
|
32
|
-
|
33
|
-
def job_url(job_id = nil)
|
34
|
-
@resource.construct_url("jobs", job_id)
|
35
|
-
end
|
36
|
-
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
data/lib/lob/v1/letter.rb
DELETED
@@ -1,33 +0,0 @@
|
|
1
|
-
module Lob
|
2
|
-
module V1
|
3
|
-
class Letter
|
4
|
-
|
5
|
-
def initialize(resource)
|
6
|
-
@resource = resource
|
7
|
-
end
|
8
|
-
|
9
|
-
def list(options={})
|
10
|
-
Lob.submit(:get, letter_url, options)
|
11
|
-
end
|
12
|
-
|
13
|
-
def find(letter_id)
|
14
|
-
Lob.submit :get, letter_url(letter_id)
|
15
|
-
end
|
16
|
-
|
17
|
-
def create(options = {})
|
18
|
-
Lob.submit :post, letter_url, options
|
19
|
-
end
|
20
|
-
|
21
|
-
def destroy(letter_id)
|
22
|
-
Lob.submit :delete, letter_url(letter_id)
|
23
|
-
end
|
24
|
-
|
25
|
-
private
|
26
|
-
|
27
|
-
def letter_url(job_id = nil)
|
28
|
-
@resource.construct_url("letters", job_id)
|
29
|
-
end
|
30
|
-
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
data/lib/lob/v1/object.rb
DELETED
@@ -1,33 +0,0 @@
|
|
1
|
-
module Lob
|
2
|
-
module V1
|
3
|
-
class Object
|
4
|
-
|
5
|
-
def initialize(resource)
|
6
|
-
@resource = resource
|
7
|
-
end
|
8
|
-
|
9
|
-
def list(options = {})
|
10
|
-
Lob.submit(:get, object_url, options)
|
11
|
-
end
|
12
|
-
|
13
|
-
def find(lob_object_id)
|
14
|
-
Lob.submit :get, object_url(lob_object_id)
|
15
|
-
end
|
16
|
-
|
17
|
-
def create(options = {})
|
18
|
-
Lob.submit :post, object_url, options
|
19
|
-
end
|
20
|
-
|
21
|
-
def destroy(lob_object_id)
|
22
|
-
Lob.submit :delete, object_url(lob_object_id)
|
23
|
-
end
|
24
|
-
|
25
|
-
private
|
26
|
-
|
27
|
-
def object_url(lob_object_id = nil)
|
28
|
-
@resource.construct_url("objects", lob_object_id)
|
29
|
-
end
|
30
|
-
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
data/lib/lob/v1/postcard.rb
DELETED
@@ -1,33 +0,0 @@
|
|
1
|
-
module Lob
|
2
|
-
module V1
|
3
|
-
class Postcard
|
4
|
-
|
5
|
-
def initialize(resource)
|
6
|
-
@resource = resource
|
7
|
-
end
|
8
|
-
|
9
|
-
def list(options={})
|
10
|
-
Lob.submit(:get, postcard_url, options)
|
11
|
-
end
|
12
|
-
|
13
|
-
def find(postcard_id)
|
14
|
-
Lob.submit :get, postcard_url(postcard_id)
|
15
|
-
end
|
16
|
-
|
17
|
-
def create(options = {})
|
18
|
-
Lob.submit :post, postcard_url, options
|
19
|
-
end
|
20
|
-
|
21
|
-
def destroy(postcard_id)
|
22
|
-
Lob.submit :delete, postcard_url(postcard_id)
|
23
|
-
end
|
24
|
-
|
25
|
-
private
|
26
|
-
|
27
|
-
def postcard_url(postcard_id = nil)
|
28
|
-
@resource.construct_url("postcards", postcard_id)
|
29
|
-
end
|
30
|
-
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
data/lib/lob/v1/resource.rb
DELETED
@@ -1,69 +0,0 @@
|
|
1
|
-
module Lob
|
2
|
-
module V1
|
3
|
-
class Resource
|
4
|
-
|
5
|
-
attr_accessor :options
|
6
|
-
|
7
|
-
def initialize(options)
|
8
|
-
@options = options
|
9
|
-
end
|
10
|
-
|
11
|
-
def areas
|
12
|
-
Lob::V1::Area.new(self)
|
13
|
-
end
|
14
|
-
|
15
|
-
def addresses
|
16
|
-
Lob::V1::Address.new(self)
|
17
|
-
end
|
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
|
-
|
31
|
-
def jobs
|
32
|
-
Lob::V1::Job.new(self)
|
33
|
-
end
|
34
|
-
|
35
|
-
def letters
|
36
|
-
Lob::V1::Letter.new(self)
|
37
|
-
end
|
38
|
-
|
39
|
-
def objects
|
40
|
-
Lob::V1::Object.new(self)
|
41
|
-
end
|
42
|
-
|
43
|
-
def postcards
|
44
|
-
Lob::V1::Postcard.new(self)
|
45
|
-
end
|
46
|
-
|
47
|
-
def routes
|
48
|
-
Lob::V1::Route.new(self)
|
49
|
-
end
|
50
|
-
|
51
|
-
def settings
|
52
|
-
Lob::V1::Setting.new(self)
|
53
|
-
end
|
54
|
-
|
55
|
-
def states
|
56
|
-
Lob::V1::State.new(self)
|
57
|
-
end
|
58
|
-
|
59
|
-
def base_url
|
60
|
-
"#{@options[:protocol]}://#{@options[:api_key]}:@#{@options[:api_host]}/v1"
|
61
|
-
end
|
62
|
-
|
63
|
-
def construct_url(resource_type, resource_id=nil)
|
64
|
-
"#{base_url}/#{resource_type}#{'/' + resource_id if resource_id}"
|
65
|
-
end
|
66
|
-
|
67
|
-
end
|
68
|
-
end
|
69
|
-
end
|