pms_integrations branch init commit

This commit is contained in:
2024-12-08 10:24:15 +09:00
parent f81ec7bba4
commit 1398f444bd
14 changed files with 161 additions and 0 deletions

View File

@@ -0,0 +1,31 @@
# pms_integration/plugins/example_pms.py
import requests
from .base_plugin import BasePMSPlugin
class ExamplePMSPlugin(BasePMSPlugin):
"""Плагин для интеграции с Example PMS."""
def fetch_data(self):
"""Получение данных от Example PMS."""
url = self.api_config.url
headers = {"Authorization": f"Bearer {self.api_config.token}"}
response = requests.get(url, headers=headers, timeout=10)
response.raise_for_status()
return response.json()
def parse_data(self, raw_data):
"""Обработка данных от Example PMS."""
reservations = raw_data.get("reservations", [])
return [
{
"id": res["id"],
"room_number": res["room_number"],
"room_type": res["room_type"],
"check_in": res["check_in"],
"check_out": res["check_out"],
"status": res["status"],
"price": res.get("price"),
}
for res in reservations
]