refactors

This commit is contained in:
counterweight 2025-12-25 18:27:59 +01:00
parent f46d2ae8b3
commit 168b67acee
Signed by: counterweight
GPG key ID: 883EDBAA726BD96C
12 changed files with 471 additions and 126 deletions

View file

@ -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,
)