# -*- coding: utf-8 -*-
from __future__ import annotations

import logging
import uuid

from hotpocket_backend.apps.accounts.models import Account
from hotpocket_soa.exceptions.backend import NotFound as NotFoundError

LOGGER = logging.getLogger(__name__)


class AccountsService:
    class AccountsServiceError(Exception):
        pass

    class NotFound(NotFoundError, AccountsServiceError):
        pass

    def get(self, *, pk: uuid.UUID) -> Account:
        try:
            query_set = Account.objects.filter(is_active=True)

            return query_set.get(pk=pk)
        except Account.DoesNotExist as exception:
            raise self.NotFound(
                f'Account not found: pk=`{pk}`',
            ) from exception
