update address

This commit is contained in:
2025-07-15 16:00:41 -03:00
parent fcbfc3b97d
commit 5c80502715
12 changed files with 426 additions and 52 deletions

View File

@@ -1,26 +1,21 @@
from http import HTTPStatus
from typing import Literal
from aws_lambda_powertools.event_handler import Response, content_types
from aws_lambda_powertools.event_handler.api_gateway import Router
from aws_lambda_powertools.event_handler.exceptions import (
BadRequestError,
)
from layercake.dynamodb import (
DynamoDBCollection,
DynamoDBPersistenceLayer,
SortKey,
TransactKey,
)
from pydantic.main import BaseModel
from pydantic import BaseModel
from api_gateway import JSONResponse
from boto3clients import dynamodb_client
from config import USER_TABLE
from rules.org import update_policies
router = Router()
org_layer = DynamoDBPersistenceLayer(USER_TABLE, dynamodb_client)
org_collect = DynamoDBCollection(org_layer, exc_cls=BadRequestError)
@router.get(
@@ -30,7 +25,7 @@ org_collect = DynamoDBCollection(org_layer, exc_cls=BadRequestError)
summary='Get organization policies',
)
def get_policies(id: str):
return org_collect.get_items(
return org_layer.collection.get_items(
TransactKey(id)
+ SortKey('metadata#billing_policy', remove_prefix='metadata#')
+ SortKey('metadata#payment_policy', remove_prefix='metadata#'),
@@ -40,7 +35,7 @@ def get_policies(id: str):
class BillingPolicy(BaseModel):
billing_day: int
payment_method: Literal['PIX', 'BANK_SLIP', 'MANUAL']
payment_method: Literal['BANK_SLIP', 'MANUAL']
class PaymentPolicy(BaseModel):
@@ -64,8 +59,7 @@ def put_policies(id: str, payload: Policies):
persistence_layer=org_layer,
)
return Response(
return JSONResponse(
body=payload,
content_type=content_types.APPLICATION_JSON,
status_code=HTTPStatus.OK,
)