From 5e87487056ba97c1428abe1003e3e3797f240838 Mon Sep 17 00:00:00 2001 From: Peter Nagel Date: Wed, 10 Dec 2014 10:41:45 -0800 Subject: [PATCH 1/2] Updated Version --- lob/version.py | 2 +- setup.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lob/version.py b/lob/version.py index 4a45c12..18e2aef 100644 --- a/lob/version.py +++ b/lob/version.py @@ -1 +1 @@ -VERSION = '2.9' +VERSION = '2.10' diff --git a/setup.py b/setup.py index 5c2e38e..8035b8a 100644 --- a/setup.py +++ b/setup.py @@ -7,7 +7,7 @@ setup ( name = 'lob', - version = '2.9', + version = '2.10', author = 'Lob', author_email = 'support@lob.com', packages = ['lob'], From 7a8823249da3955c0854633d737bb1f87f022803 Mon Sep 17 00:00:00 2001 From: Peter Nagel Date: Wed, 17 Dec 2014 16:13:51 -0800 Subject: [PATCH 2/2] added support for Lob-Version header --- README.md | 3 +++ examples/check.py | 2 +- lob/api_requestor.py | 3 +++ tests/test_lob.py | 4 ++++ 4 files changed, 11 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 1568f8d..23ae2dc 100644 --- a/README.md +++ b/README.md @@ -52,6 +52,9 @@ To initialize the wrapper, import `lob` and set the `api_key` ```python import lob lob.api_key = 'your-api-key' + +// set an api version (optional) +lob.api_version = 'api-version' ``` ## API Reference diff --git a/examples/check.py b/examples/check.py index 6fdcd40..accd29c 100644 --- a/examples/check.py +++ b/examples/check.py @@ -24,7 +24,7 @@ # Creating a Bank Account using the previously created account_address example_bank_account = lob.BankAccount.create( - routing_number = '123456789', + routing_number = '122100024', account_number = '1234564789', bank_address = { 'name': 'Bank Address', diff --git a/lob/api_requestor.py b/lob/api_requestor.py index 8ec3f5d..c389db3 100644 --- a/lob/api_requestor.py +++ b/lob/api_requestor.py @@ -38,6 +38,9 @@ def request(self, method, url, params=None): 'User-Agent': 'Lob/v1 PythonBindings/%s' % VERSION } + if hasattr(lob, 'api_version'): + headers['Lob-Version'] = lob.api_version + if method == 'get': return self.parse_response( requests.get(lob.api_base + url, auth=(self.api_key, ''), params=params, headers=headers) diff --git a/tests/test_lob.py b/tests/test_lob.py index 18c4ad7..d70d12c 100644 --- a/tests/test_lob.py +++ b/tests/test_lob.py @@ -4,6 +4,10 @@ class TestLob(unittest.TestCase): def setUp(self): lob.api_key = 'asdf' + lob.api_version = 'apiVersion' def test_bad_auth(self): self.assertRaises(lob.error.AuthenticationError, lob.Address.list) + + def test_set_version(self): + self.assertEqual(lob.api_version, 'apiVersion')