Skip to content

Commit

Permalink
Merge pull request #1234 from bcgov/15687-pay-remove-restx
Browse files Browse the repository at this point in the history
15687 - Pay remove restx
  • Loading branch information
seeker25 authored Sep 11, 2023
2 parents 5212dc3 + 7ede26c commit 2e4373b
Show file tree
Hide file tree
Showing 54 changed files with 2,012 additions and 1,909 deletions.
2 changes: 1 addition & 1 deletion bcol-api/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ sentry-sdk==1.14.0
six==1.16.0
threadloop==1.0.2
thrift==0.16.0
tornado==6.3.2
tornado==6.3.3
urllib3==1.26.13
zeep==4.2.1
zipp==3.11.0
Expand Down
2 changes: 1 addition & 1 deletion jobs/ftp-poller/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ semver==2.13.0
six==1.16.0
threadloop==1.0.2
thrift==0.16.0
tornado==6.3.2
tornado==6.3.3
urllib3==1.26.16
zipp==3.15.0
-e git+https://github.com/bcgov/sbc-common-components.git#egg=sbc-common-components&subdirectory=python
Expand Down
2 changes: 1 addition & 1 deletion jobs/payment-jobs/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ six==1.16.0
strict-rfc3339==0.7
threadloop==1.0.2
thrift==0.16.0
tornado==6.3.2
tornado==6.3.3
typing_extensions==4.6.3
urllib3==1.26.16
zipp==3.15.0
4 changes: 2 additions & 2 deletions pay-api/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
Flask-Caching==2.0.2
Flask-Cors==3.0.10
Flask-Migrate==2.7.0
Flask-Moment==1.0.5
Flask-SQLAlchemy==2.5.1
Expand Down Expand Up @@ -34,7 +35,6 @@ exceptiongroup==1.1.1
expiringdict==1.2.2
flask-jwt-oidc==0.3.0
flask-marshmallow==0.11.0
flask-restx==1.1.0
google-api-core==2.11.0
google-auth==2.18.1
google-cloud-pubsub==2.17.0
Expand Down Expand Up @@ -72,7 +72,7 @@ sentry-sdk==1.19.1
six==1.16.0
threadloop==1.0.2
thrift==0.16.0
tornado==6.3.2
tornado==6.3.3
typing_extensions==4.5.0
urllib3==1.26.15
zipp==3.15.0
Expand Down
2 changes: 1 addition & 1 deletion pay-api/requirements/prod.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
gunicorn
Flask
Flask-Caching
Flask-Cors
Flask-Migrate<3
Flask-Script
Flask-Moment
Flask-SQLAlchemy
flask-restx
flask-marshmallow==0.11.0
flask-jwt-oidc
python-dotenv
Expand Down
16 changes: 12 additions & 4 deletions pay-api/src/pay_api/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
# import pay_api.config as config
from pay_api import config
from pay_api.config import _Config
from pay_api.resources import endpoints
from pay_api.services.flags import flags
from pay_api.models import db, ma
from pay_api.utils.auth import jwt
Expand All @@ -47,6 +48,7 @@ def create_app(run_mode=os.getenv('FLASK_ENV', 'production')):
flags.init_app(app)
db.init_app(app)
ma.init_app(app)
endpoints.init_app(app)

if run_mode != 'migration':

Expand All @@ -57,18 +59,24 @@ def create_app(run_mode=os.getenv('FLASK_ENV', 'production')):
dsn=app.config.get('SENTRY_DSN'),
integrations=[FlaskIntegration()]
)
# pylint: disable=import-outside-toplevel
from pay_api.resources import API_BLUEPRINT, OPS_BLUEPRINT

app.register_blueprint(API_BLUEPRINT)
app.register_blueprint(OPS_BLUEPRINT)
app.after_request(convert_to_camel)

setup_jwt_manager(app, jwt)

ExceptionHandler(app)

@app.after_request
def handle_after_request(response): # pylint: disable=unused-variable
add_version(response)
set_access_control_header(response)
return response

def set_access_control_header(response):
response.headers['Access-Control-Allow-Origin'] = '*'
response.headers['Access-Control-Allow-Headers'] = 'Authorization, Content-Type, registries-trace-id, ' \
'Account-Id'

def add_version(response): # pylint: disable=unused-variable
version = get_run_version()
response.headers['API'] = f'pay_api/{version}'
Expand Down
4 changes: 2 additions & 2 deletions pay-api/src/pay_api/models/invoice.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,8 +190,8 @@ class Meta(BaseSchema.Meta): # pylint: disable=too-few-public-methods
payment_account = ma.Nested(PaymentAccountSchema(only=('auth_account_id', 'name', 'billable')), many=False)

_links = ma.Hyperlinks({
'self': ma.URLFor('API.invoice_invoice', invoice_id='<id>'),
'collection': ma.URLFor('API.invoice_invoices', invoice_id='<id>')
'self': ma.URLFor('INVOICE.get_invoice', invoice_id='<id>'),
'collection': ma.URLFor('INVOICE.get_invoices', invoice_id='<id>')
})

total = fields.Float(data_key='total')
Expand Down
76 changes: 1 addition & 75 deletions pay-api/src/pay_api/resources/__init__.py
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -20,78 +20,4 @@
- meta
That are used to expose operational health information about the service, and meta information.
"""
from flask import Blueprint
from sbc_common_components.exception_handling.exception_handler import ExceptionHandler

from .account import API as ACCOUNTS_API
from .account_statements import API as ACCOUNT_STATEMENTS_API
from .account_statements_notifications import API as ACCOUNT_STATEMENT_NOTIFICATIONS_API
from .account_statements_settings import API as ACCOUNT_STATEMENTS_SETTINGS_API
from .apihelper import Api
from .bank_accounts import API as BANK_ACCOUNTS_API
from .code import API as CODES_API
from .distributions import API as DISTRIBUTION_API
from .fas import ROUTING_SLIP_API, ROUTING_SLIP_REFUND_API
from .fee import API as FEE_API
from .fee_schedule import API as FEE_SCHEDULE_API
from .invoice import API as INVOICE_API
from .invoice_receipt import API as INVOICE_RECEIPT_API
from .invoices import API as INVOICES_API
from .meta import API as META_API
from .ops import API as OPS_API
from .payment import API as PAYMENT_API
from .refund import API as REFUND_API
from .transaction import API as TRANSACTION_API


__all__ = ('API_BLUEPRINT', 'OPS_BLUEPRINT')

# This will add the Authorize button to the swagger docs
# TODO oauth2 & openid may not yet be supported by restplus <- check on this
AUTHORIZATIONS = {'apikey': {'type': 'apiKey', 'in': 'header', 'name': 'Authorization'}}

OPS_BLUEPRINT = Blueprint('API_OPS', __name__, url_prefix='/ops')

API_OPS = Api(
OPS_BLUEPRINT,
title='Service OPS API',
version='1.0',
description='The Core API for the Payment System',
security=['apikey'],
authorizations=AUTHORIZATIONS,
)

API_OPS.add_namespace(OPS_API, path='/')

API_BLUEPRINT = Blueprint('API', __name__, url_prefix='/api/v1')

API = Api(
API_BLUEPRINT,
title='Payment API',
version='1.0',
description='The Core API for the Payment System',
security=['apikey'],
authorizations=AUTHORIZATIONS,
)

HANDLER = ExceptionHandler(API)

API.add_namespace(META_API, path='/meta')
API.add_namespace(INVOICE_API, path='/payment-requests')
API.add_namespace(FEE_API, path='/fees')
API.add_namespace(FEE_SCHEDULE_API, '/fees/schedules')
API.add_namespace(DISTRIBUTION_API, '/fees/distributions')
API.add_namespace(TRANSACTION_API, path='')
API.add_namespace(INVOICE_RECEIPT_API, path='/payment-requests/<int:invoice_id>')
API.add_namespace(INVOICES_API, path='/payment-requests/<int:invoice_id>/invoices')
API.add_namespace(ACCOUNTS_API, path='/accounts')
API.add_namespace(ACCOUNT_STATEMENTS_API, path='/accounts/<string:account_id>/statements')
API.add_namespace(ACCOUNT_STATEMENTS_SETTINGS_API, path='/accounts/<string:account_id>/statements/settings')
API.add_namespace(ACCOUNT_STATEMENT_NOTIFICATIONS_API, path='/accounts/<string:account_id>/statements/notifications')
API.add_namespace(BANK_ACCOUNTS_API, path='/bank-accounts/verifications')
API.add_namespace(REFUND_API, path='/payment-requests/<int:invoice_id>')
API.add_namespace(PAYMENT_API, path='/accounts/<string:account_id>/payments')

API.add_namespace(CODES_API, path='/codes')
API.add_namespace(ROUTING_SLIP_API, path='/fas/routing-slips')
API.add_namespace(ROUTING_SLIP_REFUND_API, path='/fas/routing-slips/<string:routing_slip_number>/refunds')
from .endpoints import endpoints
Loading

0 comments on commit 2e4373b

Please sign in to comment.