118 lines
3.4 KiB
Python
118 lines
3.4 KiB
Python
from alpinebits_guestrequests import ResGuest, RoomStay
|
|
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():
|
|
# Success
|
|
success = Success()
|
|
|
|
# RoomType
|
|
room_type = RoomTypeType(RoomTypeCode="A", RoomClassificationCode="5", RoomType="8")
|
|
room_types = RoomTypesType(RoomType=room_type)
|
|
|
|
# GuestCounts
|
|
guest_count = GuestCountType(Count=1)
|
|
guest_counts = GuestCountsType(GuestCount=[guest_count])
|
|
|
|
# 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)
|
|
|
|
# UniqueID
|
|
unique_id = UniqueIDType(Type="14", ID="6b34fe24ac2ff811")
|
|
|
|
# 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)
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main() |