Reading handshake into python works
This commit is contained in:
5
src/alpine_bits_python/__main__.py
Normal file
5
src/alpine_bits_python/__main__.py
Normal file
@@ -0,0 +1,5 @@
|
||||
"""Entry point for alpine_bits_python package."""
|
||||
from .main import main
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
from generated.alpinebits import (
|
||||
from .alpinebits import (
|
||||
BaseByGuestAmtType,
|
||||
BookingRuleCodeContext,
|
||||
CommentName1,
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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
|
||||
|
||||
1
src/alpine_bits_python/util/__init__.py
Normal file
1
src/alpine_bits_python/util/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
"""Utility functions for alpine_bits_python."""
|
||||
5
src/alpine_bits_python/util/__main__.py
Normal file
5
src/alpine_bits_python/util/__main__.py
Normal file
@@ -0,0 +1,5 @@
|
||||
"""Entry point for util package."""
|
||||
from .handshake_util import main
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -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__":
|
||||
|
||||
|
||||
Reference in New Issue
Block a user