Skip to content

Commit

Permalink
fix: add req file
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcoBurgos committed May 23, 2024
1 parent b3fb37f commit 51d0487
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 13 deletions.
2 changes: 2 additions & 0 deletions src/clients/.flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[flake8]
ignore = E501, W503
2 changes: 1 addition & 1 deletion src/clients/client_modules/dao/client_dao.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,4 @@ def update_client(self, item: dict) -> dict:
:rtype: dict
"""
response = self.clients_db.update_record(item)
return response
return response
21 changes: 16 additions & 5 deletions src/clients/client_modules/data_mapper/client_mapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down
3 changes: 2 additions & 1 deletion src/clients/client_modules/models/client.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from pydantic import BaseModel
from pydantic import StrictStr, StrictFloat


class Geolocation(BaseModel):
latitude: StrictFloat
longitude: StrictFloat
Expand All @@ -22,4 +23,4 @@ class HIBerryClient(HIBerryBaseClient):


class HIBerryClientUpdate(HIBerryBaseClient):
pass
pass
9 changes: 3 additions & 6 deletions src/clients/lambda_function.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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=}")
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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=}")
Expand Down
3 changes: 3 additions & 0 deletions src/clients/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
aws-lambda-powertools
pydantic==2.5.2
python-dotenv==1.0.0

0 comments on commit 51d0487

Please sign in to comment.