From 51d04870006440a9fd2e07c3a8c7e011da07c4bb Mon Sep 17 00:00:00 2001 From: Marco Burgos Date: Thu, 23 May 2024 15:13:05 -0500 Subject: [PATCH] fix: add req file --- src/clients/.flake8 | 2 ++ src/clients/client_modules/dao/client_dao.py | 2 +- .../data_mapper/client_mapper.py | 21 ++++++++++++++----- src/clients/client_modules/models/client.py | 3 ++- src/clients/lambda_function.py | 9 +++----- src/clients/requirements.txt | 3 +++ 6 files changed, 27 insertions(+), 13 deletions(-) create mode 100644 src/clients/.flake8 create mode 100644 src/clients/requirements.txt diff --git a/src/clients/.flake8 b/src/clients/.flake8 new file mode 100644 index 0000000..9214cb9 --- /dev/null +++ b/src/clients/.flake8 @@ -0,0 +1,2 @@ +[flake8] +ignore = E501, W503 \ No newline at end of file diff --git a/src/clients/client_modules/dao/client_dao.py b/src/clients/client_modules/dao/client_dao.py index c79cf5d..0a7f8ef 100644 --- a/src/clients/client_modules/dao/client_dao.py +++ b/src/clients/client_modules/dao/client_dao.py @@ -40,4 +40,4 @@ def update_client(self, item: dict) -> dict: :rtype: dict """ response = self.clients_db.update_record(item) - return response \ No newline at end of file + return response diff --git a/src/clients/client_modules/data_mapper/client_mapper.py b/src/clients/client_modules/data_mapper/client_mapper.py index 0280e66..741a99a 100644 --- a/src/clients/client_modules/data_mapper/client_mapper.py +++ b/src/clients/client_modules/data_mapper/client_mapper.py @@ -78,23 +78,34 @@ def build_client(self, username: str) -> Dict[str, Any]: "address", "address_geolocation", "ADDRESS_NEEDS_GEO", client_errors ) address_latitude = ( - float(address_geolocation.get("latitude", 0)) if address_geolocation else None + float(address_geolocation.get("latitude", 0)) + if address_geolocation + else None ) address_longitude = ( - float(address_geolocation.get("longitude", 0)) if address_geolocation else None + float(address_geolocation.get("longitude", 0)) + if address_geolocation + else None ) second_address_latitude = None second_address_longitude = None if self.client_data.get("second_address") is not None: second_address_geolocation = self.get_geolocation_data( - "second_address", "second_address_geolocation", "SECOND_ADDRESS_NEEDS_GEO", client_errors + "second_address", + "second_address_geolocation", + "SECOND_ADDRESS_NEEDS_GEO", + client_errors, ) second_address_latitude = ( - float(second_address_geolocation.get("latitude", 0)) if second_address_geolocation else None + float(second_address_geolocation.get("latitude", 0)) + if second_address_geolocation + else None ) second_address_longitude = ( - float(second_address_geolocation.get("longitude", 0)) if second_address_geolocation else None + float(second_address_geolocation.get("longitude", 0)) + if second_address_geolocation + else None ) data = { diff --git a/src/clients/client_modules/models/client.py b/src/clients/client_modules/models/client.py index 240f5ff..8132fb1 100644 --- a/src/clients/client_modules/models/client.py +++ b/src/clients/client_modules/models/client.py @@ -1,6 +1,7 @@ from pydantic import BaseModel from pydantic import StrictStr, StrictFloat + class Geolocation(BaseModel): latitude: StrictFloat longitude: StrictFloat @@ -22,4 +23,4 @@ class HIBerryClient(HIBerryBaseClient): class HIBerryClientUpdate(HIBerryBaseClient): - pass \ No newline at end of file + pass diff --git a/src/clients/lambda_function.py b/src/clients/lambda_function.py index 0efe2c1..c39e670 100644 --- a/src/clients/lambda_function.py +++ b/src/clients/lambda_function.py @@ -45,9 +45,7 @@ def create_client(event: Dict[str, Any], context: LambdaContext) -> Dict[str, An new_client_data = HIBerryClient(**body) - logger.info( - f"Processing client with phone: {new_client_data.phone_number}" - ) + logger.info(f"Processing client with phone: {new_client_data.phone_number}") builder = ClientHelper(new_client_data.model_dump()) client_db_data = builder.build_client(username=username) @@ -62,7 +60,7 @@ def create_client(event: Dict[str, Any], context: LambdaContext) -> Dict[str, An "address_longitude": client_db_data["address_longitude"], "second_address_latitude": client_db_data["second_address_latitude"], "second_address_longitude": client_db_data["second_address_longitude"], - "errors": client_db_data["errors"] + "errors": client_db_data["errors"], } logger.debug(f"Outgoing data is {output_data=}") @@ -94,7 +92,6 @@ def create_client(event: Dict[str, Any], context: LambdaContext) -> Dict[str, An ) - def update_client(event: Dict[str, Any], context: LambdaContext) -> Dict[str, Any]: """ This function is the entry point of the process that will receive a payload as an input @@ -138,7 +135,7 @@ def update_client(event: Dict[str, Any], context: LambdaContext) -> Dict[str, An "address_longitude": client_db_data["address_longitude"], "second_address_latitude": client_db_data["second_address_latitude"], "second_address_longitude": client_db_data["second_address_longitude"], - "errors": client_db_data["errors"] + "errors": client_db_data["errors"], } logger.debug(f"Outgoing data is {output_data=}") diff --git a/src/clients/requirements.txt b/src/clients/requirements.txt new file mode 100644 index 0000000..89a8489 --- /dev/null +++ b/src/clients/requirements.txt @@ -0,0 +1,3 @@ +aws-lambda-powertools +pydantic==2.5.2 +python-dotenv==1.0.0