add route to payment's details
This commit is contained in:
@@ -11,6 +11,9 @@ class ConflictError(ServiceError):
|
||||
super().__init__(HTTPStatus.CONFLICT, msg)
|
||||
|
||||
|
||||
class OrderNotFoundError(NotFoundError): ...
|
||||
|
||||
|
||||
class UserNotFoundError(NotFoundError): ...
|
||||
|
||||
|
||||
|
||||
@@ -1,12 +1,14 @@
|
||||
from aws_lambda_powertools.event_handler.api_gateway import Router
|
||||
from layercake.dynamodb import (
|
||||
DynamoDBPersistenceLayer,
|
||||
KeyPair,
|
||||
SortKey,
|
||||
TransactKey,
|
||||
)
|
||||
|
||||
from boto3clients import dynamodb_client
|
||||
from config import ORDER_TABLE
|
||||
from exceptions import OrderNotFoundError
|
||||
|
||||
from .checkout import router as checkout
|
||||
|
||||
@@ -18,12 +20,25 @@ dyn = DynamoDBPersistenceLayer(ORDER_TABLE, dynamodb_client)
|
||||
|
||||
@router.get('/<order_id>')
|
||||
def get_order(order_id: str):
|
||||
return dyn.collection.get_items(
|
||||
order = dyn.collection.get_items(
|
||||
TransactKey(order_id)
|
||||
+ SortKey('0')
|
||||
+ SortKey('ITEMS')
|
||||
+ SortKey('ADDRESS')
|
||||
+ SortKey('PIX')
|
||||
+ SortKey('NFSE')
|
||||
+ SortKey('FEE'),
|
||||
+ SortKey('ITEMS', rename_key='items')
|
||||
+ SortKey('ADDRESS', rename_key='address')
|
||||
+ SortKey('CREDIT_CARD', rename_key='credit_card')
|
||||
+ SortKey('INVOICE', rename_key='invoice')
|
||||
+ SortKey('NFSE', rename_key='nfse')
|
||||
+ SortKey('FEE', rename_key='fee')
|
||||
+ SortKey('TRANSACTION#STATS', rename_key='stats'),
|
||||
)
|
||||
|
||||
if not order:
|
||||
raise OrderNotFoundError('Order not found')
|
||||
|
||||
attempts = dyn.collection.query(KeyPair(order_id, 'TRANSACTION#ATTEMPT#'))
|
||||
enrollments = dyn.collection.query(KeyPair(order_id, 'ENROLLMENT#'))
|
||||
|
||||
return order | {
|
||||
'attempts': attempts['items'],
|
||||
'enrollments': enrollments['items'],
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user