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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 73c25870f258cf39d0d433b254712629a7ca7e91
4
- data.tar.gz: 6c7b1d259b1e8d8ee8f48398ac03290608d567a7
3
+ metadata.gz: da1de55d24c191d96b977778bc662314c4a6523d
4
+ data.tar.gz: 1a6bf843e2f9730735a0aa6ad5c89b228eb77c75
5
5
  SHA512:
6
- metadata.gz: 08df0587f62aa357c84323426dbc3cb81906be0c56a888fd5c283222ef29734373ac775e27722911525669554476545bd028ede36fa313c1dfee2c5258522151
7
- data.tar.gz: 97597db31774db70091e0dc49f2a6e71ab1a9ce28545e4c34a715094b4aa97dfed4252b9f91721ca7ae92ac95777b117f1085cb594f994c1e8871387b1f56e2f
6
+ metadata.gz: 22cddc118df4adee9bad8bc045a98138e82353b9d4783a9912dec8e75e87dede1183ba0f59c5715b8c91b416111b6cba38a96ac6175b201259cbe29547835504
7
+ data.tar.gz: 151991770ed6e72b43710473c35b9d5f34c09f2c66aaf72d5bbda99aab89955161261fddfe9bc0dd7c44f3d2bf4953947cd5746f9b5f8a14678f43d94fa14556
data/.gitignore CHANGED
@@ -3,6 +3,7 @@
3
3
  .bundle
4
4
  .config
5
5
  .yardoc
6
+ .DS_Store
6
7
  Gemfile.lock
7
8
  InstalledFiles
8
9
  _yardoc
@@ -16,4 +17,4 @@ test/tmp
16
17
  test/version_tmp
17
18
  tmp
18
19
  spec/vcr_cassettes/
19
- spec/samples/
20
+ spec/samples/
data/README.md CHANGED
@@ -1,6 +1,6 @@
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) ![](http://ruby-gem-downloads-badge.herokuapp.com/lob?color=green)
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)
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
- ### Initialization and configuration
36
+ Supported Image Types
37
+ --------
38
+ The lob.com API supports the following image types:
37
39
 
38
- ```ruby
39
- # To initialize a Lob object
40
- @lob = Lob(api_key: "your-api-key")
40
+ - PDF
41
+ - PNG
42
+ - JPEG
41
43
 
42
- # Alternatively, to set the API key for all calls in the future
43
- Lob.api_key = "your-api-key"
44
- @lob = Lob() # don't forget the paranthesis!
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
- ### Alternatively, you can use initialize and configure like this
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
- @lob.areas.list
431
+ @lob.areas.list
413
432
 
414
- # you can also pass count and offset
415
- @lob.areas.list(count: 10, offset: 3)
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
+ )
@@ -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
+ )
@@ -26,6 +26,9 @@ module Lob
26
26
  Lob.submit :post, bank_account_url, options
27
27
  end
28
28
 
29
+ def destroy(bank_account_id)
30
+ Lob.submit :delete, bank_account_url(bank_account_id)
31
+ end
29
32
 
30
33
  private
31
34
 
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.4"
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", ">= 0"
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"
@@ -4,13 +4,12 @@ describe Lob::V1::Address do
4
4
 
5
5
  let(:sample_params) {
6
6
  {
7
- name: "Test",
8
- email: "test@test.com",
9
- address_line1: "220 WILLIAM T MORRISSEY BLVD",
10
- city: "Boston",
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: 02125
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: "123456789",
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
@@ -15,7 +15,7 @@ describe Lob::V1::Check do
15
15
  }
16
16
 
17
17
  @sample_bank_account_params = {
18
- routing_number: "123456789",
18
+ routing_number: "122100024",
19
19
  account_number: "123456789"
20
20
  }
21
21
  end
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'
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-08-01 00:00:00.000000000 Z
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