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

get_date_completed json_format #1

Closed
gudaev opened this issue May 13, 2020 · 4 comments
Closed

get_date_completed json_format #1

gudaev opened this issue May 13, 2020 · 4 comments
Assignees
Labels
bug Something isn't working

Comments

@gudaev
Copy link

gudaev commented May 13, 2020

Hi,
First of all, thank you for pulling this together.
I'm getting TypeError: 'NoneType' object is not subscriptable for /venmo_api/models/json_schema.py", line 51, in get_date_completed return self.payment[payment_json_format['date_completed']]

PS.. im trying to test user.get_user_transactions

also... do you know if their https://github.com/mmohades/VenmoApiDocumentation#transaction-info would simply authorize me w/ bearer token? I can pull https://api.venmo.com/v1/users/ but transactions return me "You did not pass a valid OAuth access token."

Thanks,
Egor

@mmohades
Copy link
Owner

Hi, thanks for creating an issue.
hm, I'm guessing it might have happened because the returned JSON doesn't have a date_completed for the transaction, like a pending transaction. Could you share more info so I can reproduce the issue?

Did you obtain a token using Client.get_acess_token("username", "password") for your Venmo account? Using your token, you should be able to get user's transactions info from here:
https://github.com/mmohades/VenmoApiDocumentation#users-transactions-list
You need to pass your token in your request's header.

@mmohades mmohades added the bug Something isn't working label May 13, 2020
@mmohades mmohades self-assigned this May 13, 2020
@gudaev
Copy link
Author

gudaev commented May 13, 2020

Thank you for your reply!
I've created a token so it got me logged in fine. Here is a traceback (most recent call last):
File "json_test.py", line 21, in <module> tx = venmo.user.get_user_transactions(user_id='xxx') File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/venmo_api/apis/user_api.py", line 149, in get_user_transactions return deserialize(response=response, data_type=Transaction) File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/venmo_api/utils/api_util.py", line 43, in deserialize return __get_objs_from_json_list(json_list=data, data_type=data_type) File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/venmo_api/utils/api_util.py", line 75, in __get_objs_from_json_list return [data_type.from_json(obj) for obj in json_list] File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/venmo_api/utils/api_util.py", line 75, in <listcomp> return [data_type.from_json(obj) for obj in json_list] File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/venmo_api/models/transaction.py", line 38, in from_json date_completed = string_to_timestamp(parser.get_date_completed()) File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/venmo_api/models/json_schema.py", line 51, in get_date_completed return self.payment[payment_json_format['date_completed']] TypeError: 'NoneType' object is not subscriptable

where user id xxx is the primary (owner) of the token (me)

  • regarding individual transactions, here is a sample:
    payload = {'Authorization': 'Bearer YYY'} r = requests.get('https://api.venmo.com/v1/stories/ZZZ', params=payload) print('TEXT:', r.text)
    my guess is that the request header schema should be somewhat different. What puzzles me is that according to spec it's User.phone returning 'None' for every user. #4, same as for GET /users/{user-id} which works fine.

Thanks again for your help!

@mmohades
Copy link
Owner

Thanks for reporting the bug! Apparently, Venmo puts your bank transfers in the transaction list as well. I fixed the bug.
run pip3 install venmo-api --upgrade to update venmo-api. Let me know if this fix the issue or not.

For getting a specific transaction info, try running this:

r = requests.request(method="GET", url="https://api.venmo.com/v1/stories/ZZZZ", headers={"Authorization": f"Bearer {token}"})
print('TEXT:', r.text)

@gudaev
Copy link
Author

gudaev commented May 14, 2020

Awesome! Thank you so much! Both cases worked! Just a note to whoever is reading - ZZZ is apparently story_id, not payment_id

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants