lob 1.11.0 → 1.12.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8f49c6eee569ce8ae820f9b1cb73be42d8237421
4
- data.tar.gz: d8ca2304fd2a2e320e771d260b712b73a96a7c3c
3
+ metadata.gz: 5693e0fab190aaf395879ca007343a932cfbee1c
4
+ data.tar.gz: d5aaa570fb388bce675e1c01c9f7c03b2d90ec99
5
5
  SHA512:
6
- metadata.gz: cc75178045eef86ff9633f173c1796544e983a0308890f6932445395bcea7b3c88895812b28ef25bcf4aa41b975c6cbcc8a1c347b742ef671828554343c7a2d1
7
- data.tar.gz: 5adfe47244f5282011443dd34ee4c5475482c3e9f3f6604064e96e2fb33f595ce74ac05928089ec7e5386e1afafd11ee0f36ff622d1fb1e6471dea4c466fe42e
6
+ metadata.gz: 598edf4d2c1f3164d79a5987807e6bb3f4a5836e7574b8fd56021d5ca263fdffa37251063d99eb93e006888ef74ee8cfe099b4b75b15539bee6407af157223a6
7
+ data.tar.gz: 02e8879f217555d2f91b81823b4f6d873432caf8b8df333a255eef63e4c1d7bbbef0b7f0178c3039b79106f5d49bcdbfc8a0ca93e2c4adf09a82cac6d7404f17
data/CHANGELOG.md CHANGED
@@ -1,3 +1,6 @@
1
+ ## [**1.12.0**](https://github.com/lob/lob-ruby/releases/tag/v1.12.0)
2
+ - [**#110**] (https://github.com/lob/lob-ruby/pull/110) fixes metadata filter
3
+
1
4
  ## [**1.10.0**](https://github.com/lob/lob-ruby/releases/tag/v1.10.0)
2
5
  - [**#100**] (https://github.com/lob/lob-ruby/pull/100) adds support for Simple Letter Service
3
6
 
data/README.md CHANGED
@@ -2,7 +2,11 @@
2
2
 
3
3
  [![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/lob/lob-ruby?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
4
4
 
5
- [![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://coveralls.io/repos/lob/lob-ruby/badge.svg?branch=master)](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)
5
+ [![Build Status](https://travis-ci.org/lob/lob-ruby.svg?branch=master)](https://travis-ci.org/lob/lob-ruby)
6
+ [![Gem Version](https://badge.fury.io/rb/lob.svg)](http://badge.fury.io/rb/lob)
7
+ [![Dependency Status](https://gemnasium.com/lob/lob-ruby.svg)](https://gemnasium.com/lob/lob-ruby)
8
+ [![Coverage Status](https://coveralls.io/repos/lob/lob-ruby/badge.svg?branch=master)](https://coveralls.io/r/lob/lob-ruby?branch=master)
9
+ [![Downloads](http://ruby-gem-downloads-badge.herokuapp.com/lob?color=green&type=total)](https://rubygems.org/gems/lob)
6
10
 
7
11
  Ruby wrapper for the [Lob.com](http://lob.com) API. See the full Lob.com [API Documentation](https://lob.com/docs/ruby). This gem gives you an ActiveRecord-style syntax to use the Lob.com API.
8
12
 
@@ -86,6 +90,9 @@ The Ruby interpreter assumes it's not of base-10 and tries to convert it to base
86
90
 
87
91
  We've provided various examples for you to try out [here](https://github.com/lob/lob-ruby/tree/master/examples).
88
92
 
93
+ There are simple scripts to demonstrate how to create all the core Lob products (checks, letters, postcards, jobs etc.), as well as more complex examples that utilize other libraries and external files:
94
+
95
+ - [Creating Dynamic Postcards with HTML and Data](https://github.com/lob/lob-ruby/tree/master/examples/csv_postcards)
89
96
  ## API Documentation
90
97
 
91
98
  - [Introduction](https://lob.com/docs/ruby#introduction)
@@ -0,0 +1,27 @@
1
+ # Ruby Examples
2
+
3
+ This directory contains a collection of ruby example to help get you started using the Lob API. As always, feel free to [contact us](https://lob.com/support) directly if you have any questions.
4
+
5
+ ## /csv_postcards/
6
+
7
+ An example showing how to dynamically create postcards from a CSV using HTML, a custom font, variable data, and Lob's [Simple Postcard Service](https://lob.com/services/postcards).
8
+
9
+ ## /checks.rb
10
+
11
+ An example showing how to create a check using Lob's [Simple Check Service](https://lob.com/services/checks).
12
+
13
+ ## /create_pdf.rb
14
+
15
+ An example showing how to create PDF's with the Prawn library.
16
+
17
+ ## /jobs.rb
18
+
19
+ An example showing how to create objects and jobs using Lob's [Simple Print Service](https://lob.com/services/sps).
20
+
21
+ ## /letters.rb
22
+
23
+ And example showing how to create letters using Lob's [Simple Letter Service](https://lob.com/services/letters).
24
+
25
+ ## /postcards.rb
26
+
27
+ An example showing how to create postcards using Lob's [Simple Postcard Service](https://lob.com/services/postcards).
@@ -0,0 +1,45 @@
1
+ require 'lob'
2
+ require 'csv'
3
+
4
+ # Initialize Lob object
5
+ Lob.api_key = 'test_0dc8d51e0acffcb1880e0f19c79b2f5b0cc'
6
+ @lob = Lob.load
7
+
8
+ # Load the HTML from postcard_front.html and postcard_back.html.
9
+ front_html = File.open(File.expand_path('../postcard_front.html', __FILE__)).read
10
+ back_html = File.open(File.expand_path('../postcard_back.html', __FILE__)).read
11
+
12
+ # Parse the CSV and create the postcards.
13
+ CSV.foreach(File.expand_path('../input.csv', __FILE__)) do |row|
14
+ postcard = @lob.postcards.create(
15
+ description: 'CSV Test',
16
+ to: {
17
+ name: row[5],
18
+ address_line1: row[6],
19
+ address_line2: row[7],
20
+ city: row[8],
21
+ state: row[9],
22
+ zip: row[10],
23
+ country: row[11]
24
+ },
25
+ from: {
26
+ name: 'Lob',
27
+ address_line1: '123 Main Street',
28
+ city: 'San Francisco',
29
+ state: 'CA',
30
+ zip: '94185',
31
+ country: 'US'
32
+ },
33
+ setting: 1002,
34
+ front: front_html,
35
+ back: back_html,
36
+ data: {
37
+ background_image: row[1],
38
+ background_color: row[2],
39
+ name: row[0],
40
+ car: row[3],
41
+ mileage: row[4]
42
+ }
43
+ )
44
+ puts postcard['url']
45
+ end
@@ -0,0 +1,7 @@
1
+ Peter,https://s3-us-west-2.amazonaws.com/lob-assets/df-car2.jpg,LightBlue,Jeep Wrangler,65000,Peter,123 Main Street,Apt. 101,San Francisco,CA,94107,US
2
+ Marcus,https://s3-us-west-2.amazonaws.com/lob-assets/df-car.jpg,Bisque,Honda Pilot,65000,Marcus,456 Oak Street ,Apt. 102,San Francisco,CA,94185,US
3
+ Leore,https://s3-us-west-2.amazonaws.com/lob-assets/df-car2.jpg,PaleGreen,Jeep Wrangler,50000,Leore,123 Test Street,Apt. 101,San Francisco,CA,94105,US
4
+ Harry,https://s3-us-west-2.amazonaws.com/lob-assets/df-car.jpg,Thistle,Jeep Wrangler,50000,Harry,789 Elm Street,Apt. 101,San Francisco,CA,94107,US
5
+ Elnaz,https://s3-us-west-2.amazonaws.com/lob-assets/df-car2.jpg,PaleTurqoise,Jeep Wrangler,35000,Elnaz,111 Washington Street,Apt. 101,San Francisco,CA,94112,US
6
+ Robin,https://s3-us-west-2.amazonaws.com/lob-assets/df-car.jpg,Wheat,Jeep Wrangler,35000,Robin,888 Jefferson Street,Apt. 101,San Francisco,CA,94197,US
7
+ Russell,https://s3-us-west-2.amazonaws.com/lob-assets/df-car2.jpg,WhiteSmoke,Jeep Wrangler,15000,Russell,1212 Fourth Street,Apt. 101,San Francisco,CA,94166,US
@@ -0,0 +1,38 @@
1
+ <html>
2
+ <head>
3
+ <title>Lob.com Sample 6x11 Postcard Back Template 1</title>
4
+ <style>
5
+ @font-face {
6
+ font-family: 'Arimo';
7
+ font-style: normal;
8
+ font-weight: 400;
9
+ src: url('https://s3-us-west-2.amazonaws.com/lob-assets/Arimo-Regular.ttf') format('truetype');
10
+ }
11
+ body {
12
+ width:11.25in;
13
+ height:6.25in;
14
+ margin:0;
15
+ padding:0;
16
+ background-size: 11.25in 6.25in;
17
+ }
18
+ #left-box {
19
+ font-family: Arimo;
20
+ font-size: .25in;
21
+ background-color: {{background_color}};
22
+ width: 5.85in;
23
+ height: 5.85in;
24
+ position: absolute;
25
+ top: 0;
26
+ left: 0;
27
+ padding: .4in .6in 0 .4in;
28
+ }
29
+ </style>
30
+ </head>
31
+ <body>
32
+ <div id="left-box">
33
+ Hey {{name}},<br><br>
34
+ Your {{car}} is due for its {{mileage}} mile service. Schedule an appointment today!<br><br>
35
+ Make sure to bring this card to receive great savings!<br><br>
36
+ </div>
37
+ </body>
38
+ </html>
@@ -0,0 +1,25 @@
1
+ <html>
2
+ <head>
3
+ <title>Lob.com Sample 6x11 Postcard Front</title>
4
+ <style>
5
+ *, *:before, *:after {
6
+ -webkit-box-sizing: border-box;
7
+ -moz-box-sizing: border-box;
8
+ box-sizing: border-box;
9
+ }
10
+ body {
11
+ width: 11.25in;
12
+ height: 6.25in;
13
+ margin: 0;
14
+ padding: 0;
15
+ /* If using an image, the background image should have dimensions of 1875x1275 pixels. */
16
+ background-image: url({{background_image}});
17
+ background-size: 11.25in 6.25in;
18
+ background-repeat: no-repeat;
19
+ }
20
+ </style>
21
+ </head>
22
+
23
+ <body>
24
+ </body>
25
+ </html>
data/lib/lob.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  require "rest-client"
2
+ require "rack"
2
3
  require "json"
3
4
  require "lob/version"
4
5
  require "lob/errors/lob_error"
@@ -29,9 +30,10 @@ module Lob
29
30
 
30
31
  begin
31
32
  if method == :get || method == :delete
33
+ # Hack to URL encode nested objects like metadata.
34
+ url = "#{url}?#{Rack::Utils.build_nested_query(parameters)}"
32
35
  JSON.parse(RestClient.send(method, url, {
33
36
  user_agent: 'Lob/v1 RubyBindings/' + clientVersion,
34
- params: parameters,
35
37
  "Lob-Version" => self.api_version
36
38
  }))
37
39
  else
data/lib/lob/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Lob
2
- VERSION = "1.11.0"
2
+ VERSION = "1.12.0"
3
3
  end
data/lob.gemspec CHANGED
@@ -19,6 +19,7 @@ Gem::Specification.new do |spec|
19
19
  spec.require_paths = ["lib"]
20
20
 
21
21
  spec.add_dependency "rest-client", "~> 1.8"
22
+ spec.add_dependency "rack", "~> 1.6"
22
23
 
23
24
  spec.add_dependency "prawn"
24
25
 
@@ -69,10 +69,10 @@ describe Lob::V1::Check do
69
69
  result = subject.checks.create(
70
70
  bank_account: new_bank_account["id"],
71
71
  to: new_address["id"],
72
- amount: "2000"
72
+ amount: "2000.12"
73
73
  )
74
74
 
75
- result["amount"].to_s.must_equal("2000.00")
75
+ result["amount"].to_s.must_equal("2000.12")
76
76
  end
77
77
  end
78
78
  end
@@ -25,7 +25,7 @@ describe Lob::V1::Letter do
25
25
  new_letter = subject.letters.create(
26
26
  description: "TestLetter",
27
27
  color: true,
28
- file: "https://s3-us-west-2.amazonaws.com/lob-assets/100_101_doc.pdf",
28
+ file: "https://s3-us-west-2.amazonaws.com/lob-assets/letter-goblue.pdf",
29
29
  to: new_address["id"],
30
30
  from: new_address["id"]
31
31
  )
@@ -45,7 +45,7 @@ describe Lob::V1::Letter do
45
45
  new_letter = subject.letters.create(
46
46
  description: "TestLetter",
47
47
  color: true,
48
- file: "https://s3-us-west-2.amazonaws.com/lob-assets/100_101_doc.pdf",
48
+ file: "https://s3-us-west-2.amazonaws.com/lob-assets/letter-goblue.pdf",
49
49
  to: new_address["id"],
50
50
  from: @sample_address_params
51
51
  )
@@ -80,7 +80,7 @@ describe Lob::V1::Letter do
80
80
  new_letter = subject.letters.create(
81
81
  description: "TestLetter",
82
82
  color: true,
83
- file: "https://s3-us-west-2.amazonaws.com/lob-assets/100_101_doc.pdf",
83
+ file: "https://s3-us-west-2.amazonaws.com/lob-assets/letter-goblue.pdf",
84
84
  to: new_address["id"],
85
85
  from: new_address["id"]
86
86
  )
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.11.0
4
+ version: 1.12.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lob
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-05-01 00:00:00.000000000 Z
11
+ date: 2015-05-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rest-client
@@ -24,6 +24,20 @@ dependencies:
24
24
  - - ~>
25
25
  - !ruby/object:Gem::Version
26
26
  version: '1.8'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rack
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: '1.6'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: '1.6'
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: prawn
29
43
  requirement: !ruby/object:Gem::Requirement
@@ -178,8 +192,13 @@ files:
178
192
  - LICENSE.txt
179
193
  - README.md
180
194
  - Rakefile
195
+ - examples/README.md
181
196
  - examples/checks.rb
182
197
  - examples/create_pdf.rb
198
+ - examples/csv_postcards/create_postcards.rb
199
+ - examples/csv_postcards/input.csv
200
+ - examples/csv_postcards/postcard_back.html
201
+ - examples/csv_postcards/postcard_front.html
183
202
  - examples/jobs.rb
184
203
  - examples/letters.rb
185
204
  - examples/postcards.rb