Skip to content

Commit

Permalink
Fixed Colors enum value representation. Fixed a bug caused by refacto…
Browse files Browse the repository at this point in the history
…ring.
  • Loading branch information
mmohades committed May 9, 2020
1 parent 9f3e28d commit 49bd5c0
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 26 deletions.
62 changes: 46 additions & 16 deletions docs/index.rst
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
.. Venmo documentation master file

Venmo API
=================================
Expand All @@ -9,19 +8,39 @@ Introduction

This is a wrapper for the Venmo API. This library provides a Python interface for the Venmo API. It's compatible with Python versions 3.6+.

Installing
----------

You can install or upgrade venmo-api with:

.. code-block:: bash
$ pip3 install venmo-api --upgrade
Or you can install it from the source:

.. code-block:: bash
$ git clone https://github.com/mmohades/Venmo.git --recursive
$ cd Venmo
$ python3 setup.py install
Getting Started
---------------

Usage
-----
^^^^^

In short, you can send money, request for money, get a user's public transactions, get a user's public profile info, etc. The following is an example of initializing and working with it.

.. code-block:: python
from Venmo import VenmoApi
from venmo_api import Client
# Get your access token. You will need to complete the 2FA process
access_token = VenmoApi.get_access_token(username='myemail@random.com',
password='your password')
venmo_api = VenmoApi(access_token=access_token)
access_token = Client.get_access_token(username='myemail@random.com',
password='your password')
venmo = Client(access_token=access_token)
# Search for users. You get 50 results per page.
users = venmo.user.search_for_users(query="Peter",
Expand All @@ -38,37 +57,48 @@ In short, you can send money, request for money, get a user's public transaction
page=2,
count=10)
Getting a user's public transactions
Keep this in mind that your access token never expires! You will need to revoke it by yoursef.

.. code-block:: Python
venmo.log_out("Bearer a40fsdfhsfhdsfjhdkgljsdglkdsfj3j3i4349t34j7d")
.. code-block:: python
# Request money
venmo.payment.request_money(32.5, "house expenses", "1122334455667")
.. code-block:: python
# Send money
venmo.payment.send_money(13.68, "thanks for the 🍔", "1122334455667")
Getting a user's transactions (public, friends and privates that happen between your account and user_id account)

.. code-block:: python
def callback(transactions_list):
for transaction in transactions_list:
print(transaction)
# callback is optional
# callback is optional. Max number of transactions per request is 50.
venmo_api.user.get_user_transactions(user_id='0000000000000',
callback=callback)
Getting Started
---------------

Installation
^^^^^^^^^^^^

Documentation
^^^^^^^^^^^^^

``venmo-api``\ 's documentation lives at `readthedocs.io <https://venmo.readthedocs.io/en/latest/>`_.

Contributing
------------

Contributions of all sizes are welcome. You can also help by `reporting bugs <https://github.com/mmohades/VenmoApi/issues/new>`_.
Contributions of all sizes are welcome. You can help with the wrapper documentation located in /docs. You can also help by `reporting bugs <https://github.com/mmohades/VenmoApi/issues/new>`_. You can add more routes to both `Venmo Unofficial API Documentation <https://github.com/mmohades/VenmoApiDocumentation>`_ and the ``venmo-api`` wrapper.

Venmo Unofficial API Documentation
----------------------------------

You can find and contribute to the `Venmo Unofficial API Documentation <https://github.com/mmohades/VenmoApiDocumentation>`_.


.. toctree::
:maxdepth: 2
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def requirements():

setup(
name='venmo-api',
version='0.1.1',
version='0.1.3',
author="Mark Mohades",
license="GNU General Public License v3",
url='https://github.com/mmohades/venmo',
Expand Down
14 changes: 9 additions & 5 deletions venmo_api/apis/auth_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def login_using_credentials(self, username: str, password: str) -> str:

header_params = {'device-id': self.__device_id,
'Content-Type': 'application/json',
'Host': 'api.venmo_api.com'
'Host': 'api.venmo.com'
}

body = {"phone_email_or_username": username,
Expand All @@ -51,7 +51,11 @@ def login_using_credentials(self, username: str, password: str) -> str:

def __two_factor_process(self, response):

otp_secret = response['headers']['venmo_api-otp-secret']
otp_secret = response['headers'].get('venmo-otp-secret')
if not otp_secret:
raise AuthenticationFailedError("Failed to get the otp-secret for the 2-factor authentication process. "
"(check your password)")

self.__send_text_otp(otp_secret=otp_secret)
user_otp = self.__ask_user_for_otp_password()

Expand All @@ -64,7 +68,7 @@ def __send_text_otp(self, otp_secret):

header_params = {'device-id': self.__device_id,
'Content-Type': 'application/json',
'venmo_api-otp-secret': otp_secret
'venmo-otp-secret': otp_secret
}
body = {"via": "sms"}
resource_path = '/account/two-factor/token'
Expand Down Expand Up @@ -94,8 +98,8 @@ def __ask_user_for_otp_password():
def __login_using_otp(self, user_otp, otp_secret):

header_params = {'device-id': self.__device_id,
'venmo_api-otp': user_otp,
'venmo_api-otp-secret': otp_secret
'venmo-otp': user_otp,
'venmo-otp-secret': otp_secret
}
params = {'client_id': 1}
resource_path = '/oauth/access_token'
Expand Down
2 changes: 1 addition & 1 deletion venmo_api/apis/payment_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ def __send_or_request_money(self, amount: float,
:param callback:
:return:
"""
target_user_id = get_user_id(target_user, target_user_id)
target_user_id = str(get_user_id(target_user, target_user_id))

amount = abs(amount)
if not is_send_money:
Expand Down
4 changes: 2 additions & 2 deletions venmo_api/utils/api_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ def warn(message):
:param message:
:return:
"""
print(Colors.WARNING + message + Colors.ENDC)
print(Colors.WARNING.value + message + Colors.ENDC.value)


def confirm(message):
Expand All @@ -101,7 +101,7 @@ def confirm(message):
:param message:
:return:
"""
print(Colors.OKBLUE + message + Colors.ENDC)
print(Colors.OKBLUE.value + message + Colors.ENDC.value)


def get_user_id(user, user_id):
Expand Down
1 change: 0 additions & 1 deletion venmo_api/venmo.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,4 @@ def log_out(access_token) -> bool:
:param access_token:
:return: <bool>
"""
access_token = validate_access_token(access_token=access_token)
return AuthenticationApi.log_out(access_token=access_token)

0 comments on commit 49bd5c0

Please sign in to comment.