the autogenerated classes actually work. Halleluja

This commit is contained in:
Jonas Linter
2025-09-24 09:20:00 +02:00
parent 5d908d675d
commit 4b8b0f82b2
4 changed files with 191 additions and 50 deletions

View File

@@ -2505,7 +2505,7 @@ class OTA_HotelPostEventNotifRS(GeneratedsSuper):
self.TimeStamp = value self.TimeStamp = value
def _buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None): def _buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None):
if nodeName_ == 'Errors': if nodeName_ == 'Errors':
obj_ = ErrorsType5.factory(parent_object_=self) obj_ = ErrorsType.factory(parent_object_=self)
obj_.build(child_, gds_collector_=gds_collector_) obj_.build(child_, gds_collector_=gds_collector_)
self.Errors = obj_ self.Errors = obj_
obj_.original_tagname_ = 'Errors' obj_.original_tagname_ = 'Errors'
@@ -2516,7 +2516,7 @@ class OTA_HotelPostEventNotifRS(GeneratedsSuper):
self.Success = value_ self.Success = value_
self.Success_nsprefix_ = child_.prefix self.Success_nsprefix_ = child_.prefix
elif nodeName_ == 'Warnings': elif nodeName_ == 'Warnings':
obj_ = WarningsType8.factory(parent_object_=self) obj_ = WarningsType.factory(parent_object_=self)
obj_.build(child_, gds_collector_=gds_collector_) obj_.build(child_, gds_collector_=gds_collector_)
self.Warnings = obj_ self.Warnings = obj_
obj_.original_tagname_ = 'Warnings' obj_.original_tagname_ = 'Warnings'
@@ -2773,7 +2773,7 @@ class OTA_HotelInvCountNotifRS(GeneratedsSuper):
self.TimeStamp = value self.TimeStamp = value
def _buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None): def _buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None):
if nodeName_ == 'Errors': if nodeName_ == 'Errors':
obj_ = ErrorsType11.factory(parent_object_=self) obj_ = ErrorsType.factory(parent_object_=self)
obj_.build(child_, gds_collector_=gds_collector_) obj_.build(child_, gds_collector_=gds_collector_)
self.Errors = obj_ self.Errors = obj_
obj_.original_tagname_ = 'Errors' obj_.original_tagname_ = 'Errors'
@@ -2784,7 +2784,7 @@ class OTA_HotelInvCountNotifRS(GeneratedsSuper):
self.Success = value_ self.Success = value_
self.Success_nsprefix_ = child_.prefix self.Success_nsprefix_ = child_.prefix
elif nodeName_ == 'Warnings': elif nodeName_ == 'Warnings':
obj_ = WarningsType14.factory(parent_object_=self) obj_ = WarningsType.factory(parent_object_=self)
obj_.build(child_, gds_collector_=gds_collector_) obj_.build(child_, gds_collector_=gds_collector_)
self.Warnings = obj_ self.Warnings = obj_
obj_.original_tagname_ = 'Warnings' obj_.original_tagname_ = 'Warnings'
@@ -3049,7 +3049,7 @@ class OTA_HotelResNotifRS(GeneratedsSuper):
self.TimeStamp = value self.TimeStamp = value
def _buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None): def _buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None):
if nodeName_ == 'Errors': if nodeName_ == 'Errors':
obj_ = ErrorsType51.factory(parent_object_=self) obj_ = ErrorsType.factory(parent_object_=self)
obj_.build(child_, gds_collector_=gds_collector_) obj_.build(child_, gds_collector_=gds_collector_)
self.Errors = obj_ self.Errors = obj_
obj_.original_tagname_ = 'Errors' obj_.original_tagname_ = 'Errors'
@@ -3060,7 +3060,7 @@ class OTA_HotelResNotifRS(GeneratedsSuper):
self.Success = value_ self.Success = value_
self.Success_nsprefix_ = child_.prefix self.Success_nsprefix_ = child_.prefix
elif nodeName_ == 'Warnings': elif nodeName_ == 'Warnings':
obj_ = WarningsType54.factory(parent_object_=self) obj_ = WarningsType.factory(parent_object_=self)
obj_.build(child_, gds_collector_=gds_collector_) obj_.build(child_, gds_collector_=gds_collector_)
self.Warnings = obj_ self.Warnings = obj_
obj_.original_tagname_ = 'Warnings' obj_.original_tagname_ = 'Warnings'
@@ -3330,7 +3330,7 @@ class OTA_ResRetrieveRS(GeneratedsSuper):
self.TimeStamp = value self.TimeStamp = value
def _buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None): def _buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None):
if nodeName_ == 'Errors': if nodeName_ == 'Errors':
obj_ = ErrorsType60.factory(parent_object_=self) obj_ = ErrorsType.factory(parent_object_=self)
obj_.build(child_, gds_collector_=gds_collector_) obj_.build(child_, gds_collector_=gds_collector_)
self.Errors = obj_ self.Errors = obj_
obj_.original_tagname_ = 'Errors' obj_.original_tagname_ = 'Errors'
@@ -3341,7 +3341,7 @@ class OTA_ResRetrieveRS(GeneratedsSuper):
self.Success = value_ self.Success = value_
self.Success_nsprefix_ = child_.prefix self.Success_nsprefix_ = child_.prefix
elif nodeName_ == 'Warnings': elif nodeName_ == 'Warnings':
obj_ = WarningsType63.factory(parent_object_=self) obj_ = WarningsType.factory(parent_object_=self)
obj_.build(child_, gds_collector_=gds_collector_) obj_.build(child_, gds_collector_=gds_collector_)
self.Warnings = obj_ self.Warnings = obj_
obj_.original_tagname_ = 'Warnings' obj_.original_tagname_ = 'Warnings'
@@ -3490,7 +3490,7 @@ class OTA_NotifReportRQ(GeneratedsSuper):
self.Success = value_ self.Success = value_
self.Success_nsprefix_ = child_.prefix self.Success_nsprefix_ = child_.prefix
elif nodeName_ == 'Warnings': elif nodeName_ == 'Warnings':
obj_ = WarningsType184.factory(parent_object_=self) obj_ = WarningsType.factory(parent_object_=self)
obj_.build(child_, gds_collector_=gds_collector_) obj_.build(child_, gds_collector_=gds_collector_)
self.Warnings = obj_ self.Warnings = obj_
obj_.original_tagname_ = 'Warnings' obj_.original_tagname_ = 'Warnings'
@@ -3633,7 +3633,7 @@ class OTA_NotifReportRS(GeneratedsSuper):
self.TimeStamp = value self.TimeStamp = value
def _buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None): def _buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None):
if nodeName_ == 'Errors': if nodeName_ == 'Errors':
obj_ = ErrorsType190.factory(parent_object_=self) obj_ = ErrorsType.factory(parent_object_=self)
obj_.build(child_, gds_collector_=gds_collector_) obj_.build(child_, gds_collector_=gds_collector_)
self.Errors = obj_ self.Errors = obj_
obj_.original_tagname_ = 'Errors' obj_.original_tagname_ = 'Errors'
@@ -3644,7 +3644,7 @@ class OTA_NotifReportRS(GeneratedsSuper):
self.Success = value_ self.Success = value_
self.Success_nsprefix_ = child_.prefix self.Success_nsprefix_ = child_.prefix
elif nodeName_ == 'Warnings': elif nodeName_ == 'Warnings':
obj_ = WarningsType193.factory(parent_object_=self) obj_ = WarningsType.factory(parent_object_=self)
obj_.build(child_, gds_collector_=gds_collector_) obj_.build(child_, gds_collector_=gds_collector_)
self.Warnings = obj_ self.Warnings = obj_
obj_.original_tagname_ = 'Warnings' obj_.original_tagname_ = 'Warnings'
@@ -3899,7 +3899,7 @@ class OTA_HotelDescriptiveContentNotifRS(GeneratedsSuper):
self.TimeStamp = value self.TimeStamp = value
def _buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None): def _buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None):
if nodeName_ == 'Errors': if nodeName_ == 'Errors':
obj_ = ErrorsType257.factory(parent_object_=self) obj_ = ErrorsType.factory(parent_object_=self)
obj_.build(child_, gds_collector_=gds_collector_) obj_.build(child_, gds_collector_=gds_collector_)
self.Errors = obj_ self.Errors = obj_
obj_.original_tagname_ = 'Errors' obj_.original_tagname_ = 'Errors'
@@ -3910,7 +3910,7 @@ class OTA_HotelDescriptiveContentNotifRS(GeneratedsSuper):
self.Success = value_ self.Success = value_
self.Success_nsprefix_ = child_.prefix self.Success_nsprefix_ = child_.prefix
elif nodeName_ == 'Warnings': elif nodeName_ == 'Warnings':
obj_ = WarningsType260.factory(parent_object_=self) obj_ = WarningsType.factory(parent_object_=self)
obj_.build(child_, gds_collector_=gds_collector_) obj_.build(child_, gds_collector_=gds_collector_)
self.Warnings = obj_ self.Warnings = obj_
obj_.original_tagname_ = 'Warnings' obj_.original_tagname_ = 'Warnings'
@@ -4175,7 +4175,7 @@ class OTA_HotelDescriptiveInfoRS(GeneratedsSuper):
self.TimeStamp = value self.TimeStamp = value
def _buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None): def _buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None):
if nodeName_ == 'Errors': if nodeName_ == 'Errors':
obj_ = ErrorsType262.factory(parent_object_=self) obj_ = ErrorsType.factory(parent_object_=self)
obj_.build(child_, gds_collector_=gds_collector_) obj_.build(child_, gds_collector_=gds_collector_)
self.Errors = obj_ self.Errors = obj_
obj_.original_tagname_ = 'Errors' obj_.original_tagname_ = 'Errors'
@@ -4186,7 +4186,7 @@ class OTA_HotelDescriptiveInfoRS(GeneratedsSuper):
self.Success = value_ self.Success = value_
self.Success_nsprefix_ = child_.prefix self.Success_nsprefix_ = child_.prefix
elif nodeName_ == 'Warnings': elif nodeName_ == 'Warnings':
obj_ = WarningsType265.factory(parent_object_=self) obj_ = WarningsType.factory(parent_object_=self)
obj_.build(child_, gds_collector_=gds_collector_) obj_.build(child_, gds_collector_=gds_collector_)
self.Warnings = obj_ self.Warnings = obj_
obj_.original_tagname_ = 'Warnings' obj_.original_tagname_ = 'Warnings'
@@ -4461,7 +4461,7 @@ class OTA_HotelRatePlanNotifRS(GeneratedsSuper):
self.TimeStamp = value self.TimeStamp = value
def _buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None): def _buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None):
if nodeName_ == 'Errors': if nodeName_ == 'Errors':
obj_ = ErrorsType433.factory(parent_object_=self) obj_ = ErrorsType.factory(parent_object_=self)
obj_.build(child_, gds_collector_=gds_collector_) obj_.build(child_, gds_collector_=gds_collector_)
self.Errors = obj_ self.Errors = obj_
obj_.original_tagname_ = 'Errors' obj_.original_tagname_ = 'Errors'
@@ -4472,7 +4472,7 @@ class OTA_HotelRatePlanNotifRS(GeneratedsSuper):
self.Success = value_ self.Success = value_
self.Success_nsprefix_ = child_.prefix self.Success_nsprefix_ = child_.prefix
elif nodeName_ == 'Warnings': elif nodeName_ == 'Warnings':
obj_ = WarningsType436.factory(parent_object_=self) obj_ = WarningsType.factory(parent_object_=self)
obj_.build(child_, gds_collector_=gds_collector_) obj_.build(child_, gds_collector_=gds_collector_)
self.Warnings = obj_ self.Warnings = obj_
obj_.original_tagname_ = 'Warnings' obj_.original_tagname_ = 'Warnings'
@@ -4737,7 +4737,7 @@ class OTA_HotelRatePlanRS(GeneratedsSuper):
self.TimeStamp = value self.TimeStamp = value
def _buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None): def _buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None):
if nodeName_ == 'Errors': if nodeName_ == 'Errors':
obj_ = ErrorsType440.factory(parent_object_=self) obj_ = ErrorsType.factory(parent_object_=self)
obj_.build(child_, gds_collector_=gds_collector_) obj_.build(child_, gds_collector_=gds_collector_)
self.Errors = obj_ self.Errors = obj_
obj_.original_tagname_ = 'Errors' obj_.original_tagname_ = 'Errors'
@@ -4748,7 +4748,7 @@ class OTA_HotelRatePlanRS(GeneratedsSuper):
self.Success = value_ self.Success = value_
self.Success_nsprefix_ = child_.prefix self.Success_nsprefix_ = child_.prefix
elif nodeName_ == 'Warnings': elif nodeName_ == 'Warnings':
obj_ = WarningsType443.factory(parent_object_=self) obj_ = WarningsType.factory(parent_object_=self)
obj_.build(child_, gds_collector_=gds_collector_) obj_.build(child_, gds_collector_=gds_collector_)
self.Warnings = obj_ self.Warnings = obj_
obj_.original_tagname_ = 'Warnings' obj_.original_tagname_ = 'Warnings'
@@ -75894,16 +75894,16 @@ __all__ = [
"ErrorType61", "ErrorType61",
"ErrorType836", "ErrorType836",
"ErrorsType", "ErrorsType",
"ErrorsType11", "ErrorsType",
"ErrorsType190", "ErrorsType",
"ErrorsType257", "ErrorsType",
"ErrorsType262", "ErrorsType",
"ErrorsType433", "ErrorsType",
"ErrorsType440", "ErrorsType",
"ErrorsType5", "ErrorsType",
"ErrorsType51", "ErrorsType",
"ErrorsType60", "ErrorsType",
"ErrorsType835", "ErrorsType",
"EventContactType", "EventContactType",
"EventContactsType", "EventContactsType",
"EventReportType", "EventReportType",
@@ -76386,15 +76386,15 @@ __all__ = [
"WarningType839", "WarningType839",
"WarningType9", "WarningType9",
"WarningsType", "WarningsType",
"WarningsType14", "WarningsType",
"WarningsType184", "WarningsType",
"WarningsType193", "WarningsType",
"WarningsType260", "WarningsType",
"WarningsType265", "WarningsType",
"WarningsType436", "WarningsType",
"WarningsType443", "WarningsType",
"WarningsType54", "WarningsType",
"WarningsType63", "WarningsType",
"WarningsType8", "WarningsType",
"WarningsType838" "WarningsType"
] ]

View File

@@ -1,22 +1,116 @@
from alpinebits_guestrequests import ResGuest, RoomStay from alpinebits_guestrequests import ResGuest, RoomStay
from alpine_bits_classes import ResGuestType, ProfilesType, ProfileType, ProfileInfoType from alpine_bits_classes import (
OTA_ResRetrieveRS,
Success,
ReservationsListType,
HotelReservationType,
UniqueIDType,
RoomStaysType,
RoomStayType,
RoomTypesType,
RoomTypeType,
GuestCountsType,
GuestCountType,
TimeSpanType,
StartDateWindowType,
ResGuestsType,
ResGuestType,
ProfilesType,
ProfileInfoType,
ProfileType,
CustomerType,
PersonNameType,
AddressType,
CountryNameType,
ResGlobalInfoType,
HotelReservationIDsType,
HotelReservationIDType,
BasicPropertyInfoType,
GivenNameType,
SurnameType,
)
from io import BytesIO
import sys
from datetime import datetime, timezone
def main(): def main():
guest1 = ResGuest(given_name="John", surname="Doe", email="john.doe@example.com") # Success
print(guest1) success = Success()
# RoomType
room_type = RoomTypeType(RoomTypeCode="A", RoomClassificationCode="5", RoomType="8")
room_types = RoomTypesType(RoomType=room_type)
profileInfo = ProfileInfoType() # GuestCounts
guest_count = GuestCountType(Count=1)
guest_counts = GuestCountsType(GuestCount=[guest_count])
profile = ProfileType() # TimeSpan with StartDateWindow
start_date_window = StartDateWindowType(EarliestDate=datetime(2022, 10, 3, tzinfo=timezone.utc), LatestDate=datetime(2022, 10, 8, tzinfo=timezone.utc))
time_span = TimeSpanType(StartDateWindow=start_date_window)
# RoomStay
room_stay = RoomStayType(
RoomTypes=room_types,
GuestCounts=guest_counts,
TimeSpan=time_span
)
room_stays = RoomStaysType(RoomStay=[room_stay])
# ResGuest
person_name = PersonNameType(GivenName=GivenNameType("Otto"), Surname=SurnameType("Mustermann"))
country_name = CountryNameType(Code="DE")
address = AddressType(CountryName=country_name)
customer = CustomerType(Language="de", Gender="Unknown", PersonName=person_name, Address=address)
profile = ProfileType(Customer=customer)
profile_info = ProfileInfoType(Profile=profile)
profiles = ProfilesType(ProfileInfo=profile_info)
res_guest = ResGuestType(Profiles=profiles)
res_guests = ResGuestsType(ResGuest=res_guest)
profiles = ProfilesType() # UniqueID
unique_id = UniqueIDType(Type="14", ID="6b34fe24ac2ff811")
resGuest = ResGuestType() # ResGlobalInfo
hotel_res_id = HotelReservationIDType(
ResID_Type="13",
ResID_SourceContext="cnt",
ResID_Value="res",
ResID_Source="www.example.com"
)
hotel_res_ids = HotelReservationIDsType(HotelReservationID=[hotel_res_id])
basic_property_info = BasicPropertyInfoType(HotelCode="123", HotelName="Frangart Inn")
res_global_info = ResGlobalInfoType(
HotelReservationIDs=hotel_res_ids,
BasicPropertyInfo=basic_property_info
)
# HotelReservation
hotel_reservation = HotelReservationType(
CreateDateTime=datetime.now(timezone.utc).isoformat(),
ResStatus="Requested",
RoomStayReservation=True,
UniqueID=unique_id,
RoomStays=room_stays,
ResGuests=res_guests,
ResGlobalInfo=res_global_info
)
hotel_reservation.set_CreateDateTime(datetime.now(timezone.utc))
reservations_list = ReservationsListType(HotelReservation=[hotel_reservation])
# Root element
ota_res_retrieve_rs = OTA_ResRetrieveRS(
Version="7.000",
Success=success,
ReservationsList=reservations_list
)
# Serialize to XML string
# create outfile
with open('output.xml', 'w', encoding='utf-8') as outfile:
ota_res_retrieve_rs.export(outfile, 0)

47
src/output.xml Normal file
View File

@@ -0,0 +1,47 @@
<OTA_ResRetrieveRS xmlns:None="http://www.opentravel.org/OTA/2003/05" Version="7.000">
<Success>&lt;Success/&gt;
</Success>
<ReservationsList>
<HotelReservation CreateDateTime="2025-09-24T07:18:57.913865Z" ResStatus="Requested" RoomStayReservation="true">
<UniqueID Type="14" ID="6b34fe24ac2ff811"/>
<RoomStays>
<RoomStay>
<RoomTypes>
<RoomType RoomTypeCode="A" RoomClassificationCode="5" RoomType="8"/>
</RoomTypes>
<GuestCounts>
<GuestCount Count="1"/>
</GuestCounts>
<TimeSpan>
<StartDateWindow EarliestDate="2022-10-03Z" LatestDate="2022-10-08Z"/>
</TimeSpan>
</RoomStay>
</RoomStays>
<ResGuests>
<ResGuest>
<Profiles>
<ProfileInfo>
<Profile>
<Customer Gender="Unknown" Language="de">
<PersonName>
<GivenName>Otto</GivenName>
<Surname>Mustermann</Surname>
</PersonName>
<Address>
<CountryName Code="DE"/>
</Address>
</Customer>
</Profile>
</ProfileInfo>
</Profiles>
</ResGuest>
</ResGuests>
<ResGlobalInfo>
<HotelReservationIDs>
<HotelReservationID ResID_Type="13" ResID_Value="res" ResID_Source="www.example.com" ResID_SourceContext="cnt"/>
</HotelReservationIDs>
<BasicPropertyInfo HotelCode="123" HotelName="Frangart Inn"/>
</ResGlobalInfo>
</HotelReservation>
</ReservationsList>
</OTA_ResRetrieveRS>

0
src/test.xml Normal file
View File