docs: document sheets export helpers
This commit is contained in:
1 parent
899e194447
commit
09be5d5969
1 file changed
+3
@@ -22,6 +22,7 @@ class GoogleSheetsExportConfig:
|
|||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def from_environment(cls) -> "GoogleSheetsExportConfig":
|
def from_environment(cls) -> "GoogleSheetsExportConfig":
|
||||||
|
"""Считывает флаг, URL webhook-а и токен из окружения приложения."""
|
||||||
return cls(
|
return cls(
|
||||||
enabled=os.getenv("BELKI_GOOGLE_EXPORT_ENABLED", "0") == "1",
|
enabled=os.getenv("BELKI_GOOGLE_EXPORT_ENABLED", "0") == "1",
|
||||||
url=os.getenv("BELKI_GOOGLE_EXPORT_URL", "").strip(),
|
url=os.getenv("BELKI_GOOGLE_EXPORT_URL", "").strip(),
|
||||||
@@ -30,6 +31,7 @@ class GoogleSheetsExportConfig:
|
|||||||
|
|
||||||
@property
|
@property
|
||||||
def ready(self) -> bool:
|
def ready(self) -> bool:
|
||||||
|
"""Проверяет, что экспорт включён и настроен на HTTPS-адрес с hostname."""
|
||||||
parsed = urlparse(self.url)
|
parsed = urlparse(self.url)
|
||||||
return self.enabled and parsed.scheme == "https" and bool(parsed.hostname)
|
return self.enabled and parsed.scheme == "https" and bool(parsed.hostname)
|
||||||
|
|
||||||
@@ -38,6 +40,7 @@ class GoogleSheetsExportService:
|
|||||||
"""Доставляет outbox-события; при выключенной интеграции ничего не делает."""
|
"""Доставляет outbox-события; при выключенной интеграции ничего не делает."""
|
||||||
|
|
||||||
def __init__(self, store: ApplicationStore, config: GoogleSheetsExportConfig | None = None) -> None:
|
def __init__(self, store: ApplicationStore, config: GoogleSheetsExportConfig | None = None) -> None:
|
||||||
|
"""Связывает сервис доставки с хранилищем заявок и конфигурацией."""
|
||||||
self.store = store
|
self.store = store
|
||||||
self.config = config or GoogleSheetsExportConfig.from_environment()
|
self.config = config or GoogleSheetsExportConfig.from_environment()
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user