Files
Touchh/pms_integration/plugins/shelter_pms.py

32 lines
1.1 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# pms_integration/plugins/shelter_pms.py
import requests
from .base_plugin import BasePMSPlugin
class ShelterPMSPlugin(BasePMSPlugin):
"""Плагин для интеграции с Shelter PMS."""
def fetch_data(self):
"""Получение данных от Shelter 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):
"""Обработка данных от Shelter 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
]