refactors
This commit is contained in:
parent
f46d2ae8b3
commit
168b67acee
12 changed files with 471 additions and 126 deletions
|
|
@ -1,11 +1,12 @@
|
|||
"""Response mappers for converting models to API response schemas."""
|
||||
|
||||
from models import Exchange, Invite
|
||||
from models import Exchange, Invite, PriceHistory
|
||||
from schemas import (
|
||||
AdminExchangeResponse,
|
||||
ExchangeResponse,
|
||||
ExchangeUserContact,
|
||||
InviteResponse,
|
||||
PriceHistoryResponse,
|
||||
)
|
||||
|
||||
|
||||
|
|
@ -89,3 +90,19 @@ class InviteMapper:
|
|||
spent_at=invite.spent_at,
|
||||
revoked_at=invite.revoked_at,
|
||||
)
|
||||
|
||||
|
||||
class PriceHistoryMapper:
|
||||
"""Mapper for PriceHistory model to response schemas."""
|
||||
|
||||
@staticmethod
|
||||
def to_response(record: PriceHistory) -> PriceHistoryResponse:
|
||||
"""Convert a PriceHistory model to PriceHistoryResponse schema."""
|
||||
return PriceHistoryResponse(
|
||||
id=record.id,
|
||||
source=record.source,
|
||||
pair=record.pair,
|
||||
price=record.price,
|
||||
timestamp=record.timestamp,
|
||||
created_at=record.created_at,
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue