Skip to content

Commit 305eeaf

Browse files
authored
Merge pull request #44 from Dwolla/DEV-1012
DEV-1012: Update README to conform to new style guide
2 parents ad54e12 + 0a12f07 commit 305eeaf

File tree

2 files changed

+84
-51
lines changed

2 files changed

+84
-51
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,3 +89,6 @@ ENV/
8989

9090
# Visual Studio Code
9191
.vscode/
92+
93+
# IntelliJ Idea
94+
.idea/

README.md

Lines changed: 81 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,42 @@
1-
# DwollaV2
1+
# Dwolla SDK for Python
22

3-
Dwolla V2 Python client.
3+
This repository contains the source code for Dwolla's Python-based SDK, which allows developers to interact with Dwolla's server-side API via a Python API. Any action that can be performed via an HTTP request can be made using this SDK when executed within a server-side environment.
44

5-
[API Documentation](https://docsv2.dwolla.com)
5+
## Table of Contents
66

7-
## Installation
7+
- [Getting Started](#getting-started)
8+
- [Installation](#installation)
9+
- [Initialization](#initialization)
10+
- [Tokens](#tokens)
11+
- [Making Requests](#making-requests)
12+
- [Low-level Requests](#low-level-requests)
13+
- [Setting Headers](#setting-headers)
14+
- [Responses](#responses)
15+
- [Success](#success)
16+
- [Error](#error)
17+
- [Changelog](#changelog)
18+
- [Community](#community)
19+
- [Additional Resources](#additional-resources)
820

9-
`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/).
1021

11-
```
12-
pip install dwollav2
22+
## Getting Started
23+
24+
### Installation
25+
26+
To begin using this SDK, you will first need to download it to your machine. We use [PyPi](https://pypi.python.org/pypi/dwollav2) to distribute this package from where you can automagically download it via [pip](https://pip.pypa.io/en/stable/installing/).
27+
28+
```shell
29+
$ pip install dwollav2
1330
```
1431

15-
## `dwollav2.Client`
32+
### Initialization
1633

17-
### Basic usage
34+
Before any API requests can be made, you must first determine which environment you will be using, as well as fetch the application key and secret. To fetch your application key and secret, please visit one of the following links:
1835

19-
Create a client using your application's consumer key and secret found on the applications page
20-
([Sandbox][apsandbox], [Production][approd]).
36+
* Production: https://dashboard.dwolla.com/applications
37+
* Sandbox: https://dashboard-sandbox.dwolla.com/applications
2138

22-
[apsandbox]: https://dashboard-sandbox.dwolla.com/applications
23-
[approd]: https://dashboard.dwolla.com/applications
39+
Finally, you can create an instance of `Client` with `key` and `secret` replaced with the application key and secret that you fetched from one of the aforementioned links, respectively.
2440

2541
```python
2642
client = dwollav2.Client(
@@ -31,7 +47,7 @@ client = dwollav2.Client(
3147
)
3248
```
3349

34-
### Configure an `on_grant` callback (optional)
50+
##### Configure an `on_grant` callback (optional)
3551

3652
An `on_grant` callback is useful for storing new tokens when they are granted. The `on_grant`
3753
callback is called with the `Token` that was just granted by the server.
@@ -46,53 +62,57 @@ client = dwollav2.Client(
4662

4763
It is highly recommended that you encrypt any token data you store.
4864

49-
## `Token`
65+
#### Tokens
5066

51-
Tokens can be used to make requests to the Dwolla V2 API.
67+
##### Generating New Access Tokens
5268

53-
### Application tokens
69+
Application access tokens are used to authenticate against the API on behalf of an 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 Dwolla Account that owns the 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:
5470

55-
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:
56-
57-
[client_credentials]: https://tools.ietf.org/html/rfc6749#section-4.4
5871

5972
```python
6073
application_token = client.Auth.client()
6174
```
6275

63-
_Application tokens do not include a `refresh_token`. When an application token expires, generate
64-
a new one using `client.Auth.client()`._
76+
_Application access tokens are short-lived: 1 hour. They do not include a `refresh_token`. When it expires, generate a new one using `client.Auth.client()`._
6577

66-
### Initializing pre-existing tokens:
78+
##### Initializing Pre-Existing Tokens:
6779

68-
`Token`s can be initialized with the following attributes:
80+
The [Dwolla Sandbox Dashboard](https://dashboard-sandbox.dwolla.com/applications-legacy) allows you to generate tokens for your application. A `Token` can be initialized with the following attributes:
6981

7082
```python
7183
client.Token(access_token = '...',
7284
expires_in = 123)
7385
```
7486

75-
## Requests
87+
## Making Requests
88+
89+
Once you've created a `Token`, currently, you can make low-level HTTP requests.
90+
91+
### Low-level Requests
7692

77-
`Token`s can make requests using the `#get`, `#post`, and `#delete` methods.
93+
To make low-level HTTP requests, you can use the `get()`, `post()`, and `delete()` methods. These methods will return a `Response` object.
7894

95+
#### `GET`
7996
```python
8097
# GET api.dwolla.com/resource?foo=bar
8198
token.get('resource', foo = 'bar')
8299

83100
# GET requests can also use objects as parameters
84101
# GET api.dwolla.com/resource?foo=bar
85102
token.get('resource', {'foo' = 'bar', 'baz' = 'foo'})
103+
```
86104

105+
#### `POST`
106+
```python
87107
# POST api.dwolla.com/resource {"foo":"bar"}
88108
token.post('resource', foo = 'bar')
89109

90110
# POST api.dwolla.com/resource multipart/form-data foo=...
91111
token.post('resource', foo = ('mclovin.jpg', open('mclovin.jpg', 'rb'), 'image/jpeg'))
112+
```
92113

93-
# PUT api.dwolla.com/resource {"foo":"bar"}
94-
token.put('resource', foo = 'bar')
95-
114+
#### `DELETE`
115+
```python
96116
# DELETE api.dwolla.com/resource
97117
token.delete('resource')
98118
```
@@ -108,10 +128,14 @@ token.post('customers', { 'firstName': 'John', 'lastName': 'Doe', 'email': 'jd@d
108128
{ 'Idempotency-Key': 'a52fcf63-0730-41c3-96e8-7147b5d1fb01' })
109129
```
110130

111-
## Responses
131+
#### Responses
132+
133+
The following snippets demonstrate successful and errored responses from the Dwolla API.
134+
135+
An errored response is returned when Dwolla's servers respond with a status code that is greater than or equal to 400, whereas a successful response is when Dwolla's servers respond with a 200-level status code.
112136

113-
Requests return a `Response`.
114137

138+
##### Success
115139
```python
116140
res = token.get('/')
117141

@@ -125,7 +149,7 @@ res.body['_links']['events']['href']
125149
# => 'https://api-sandbox.dwolla.com/events'
126150
```
127151

128-
## Errors
152+
##### Error
129153

130154
If the server returns an error, a `dwollav2.Error` (or one of its subclasses) will be raised.
131155
`dwollav2.Error`s are similar to `Response`s.
@@ -145,10 +169,9 @@ except dwollav2.NotFoundError as e:
145169
except dwollav2.Error:
146170
# ...
147171
```
172+
###### `dwollav2.Error` subclasses:
148173

149-
### `dwollav2.Error` subclasses:
150-
151-
_See https://docsv2.dwolla.com/#errors for more info._
174+
_See https://developers.dwolla.com/api-reference#errors for more info._
152175

153176
- `dwollav2.AccessDeniedError`
154177
- `dwollav2.InvalidCredentialsError`
@@ -177,21 +200,6 @@ _See https://docsv2.dwolla.com/#errors for more info._
177200
- `dwollav2.TooManyRequestsError`
178201
- `dwollav2.ConflictError`
179202

180-
## Development
181-
182-
After checking out the repo, run `pip install -r requirements.txt` to install dependencies.
183-
Then, run `python setup.py test` to run the tests.
184-
185-
To install this gem onto your local machine, run `pip install -e .`.
186-
187-
## Contributing
188-
189-
Bug reports and pull requests are welcome on GitHub at https://github.com/Dwolla/dwolla-v2-python.
190-
191-
## License
192-
193-
The package is available as open source under the terms of the [MIT License](https://github.com/Dwolla/dwolla-v2-python).
194-
195203
## Changelog
196204

197205
- **2.2.1**
@@ -221,10 +229,32 @@ The package is available as open source under the terms of the [MIT License](htt
221229
- **1.2.1** Update sandbox URLs from uat => sandbox.
222230
- **1.2.0** Refer to Client id as key.
223231
- **1.1.8** Support `verified_account` and `dwolla_landing` auth flags
224-
- **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!)
232+
- **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](https://github.com/bfeeser)!
225233
- **1.1.5** Fix file upload bug when using with Python 2 ([#6](https://github.com/Dwolla/dwolla-v2-python/issues/6))
226234
- **1.1.2** Add `TooManyRequestsError` and `ConflictError`
227235
- **1.1.1** Add MANIFEST.in
228236
- **1.1.0** Support per-request headers
229237

238+
## Community
239+
* If you have any feedback, please reach out to us on [our forums](https://discuss.dwolla.com/) or by [creating a GitHub issue](https://github.com/Dwolla/dwolla-v2-python/issues/new).
240+
* If you would like to contribute to this library, [bug reports](https://github.com/Dwolla/dwolla-v2-python/issues) and [pull requests](https://github.com/Dwolla/dwolla-v2-python/pulls) are always appreciated!
241+
* After checking out the repo, run `pip install -r requirements.txt` to install dependencies. Then, run `python setup.py` test to run the tests.
242+
* To install this gem onto your local machine, `run pip install -e .`.
243+
244+
245+
## Additional Resources
246+
247+
To learn more about Dwolla and how to integrate our product with your application, please consider visiting the following resources and becoming a member of our community!
248+
249+
* [Dwolla](https://www.dwolla.com/)
250+
* [Dwolla Developers](https://developers.dwolla.com/)
251+
* [SDKs and Tools](https://developers.dwolla.com/sdks-tools)
252+
* [Dwolla SDK for C#](https://github.com/Dwolla/dwolla-v2-csharp)
253+
* [Dwolla SDK for Kotlin](https://github.com/Dwolla/dwolla-v2-kotlin)
254+
* [Dwolla SDK for Node](https://github.com/Dwolla/dwolla-v2-node)
255+
* [Dwolla SDK for PHP](https://github.com/Dwolla/dwolla-swagger-php)
256+
* [Dwolla SDK for Ruby](https://github.com/Dwolla/dwolla-v2-ruby)
257+
* [Developer Support Forum](https://discuss.dwolla.com/)
258+
259+
230260
[`idempotency-key`]: https://docs.dwolla.com/#idempotency-key

0 commit comments

Comments
 (0)