add discount
This commit is contained in:
@@ -15,7 +15,7 @@ from aws_lambda_powertools.utilities.typing import LambdaContext
|
||||
from api_gateway import JSONResponse
|
||||
from json_encoder import JSONEncoder
|
||||
from middlewares.authentication_middleware import AuthenticationMiddleware
|
||||
from routes import courses, enrollments, orders, orgs, users
|
||||
from routes import coupons, courses, enrollments, orders, orgs, users
|
||||
|
||||
logger = Logger(__name__)
|
||||
tracer = Tracer()
|
||||
@@ -35,6 +35,7 @@ app = APIGatewayHttpResolver(
|
||||
)
|
||||
app.use(middlewares=[AuthenticationMiddleware()])
|
||||
app.enable_swagger(path='/swagger')
|
||||
app.include_router(coupons.router, prefix='/coupons')
|
||||
app.include_router(courses.router, prefix='/courses')
|
||||
app.include_router(enrollments.router, prefix='/enrollments')
|
||||
app.include_router(enrollments.cancel, prefix='/enrollments')
|
||||
|
||||
25
api.saladeaula.digital/app/routes/coupons/__init__.py
Normal file
25
api.saladeaula.digital/app/routes/coupons/__init__.py
Normal 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,
|
||||
)
|
||||
Reference in New Issue
Block a user