Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
Current Version
-

2.7.0 June 21, 2018
- Added optional `time_field` argument to `client.accounts.transactions`

2.6.1 June 5, 2018
- Added `HTTPResponseError` to top-level import
- Remove `__all__` imports: they never worked
Expand Down
1 change: 1 addition & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ pass the following optional arguments:
* ``cursor`` (string): An API cursor to fetch a specific set of results.
* ``start`` (ISO-8601 datetime string): Fetch transactions after this time.
* ``end`` (ISO-8601 datetime string): Fetch transactions before this time.
* ``time_field`` (string): Which time field ``start`` and ``end`` filter on.

.. code:: python

Expand Down
7 changes: 6 additions & 1 deletion pybutton/resources/accounts.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ def all(self):

return self.api_get('/v1/affiliation/accounts')

def transactions(self, account_id, cursor=None, start=None, end=None):
def transactions(self, account_id, cursor=None, start=None, end=None,
time_field=None):
'''Get a list of transactions.
To paginate transactions, pass the result of response.next_cursor() as
the cursor argument.
Expand All @@ -40,6 +41,8 @@ def transactions(self, account_id, cursor=None, start=None, end=None):
created at or after this time.
end (ISO-8601 datetime str) optional: Filter out transactions
created before this time.
time_field (str) optional: Which time field ``start`` and ``end``
filter on

Raises:
pybutton.ButtonClientError
Expand All @@ -57,6 +60,8 @@ def transactions(self, account_id, cursor=None, start=None, end=None):
query['start'] = start
if end:
query['end'] = end
if time_field:
query['time_field'] = time_field

path = '/v1/affiliation/accounts/{0}/transactions'.format(
account_id
Expand Down
11 changes: 11 additions & 0 deletions pybutton/test/resources/accounts_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,14 @@ def test_transactions(self):
self.assertEqual(query['cursor'], 'abc')
self.assertEqual(query['start'], '2016-09-15T00:00:00.000Z')
self.assertEqual(query['end'], '2016-09-30T00:00:00.000Z')

response = account.transactions(
'acc-123',
cursor='abc',
start='2016-09-15T00:00:00.000Z',
end='2016-09-30T00:00:00.000Z',
time_field='created_date'
)
self.assertEqual(response, account_response)
query = api_get.call_args[1]['query']
self.assertEqual(query['time_field'], 'created_date')
2 changes: 1 addition & 1 deletion pybutton/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
VERSION = '2.6.1'
VERSION = '2.7.0'