A journey to fix `ValidationError` in Pocket imports turned service layer refactoring :D
37 lines
981 B
Python
37 lines
981 B
Python
# -*- coding: utf-8 -*-
|
|
from __future__ import annotations
|
|
|
|
from hotpocket_backend.apps.bot.services import BotService as BackendBotService
|
|
from hotpocket_soa.dto import BotResultOut
|
|
|
|
from .base import ProxyService, SOAError
|
|
|
|
|
|
class BotService(ProxyService):
|
|
class BotServiceError(SOAError):
|
|
pass
|
|
|
|
def __init__(self):
|
|
super().__init__()
|
|
self.backend_associations_service = BackendBotService()
|
|
|
|
def get_error_class(self) -> type[SOAError]:
|
|
return self.BotServiceError
|
|
|
|
def is_netloc_banned(self, *, url: str) -> bool:
|
|
return self.call(
|
|
self.backend_associations_service,
|
|
'is_netloc_banned',
|
|
url=url,
|
|
)
|
|
|
|
def handle(self, *, url: str) -> BotResultOut:
|
|
return BotResultOut.model_validate(
|
|
self.call(
|
|
self.backend_associations_service,
|
|
'handle',
|
|
url=url,
|
|
),
|
|
from_attributes=True,
|
|
)
|