Skip to content

Commit

Permalink
chore: Deprecate account_feed methods in favor of the paginated one
Browse files Browse the repository at this point in the history
The API is not returning the feed anymore for some people. In the future we can remove this method.
  • Loading branch information
andreroggeri committed Oct 7, 2022
1 parent c62b607 commit d5f3469
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
8 changes: 8 additions & 0 deletions pynubank/nubank.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import itertools
import uuid
from typing import Tuple
from deprecated import deprecated

from qrcode import QRCode

Expand Down Expand Up @@ -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']
Expand All @@ -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')
Expand Down
3 changes: 2 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ requests==2.28.1
qrcode==7.3.1
pyOpenSSL==22.0.0
colorama==0.4.3
requests-pkcs12==1.13
requests-pkcs12==1.13
Deprecated==1.2.13

0 comments on commit d5f3469

Please sign in to comment.