Skip to content

Commit

Permalink
Setting up the project for PyPi deployment on pip.
Browse files Browse the repository at this point in the history
Updated README
Created LICENSE
  • Loading branch information
mmohades committed Feb 20, 2020
1 parent cd87b36 commit b8957fc
Show file tree
Hide file tree
Showing 21 changed files with 830 additions and 47 deletions.
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@ __pycache__/
local_settings.py
db.sqlite3
media


### Other ###
tests.py
venmo_api/test.py

### Linux ###
*~
Expand Down Expand Up @@ -124,6 +128,7 @@ fabric.properties
# C extensions
*.so


# Distribution / packaging
.Python
env/
Expand All @@ -143,6 +148,7 @@ wheels/
.installed.cfg
*.egg


# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
Expand Down
674 changes: 674 additions & 0 deletions LICENSE

Large diffs are not rendered by default.

48 changes: 37 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,35 @@

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+.

## Usage
## Installing

You can install or upgrade venmo-api with:

```bash
$ pip3 install venmo-api --upgrade
```

Or you can install it from the source:

```bash
$ git clone https://github.com/mmohades/Venmo.git --recursive
$ cd python-telegram-bot
$ python 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.

```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',
access_token = Client.get_access_token(username='myemail@random.com',
password='your password')
venmo_api = VenmoApi(access_token=access_token)
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 @@ -32,6 +50,19 @@ venmo.user.search_for_users(query="peter",
count=10)

```
Just keep this in mind that your access token almost never expires! You will need to revoke it by yoursef.

```Python
venmo.log_out("Bearer a40fsdfhsfhdsfjhdkgljsdglkdsfj3j3i4349t34j7d")
```

```python
# Request money
users = venmoash.payment.request_money(32.5, "house expenses", "1122334455667")
```



Getting a user's public transactions

```python
Expand All @@ -45,19 +76,14 @@ venmo_api.user.get_user_transactions(user_id='0000000000000',
```


## 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

Expand Down
3 changes: 0 additions & 3 deletions apis/__init__.py

This file was deleted.

3 changes: 0 additions & 3 deletions models/__init__.py

This file was deleted.

1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
requests>=2.19.0
52 changes: 52 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#!/usr/bin/env python

"""The setup script."""
from setuptools import setup, find_packages

with open('README.md') as readme_file:
readme = readme_file.read()


def requirements():
"""Build the requirements list for this project"""
requirements_list = []

with open('requirements.txt') as requirements:
for install in requirements:
requirements_list.append(install.strip())

return requirements_list


requirements = requirements()

setup(
name='venmo-api',
version='0.1.0',
author="Mark Mohades",
author_email='mohades@umd.edu',
license="GNU General Public License v3",
url='https://github.com/mmohades/venmo',
keywords='Python Venmo API wrapper',
description="A simple Python wrapper for the Venmo API",
long_description=readme,
long_description_content_type="text/markdown",
packages=find_packages(),
install_requires=requirements,
python_requires='>=3.6',
include_package_data=True,
classifiers=[
'Development Status :: 3 - Alpha',
'Intended Audience :: Developers',
'License :: OSI Approved :: GNU General Public License v3 (GPLv3)',
'Operating System :: OS Independent',
'Natural Language :: English',
'Topic :: Software Development :: Libraries :: Python Modules',
'Topic :: Internet',
'Programming Language :: Python',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
]
)
26 changes: 26 additions & 0 deletions venmo_api/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
from .models.exception import *

from .utils import (string_to_timestamp, get_phone_model_from_json, random_device_id, deserialize, wrap_callback,
warn, confirm)
from .utils.api_client import ApiClient

from .models.json_schema import JSONSchema
from .models.user import User
from .models.transaction import Transaction
from .models.payment_method import PaymentMethod, PaymentRole, PaymentPrivacy

from .apis.auth_api import AuthenticationApi
from .apis.payment_api import PaymentApi
from .apis.user_api import UserApi

from .venmo import Client


__all__ = ["AuthenticationFailedError", "InvalidArgumentError", "InvalidHttpMethodError", "ArgumentMissingError",
"JSONDecodeError", "ResourceNotFoundError", "HttpCodeError", "NoPaymentMethodFoundError",
"string_to_timestamp", "get_phone_model_from_json", "random_device_id", "deserialize", "wrap_callback",
"warn", "confirm",
"JSONSchema", "User", "Transaction", "PaymentMethod", "PaymentRole", "PaymentPrivacy",
"ApiClient", "AuthenticationApi", "UserApi", "PaymentApi",
"Client"
]
Empty file added venmo_api/apis/__init__.py
Empty file.
16 changes: 8 additions & 8 deletions apis/auth_api.py → venmo_api/apis/auth_api.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from utils import random_device_id, warn, confirm
from models.exception import AuthenticationFailedError
from utils.api_client import ApiClient
from venmo_api import random_device_id, warn, confirm
from venmo_api import AuthenticationFailedError
from venmo_api import ApiClient


class AuthenticationApi(object):
Expand All @@ -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.com'
'Host': 'api.venmo_api.com'
}

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

def __two_factor_process(self, response):

otp_secret = response['headers']['venmo-otp-secret']
otp_secret = response['headers']['venmo_api-otp-secret']
self.__send_text_otp(otp_secret=otp_secret)
user_otp = self.__ask_user_for_otp_password()

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

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

header_params = {'device-id': self.__device_id,
'venmo-otp': user_otp,
'venmo-otp-secret': otp_secret
'venmo_api-otp': user_otp,
'venmo_api-otp-secret': otp_secret
}
params = {'client_id': 1}
resource_path = '/oauth/access_token'
Expand Down
10 changes: 5 additions & 5 deletions apis/payment_api.py → venmo_api/apis/payment_api.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from utils.api_client import ApiClient
from models import User, PaymentMethod, PaymentRole, PaymentPrivacy
from models.exception import ArgumentMissingError, NoPaymentMethodFoundError
from utils import deserialize, wrap_callback
from venmo_api import ApiClient
from venmo_api import User, PaymentMethod, PaymentRole, PaymentPrivacy
from venmo_api import ArgumentMissingError, NoPaymentMethodFoundError
from venmo_api import deserialize, wrap_callback
from threading import Thread
from typing import List, Union

Expand Down Expand Up @@ -55,8 +55,8 @@ def send_money(self, amount: float,

def request_money(self, amount: float,
note: str,
privacy_setting: str = PaymentPrivacy.private.value,
target_user_id: int = None, target_user: User = None,
privacy_setting: str = PaymentPrivacy.private.value,
callback=None) -> Union[bool, Thread]:
"""
Request money from a user.
Expand Down
8 changes: 4 additions & 4 deletions apis/user_api.py → venmo_api/apis/user_api.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from models.user import User
from models.transaction import Transaction
from models.exception import InvalidArgumentError, ArgumentMissingError
from utils import deserialize, wrap_callback
from venmo_api import User
from venmo_api import Transaction
from venmo_api import InvalidArgumentError, ArgumentMissingError
from venmo_api import deserialize, wrap_callback
from threading import Thread
from typing import List, Union

Expand Down
Empty file added venmo_api/models/__init__.py
Empty file.
5 changes: 5 additions & 0 deletions models/exception.py → venmo_api/models/exception.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,3 +71,8 @@ class NoPaymentMethodFoundError(Exception):
def __init__(self, msg: str = None, reason=None):
self.msg = msg or ("No eligible payment method found." + "" or reason)
super(NoPaymentMethodFoundError, self).__init__(self.msg)


__all__ = ["AuthenticationFailedError", "InvalidArgumentError", "InvalidHttpMethodError", "ArgumentMissingError",
"JSONDecodeError", "ResourceNotFoundError", "HttpCodeError", "NoPaymentMethodFoundError"
]
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from typing import Dict
from enum import Enum
from utils.json_schema import JSONSchema
from venmo_api import JSONSchema


class PaymentMethod(object):
Expand Down
8 changes: 4 additions & 4 deletions models/transaction.py → venmo_api/models/transaction.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from utils import string_to_timestamp
from models.user import User
from utils import get_phone_model_from_json
from utils.json_schema import JSONSchema
from venmo_api import string_to_timestamp
from venmo_api import User
from venmo_api import get_phone_model_from_json
from venmo_api import JSONSchema


class Transaction(object):
Expand Down
4 changes: 2 additions & 2 deletions models/user.py → venmo_api/models/user.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from utils import string_to_timestamp
from utils.json_schema import JSONSchema
from venmo_api import string_to_timestamp
from venmo_api import JSONSchema


class User(object):
Expand Down
File renamed without changes.
6 changes: 3 additions & 3 deletions utils/api_client.py → venmo_api/utils/api_client.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import requests
import threading
from json import JSONDecodeError
from typing import List
from models.exception import ResourceNotFoundError, InvalidHttpMethodError, HttpCodeError
from venmo_api import ResourceNotFoundError, InvalidHttpMethodError, HttpCodeError
import requests
import threading


class ApiClient(object):
Expand Down
5 changes: 2 additions & 3 deletions venmo.py → venmo_api/venmo.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
from utils.api_client import ApiClient
from apis import *
from venmo_api import ApiClient, UserApi, PaymentApi, AuthenticationApi


class VenmoApi(object):
class Client(object):

def __init__(self, access_token: str):
"""
Expand Down

0 comments on commit b8957fc

Please sign in to comment.