From 12712d7854d7ecb8dfad7087491c7c44a65b217c Mon Sep 17 00:00:00 2001 From: Tomas Perestrelo Date: Tue, 9 Jan 2024 13:18:46 +0000 Subject: [PATCH] Change arguments in get_loans function to return group guaranteed loans by default. --- peerberrypy/api.py | 7 ++++++- pyproject.toml | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/peerberrypy/api.py b/peerberrypy/api.py index 6bf59bc..e52b872 100644 --- a/peerberrypy/api.py +++ b/peerberrypy/api.py @@ -156,7 +156,7 @@ def get_loans( loan_types: Optional[List[str]] = None, sort: str = 'loan_amount', ascending_sort: bool = False, - group_guarantee: Optional[bool] = None, + group_guarantee: bool = True, exclude_invested_loans: Optional[bool] = None, raw: bool = False, ) -> 'Union[pd.DataFrame, List[dict]]': @@ -179,7 +179,9 @@ def get_loans( :param raw: Returns python list if True or pandas DataFrame if False (False by default) :return: All available loans for investment according to specified parameters """ + argv = locals() + if quantity <= 0: raise ValueError('You need to fetch at least 1 loan.') @@ -189,6 +191,7 @@ def get_loans( argv.pop('quantity', None) argv.pop('raw', None) argv.pop('start_page', None) + do_get_loans_page = functools.partial(self.get_loans_page, **argv) loans = [] @@ -198,7 +201,9 @@ def get_loans( for page_num in range(total_pages): remaining_items = quantity - (page_num * max_page_size) + page_size = min(remaining_items, max_page_size) + loans_data = do_get_loans_page(page_num)['data'] if len(loans_data) == 0: diff --git a/pyproject.toml b/pyproject.toml index 2186669..659ce64 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta" [project] name = "peerberrypy" -version = "1.7.0" +version = "1.9.0" authors = [ { name = "Tomás Perestrelo", email = "tomasperestrelo21@gmail.com" } ]