add discount

This commit is contained in:
2025-12-24 01:40:07 -03:00
parent 1a59ad9e91
commit 2459bafc5d
16 changed files with 423 additions and 132 deletions

View File

@@ -0,0 +1,25 @@
from typing import Annotated
from aws_lambda_powertools.event_handler.api_gateway import Router
from aws_lambda_powertools.event_handler.exceptions import (
NotFoundError,
)
from aws_lambda_powertools.event_handler.openapi.params import Path
from layercake.dynamodb import DynamoDBPersistenceLayer, KeyPair
from boto3clients import dynamodb_client
from config import ORDER_TABLE
router = Router()
dyn = DynamoDBPersistenceLayer(ORDER_TABLE, dynamodb_client)
class CouponNotFoundError(NotFoundError): ...
@router.get('/<coupon>')
def coupon(coupon: Annotated[str, Path(min_length=3)]):
return dyn.collection.get_item(
KeyPair('COUPON', coupon.upper()),
exc_cls=CouponNotFoundError,
)