Skip to content

Commit

Permalink
created sdist and bdist for PyPi to deploy on pip
Browse files Browse the repository at this point in the history
  • Loading branch information
mmohades committed Feb 20, 2020
1 parent cd87b36 commit 36d513a
Show file tree
Hide file tree
Showing 64 changed files with 2,909 additions and 64 deletions.
22 changes: 4 additions & 18 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/test.py

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

# Distribution / packaging
.Python
env/
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
*.egg-info/
.installed.cfg
*.egg

# PyInstaller
# Usually these files are written by a python script from a template
Expand Down
43 changes: 32 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_api = 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,14 @@ 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

```



Getting a user's public transactions

```python
Expand All @@ -45,19 +71,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.

16 changes: 16 additions & 0 deletions build/lib/venmo/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
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_api import Client
Empty file.
16 changes: 8 additions & 8 deletions apis/auth_api.py → build/lib/venmo/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
8 changes: 4 additions & 4 deletions apis/payment_api.py → build/lib/venmo/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
8 changes: 4 additions & 4 deletions apis/user_api.py → build/lib/venmo/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.
File renamed without changes.
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
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 → build/lib/venmo/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
7 changes: 7 additions & 0 deletions build/lib/venmo/test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from venmo_api.venmo import Client

venmoash = Client("Bearer a40feeb268f13825bcca7b79130a7711352854b52633bda5e16349656b06367d")

users = venmoash.user.search_for_users('mamali')
for user in users:
print(user)
File renamed without changes.
6 changes: 3 additions & 3 deletions utils/api_client.py → build/lib/venmo/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
37 changes: 37 additions & 0 deletions build/lib/venmo/venmo_api.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
from venmo_api import ApiClient, UserApi, PaymentApi, AuthenticationApi


class Client(object):

def __init__(self, access_token: str):
"""
VenmoAPI Client
:param access_token: <str> Need access_token to work with the API.
"""
super().__init__()
self.__access_token = access_token
self.__api_client = ApiClient(access_token=access_token)
self.user = UserApi(self.__api_client)
self.payment = PaymentApi(self.__api_client)

@staticmethod
def get_access_token(username: str, password: str, device_id: str = None) -> str:
"""
Log in using your credentials and get an access_token to use in the API
:param username: <str> Can be username, phone number (without +1) or email address.
:param password: <str> Account's password
:param device_id: <str> [optional] A valid device-id.
:return: <str> access_token
"""
authn_api = AuthenticationApi(api_client=ApiClient(), device_id=device_id)
return authn_api.login_using_credentials(username=username, password=password)

@staticmethod
def log_out(access_token) -> bool:
"""
Revoke your access_token. Log out, in other words.
:param access_token:
:return: <bool>
"""
return AuthenticationApi.log_out(access_token=access_token)
26 changes: 26 additions & 0 deletions build/lib/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.

0 comments on commit 36d513a

Please sign in to comment.