"""Order business logic: delegates to repository."""

from order_app.domain.order import Order
from order_app.repositories.order_repository import OrderRepository


class OrderService:
    def __init__(self, repository: OrderRepository) -> None:
        self._repo = repository

    def create_order(self, product_id: str | None = None, quantity: int = 1) -> Order:
        order = Order(product_id=product_id or "", quantity=quantity)
        return self._repo.save(order)

    def get_order(self, order_id: str) -> Order | None:
        return self._repo.find_by_id(order_id)
