Skip to content

Commit 290ec13

Browse files
committed
Added start_position and max_results to "filter" method.
1 parent 44ae8bb commit 290ec13

File tree

3 files changed

+12
-7
lines changed

3 files changed

+12
-7
lines changed

README.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,12 +68,17 @@ List of objects:
6868
customers = Customer.all()
6969

7070
__Note:__ The maximum number of entities that can be returned in a response is 1000. If the result size is not specified, the default number is 100.
71-
(See [Intuit developer guide](https://developer.intuit.com/docs/0100_accounting/0300_developer_guides/querying_data) for supported SQL statements)
71+
(See [Intuit developer guide](https://developer.intuit.com/docs/0100_accounting/0300_developer_guides/querying_data) for details)
7272

7373
Filtered list of objects:
7474

7575
customers = Customer.filter(Active=True, FamilyName="Smith")
76+
77+
78+
Filtered list of objects with paging:
7679

80+
customers = Customer.filter(start_position=1, max_results=25, Active=True, FamilyName="Smith")
81+
7782

7883
List with custom Where Clause (do not include the "WHERE"):
7984

@@ -83,7 +88,7 @@ List with custom Where Clause (do not include the "WHERE"):
8388
List with custom Where Clause with paging:
8489

8590

86-
customers = Customer.where("Active = True AND CompanyName LIKE 'S%'", start_position=1, max_results=25)
91+
customers = Customer.where("CompanyName LIKE 'S%'", start_position=1, max_results=25)
8792

8893

8994
Filtering a list with a custom query (See [Intuit developer guide](https://developer.intuit.com/docs/0100_accounting/0300_developer_guides/querying_data) for supported SQL statements):

quickbooks/mixins.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,12 +76,12 @@ def all(cls, start_position="", max_results=100):
7676
return cls.where("", start_position=start_position, max_results=max_results)
7777

7878
@classmethod
79-
def filter(cls, **kwargs):
79+
def filter(cls, start_position="", max_results="", **kwargs):
8080
"""
8181
:param kwargs: field names and values to filter the query
8282
:return: Filtered list
8383
"""
84-
return cls.where(build_where_clause(**kwargs))
84+
return cls.where(build_where_clause(**kwargs), start_position=start_position, max_results=max_results)
8585

8686
@classmethod
8787
def where(cls, where_clause="", start_position="", max_results=""):

tests/unit/test_mixins.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@ class ListMixinTest(unittest.TestCase):
1919
@patch('quickbooks.mixins.ListMixin.where')
2020
def test_all(self, where):
2121
Department.all()
22-
where.assert_called_once_with('', max_results=1000, start_position='')
22+
where.assert_called_once_with('', max_results=100, start_position='')
2323

2424
@patch('quickbooks.mixins.ListMixin.where')
2525
def test_filter(self, where):
26-
Department.filter(Active=True)
27-
where.assert_called_once_with("Active = True")
26+
Department.filter(max_results=25, start_position='1', Active=True)
27+
where.assert_called_once_with("Active = True", max_results=25, start_position='1')
2828

2929
@patch('quickbooks.mixins.ListMixin.query')
3030
def test_where(self, query):

0 commit comments

Comments
 (0)