Skip to content

Commit b1d75ad

Browse files
author
Will Myers
authored
Add time_field to accounts#transactions (#33)
* Added optional `time_field` argument to `client.accounts.transactions` * Fixup flake8; add test
1 parent 14f5641 commit b1d75ad

File tree

5 files changed

+22
-2
lines changed

5 files changed

+22
-2
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
Current Version
22
-
33

4+
2.7.0 June 21, 2018
5+
- Added optional `time_field` argument to `client.accounts.transactions`
6+
47
2.6.1 June 5, 2018
58
- Added `HTTPResponseError` to top-level import
69
- Remove `__all__` imports: they never worked

README.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ pass the following optional arguments:
123123
* ``cursor`` (string): An API cursor to fetch a specific set of results.
124124
* ``start`` (ISO-8601 datetime string): Fetch transactions after this time.
125125
* ``end`` (ISO-8601 datetime string): Fetch transactions before this time.
126+
* ``time_field`` (string): Which time field ``start`` and ``end`` filter on.
126127

127128
.. code:: python
128129

pybutton/resources/accounts.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ def all(self):
2626

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

29-
def transactions(self, account_id, cursor=None, start=None, end=None):
29+
def transactions(self, account_id, cursor=None, start=None, end=None,
30+
time_field=None):
3031
'''Get a list of transactions.
3132
To paginate transactions, pass the result of response.next_cursor() as
3233
the cursor argument.
@@ -40,6 +41,8 @@ def transactions(self, account_id, cursor=None, start=None, end=None):
4041
created at or after this time.
4142
end (ISO-8601 datetime str) optional: Filter out transactions
4243
created before this time.
44+
time_field (str) optional: Which time field ``start`` and ``end``
45+
filter on
4346
4447
Raises:
4548
pybutton.ButtonClientError
@@ -57,6 +60,8 @@ def transactions(self, account_id, cursor=None, start=None, end=None):
5760
query['start'] = start
5861
if end:
5962
query['end'] = end
63+
if time_field:
64+
query['time_field'] = time_field
6065

6166
path = '/v1/affiliation/accounts/{0}/transactions'.format(
6267
account_id

pybutton/test/resources/accounts_test.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,3 +58,14 @@ def test_transactions(self):
5858
self.assertEqual(query['cursor'], 'abc')
5959
self.assertEqual(query['start'], '2016-09-15T00:00:00.000Z')
6060
self.assertEqual(query['end'], '2016-09-30T00:00:00.000Z')
61+
62+
response = account.transactions(
63+
'acc-123',
64+
cursor='abc',
65+
start='2016-09-15T00:00:00.000Z',
66+
end='2016-09-30T00:00:00.000Z',
67+
time_field='created_date'
68+
)
69+
self.assertEqual(response, account_response)
70+
query = api_get.call_args[1]['query']
71+
self.assertEqual(query['time_field'], 'created_date')

pybutton/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
VERSION = '2.6.1'
1+
VERSION = '2.7.0'

0 commit comments

Comments
 (0)