add email events

This commit is contained in:
2025-07-30 21:55:52 -03:00
parent d4f7c84cdf
commit 4b7783964f
14 changed files with 220 additions and 276 deletions

View File

@@ -6,10 +6,11 @@ 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
from config import ORDER_TABLE, USER_TABLE
router = Router()
order_layer = DynamoDBPersistenceLayer(ORDER_TABLE, dynamodb_client)
user_layer = DynamoDBPersistenceLayer(USER_TABLE, dynamodb_client)
@router.get('/<id>', compress=True, tags=['Billing'])
@@ -22,6 +23,21 @@ def get_billing(
KeyPair(
pk=f'BILLING#ORG#{id}',
sk=f'START#{start_date}#END#{end_date}',
)
),
limit=100,
)
return result
@router.get('/<id>/terms', compress=True, tags=['Billing'])
def get_terms(id: Annotated[str, Path()]):
return user_layer.collection.get_item(
KeyPair(
pk=id,
sk='metadata#billing_policy',
# Post-migration: uncomment the following line
# sk='METADATA#BILLING_TERMS',
),
raise_on_error=False,
default={},
)