diff --git a/http-api/app/routes/billing/__init__.py b/http-api/app/routes/billing/__init__.py new file mode 100644 index 0000000..14f4b4a --- /dev/null +++ b/http-api/app/routes/billing/__init__.py @@ -0,0 +1,27 @@ +from datetime import date +from typing import Annotated + +from aws_lambda_powertools.event_handler.api_gateway import Router +from aws_lambda_powertools.event_handler.openapi.params import Path, Query +from layercake.dynamodb import DynamoDBPersistenceLayer, KeyPair + +from boto3clients import dynamodb_client +from config import ORDER_TABLE + +router = Router() +order_layer = DynamoDBPersistenceLayer(ORDER_TABLE, dynamodb_client) + + +@router.get('/', compress=True, tags=['Billing']) +def get_billing( + id: Annotated[str, Path()], + start_date: Annotated[date, Query()], + end_date: Annotated[date, Query()], +): + result = order_layer.collection.query( + KeyPair( + pk=f'BILLING#ORG#{id}', + sk=f'START#{start_date}#END#{end_date}', + ) + ) + return result