Skip to content

Commit

Permalink
restructure, bug fix for transactions, etc
Browse files Browse the repository at this point in the history
  • Loading branch information
ZhongxuanWang committed Nov 30, 2023
1 parent 282127c commit 089b1ee
Show file tree
Hide file tree
Showing 10 changed files with 72 additions and 72 deletions.
38 changes: 14 additions & 24 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,24 +1,14 @@
blinker==1.6.3
boto3==1.28.84
botocore==1.31.84
certifi==2022.9.24
charset-normalizer==2.1.1
click==8.1.3
Flask==2.2.2
Flask-SQLAlchemy==3.0.2
gunicorn==21.2.0
idna==3.4
itsdangerous==2.1.2
Jinja2==3.1.2
jmespath==1.0.1
MarkupSafe==2.1.1
packaging==23.2
python-dateutil==2.8.2
requests==2.28.1
s3transfer==0.7.0
six==1.16.0
SQLAlchemy==1.4.42
typing_extensions==4.8.0
urllib3==1.26.12
Werkzeug==2.2.2
python-dotenv~=1.0.0
blinker
boto3
cryptography
docopt
firebase-admin
flask-sqlalchemy
grpcio-status
gunicorn
pip-chill
pyrebase
python-dotenv
typing-extensions
venmo-api
yarg
3 changes: 3 additions & 0 deletions src/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ def create_app(config=Config()):
from src.transactions import bp as transactions_bp
app.register_blueprint(blueprint=transactions_bp, url_prefix='/transactions')

from src.services import bp as services_bp
app.register_blueprint(blueprint=services_bp, url_prefix='')

from src.main import bp as main_bp
app.register_blueprint(blueprint=main_bp, url_prefix='')

Expand Down
4 changes: 2 additions & 2 deletions src/extensions.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from flask_sqlalchemy import SQLAlchemy
# from venmo_api import Client
from venmo_api import Client

import os

db = SQLAlchemy()
# client = Client(access_token=os.environ["VENMO_TOKEN"])
client = Client(access_token=os.environ["VENMO_TOKEN"], )
10 changes: 0 additions & 10 deletions src/main/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,3 @@
@bp.route('/', methods=['GET'])
def index():
return success_message('CURaise Backend. Please go to https://github.com/CURaise/CURaise-backend for more guidance')


@bp.route('/signup/', methods=['POST'])
def signup():
pass


@bp.route('/signin/', methods=['POST'])
def signin():
pass
5 changes: 5 additions & 0 deletions src/services/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from flask import Blueprint

bp = Blueprint('services', __name__)

from src.services import routes
12 changes: 12 additions & 0 deletions src/services/routes.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
from src.services import bp
from src.utils import success_message


@bp.route('/signup/', methods=['POST'])
def signup():
pass


@bp.route('/signin/', methods=['POST'])
def signin():
pass
4 changes: 2 additions & 2 deletions src/transactions/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from flask import Blueprint

from src.students import routes

bp = Blueprint('transactions', __name__)

from src.transactions import routes
39 changes: 30 additions & 9 deletions src/transactions/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,46 @@
import string

from src.extensions import db
from src.extensions import client
from src.transactions import bp
from src.models import Club, Fundraiser, FundraiserItem
from src.utils import *


@bp.route('/verify/', methods=['POST'])
def verify_transaction():
try:
json_data = json.loads(request.data)
username = json_data['username']
except KeyError as e:
return failure_message(FAIL_MSG.POST_FORM.FIELD_NAME_WRONG + str(e))
except json.decoder.JSONDecodeError as e:
return failure_message(FAIL_MSG.POST_FORM.ERROR + str(e))

try:
user_id = client.user.search_for_users(query=username)[0].id
except Exception as e:
return failure_message(FAIL_MSG.VENMO.UNABLE_GET_USER_ID + str(e))

try:
new_transactions = client.user.get_user_transactions(user_id=user_id)
except Exception as e:
return failure_message(FAIL_MSG.VENMO.UNABLE_GET_TRANSACTION + str(e))

return success_message(new_transactions)


@bp.route('/create/', methods=['POST'])
def create_transaction():
pass


def get_qr_code_link(transaction_id, reference_string):
return f'https://chart.googleapis.com/chart?cht=qr&chl={transaction_id}__{reference_string}&chs=500x500'


def create_reference_string(transaction_id):
transaction_id * 76622729181571704961
characters = string.ascii_letters + string.digits
random_string = [''.join(random.choice(characters)) for _ in range(15)]
return random_string
# def get_qr_code_link(transaction_id, reference_string):
# return f'https://chart.googleapis.com/chart?cht=qr&chl={transaction_id}__{reference_string}&chs=500x500'
#
#
# def create_reference_string(transaction_id):
# transaction_id * 76622729181571704961
# characters = string.ascii_letters + string.digits
# random_string = [''.join(random.choice(characters)) for _ in range(15)]
# return random_string
6 changes: 4 additions & 2 deletions src/utils.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from flask import request

import json

DATETIME_FORMAT = "%Y-%m-%d %H:%M:%S"
Expand All @@ -15,6 +13,10 @@ class PARSE_ERROR:
DATETIME = "Unable to parse the datetime supplied. "
FLOAT = "Unable to parse the float supplied. "

class VENMO:
UNABLE_GET_USER_ID = "Unable to get the user id by the username provided. "
UNABLE_GET_TRANSACTION = "Unable to get the transactions by the id provided. "

ADD_TO_DATABASE = "Internal issue. Unable to add the item to the database. "
REMOVE_FROM_DATABASE = "Internal issue. Unable to remove the item from the database. "
TARGET_NOT_FOUND = "Target not found in our database. Unable to query. "
Expand Down
23 changes: 0 additions & 23 deletions src/venmo.py

This file was deleted.

0 comments on commit 089b1ee

Please sign in to comment.