pms_integrations branch init commit
This commit is contained in:
0
pms_integration/plugins/__init__.py
Normal file
0
pms_integration/plugins/__init__.py
Normal file
27
pms_integration/plugins/base_plugin.py
Normal file
27
pms_integration/plugins/base_plugin.py
Normal file
@@ -0,0 +1,27 @@
|
||||
# pms_integration/plugins/base_plugin.py
|
||||
|
||||
from abc import ABC, abstractmethod
|
||||
|
||||
class BasePMSPlugin(ABC):
|
||||
"""Базовый класс для всех плагинов PMS интеграции."""
|
||||
|
||||
def __init__(self, api_config):
|
||||
"""
|
||||
Конструктор плагина.
|
||||
:param api_config: Конфигурация API (объект модели APIConfiguration).
|
||||
"""
|
||||
self.api_config = api_config
|
||||
|
||||
@abstractmethod
|
||||
def fetch_data(self):
|
||||
"""
|
||||
Метод для получения данных от PMS.
|
||||
"""
|
||||
pass
|
||||
|
||||
@abstractmethod
|
||||
def parse_data(self, raw_data):
|
||||
"""
|
||||
Метод для обработки сырых данных от PMS.
|
||||
"""
|
||||
pass
|
||||
31
pms_integration/plugins/bnovo_pms.py
Normal file
31
pms_integration/plugins/bnovo_pms.py
Normal 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
|
||||
]
|
||||
0
pms_integration/plugins/ecvi_pms.py
Normal file
0
pms_integration/plugins/ecvi_pms.py
Normal file
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