Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
seeker25 committed Mar 13, 2024
1 parent 9473336 commit 0d290df
Show file tree
Hide file tree
Showing 10 changed files with 30 additions and 36 deletions.
4 changes: 4 additions & 0 deletions jobs/ftp-poller/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,10 @@ class _Config(object): # pylint: disable=too-few-public-methods
SENTRY_ENABLE = os.getenv('SENTRY_ENABLE', 'False')
SENTRY_DSN = os.getenv('SENTRY_DSN', None)

# GCP PubSub
AUDIENCE = os.getenv('AUDIENCE', None)
GCP_AUTH_KEY = os.getenv('GCP_AUTH_KEY', None)
PUBLISHER_AUDIENCE = os.getenv('PUBLISHER_AUDIENCE', None)
FTP_POLLER_TOPIC = os.getenv('FTP_POLLER_TOPIC', None)

TESTING = False
Expand Down
7 changes: 4 additions & 3 deletions jobs/ftp-poller/tasks/cgi_feeder_poller_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
from flask import current_app
from paramiko.sftp_attr import SFTPAttributes

from pay_api.utils.enums import MessageType
from services.sftp import SFTPService
from utils.constants import CGI_ACK_MESSAGE_TYPE, CGI_FEEDBACK_MESSAGE_TYPE
from utils import utils


Expand Down Expand Up @@ -48,12 +48,13 @@ def poll_ftp(cls):
f'Skipping directory {file_name}.')
continue
if cls._is_ack_file(file_name):
utils.publish_to_queue([file_name], CGI_ACK_MESSAGE_TYPE)
utils.publish_to_queue([file_name], MessageType.CGI_ACK_RECEIVED.value)
cls._move_file_to_backup(sftp_client, [file_name])
elif cls._is_feedback_file(file_name):
bucket_name = current_app.config.get('MINIO_CGI_BUCKET_NAME')
utils.upload_to_minio(file, file_full_name, sftp_client, bucket_name)
utils.publish_to_queue([file_name], CGI_FEEDBACK_MESSAGE_TYPE, location=bucket_name)
utils.publish_to_queue([file_name], MessageType.CGI_FEEDBACK_RECEIVED.value,
location=bucket_name)
cls._move_file_to_backup(sftp_client, [file_name])
elif cls._is_a_trigger_file(file_name):
cls._remove_file(sftp_client, file_name)
Expand Down
5 changes: 3 additions & 2 deletions jobs/ftp-poller/tasks/eft_poller_ftp.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
from flask import current_app
from paramiko.sftp_attr import SFTPAttributes

from pay_api.utils.enums import MessageType
from services.sftp import SFTPService
from utils.constants import EFT_MESSAGE_TYPE
from utils.utils import publish_to_queue, upload_to_minio


Expand Down Expand Up @@ -66,7 +66,8 @@ def _post_process(cls, sftp_client, payment_file_list: List[str]):
2.Send a message to queue
"""
cls._move_file_to_backup(sftp_client, payment_file_list)
publish_to_queue(payment_file_list, EFT_MESSAGE_TYPE, location=current_app.config.get('MINIO_EFT_BUCKET_NAME'))
publish_to_queue(payment_file_list, MessageType.EFT_FILE_UPLOADED.value,
location=current_app.config.get('MINIO_EFT_BUCKET_NAME'))

@classmethod
def _move_file_to_backup(cls, sftp_client, payment_file_list):
Expand Down
19 changes: 0 additions & 19 deletions jobs/ftp-poller/utils/constants.py

This file was deleted.

6 changes: 2 additions & 4 deletions jobs/ftp-poller/utils/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,12 @@
from paramiko import SFTPFile
from pay_api.services import gcp_queue_publisher
from pay_api.services.gcp_queue_publisher import QueueMessage
from pay_api.utils.enums import QueueSources
from pay_api.utils.enums import MessageType, QueueSources


from utils.constants import CAS_MESSAGE_TYPE
from utils.minio import put_object


def publish_to_queue(payment_file_list: List[str], message_type=CAS_MESSAGE_TYPE, location: str = ''):
def publish_to_queue(payment_file_list: List[str], message_type=MessageType.CAS_UPLOADED.value, location: str = ''):
"""Publish message to the Queue, saying file has been uploaded. Using the event spec."""
queue_data = {
'fileSource': 'MINIO',
Expand Down
5 changes: 5 additions & 0 deletions jobs/payment-jobs/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,11 @@ class _Config(object): # pylint: disable=too-few-public-methods
EFT_HOLDING_GL = os.getenv('EFT_HOLDING_GL', '')
EFT_TRANSFER_DESC = os.getenv('EFT_TRANSFER_DESC', 'BCREGISTRIES {} {} EFT TRANSFER')

# GCP PubSub
AUDIENCE = os.getenv('AUDIENCE', None)
GCP_AUTH_KEY = os.getenv('GCP_AUTH_KEY', None)
PUBLISHER_AUDIENCE = os.getenv('PUBLISHER_AUDIENCE', None)
ACCOUNT_MAILER_TOPIC = os.getenv('ACCOUNT_MAILER_TOPIC', None)

class DevConfig(_Config): # pylint: disable=too-few-public-methods
TESTING = False
Expand Down
7 changes: 3 additions & 4 deletions pay-api/src/pay_api/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,10 +124,9 @@ class _Config(): # pylint: disable=too-few-public-methods
AUDIENCE = os.getenv('AUDIENCE', None)
GCP_AUTH_KEY = os.getenv('GCP_AUTH_KEY', None)
PUBLISHER_AUDIENCE = os.getenv('PUBLISHER_AUDIENCE', None)
# Used for sending queue messages for Namex transactions
NRO_TOPIC = os.getenv('NRO_TOPIC', None)
# Used for sending queue messages for Entity or Business transactions.
BUSINESS_TOPIC = os.getenv('BUSINESS_TOPIC', None)
ACCOUNT_MAILER_TOPIC = os.getenv('ACCOUNT_MAILER_TOPIC', None)
NAMEX_PAY_TOPIC = os.getenv('NAMEX_PAY_TOPIC', None)
BUSINESS_PAY_TOPIC = os.getenv('BUSINESS_PAY_TOPIC', None)

# Auth API Endpoint
AUTH_API_ENDPOINT = f'{_get_config("AUTH_API_URL")}/'
Expand Down
5 changes: 5 additions & 0 deletions pay-queue/src/pay_queue/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,11 @@ class _Config(): # pylint: disable=too-few-public-methods
# Disable PAD Success Email - Incase we need to reprocess records weeks/months later
DISABLE_PAD_SUCCESS_EMAIL = os.getenv('DISABLE_PAD_SUCCESS_EMAIL', 'false').lower() == 'true'

# GCP PubSub
AUDIENCE = os.getenv('AUDIENCE', None)
GCP_AUTH_KEY = os.getenv('GCP_AUTH_KEY', None)
PUBLISHER_AUDIENCE = os.getenv('PUBLISHER_AUDIENCE', None)
ACCOUNT_MAILER_TOPIC = os.getenv('ACCOUNT_MAILER_TOPIC', None)

class DevConfig(_Config): # pylint: disable=too-few-public-methods
"""Creates the Development Config object."""
Expand Down
2 changes: 1 addition & 1 deletion pay-queue/src/pay_queue/services/eft/eft_reconciliation.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def reconcile_eft_payments(msg: Dict[str, any]): # pylint: disable=too-many-loc
7: Apply balance to outstanding EFT invoices - Update invoice paid amount and status, create payment,
invoice reference, and receipt
8: Create EFT Credit records for left over balances
9: Finalize and completeF
9: Finalize and complete
"""
# Fetch EFT File
file_name: str = msg.get('fileName')
Expand Down
6 changes: 3 additions & 3 deletions pay-queue/tests/integration/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
from simple_cloudevent import SimpleCloudEvent, to_queue_message


def build_request_for_queue_message(message_type, payload):
def build_request_for_queue_push(message_type, payload):
"""Build request for queue message."""
queue_message_bytes = to_queue_message(SimpleCloudEvent(
id=str(uuid.uuid4()),
Expand Down Expand Up @@ -99,7 +99,7 @@ def helper_add_file_event_to_queue(client, file_name: str, message_type: str):
'fileName': file_name,
'location': current_app.config['MINIO_BUCKET_NAME']
}
request_payload = build_request_for_queue_message(message_type, queue_payload)
request_payload = build_request_for_queue_push(message_type, queue_payload)
post_to_queue(client, request_payload)


Expand All @@ -115,5 +115,5 @@ def helper_add_identifier_event_to_queue(client, old_identifier: str = 'T1234567
'identifier': new_identifier,
'tempidentifier': old_identifier,
}
request_payload = build_request_for_queue_message(message_type, queue_payload)
request_payload = build_request_for_queue_push(message_type, queue_payload)
post_to_queue(client, request_payload)

0 comments on commit 0d290df

Please sign in to comment.