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 ede6695
Show file tree
Hide file tree
Showing 20 changed files with 123 additions and 35 deletions.
4 changes: 4 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/test.py

### Linux ###
*~
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
8 changes: 4 additions & 4 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
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
7 changes: 7 additions & 0 deletions venmo_api/test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from venmo_api 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 → 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 ede6695

Please sign in to comment.