28 lines
781 B
Python
28 lines
781 B
Python
from app.models.tcgplayer_product import TCGPlayerProduct
|
|
from sqlalchemy.orm import Session
|
|
|
|
class InventoryProductContext:
|
|
def __init__(self, product: TCGPlayerProduct, db: Session):
|
|
self.product = product
|
|
self.prices = product.most_recent_tcgplayer_price
|
|
self.db = db
|
|
|
|
@property
|
|
def market_price(self) -> float:
|
|
return self.product.most_recent_tcgplayer_price.market_price
|
|
|
|
@property
|
|
def low_price(self) -> float:
|
|
return self.product.most_recent_tcgplayer_price.low_price
|
|
|
|
@property
|
|
def name(self) -> str:
|
|
return self.product.name
|
|
|
|
@property
|
|
def image_url(self) -> str:
|
|
return self.product.image_url
|
|
|
|
@property
|
|
def id(self) -> int:
|
|
return self.product.id |