From d5f34693b01223ae86f49599288dcc73001e2fdf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Roggeri=20Campos?= Date: Tue, 4 Oct 2022 10:59:05 -0300 Subject: [PATCH] chore: Deprecate account_feed methods in favor of the paginated one The API is not returning the feed anymore for some people. In the future we can remove this method. --- pynubank/nubank.py | 8 ++++++++ requirements.txt | 3 ++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/pynubank/nubank.py b/pynubank/nubank.py index a44d3ed..ec1b90e 100644 --- a/pynubank/nubank.py +++ b/pynubank/nubank.py @@ -3,6 +3,7 @@ import itertools import uuid from typing import Tuple +from deprecated import deprecated from qrcode import QRCode @@ -185,6 +186,7 @@ def get_card_statement_details(self, statement): return self._client.get(statement['_links']['self']['href']) @requires_auth_mode(AuthMode.APP) + @deprecated(version='2.21.0', reason='Use get_account_feed_paginated instead') def get_account_feed(self): data = self._make_graphql_request('account_feed') return data['data']['viewer']['savingsAccount']['feed'] @@ -201,11 +203,17 @@ def get_account_feed_paginated(self, cursor=None): return items @requires_auth_mode(AuthMode.APP) + @deprecated(version='2.21.0', reason='Use get_account_statements_paginated instead') def get_account_statements(self): feed = self.get_account_feed() feed = map(parse_pix_transaction, feed) return list(filter(lambda x: x['__typename'] in PAYMENT_EVENT_TYPES, feed)) + def get_account_statements_paginated(self, cursor=None): + feed = self.get_account_feed_paginated(cursor) + feed['edges'] = list(filter(lambda x: x['node'].get('amount') is not None, feed['edges'])) + return feed + @requires_auth_mode(AuthMode.APP) def get_account_balance(self): data = self._make_graphql_request('account_balance') diff --git a/requirements.txt b/requirements.txt index 0d00378..284dd55 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,4 +2,5 @@ requests==2.28.1 qrcode==7.3.1 pyOpenSSL==22.0.0 colorama==0.4.3 -requests-pkcs12==1.13 \ No newline at end of file +requests-pkcs12==1.13 +Deprecated==1.2.13 \ No newline at end of file