Skip to content

Commit cba3e8e

Browse files
author
Will Myers
authored
Update stale docs for pybutton.response.Response (#9)
👍
1 parent 92bda72 commit cba3e8e

File tree

2 files changed

+17
-19
lines changed

2 files changed

+17
-19
lines changed

README.rst

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,7 @@ The client will always attempt to raise a ``pybutton.ButtonClientError``
4040
in an error condition.
4141

4242
All API requests will return a ``pybutton.response.Response`` instance,
43-
which supports accessing data properties from the API response as
44-
attributes. To access the raw response dict, use ``#to_dict``. For
45-
instance:
43+
which supports accessing data via the `#data` method. For instance:
4644

4745
.. code:: python
4846
@@ -59,12 +57,10 @@ instance:
5957
print(response)
6058
# <class pybutton.Response status: open, btn_ref: None, line_items: [], ...>
6159
62-
print(response.status)
63-
# 'open'
64-
65-
print(response.to_dict())
60+
print(response.data())
6661
# {'status': open, 'btn_ref': None, 'line_items': [], ...}
6762
63+
6864
Configuration
6965
-------------
7066

pybutton/response.py

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,6 @@ class Response(object):
1616
meta (dict): The metadata from an API call
1717
response_data (dict or array<dict>): The response elements from an
1818
API call
19-
20-
Attributes:
21-
* (*): All keys in `attrs` will be exposed as attributes of an instance
22-
2319
'''
2420

2521
classPrefix = 'class pybutton.Response'
@@ -29,21 +25,27 @@ def __init__(self, meta, response_data):
2925
self.response_data = response_data
3026

3127
def data(self):
32-
'''Return the raw response element(s) received from the server.
33-
May be a single dict or an array of dicts.
3428
'''
29+
Return the raw response element(s) received from the server.
30+
May be a single dict or an array of dicts.
31+
'''
32+
3533
return self.response_data
3634

3735
def next_cursor(self):
38-
'''For paginated responses, returns the url used to fetch
39-
the next elements.
4036
'''
37+
For paginated responses, returns the url used to fetch
38+
the next elements.
39+
'''
40+
4141
return self._format_cursor(self.meta.get('next'))
4242

4343
def prev_cursor(self):
44-
'''For paginated responses, returns the url used to fetch
45-
the previous elements.
4644
'''
45+
For paginated responses, returns the url used to fetch
46+
the previous elements.
47+
'''
48+
4749
return self._format_cursor(self.meta.get('prev'))
4850

4951
def __repr__(self):
@@ -60,8 +62,8 @@ def __repr__(self):
6062
Response.classPrefix,
6163
len(self.response_data)
6264
)
63-
else:
64-
return '<class pybutton.Response>'
65+
66+
return '<class pybutton.Response>'
6567

6668
def _format_cursor(self, cursor_url):
6769
if cursor_url:

0 commit comments

Comments
 (0)