Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: 'NoneType' object is not iterable #370

Closed
flarco opened this issue Dec 29, 2022 · 2 comments
Closed

TypeError: 'NoneType' object is not iterable #370

flarco opened this issue Dec 29, 2022 · 2 comments

Comments

@flarco
Copy link

flarco commented Dec 29, 2022

Hi, getting the following error when I call nu.get_account_statements(). Has anyone seen this before? My unchanged daily script started erroring out yesterday. Maybe nubank's API has changed?

Traceback (most recent call last):
  File "/_/projects/numbers/finance.py", line 175, in <module>
    import_nubank()
  File "/_/projects/numbers/finance.py", line 63, in import_nubank
    account_rows = nu.get_account_statements()
  File "/usr/local/anaconda3/lib/python3.8/site-packages/pynubank/auth_mode.py", line 23, in wrapper
    return function(*args, **kwargs)
  File "/usr/local/anaconda3/lib/python3.8/site-packages/deprecated/classic.py", line 285, in wrapper_function
    return wrapped_(*args_, **kwargs_)
  File "/usr/local/anaconda3/lib/python3.8/site-packages/pynubank/nubank.py", line 209, in get_account_statements
    feed = map(parse_pix_transaction, feed)
TypeError: 'NoneType' object is not iterable
@andreroggeri
Copy link
Owner

This is a known issue, it seems that nubank is deprecating this endpoint in favor of the paginated one.

Can you try it and check if it works with you?

@flarco
Copy link
Author

flarco commented Dec 29, 2022

Opa, that was more work than I anticipated, since get_account_statements_paginated returns a different record structure 😀 . Below is a snippet to gather all records for past 4 weeks into account_rows (with similar structure as get_account_statements).

Thank you! I'll close this.

  DATE_ANCHOR = str(datetime.today() - timedelta(weeks=4)).split()[0]

  account_rows = []
  feed = nu.get_account_statements_paginated()
  account_rows += [e['node'] for e in feed['edges']]
  has_next_page = feed['pageInfo']['hasNextPage']
  while has_next_page:
    cursor = feed['edges'][-1]['cursor']
    feed = nu.get_account_feed_paginated(cursor)
    account_rows += [e['node'] for e in feed['edges']]
    has_next_page = feed['pageInfo']['hasNextPage']
    if account_rows[-1]['postDate'] < DATE_ANCHOR: break

@flarco flarco closed this as completed Dec 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants