dwollav2
Advanced tools
+153
-191
@@ -1,4 +0,4 @@ | ||
| Metadata-Version: 1.1 | ||
| Metadata-Version: 2.1 | ||
| Name: dwollav2 | ||
| Version: 1.3.0 | ||
| Version: 1.4.0 | ||
| Summary: Official Dwolla V2 API client | ||
@@ -9,257 +9,217 @@ Home-page: https://docsv2.dwolla.com | ||
| License: MIT | ||
| Description: DwollaV2 | ||
| ======== | ||
| Description: # DwollaV2 | ||
| .. figure:: https://travis-ci.org/Dwolla/dwolla-v2-python.svg | ||
| :alt: Build Status | ||
|  | ||
| Build Status | ||
| Dwolla V2 Python client. | ||
| `API Documentation <https://docsv2.dwolla.com>`__ | ||
| [API Documentation](https://docsv2.dwolla.com) | ||
| Installation | ||
| ------------ | ||
| ## Installation | ||
| ``dwollav2`` is available on | ||
| `PyPi <https://pypi.python.org/pypi/dwollav2>`__, and therefore can be | ||
| installed automagically via | ||
| `pip <https://pip.pypa.io/en/stable/installing/>`__. | ||
| `dwollav2` is available on [PyPi](https://pypi.python.org/pypi/dwollav2), and therefore can be installed automagically via [pip](https://pip.pypa.io/en/stable/installing/). | ||
| :: | ||
| ``` | ||
| pip install dwollav2 | ||
| ``` | ||
| pip install dwollav2 | ||
| ## `dwollav2.Client` | ||
| ``dwollav2.Client`` | ||
| ------------------- | ||
| ### Basic usage | ||
| Basic usage | ||
| ~~~~~~~~~~~ | ||
| Create a client using your application's consumer key and secret found on the applications page | ||
| ([Sandbox][apsandbox], [Production][approd]). | ||
| Create a client using your application's consumer key and secret found | ||
| on the applications page | ||
| (`Sandbox <https://dashboard-sandbox.dwolla.com/applications>`__, | ||
| `Production <https://dashboard.dwolla.com/applications>`__). | ||
| [apsandbox]: https://dashboard-sandbox.dwolla.com/applications | ||
| [approd]: https://dashboard.dwolla.com/applications | ||
| .. code:: python | ||
| ```python | ||
| client = dwollav2.Client(key = os.environ['DWOLLA_APP_KEY'], secret = os.environ['DWOLLA_APP_SECRET']) | ||
| ``` | ||
| client = dwollav2.Client(id = os.environ['DWOLLA_APP_KEY'], secret = os.environ['DWOLLA_APP_SECRET']) | ||
| ### Using the sandbox environment (optional) | ||
| Using the sandbox environment (optional) | ||
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
| ```python | ||
| client = dwollav2.Client( | ||
| key = os.environ['DWOLLA_APP_KEY'], | ||
| secret = os.environ['DWOLLA_APP_SECRET'], | ||
| environment = 'sandbox' | ||
| ) | ||
| ``` | ||
| .. code:: python | ||
| `environment` defaults to `'production'`. | ||
| client = dwollav2.Client( | ||
| key = os.environ['DWOLLA_APP_KEY'], | ||
| secret = os.environ['DWOLLA_APP_SECRET'], | ||
| environment = 'sandbox' | ||
| ) | ||
| ### Configure an `on_grant` callback (optional) | ||
| ``environment`` defaults to ``'production'``. | ||
| An `on_grant` callback is useful for storing new tokens when they are granted. The `on_grant` | ||
| callback is called with the `Token` that was just granted by the server. | ||
| Configure an ``on_grant`` callback (optional) | ||
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
| ```python | ||
| client = dwollav2.Client( | ||
| key = os.environ['DWOLLA_APP_KEY'], | ||
| secret = os.environ['DWOLLA_APP_SECRET'], | ||
| on_grant = lambda t: save(t) | ||
| ) | ||
| ``` | ||
| An ``on_grant`` callback is useful for storing new tokens when they are | ||
| granted. The ``on_grant`` callback is called with the ``Token`` that was | ||
| just granted by the server. | ||
| .. code:: python | ||
| client = dwollav2.Client( | ||
| key = os.environ['DWOLLA_APP_KEY'], | ||
| secret = os.environ['DWOLLA_APP_SECRET'], | ||
| on_grant = lambda t: save(t) | ||
| ) | ||
| It is highly recommended that you encrypt any token data you store. | ||
| ``Token`` | ||
| --------- | ||
| ## `Token` | ||
| Tokens can be used to make requests to the Dwolla V2 API. | ||
| Application tokens | ||
| ~~~~~~~~~~~~~~~~~~ | ||
| ### Application tokens | ||
| Application access tokens are used to authenticate against the API on | ||
| behalf of a consumer application. Application tokens can be used to | ||
| access resources in the API that either belong to the application itself | ||
| (``webhooks``, ``events``, ``webhook-subscriptions``) or the partner | ||
| Account that owns the consumer application (``accounts``, ``customers``, | ||
| ``funding-sources``, etc.). Application tokens are obtained by using the | ||
| ```client_credentials`` <https://tools.ietf.org/html/rfc6749#section-4.4>`__ | ||
| OAuth grant type: | ||
| Application access tokens are used to authenticate against the API on behalf of a consumer application. Application tokens can be used to access resources in the API that either belong to the application itself (`webhooks`, `events`, `webhook-subscriptions`) or the partner Account that owns the consumer application (`accounts`, `customers`, `funding-sources`, etc.). Application tokens are obtained by using the [`client_credentials`][client_credentials] OAuth grant type: | ||
| .. code:: python | ||
| [client_credentials]: https://tools.ietf.org/html/rfc6749#section-4.4 | ||
| application_token = client.Auth.client() | ||
| ```python | ||
| application_token = client.Auth.client() | ||
| ``` | ||
| *Application tokens do not include a ``refresh_token``. When an | ||
| application token expires, generate a new one using | ||
| ``client.Auth.client()``.* | ||
| _Application tokens do not include a `refresh_token`. When an application token expires, generate | ||
| a new one using `client.Auth.client()`._ | ||
| Initializing pre-existing tokens: | ||
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
| ### Initializing pre-existing tokens: | ||
| ``Token``\ s can be initialized with the following attributes: | ||
| `Token`s can be initialized with the following attributes: | ||
| .. code:: python | ||
| ```python | ||
| client.Token(access_token = '...', | ||
| expires_in = 123) | ||
| ``` | ||
| client.Token(access_token = '...', | ||
| expires_in = 123) | ||
| ## Requests | ||
| Requests | ||
| -------- | ||
| `Token`s can make requests using the `#get`, `#post`, and `#delete` methods. | ||
| ``Token``\ s can make requests using the ``#get``, ``#post``, and | ||
| ``#delete`` methods. | ||
| ```python | ||
| # GET api.dwolla.com/resource?foo=bar | ||
| token.get('resource', foo = 'bar') | ||
| .. code:: python | ||
| # POST api.dwolla.com/resource {"foo":"bar"} | ||
| token.post('resource', foo = 'bar') | ||
| # GET api.dwolla.com/resource?foo=bar | ||
| token.get('resource', foo = 'bar') | ||
| # POST api.dwolla.com/resource multipart/form-data foo=... | ||
| token.post('resource', foo = ('mclovin.jpg', open('mclovin.jpg', 'rb'), 'image/jpeg')) | ||
| # POST api.dwolla.com/resource {"foo":"bar"} | ||
| token.post('resource', foo = 'bar') | ||
| # PUT api.dwolla.com/resource {"foo":"bar"} | ||
| token.put('resource', foo = 'bar') | ||
| # POST api.dwolla.com/resource multipart/form-data foo=... | ||
| token.post('resource', foo = ('mclovin.jpg', open('mclovin.jpg', 'rb'), 'image/jpeg')) | ||
| # DELETE api.dwolla.com/resource | ||
| token.delete('resource') | ||
| ``` | ||
| # PUT api.dwolla.com/resource {"foo":"bar"} | ||
| token.put('resource', foo = 'bar') | ||
| #### Setting headers | ||
| # DELETE api.dwolla.com/resource | ||
| token.delete('resource') | ||
| To set additional headers on a request you can pass a `dict` of headers as the 3rd argument. | ||
| Setting headers | ||
| ^^^^^^^^^^^^^^^ | ||
| To set additional headers on a request you can pass a ``dict`` of | ||
| headers as the 3rd argument. | ||
| For example: | ||
| .. code:: python | ||
| ```python | ||
| token.post('customers', { 'firstName': 'John', 'lastName': 'Doe', 'email': 'jd@doe.com' }, | ||
| { 'Idempotency-Key': 'a52fcf63-0730-41c3-96e8-7147b5d1fb01' }) | ||
| ``` | ||
| token.post('customers', { 'firstName': 'John', 'lastName': 'Doe', 'email': 'jd@doe.com' }, | ||
| { 'Idempotency-Key': 'a52fcf63-0730-41c3-96e8-7147b5d1fb01' }) | ||
| ## Responses | ||
| Responses | ||
| --------- | ||
| Requests return a `Response`. | ||
| Requests return a ``Response``. | ||
| ```python | ||
| res = token.get('/') | ||
| .. code:: python | ||
| res.status | ||
| # => 200 | ||
| res = token.get('/') | ||
| res.headers | ||
| # => {'server'=>'cloudflare-nginx', 'date'=>'Mon, 28 Mar 2016 15:30:23 GMT', 'content-type'=>'application/vnd.dwolla.v1.hal+json; charset=UTF-8', 'content-length'=>'150', 'connection'=>'close', 'set-cookie'=>'__cfduid=d9dcd0f586c166d36cbd45b992bdaa11b1459179023; expires=Tue, 28-Mar-17 15:30:23 GMT; path=/; domain=.dwolla.com; HttpOnly', 'x-request-id'=>'69a4e612-5dae-4c52-a6a0-2f921e34a88a', 'cf-ray'=>'28ac1f81875941e3-MSP'} | ||
| res.status | ||
| # => 200 | ||
| res.body['_links']['events']['href'] | ||
| # => 'https://api-sandbox.dwolla.com/events' | ||
| ``` | ||
| res.headers | ||
| # => {'server'=>'cloudflare-nginx', 'date'=>'Mon, 28 Mar 2016 15:30:23 GMT', 'content-type'=>'application/vnd.dwolla.v1.hal+json; charset=UTF-8', 'content-length'=>'150', 'connection'=>'close', 'set-cookie'=>'__cfduid=d9dcd0f586c166d36cbd45b992bdaa11b1459179023; expires=Tue, 28-Mar-17 15:30:23 GMT; path=/; domain=.dwolla.com; HttpOnly', 'x-request-id'=>'69a4e612-5dae-4c52-a6a0-2f921e34a88a', 'cf-ray'=>'28ac1f81875941e3-MSP'} | ||
| ## Errors | ||
| res.body['_links']['events']['href'] | ||
| # => 'https://api-sandbox.dwolla.com/events' | ||
| If the server returns an error, a `dwollav2.Error` (or one of its subclasses) will be raised. | ||
| `dwollav2.Error`s are similar to `Response`s. | ||
| Errors | ||
| ------ | ||
| ```python | ||
| try: | ||
| token.get('/not-found') | ||
| except dwollav2.NotFoundError as e: | ||
| e.status | ||
| # => 404 | ||
| If the server returns an error, a ``dwollav2.Error`` (or one of its | ||
| subclasses) will be raised. ``dwollav2.Error``\ s are similar to | ||
| ``Response``\ s. | ||
| e.headers | ||
| # => {"server"=>"cloudflare-nginx", "date"=>"Mon, 28 Mar 2016 15:35:32 GMT", "content-type"=>"application/vnd.dwolla.v1.hal+json; profile=\"http://nocarrier.co.uk/profiles/vnd.error/\"; charset=UTF-8", "content-length"=>"69", "connection"=>"close", "set-cookie"=>"__cfduid=da1478bfdf3e56275cd8a6a741866ccce1459179332; expires=Tue, 28-Mar-17 15:35:32 GMT; path=/; domain=.dwolla.com; HttpOnly", "access-control-allow-origin"=>"*", "x-request-id"=>"667fca74-b53d-43db-bddd-50426a011881", "cf-ray"=>"28ac270abca64207-MSP"} | ||
| .. code:: python | ||
| e.body.code | ||
| # => "NotFound" | ||
| except dwollav2.Error: | ||
| # ... | ||
| ``` | ||
| try: | ||
| token.get('/not-found') | ||
| except dwollav2.NotFoundError: | ||
| e.status | ||
| # => 404 | ||
| ### `dwollav2.Error` subclasses: | ||
| e.headers | ||
| # => {"server"=>"cloudflare-nginx", "date"=>"Mon, 28 Mar 2016 15:35:32 GMT", "content-type"=>"application/vnd.dwolla.v1.hal+json; profile=\"http://nocarrier.co.uk/profiles/vnd.error/\"; charset=UTF-8", "content-length"=>"69", "connection"=>"close", "set-cookie"=>"__cfduid=da1478bfdf3e56275cd8a6a741866ccce1459179332; expires=Tue, 28-Mar-17 15:35:32 GMT; path=/; domain=.dwolla.com; HttpOnly", "access-control-allow-origin"=>"*", "x-request-id"=>"667fca74-b53d-43db-bddd-50426a011881", "cf-ray"=>"28ac270abca64207-MSP"} | ||
| _See https://docsv2.dwolla.com/#errors for more info._ | ||
| e.body.code | ||
| # => "NotFound" | ||
| except dwollav2.Error: | ||
| # ... | ||
| - `dwollav2.AccessDeniedError` | ||
| - `dwollav2.InvalidCredentialsError` | ||
| - `dwollav2.NotFoundError` | ||
| - `dwollav2.BadRequestError` | ||
| - `dwollav2.InvalidGrantError` | ||
| - `dwollav2.RequestTimeoutError` | ||
| - `dwollav2.ExpiredAccessTokenError` | ||
| - `dwollav2.InvalidRequestError` | ||
| - `dwollav2.ServerError` | ||
| - `dwollav2.ForbiddenError` | ||
| - `dwollav2.InvalidResourceStateError` | ||
| - `dwollav2.TemporarilyUnavailableError` | ||
| - `dwollav2.InvalidAccessTokenError` | ||
| - `dwollav2.InvalidScopeError` | ||
| - `dwollav2.UnauthorizedClientError` | ||
| - `dwollav2.InvalidAccountStatusError` | ||
| - `dwollav2.InvalidScopesError` | ||
| - `dwollav2.UnsupportedGrantTypeError` | ||
| - `dwollav2.InvalidApplicationStatusError` | ||
| - `dwollav2.InvalidVersionError` | ||
| - `dwollav2.UnsupportedResponseTypeError` | ||
| - `dwollav2.InvalidClientError` | ||
| - `dwollav2.MethodNotAllowedError` | ||
| - `dwollav2.ValidationError` | ||
| - `dwollav2.TooManyRequestsError` | ||
| - `dwollav2.ConflictError` | ||
| ``dwollav2.Error`` subclasses: | ||
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
| ## Development | ||
| *See https://docsv2.dwolla.com/#errors for more info.* | ||
| After checking out the repo, run `pip install -r requirements.txt` to install dependencies. | ||
| Then, run `python setup.py test` to run the tests. | ||
| - ``dwollav2.AccessDeniedError`` | ||
| - ``dwollav2.InvalidCredentialsError`` | ||
| - ``dwollav2.NotFoundError`` | ||
| - ``dwollav2.BadRequestError`` | ||
| - ``dwollav2.InvalidGrantError`` | ||
| - ``dwollav2.RequestTimeoutError`` | ||
| - ``dwollav2.ExpiredAccessTokenError`` | ||
| - ``dwollav2.InvalidRequestError`` | ||
| - ``dwollav2.ServerError`` | ||
| - ``dwollav2.ForbiddenError`` | ||
| - ``dwollav2.InvalidResourceStateError`` | ||
| - ``dwollav2.TemporarilyUnavailableError`` | ||
| - ``dwollav2.InvalidAccessTokenError`` | ||
| - ``dwollav2.InvalidScopeError`` | ||
| - ``dwollav2.UnauthorizedClientError`` | ||
| - ``dwollav2.InvalidAccountStatusError`` | ||
| - ``dwollav2.InvalidScopesError`` | ||
| - ``dwollav2.UnsupportedGrantTypeError`` | ||
| - ``dwollav2.InvalidApplicationStatusError`` | ||
| - ``dwollav2.InvalidVersionError`` | ||
| - ``dwollav2.UnsupportedResponseTypeError`` | ||
| - ``dwollav2.InvalidClientError`` | ||
| - ``dwollav2.MethodNotAllowedError`` | ||
| - ``dwollav2.ValidationError`` | ||
| - ``dwollav2.TooManyRequestsError`` | ||
| - ``dwollav2.ConflictError`` | ||
| To install this gem onto your local machine, run `pip install -e .`. | ||
| Development | ||
| ----------- | ||
| ## Contributing | ||
| After checking out the repo, run ``pip install -r requirements.txt`` to | ||
| install dependencies. Then, run ``python setup.py test`` to run the | ||
| tests. | ||
| Bug reports and pull requests are welcome on GitHub at https://github.com/Dwolla/dwolla-v2-python. | ||
| To install this gem onto your local machine, run ``pip install -e .``. | ||
| ## License | ||
| Contributing | ||
| ------------ | ||
| The package is available as open source under the terms of the [MIT License](https://github.com/Dwolla/dwolla-v2-python). | ||
| Bug reports and pull requests are welcome on GitHub at | ||
| https://github.com/Dwolla/dwolla-v2-python. | ||
| ## Changelog | ||
| License | ||
| ------- | ||
| - **1.4.0** Allow kwargs to be passed to `get`, `post`, and `delete` methods. | ||
| - **1.3.0** Change token URLs, update dependencies. | ||
| - **1.2.4** Create a new session for each Token. | ||
| - **1.2.3** Check if IOBase when checking to see if something is a file. | ||
| - **1.2.2** Strip domain from URLs provided to token.\* methods. | ||
| - **1.2.1** Update sandbox URLs from uat => sandbox. | ||
| - **1.2.0** Refer to Client id as key. | ||
| - **1.1.8** Support `verified_account` and `dwolla_landing` auth flags | ||
| - **1.1.7** Use session over connections for [performance improvement](http://docs.python-requests.org/en/master/user/advanced/#session-objects) ([#8](https://github.com/Dwolla/dwolla-v2-python/pull/8) - Thanks @bfeeser!) | ||
| - **1.1.5** Fix file upload bug when using with Python 2 ([#6](https://github.com/Dwolla/dwolla-v2-python/issues/6)) | ||
| - **1.1.2** Add `TooManyRequestsError` and `ConflictError` | ||
| - **1.1.1** Add MANIFEST.in | ||
| - **1.1.0** Support per-request headers | ||
| The package is available as open source under the terms of the `MIT | ||
| License <https://github.com/Dwolla/dwolla-v2-python>`__. | ||
| Changelog | ||
| --------- | ||
| - **1.2.4** Create a new session for each Token. | ||
| - **1.2.3** Check if IOBase when checking to see if something is a | ||
| file. | ||
| - **1.2.2** Strip domain from URLs provided to token.\* methods. | ||
| - **1.2.1** Update sandbox URLs from uat => sandbox. | ||
| - **1.2.0** Refer to Client id as key. | ||
| - **1.1.8** Support ``verified_account`` and ``dwolla_landing`` auth | ||
| flags | ||
| - **1.1.7** Use session over connections for `performance | ||
| improvement <http://docs.python-requests.org/en/master/user/advanced/#session-objects>`__ | ||
| (`#8 <https://github.com/Dwolla/dwolla-v2-python/pull/8>`__ - Thanks | ||
| @bfeeser!) | ||
| - **1.1.5** Fix file upload bug when using with Python 2 | ||
| (`#6 <https://github.com/Dwolla/dwolla-v2-python/issues/6>`__) | ||
| - **1.1.2** Add ``TooManyRequestsError`` and ``ConflictError`` | ||
| - **1.1.1** Add MANIFEST.in | ||
| - **1.1.0** Support per-request headers | ||
| Platform: UNKNOWN | ||
@@ -275,6 +235,8 @@ Classifier: Development Status :: 4 - Beta | ||
| Classifier: Programming Language :: Python :: 3.2 | ||
| Classifier: Programming Language :: Python :: 3.3 | ||
| Classifier: Programming Language :: Python :: 3.4 | ||
| Classifier: Programming Language :: Python :: 3.5 | ||
| Classifier: Programming Language :: Python :: 3.6 | ||
| Classifier: Programming Language :: Python :: 3.7 | ||
| Classifier: Programming Language :: Python :: Implementation :: PyPy | ||
| Classifier: Topic :: Software Development :: Libraries :: Python Modules | ||
| Description-Content-Type: text/markdown |
| LICENSE.txt | ||
| MANIFEST.in | ||
| README.md | ||
| README.rst | ||
| setup.py | ||
@@ -6,0 +5,0 @@ dwollav2/__init__.py |
@@ -57,12 +57,12 @@ import requests | ||
| data = [(k, v) for k, v in _items_or_iteritems(body) if not _contains_file(v)] | ||
| return Response(self.session.post(self._full_url(url), headers=headers, files=files, data=data)) | ||
| return Response(self.session.post(self._full_url(url), headers=headers, files=files, data=data, **kwargs)) | ||
| else: | ||
| return Response(self.session.post(self._full_url(url), headers=headers, json=body)) | ||
| return Response(self.session.post(self._full_url(url), headers=headers, json=body, **kwargs)) | ||
| def get(self, url, params = None, headers = {}, **kwargs): | ||
| params = kwargs if params is None else params | ||
| return Response(self.session.get(self._full_url(url), headers=headers, params=params)) | ||
| return Response(self.session.get(self._full_url(url), headers=headers, params=params, **kwargs)) | ||
| def delete(self, url, params = None, headers = {}): | ||
| return Response(self.session.delete(self._full_url(url), headers=headers, params=params)) | ||
| def delete(self, url, params = None, headers = {}, **kwargs): | ||
| return Response(self.session.delete(self._full_url(url), headers=headers, params=params, **kwargs)) | ||
@@ -69,0 +69,0 @@ def _full_url(self, path): |
+153
-191
@@ -1,4 +0,4 @@ | ||
| Metadata-Version: 1.1 | ||
| Metadata-Version: 2.1 | ||
| Name: dwollav2 | ||
| Version: 1.3.0 | ||
| Version: 1.4.0 | ||
| Summary: Official Dwolla V2 API client | ||
@@ -9,257 +9,217 @@ Home-page: https://docsv2.dwolla.com | ||
| License: MIT | ||
| Description: DwollaV2 | ||
| ======== | ||
| Description: # DwollaV2 | ||
| .. figure:: https://travis-ci.org/Dwolla/dwolla-v2-python.svg | ||
| :alt: Build Status | ||
|  | ||
| Build Status | ||
| Dwolla V2 Python client. | ||
| `API Documentation <https://docsv2.dwolla.com>`__ | ||
| [API Documentation](https://docsv2.dwolla.com) | ||
| Installation | ||
| ------------ | ||
| ## Installation | ||
| ``dwollav2`` is available on | ||
| `PyPi <https://pypi.python.org/pypi/dwollav2>`__, and therefore can be | ||
| installed automagically via | ||
| `pip <https://pip.pypa.io/en/stable/installing/>`__. | ||
| `dwollav2` is available on [PyPi](https://pypi.python.org/pypi/dwollav2), and therefore can be installed automagically via [pip](https://pip.pypa.io/en/stable/installing/). | ||
| :: | ||
| ``` | ||
| pip install dwollav2 | ||
| ``` | ||
| pip install dwollav2 | ||
| ## `dwollav2.Client` | ||
| ``dwollav2.Client`` | ||
| ------------------- | ||
| ### Basic usage | ||
| Basic usage | ||
| ~~~~~~~~~~~ | ||
| Create a client using your application's consumer key and secret found on the applications page | ||
| ([Sandbox][apsandbox], [Production][approd]). | ||
| Create a client using your application's consumer key and secret found | ||
| on the applications page | ||
| (`Sandbox <https://dashboard-sandbox.dwolla.com/applications>`__, | ||
| `Production <https://dashboard.dwolla.com/applications>`__). | ||
| [apsandbox]: https://dashboard-sandbox.dwolla.com/applications | ||
| [approd]: https://dashboard.dwolla.com/applications | ||
| .. code:: python | ||
| ```python | ||
| client = dwollav2.Client(key = os.environ['DWOLLA_APP_KEY'], secret = os.environ['DWOLLA_APP_SECRET']) | ||
| ``` | ||
| client = dwollav2.Client(id = os.environ['DWOLLA_APP_KEY'], secret = os.environ['DWOLLA_APP_SECRET']) | ||
| ### Using the sandbox environment (optional) | ||
| Using the sandbox environment (optional) | ||
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
| ```python | ||
| client = dwollav2.Client( | ||
| key = os.environ['DWOLLA_APP_KEY'], | ||
| secret = os.environ['DWOLLA_APP_SECRET'], | ||
| environment = 'sandbox' | ||
| ) | ||
| ``` | ||
| .. code:: python | ||
| `environment` defaults to `'production'`. | ||
| client = dwollav2.Client( | ||
| key = os.environ['DWOLLA_APP_KEY'], | ||
| secret = os.environ['DWOLLA_APP_SECRET'], | ||
| environment = 'sandbox' | ||
| ) | ||
| ### Configure an `on_grant` callback (optional) | ||
| ``environment`` defaults to ``'production'``. | ||
| An `on_grant` callback is useful for storing new tokens when they are granted. The `on_grant` | ||
| callback is called with the `Token` that was just granted by the server. | ||
| Configure an ``on_grant`` callback (optional) | ||
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
| ```python | ||
| client = dwollav2.Client( | ||
| key = os.environ['DWOLLA_APP_KEY'], | ||
| secret = os.environ['DWOLLA_APP_SECRET'], | ||
| on_grant = lambda t: save(t) | ||
| ) | ||
| ``` | ||
| An ``on_grant`` callback is useful for storing new tokens when they are | ||
| granted. The ``on_grant`` callback is called with the ``Token`` that was | ||
| just granted by the server. | ||
| .. code:: python | ||
| client = dwollav2.Client( | ||
| key = os.environ['DWOLLA_APP_KEY'], | ||
| secret = os.environ['DWOLLA_APP_SECRET'], | ||
| on_grant = lambda t: save(t) | ||
| ) | ||
| It is highly recommended that you encrypt any token data you store. | ||
| ``Token`` | ||
| --------- | ||
| ## `Token` | ||
| Tokens can be used to make requests to the Dwolla V2 API. | ||
| Application tokens | ||
| ~~~~~~~~~~~~~~~~~~ | ||
| ### Application tokens | ||
| Application access tokens are used to authenticate against the API on | ||
| behalf of a consumer application. Application tokens can be used to | ||
| access resources in the API that either belong to the application itself | ||
| (``webhooks``, ``events``, ``webhook-subscriptions``) or the partner | ||
| Account that owns the consumer application (``accounts``, ``customers``, | ||
| ``funding-sources``, etc.). Application tokens are obtained by using the | ||
| ```client_credentials`` <https://tools.ietf.org/html/rfc6749#section-4.4>`__ | ||
| OAuth grant type: | ||
| Application access tokens are used to authenticate against the API on behalf of a consumer application. Application tokens can be used to access resources in the API that either belong to the application itself (`webhooks`, `events`, `webhook-subscriptions`) or the partner Account that owns the consumer application (`accounts`, `customers`, `funding-sources`, etc.). Application tokens are obtained by using the [`client_credentials`][client_credentials] OAuth grant type: | ||
| .. code:: python | ||
| [client_credentials]: https://tools.ietf.org/html/rfc6749#section-4.4 | ||
| application_token = client.Auth.client() | ||
| ```python | ||
| application_token = client.Auth.client() | ||
| ``` | ||
| *Application tokens do not include a ``refresh_token``. When an | ||
| application token expires, generate a new one using | ||
| ``client.Auth.client()``.* | ||
| _Application tokens do not include a `refresh_token`. When an application token expires, generate | ||
| a new one using `client.Auth.client()`._ | ||
| Initializing pre-existing tokens: | ||
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
| ### Initializing pre-existing tokens: | ||
| ``Token``\ s can be initialized with the following attributes: | ||
| `Token`s can be initialized with the following attributes: | ||
| .. code:: python | ||
| ```python | ||
| client.Token(access_token = '...', | ||
| expires_in = 123) | ||
| ``` | ||
| client.Token(access_token = '...', | ||
| expires_in = 123) | ||
| ## Requests | ||
| Requests | ||
| -------- | ||
| `Token`s can make requests using the `#get`, `#post`, and `#delete` methods. | ||
| ``Token``\ s can make requests using the ``#get``, ``#post``, and | ||
| ``#delete`` methods. | ||
| ```python | ||
| # GET api.dwolla.com/resource?foo=bar | ||
| token.get('resource', foo = 'bar') | ||
| .. code:: python | ||
| # POST api.dwolla.com/resource {"foo":"bar"} | ||
| token.post('resource', foo = 'bar') | ||
| # GET api.dwolla.com/resource?foo=bar | ||
| token.get('resource', foo = 'bar') | ||
| # POST api.dwolla.com/resource multipart/form-data foo=... | ||
| token.post('resource', foo = ('mclovin.jpg', open('mclovin.jpg', 'rb'), 'image/jpeg')) | ||
| # POST api.dwolla.com/resource {"foo":"bar"} | ||
| token.post('resource', foo = 'bar') | ||
| # PUT api.dwolla.com/resource {"foo":"bar"} | ||
| token.put('resource', foo = 'bar') | ||
| # POST api.dwolla.com/resource multipart/form-data foo=... | ||
| token.post('resource', foo = ('mclovin.jpg', open('mclovin.jpg', 'rb'), 'image/jpeg')) | ||
| # DELETE api.dwolla.com/resource | ||
| token.delete('resource') | ||
| ``` | ||
| # PUT api.dwolla.com/resource {"foo":"bar"} | ||
| token.put('resource', foo = 'bar') | ||
| #### Setting headers | ||
| # DELETE api.dwolla.com/resource | ||
| token.delete('resource') | ||
| To set additional headers on a request you can pass a `dict` of headers as the 3rd argument. | ||
| Setting headers | ||
| ^^^^^^^^^^^^^^^ | ||
| To set additional headers on a request you can pass a ``dict`` of | ||
| headers as the 3rd argument. | ||
| For example: | ||
| .. code:: python | ||
| ```python | ||
| token.post('customers', { 'firstName': 'John', 'lastName': 'Doe', 'email': 'jd@doe.com' }, | ||
| { 'Idempotency-Key': 'a52fcf63-0730-41c3-96e8-7147b5d1fb01' }) | ||
| ``` | ||
| token.post('customers', { 'firstName': 'John', 'lastName': 'Doe', 'email': 'jd@doe.com' }, | ||
| { 'Idempotency-Key': 'a52fcf63-0730-41c3-96e8-7147b5d1fb01' }) | ||
| ## Responses | ||
| Responses | ||
| --------- | ||
| Requests return a `Response`. | ||
| Requests return a ``Response``. | ||
| ```python | ||
| res = token.get('/') | ||
| .. code:: python | ||
| res.status | ||
| # => 200 | ||
| res = token.get('/') | ||
| res.headers | ||
| # => {'server'=>'cloudflare-nginx', 'date'=>'Mon, 28 Mar 2016 15:30:23 GMT', 'content-type'=>'application/vnd.dwolla.v1.hal+json; charset=UTF-8', 'content-length'=>'150', 'connection'=>'close', 'set-cookie'=>'__cfduid=d9dcd0f586c166d36cbd45b992bdaa11b1459179023; expires=Tue, 28-Mar-17 15:30:23 GMT; path=/; domain=.dwolla.com; HttpOnly', 'x-request-id'=>'69a4e612-5dae-4c52-a6a0-2f921e34a88a', 'cf-ray'=>'28ac1f81875941e3-MSP'} | ||
| res.status | ||
| # => 200 | ||
| res.body['_links']['events']['href'] | ||
| # => 'https://api-sandbox.dwolla.com/events' | ||
| ``` | ||
| res.headers | ||
| # => {'server'=>'cloudflare-nginx', 'date'=>'Mon, 28 Mar 2016 15:30:23 GMT', 'content-type'=>'application/vnd.dwolla.v1.hal+json; charset=UTF-8', 'content-length'=>'150', 'connection'=>'close', 'set-cookie'=>'__cfduid=d9dcd0f586c166d36cbd45b992bdaa11b1459179023; expires=Tue, 28-Mar-17 15:30:23 GMT; path=/; domain=.dwolla.com; HttpOnly', 'x-request-id'=>'69a4e612-5dae-4c52-a6a0-2f921e34a88a', 'cf-ray'=>'28ac1f81875941e3-MSP'} | ||
| ## Errors | ||
| res.body['_links']['events']['href'] | ||
| # => 'https://api-sandbox.dwolla.com/events' | ||
| If the server returns an error, a `dwollav2.Error` (or one of its subclasses) will be raised. | ||
| `dwollav2.Error`s are similar to `Response`s. | ||
| Errors | ||
| ------ | ||
| ```python | ||
| try: | ||
| token.get('/not-found') | ||
| except dwollav2.NotFoundError as e: | ||
| e.status | ||
| # => 404 | ||
| If the server returns an error, a ``dwollav2.Error`` (or one of its | ||
| subclasses) will be raised. ``dwollav2.Error``\ s are similar to | ||
| ``Response``\ s. | ||
| e.headers | ||
| # => {"server"=>"cloudflare-nginx", "date"=>"Mon, 28 Mar 2016 15:35:32 GMT", "content-type"=>"application/vnd.dwolla.v1.hal+json; profile=\"http://nocarrier.co.uk/profiles/vnd.error/\"; charset=UTF-8", "content-length"=>"69", "connection"=>"close", "set-cookie"=>"__cfduid=da1478bfdf3e56275cd8a6a741866ccce1459179332; expires=Tue, 28-Mar-17 15:35:32 GMT; path=/; domain=.dwolla.com; HttpOnly", "access-control-allow-origin"=>"*", "x-request-id"=>"667fca74-b53d-43db-bddd-50426a011881", "cf-ray"=>"28ac270abca64207-MSP"} | ||
| .. code:: python | ||
| e.body.code | ||
| # => "NotFound" | ||
| except dwollav2.Error: | ||
| # ... | ||
| ``` | ||
| try: | ||
| token.get('/not-found') | ||
| except dwollav2.NotFoundError: | ||
| e.status | ||
| # => 404 | ||
| ### `dwollav2.Error` subclasses: | ||
| e.headers | ||
| # => {"server"=>"cloudflare-nginx", "date"=>"Mon, 28 Mar 2016 15:35:32 GMT", "content-type"=>"application/vnd.dwolla.v1.hal+json; profile=\"http://nocarrier.co.uk/profiles/vnd.error/\"; charset=UTF-8", "content-length"=>"69", "connection"=>"close", "set-cookie"=>"__cfduid=da1478bfdf3e56275cd8a6a741866ccce1459179332; expires=Tue, 28-Mar-17 15:35:32 GMT; path=/; domain=.dwolla.com; HttpOnly", "access-control-allow-origin"=>"*", "x-request-id"=>"667fca74-b53d-43db-bddd-50426a011881", "cf-ray"=>"28ac270abca64207-MSP"} | ||
| _See https://docsv2.dwolla.com/#errors for more info._ | ||
| e.body.code | ||
| # => "NotFound" | ||
| except dwollav2.Error: | ||
| # ... | ||
| - `dwollav2.AccessDeniedError` | ||
| - `dwollav2.InvalidCredentialsError` | ||
| - `dwollav2.NotFoundError` | ||
| - `dwollav2.BadRequestError` | ||
| - `dwollav2.InvalidGrantError` | ||
| - `dwollav2.RequestTimeoutError` | ||
| - `dwollav2.ExpiredAccessTokenError` | ||
| - `dwollav2.InvalidRequestError` | ||
| - `dwollav2.ServerError` | ||
| - `dwollav2.ForbiddenError` | ||
| - `dwollav2.InvalidResourceStateError` | ||
| - `dwollav2.TemporarilyUnavailableError` | ||
| - `dwollav2.InvalidAccessTokenError` | ||
| - `dwollav2.InvalidScopeError` | ||
| - `dwollav2.UnauthorizedClientError` | ||
| - `dwollav2.InvalidAccountStatusError` | ||
| - `dwollav2.InvalidScopesError` | ||
| - `dwollav2.UnsupportedGrantTypeError` | ||
| - `dwollav2.InvalidApplicationStatusError` | ||
| - `dwollav2.InvalidVersionError` | ||
| - `dwollav2.UnsupportedResponseTypeError` | ||
| - `dwollav2.InvalidClientError` | ||
| - `dwollav2.MethodNotAllowedError` | ||
| - `dwollav2.ValidationError` | ||
| - `dwollav2.TooManyRequestsError` | ||
| - `dwollav2.ConflictError` | ||
| ``dwollav2.Error`` subclasses: | ||
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
| ## Development | ||
| *See https://docsv2.dwolla.com/#errors for more info.* | ||
| After checking out the repo, run `pip install -r requirements.txt` to install dependencies. | ||
| Then, run `python setup.py test` to run the tests. | ||
| - ``dwollav2.AccessDeniedError`` | ||
| - ``dwollav2.InvalidCredentialsError`` | ||
| - ``dwollav2.NotFoundError`` | ||
| - ``dwollav2.BadRequestError`` | ||
| - ``dwollav2.InvalidGrantError`` | ||
| - ``dwollav2.RequestTimeoutError`` | ||
| - ``dwollav2.ExpiredAccessTokenError`` | ||
| - ``dwollav2.InvalidRequestError`` | ||
| - ``dwollav2.ServerError`` | ||
| - ``dwollav2.ForbiddenError`` | ||
| - ``dwollav2.InvalidResourceStateError`` | ||
| - ``dwollav2.TemporarilyUnavailableError`` | ||
| - ``dwollav2.InvalidAccessTokenError`` | ||
| - ``dwollav2.InvalidScopeError`` | ||
| - ``dwollav2.UnauthorizedClientError`` | ||
| - ``dwollav2.InvalidAccountStatusError`` | ||
| - ``dwollav2.InvalidScopesError`` | ||
| - ``dwollav2.UnsupportedGrantTypeError`` | ||
| - ``dwollav2.InvalidApplicationStatusError`` | ||
| - ``dwollav2.InvalidVersionError`` | ||
| - ``dwollav2.UnsupportedResponseTypeError`` | ||
| - ``dwollav2.InvalidClientError`` | ||
| - ``dwollav2.MethodNotAllowedError`` | ||
| - ``dwollav2.ValidationError`` | ||
| - ``dwollav2.TooManyRequestsError`` | ||
| - ``dwollav2.ConflictError`` | ||
| To install this gem onto your local machine, run `pip install -e .`. | ||
| Development | ||
| ----------- | ||
| ## Contributing | ||
| After checking out the repo, run ``pip install -r requirements.txt`` to | ||
| install dependencies. Then, run ``python setup.py test`` to run the | ||
| tests. | ||
| Bug reports and pull requests are welcome on GitHub at https://github.com/Dwolla/dwolla-v2-python. | ||
| To install this gem onto your local machine, run ``pip install -e .``. | ||
| ## License | ||
| Contributing | ||
| ------------ | ||
| The package is available as open source under the terms of the [MIT License](https://github.com/Dwolla/dwolla-v2-python). | ||
| Bug reports and pull requests are welcome on GitHub at | ||
| https://github.com/Dwolla/dwolla-v2-python. | ||
| ## Changelog | ||
| License | ||
| ------- | ||
| - **1.4.0** Allow kwargs to be passed to `get`, `post`, and `delete` methods. | ||
| - **1.3.0** Change token URLs, update dependencies. | ||
| - **1.2.4** Create a new session for each Token. | ||
| - **1.2.3** Check if IOBase when checking to see if something is a file. | ||
| - **1.2.2** Strip domain from URLs provided to token.\* methods. | ||
| - **1.2.1** Update sandbox URLs from uat => sandbox. | ||
| - **1.2.0** Refer to Client id as key. | ||
| - **1.1.8** Support `verified_account` and `dwolla_landing` auth flags | ||
| - **1.1.7** Use session over connections for [performance improvement](http://docs.python-requests.org/en/master/user/advanced/#session-objects) ([#8](https://github.com/Dwolla/dwolla-v2-python/pull/8) - Thanks @bfeeser!) | ||
| - **1.1.5** Fix file upload bug when using with Python 2 ([#6](https://github.com/Dwolla/dwolla-v2-python/issues/6)) | ||
| - **1.1.2** Add `TooManyRequestsError` and `ConflictError` | ||
| - **1.1.1** Add MANIFEST.in | ||
| - **1.1.0** Support per-request headers | ||
| The package is available as open source under the terms of the `MIT | ||
| License <https://github.com/Dwolla/dwolla-v2-python>`__. | ||
| Changelog | ||
| --------- | ||
| - **1.2.4** Create a new session for each Token. | ||
| - **1.2.3** Check if IOBase when checking to see if something is a | ||
| file. | ||
| - **1.2.2** Strip domain from URLs provided to token.\* methods. | ||
| - **1.2.1** Update sandbox URLs from uat => sandbox. | ||
| - **1.2.0** Refer to Client id as key. | ||
| - **1.1.8** Support ``verified_account`` and ``dwolla_landing`` auth | ||
| flags | ||
| - **1.1.7** Use session over connections for `performance | ||
| improvement <http://docs.python-requests.org/en/master/user/advanced/#session-objects>`__ | ||
| (`#8 <https://github.com/Dwolla/dwolla-v2-python/pull/8>`__ - Thanks | ||
| @bfeeser!) | ||
| - **1.1.5** Fix file upload bug when using with Python 2 | ||
| (`#6 <https://github.com/Dwolla/dwolla-v2-python/issues/6>`__) | ||
| - **1.1.2** Add ``TooManyRequestsError`` and ``ConflictError`` | ||
| - **1.1.1** Add MANIFEST.in | ||
| - **1.1.0** Support per-request headers | ||
| Platform: UNKNOWN | ||
@@ -275,6 +235,8 @@ Classifier: Development Status :: 4 - Beta | ||
| Classifier: Programming Language :: Python :: 3.2 | ||
| Classifier: Programming Language :: Python :: 3.3 | ||
| Classifier: Programming Language :: Python :: 3.4 | ||
| Classifier: Programming Language :: Python :: 3.5 | ||
| Classifier: Programming Language :: Python :: 3.6 | ||
| Classifier: Programming Language :: Python :: 3.7 | ||
| Classifier: Programming Language :: Python :: Implementation :: PyPy | ||
| Classifier: Topic :: Software Development :: Libraries :: Python Modules | ||
| Description-Content-Type: text/markdown |
+6
-5
@@ -28,3 +28,3 @@ # DwollaV2 | ||
| ```python | ||
| client = dwollav2.Client(id = os.environ['DWOLLA_APP_KEY'], secret = os.environ['DWOLLA_APP_SECRET']) | ||
| client = dwollav2.Client(key = os.environ['DWOLLA_APP_KEY'], secret = os.environ['DWOLLA_APP_SECRET']) | ||
| ``` | ||
@@ -73,4 +73,4 @@ | ||
| *Application tokens do not include a `refresh_token`. When an application token expires, generate | ||
| a new one using `client.Auth.client()`.* | ||
| _Application tokens do not include a `refresh_token`. When an application token expires, generate | ||
| a new one using `client.Auth.client()`._ | ||
@@ -158,3 +158,3 @@ ### Initializing pre-existing tokens: | ||
| *See https://docsv2.dwolla.com/#errors for more info.* | ||
| _See https://docsv2.dwolla.com/#errors for more info._ | ||
@@ -205,6 +205,7 @@ - `dwollav2.AccessDeniedError` | ||
| - **1.4.0** Allow kwargs to be passed to `get`, `post`, and `delete` methods. | ||
| - **1.3.0** Change token URLs, update dependencies. | ||
| - **1.2.4** Create a new session for each Token. | ||
| - **1.2.3** Check if IOBase when checking to see if something is a file. | ||
| - **1.2.2** Strip domain from URLs provided to token.* methods. | ||
| - **1.2.2** Strip domain from URLs provided to token.\* methods. | ||
| - **1.2.1** Update sandbox URLs from uat => sandbox. | ||
@@ -211,0 +212,0 @@ - **1.2.0** Refer to Client id as key. |
+5
-3
@@ -12,3 +12,3 @@ import os | ||
| name='dwollav2', | ||
| version='1.3.0', | ||
| version='1.4.0', | ||
| packages=['dwollav2'], | ||
@@ -24,3 +24,4 @@ install_requires=[ | ||
| author_email='stephen@dwolla.com', | ||
| long_description=open('README.rst').read(), | ||
| long_description=open('README.md').read(), | ||
| long_description_content_type="text/markdown", | ||
| description='Official Dwolla V2 API client', | ||
@@ -37,5 +38,6 @@ classifiers=[ | ||
| "Programming Language :: Python :: 3.2", | ||
| "Programming Language :: Python :: 3.3", | ||
| "Programming Language :: Python :: 3.4", | ||
| "Programming Language :: Python :: 3.5", | ||
| "Programming Language :: Python :: 3.6", | ||
| "Programming Language :: Python :: 3.7", | ||
| "Programming Language :: Python :: Implementation :: PyPy", | ||
@@ -42,0 +44,0 @@ "Topic :: Software Development :: Libraries :: Python Modules", |
-254
| DwollaV2 | ||
| ======== | ||
| .. figure:: https://travis-ci.org/Dwolla/dwolla-v2-python.svg | ||
| :alt: Build Status | ||
| Build Status | ||
| Dwolla V2 Python client. | ||
| `API Documentation <https://docsv2.dwolla.com>`__ | ||
| Installation | ||
| ------------ | ||
| ``dwollav2`` is available on | ||
| `PyPi <https://pypi.python.org/pypi/dwollav2>`__, and therefore can be | ||
| installed automagically via | ||
| `pip <https://pip.pypa.io/en/stable/installing/>`__. | ||
| :: | ||
| pip install dwollav2 | ||
| ``dwollav2.Client`` | ||
| ------------------- | ||
| Basic usage | ||
| ~~~~~~~~~~~ | ||
| Create a client using your application's consumer key and secret found | ||
| on the applications page | ||
| (`Sandbox <https://dashboard-sandbox.dwolla.com/applications>`__, | ||
| `Production <https://dashboard.dwolla.com/applications>`__). | ||
| .. code:: python | ||
| client = dwollav2.Client(id = os.environ['DWOLLA_APP_KEY'], secret = os.environ['DWOLLA_APP_SECRET']) | ||
| Using the sandbox environment (optional) | ||
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
| .. code:: python | ||
| client = dwollav2.Client( | ||
| key = os.environ['DWOLLA_APP_KEY'], | ||
| secret = os.environ['DWOLLA_APP_SECRET'], | ||
| environment = 'sandbox' | ||
| ) | ||
| ``environment`` defaults to ``'production'``. | ||
| Configure an ``on_grant`` callback (optional) | ||
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
| An ``on_grant`` callback is useful for storing new tokens when they are | ||
| granted. The ``on_grant`` callback is called with the ``Token`` that was | ||
| just granted by the server. | ||
| .. code:: python | ||
| client = dwollav2.Client( | ||
| key = os.environ['DWOLLA_APP_KEY'], | ||
| secret = os.environ['DWOLLA_APP_SECRET'], | ||
| on_grant = lambda t: save(t) | ||
| ) | ||
| It is highly recommended that you encrypt any token data you store. | ||
| ``Token`` | ||
| --------- | ||
| Tokens can be used to make requests to the Dwolla V2 API. | ||
| Application tokens | ||
| ~~~~~~~~~~~~~~~~~~ | ||
| Application access tokens are used to authenticate against the API on | ||
| behalf of a consumer application. Application tokens can be used to | ||
| access resources in the API that either belong to the application itself | ||
| (``webhooks``, ``events``, ``webhook-subscriptions``) or the partner | ||
| Account that owns the consumer application (``accounts``, ``customers``, | ||
| ``funding-sources``, etc.). Application tokens are obtained by using the | ||
| ```client_credentials`` <https://tools.ietf.org/html/rfc6749#section-4.4>`__ | ||
| OAuth grant type: | ||
| .. code:: python | ||
| application_token = client.Auth.client() | ||
| *Application tokens do not include a ``refresh_token``. When an | ||
| application token expires, generate a new one using | ||
| ``client.Auth.client()``.* | ||
| Initializing pre-existing tokens: | ||
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
| ``Token``\ s can be initialized with the following attributes: | ||
| .. code:: python | ||
| client.Token(access_token = '...', | ||
| expires_in = 123) | ||
| Requests | ||
| -------- | ||
| ``Token``\ s can make requests using the ``#get``, ``#post``, and | ||
| ``#delete`` methods. | ||
| .. code:: python | ||
| # GET api.dwolla.com/resource?foo=bar | ||
| token.get('resource', foo = 'bar') | ||
| # POST api.dwolla.com/resource {"foo":"bar"} | ||
| token.post('resource', foo = 'bar') | ||
| # POST api.dwolla.com/resource multipart/form-data foo=... | ||
| token.post('resource', foo = ('mclovin.jpg', open('mclovin.jpg', 'rb'), 'image/jpeg')) | ||
| # PUT api.dwolla.com/resource {"foo":"bar"} | ||
| token.put('resource', foo = 'bar') | ||
| # DELETE api.dwolla.com/resource | ||
| token.delete('resource') | ||
| Setting headers | ||
| ^^^^^^^^^^^^^^^ | ||
| To set additional headers on a request you can pass a ``dict`` of | ||
| headers as the 3rd argument. | ||
| For example: | ||
| .. code:: python | ||
| token.post('customers', { 'firstName': 'John', 'lastName': 'Doe', 'email': 'jd@doe.com' }, | ||
| { 'Idempotency-Key': 'a52fcf63-0730-41c3-96e8-7147b5d1fb01' }) | ||
| Responses | ||
| --------- | ||
| Requests return a ``Response``. | ||
| .. code:: python | ||
| res = token.get('/') | ||
| res.status | ||
| # => 200 | ||
| res.headers | ||
| # => {'server'=>'cloudflare-nginx', 'date'=>'Mon, 28 Mar 2016 15:30:23 GMT', 'content-type'=>'application/vnd.dwolla.v1.hal+json; charset=UTF-8', 'content-length'=>'150', 'connection'=>'close', 'set-cookie'=>'__cfduid=d9dcd0f586c166d36cbd45b992bdaa11b1459179023; expires=Tue, 28-Mar-17 15:30:23 GMT; path=/; domain=.dwolla.com; HttpOnly', 'x-request-id'=>'69a4e612-5dae-4c52-a6a0-2f921e34a88a', 'cf-ray'=>'28ac1f81875941e3-MSP'} | ||
| res.body['_links']['events']['href'] | ||
| # => 'https://api-sandbox.dwolla.com/events' | ||
| Errors | ||
| ------ | ||
| If the server returns an error, a ``dwollav2.Error`` (or one of its | ||
| subclasses) will be raised. ``dwollav2.Error``\ s are similar to | ||
| ``Response``\ s. | ||
| .. code:: python | ||
| try: | ||
| token.get('/not-found') | ||
| except dwollav2.NotFoundError: | ||
| e.status | ||
| # => 404 | ||
| e.headers | ||
| # => {"server"=>"cloudflare-nginx", "date"=>"Mon, 28 Mar 2016 15:35:32 GMT", "content-type"=>"application/vnd.dwolla.v1.hal+json; profile=\"http://nocarrier.co.uk/profiles/vnd.error/\"; charset=UTF-8", "content-length"=>"69", "connection"=>"close", "set-cookie"=>"__cfduid=da1478bfdf3e56275cd8a6a741866ccce1459179332; expires=Tue, 28-Mar-17 15:35:32 GMT; path=/; domain=.dwolla.com; HttpOnly", "access-control-allow-origin"=>"*", "x-request-id"=>"667fca74-b53d-43db-bddd-50426a011881", "cf-ray"=>"28ac270abca64207-MSP"} | ||
| e.body.code | ||
| # => "NotFound" | ||
| except dwollav2.Error: | ||
| # ... | ||
| ``dwollav2.Error`` subclasses: | ||
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
| *See https://docsv2.dwolla.com/#errors for more info.* | ||
| - ``dwollav2.AccessDeniedError`` | ||
| - ``dwollav2.InvalidCredentialsError`` | ||
| - ``dwollav2.NotFoundError`` | ||
| - ``dwollav2.BadRequestError`` | ||
| - ``dwollav2.InvalidGrantError`` | ||
| - ``dwollav2.RequestTimeoutError`` | ||
| - ``dwollav2.ExpiredAccessTokenError`` | ||
| - ``dwollav2.InvalidRequestError`` | ||
| - ``dwollav2.ServerError`` | ||
| - ``dwollav2.ForbiddenError`` | ||
| - ``dwollav2.InvalidResourceStateError`` | ||
| - ``dwollav2.TemporarilyUnavailableError`` | ||
| - ``dwollav2.InvalidAccessTokenError`` | ||
| - ``dwollav2.InvalidScopeError`` | ||
| - ``dwollav2.UnauthorizedClientError`` | ||
| - ``dwollav2.InvalidAccountStatusError`` | ||
| - ``dwollav2.InvalidScopesError`` | ||
| - ``dwollav2.UnsupportedGrantTypeError`` | ||
| - ``dwollav2.InvalidApplicationStatusError`` | ||
| - ``dwollav2.InvalidVersionError`` | ||
| - ``dwollav2.UnsupportedResponseTypeError`` | ||
| - ``dwollav2.InvalidClientError`` | ||
| - ``dwollav2.MethodNotAllowedError`` | ||
| - ``dwollav2.ValidationError`` | ||
| - ``dwollav2.TooManyRequestsError`` | ||
| - ``dwollav2.ConflictError`` | ||
| Development | ||
| ----------- | ||
| After checking out the repo, run ``pip install -r requirements.txt`` to | ||
| install dependencies. Then, run ``python setup.py test`` to run the | ||
| tests. | ||
| To install this gem onto your local machine, run ``pip install -e .``. | ||
| Contributing | ||
| ------------ | ||
| Bug reports and pull requests are welcome on GitHub at | ||
| https://github.com/Dwolla/dwolla-v2-python. | ||
| License | ||
| ------- | ||
| The package is available as open source under the terms of the `MIT | ||
| License <https://github.com/Dwolla/dwolla-v2-python>`__. | ||
| Changelog | ||
| --------- | ||
| - **1.2.4** Create a new session for each Token. | ||
| - **1.2.3** Check if IOBase when checking to see if something is a | ||
| file. | ||
| - **1.2.2** Strip domain from URLs provided to token.\* methods. | ||
| - **1.2.1** Update sandbox URLs from uat => sandbox. | ||
| - **1.2.0** Refer to Client id as key. | ||
| - **1.1.8** Support ``verified_account`` and ``dwolla_landing`` auth | ||
| flags | ||
| - **1.1.7** Use session over connections for `performance | ||
| improvement <http://docs.python-requests.org/en/master/user/advanced/#session-objects>`__ | ||
| (`#8 <https://github.com/Dwolla/dwolla-v2-python/pull/8>`__ - Thanks | ||
| @bfeeser!) | ||
| - **1.1.5** Fix file upload bug when using with Python 2 | ||
| (`#6 <https://github.com/Dwolla/dwolla-v2-python/issues/6>`__) | ||
| - **1.1.2** Add ``TooManyRequestsError`` and ``ConflictError`` | ||
| - **1.1.1** Add MANIFEST.in | ||
| - **1.1.0** Support per-request headers | ||
Alert delta unavailable
Currently unable to show alert delta for PyPI packages.
336
0.6%41198
-17.94%18
-5.26%