pms_integrations branch init commit
This commit is contained in:
31
pms_integration/plugins/shelter_pms.py
Normal file
31
pms_integration/plugins/shelter_pms.py
Normal file
@@ -0,0 +1,31 @@
|
||||
# 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
|
||||
]
|
||||
Reference in New Issue
Block a user