Reading handshake into python works

This commit is contained in:
Jonas Linter
2025-09-25 09:47:38 +02:00
parent 9ea09ffa3f
commit 35da6d3c24
11 changed files with 44 additions and 15 deletions

View File

@@ -0,0 +1,5 @@
"""Entry point for alpine_bits_python package."""
from .main import main
if __name__ == "__main__":
main()

View File

@@ -11,7 +11,7 @@ import json
from typing import Dict, List, Optional, Any
from xml.etree import ElementTree as ET
from generated.alpinebits import OtaPingRq, OtaPingRs, WarningStatus
from .generated.alpinebits import OtaPingRq, OtaPingRs, WarningStatus
from xsdata_pydantic.bindings import XmlSerializer
from xsdata.formats.dataclass.serializers.config import SerializerConfig

View File

@@ -1,4 +1,4 @@
from generated.alpinebits import (
from .alpinebits import (
BaseByGuestAmtType,
BookingRuleCodeContext,
CommentName1,

View File

@@ -1,12 +1,12 @@
from .alpinebits_guestrequests import ResGuest, RoomStay
import generated.alpinebits as ab
from .generated import alpinebits as ab
from io import BytesIO
import sys
from datetime import datetime, timezone
import re
from xsdata_pydantic.bindings import XmlSerializer
from simplified_access import (
from .simplified_access import (
CommentData,
CommentsData,
CommentListItemData,

View File

@@ -4,7 +4,7 @@ from dataclasses import dataclass
from enum import Enum
# Import the generated classes
from generated.alpinebits import OtaHotelResNotifRq, OtaResRetrieveRs, CommentName2
from .generated.alpinebits import OtaHotelResNotifRq, OtaResRetrieveRs, CommentName2
# Define type aliases for the two Customer types
NotifCustomer = OtaHotelResNotifRq.HotelReservations.HotelReservation.ResGuests.ResGuest.Profiles.ProfileInfo.Profile.Customer

View File

@@ -0,0 +1 @@
"""Utility functions for alpine_bits_python."""

View File

@@ -0,0 +1,5 @@
"""Entry point for util package."""
from .handshake_util import main
if __name__ == "__main__":
main()

View File

@@ -1,4 +1,5 @@
from generated.alpinebits import OtaPingRq, OtaPingRs
from ..generated.alpinebits import OtaPingRq, OtaPingRs
from xsdata_pydantic.bindings import XmlParser
@@ -6,15 +7,26 @@ from generated.alpinebits import OtaPingRq, OtaPingRs
def main():
# test parsing a ping request sample
path = "../../AlpineBits-HotelData-2024-10/files/samples/Handshake/Handshake-OTA_PingRQ.xml"
path = "AlpineBits-HotelData-2024-10/files/samples/Handshake/Handshake-OTA_PingRQ.xml"
with open(
path, "r", encoding="utf-8") as f:
xml = f.read()
# Parse the XML into the request object
request = OtaPingRq.from_xml(xml)
print("Parsed OTA_PingRQ:", request)
# Test parsing back
parser = XmlParser()
parsed_result = parser.from_string(xml, OtaPingRq)
print(parsed_result.echo_data)
if __name__ == "__main__":