Skip to content

Commit

Permalink
Added start_position and max_results to "filter" method.
Browse files Browse the repository at this point in the history
  • Loading branch information
ej2 committed Sep 13, 2015
1 parent 44ae8bb commit 290ec13
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
9 changes: 7 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,17 @@ List of objects:
customers = Customer.all()

__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.
(See [Intuit developer guide](https://developer.intuit.com/docs/0100_accounting/0300_developer_guides/querying_data) for supported SQL statements)
(See [Intuit developer guide](https://developer.intuit.com/docs/0100_accounting/0300_developer_guides/querying_data) for details)

Filtered list of objects:

customers = Customer.filter(Active=True, FamilyName="Smith")


Filtered list of objects with paging:

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


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

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


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


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):
Expand Down
4 changes: 2 additions & 2 deletions quickbooks/mixins.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,12 @@ def all(cls, start_position="", max_results=100):
return cls.where("", start_position=start_position, max_results=max_results)

@classmethod
def filter(cls, **kwargs):
def filter(cls, start_position="", max_results="", **kwargs):
"""
:param kwargs: field names and values to filter the query
:return: Filtered list
"""
return cls.where(build_where_clause(**kwargs))
return cls.where(build_where_clause(**kwargs), start_position=start_position, max_results=max_results)

@classmethod
def where(cls, where_clause="", start_position="", max_results=""):
Expand Down
6 changes: 3 additions & 3 deletions tests/unit/test_mixins.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ class ListMixinTest(unittest.TestCase):
@patch('quickbooks.mixins.ListMixin.where')
def test_all(self, where):
Department.all()
where.assert_called_once_with('', max_results=1000, start_position='')
where.assert_called_once_with('', max_results=100, start_position='')

@patch('quickbooks.mixins.ListMixin.where')
def test_filter(self, where):
Department.filter(Active=True)
where.assert_called_once_with("Active = True")
Department.filter(max_results=25, start_position='1', Active=True)
where.assert_called_once_with("Active = True", max_results=25, start_position='1')

@patch('quickbooks.mixins.ListMixin.query')
def test_where(self, query):
Expand Down

0 comments on commit 290ec13

Please sign in to comment.