bnovo plugin

scheduller
This commit is contained in:
2024-12-10 20:07:23 +09:00
parent 8dce756a27
commit 806c611cc7
38 changed files with 1301 additions and 277 deletions

View File

@@ -138,18 +138,18 @@ async def check_pms(update, context):
# Создаем экземпляр PMSIntegrationManager
pms_manager = PMSIntegrationManager(hotel_id=hotel_id)
await sync_to_async(pms_manager.load_hotel)()
await pms_manager.load_hotel()
await sync_to_async(pms_manager.load_plugin)()
# Проверяем, какой способ интеграции использовать
if hasattr(pms_manager.plugin, 'fetch_data'):
if hasattr(pms_manager.plugin, 'fetch_data') and callable(pms_manager.plugin.fetch_data):
# Плагин поддерживает метод fetch_data
data = await sync_to_async(pms_manager.plugin.fetch_data)()
data = await pms_manager.plugin.fetch_data()
elif pms_config.api_url and pms_config.token:
# Используем прямой запрос к API
from pms_integration.api_client import APIClient
api_client = APIClient(base_url=pms_config.api_url, access_token=pms_config.token)
data = await sync_to_async(api_client.fetch_reservations)()
data = api_client.fetch_reservations()
else:
# Если подходящий способ не найден
await query.edit_message_text("Подходящий способ интеграции с PMS не найден.")
@@ -163,7 +163,8 @@ async def check_pms(update, context):
await query.edit_message_text(f"Интеграция PMS {pms_config.name} завершена успешно.")
except Exception as e:
# Обрабатываем и логируем ошибки
await query.edit_message_text(f"Ошибка: {str(e)}")
await query.edit_message_text(f"Ошибка: {str(e)}")
async def setup_rooms(update: Update, context):
"""Настроить номера отеля."""