Handshake looks servicable
This commit is contained in:
@@ -299,16 +299,24 @@ class PingAction(AlpineBitsAction):
|
||||
|
||||
# Create successful ping response with matched capabilities
|
||||
capabilities_json = json.dumps(matching_capabilities, indent=2)
|
||||
|
||||
response_xml = f'''<?xml version="1.0" encoding="UTF-8"?>
|
||||
<OTA_PingRS xmlns="http://www.opentravel.org/OTA/2003/05" Version="8.000">
|
||||
<Success/>
|
||||
<Warnings>
|
||||
<Warning Type="11" Status="AlpineBitsHandshake">{capabilities_json}</Warning>
|
||||
</Warnings>
|
||||
<EchoData>{capabilities_json}</EchoData>
|
||||
</OTA_PingRS>'''
|
||||
|
||||
warning = OtaPingRs.Warnings.Warning(type_value=WarningStatus.ALPINEBITS_HANDSHAKE.value, code="11", content=[capabilities_json])
|
||||
|
||||
warning_response = OtaPingRs.Warnings(warning=[warning])
|
||||
|
||||
response_ota_ping = OtaPingRs(version= "7.000", warnings=warning_response, echo_data=capabilities_json)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
config = SerializerConfig(
|
||||
pretty_print=True, xml_declaration=True, encoding="UTF-8"
|
||||
)
|
||||
|
||||
serializer = XmlSerializer(config=config)
|
||||
|
||||
response_xml = serializer.render(response_ota_ping, ns_map={None: "http://www.opentravel.org/OTA/2003/05"})
|
||||
|
||||
|
||||
|
||||
@@ -338,7 +346,7 @@ class HotelAvailNotifAction(AlpineBitsAction):
|
||||
|
||||
def __init__(self):
|
||||
self.name = AlpineBitsActionName.OTA_HOTEL_AVAIL_NOTIF
|
||||
self.version = Version.V2024_10
|
||||
self.version = Version.V2022_10
|
||||
self.supports = [
|
||||
"OTA_HotelAvailNotif_accept_rooms",
|
||||
"OTA_HotelAvailNotif_accept_categories",
|
||||
@@ -450,6 +458,10 @@ class AlpineBitsServer:
|
||||
else:
|
||||
return await action_instance.handle(request_action_name, request_xml, version_enum)
|
||||
except Exception as e:
|
||||
print(f"Error handling request {request_action_name}: {str(e)}")
|
||||
# print stack trace for debugging
|
||||
import traceback
|
||||
traceback.print_exc()
|
||||
return AlpineBitsResponse(
|
||||
f"Error: Internal server error while processing {request_action_name}: {str(e)}",
|
||||
HttpStatusCode.INTERNAL_SERVER_ERROR
|
||||
|
||||
@@ -7,7 +7,7 @@ from xsdata_pydantic.bindings import XmlParser
|
||||
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_PingRS.xml"
|
||||
|
||||
with open(
|
||||
path, "r", encoding="utf-8") as f:
|
||||
@@ -22,12 +22,23 @@ def main():
|
||||
|
||||
|
||||
|
||||
parsed_result = parser.from_string(xml, OtaPingRq)
|
||||
parsed_result = parser.from_string(xml, OtaPingRs)
|
||||
|
||||
print(parsed_result.echo_data)
|
||||
|
||||
warning = parsed_result.warnings.warning[0]
|
||||
|
||||
print(warning.type_value)
|
||||
|
||||
print(type(warning.content))
|
||||
|
||||
print(warning.content[0])
|
||||
|
||||
|
||||
|
||||
|
||||
# save json in echo_data to file with indents
|
||||
output_path = "parsed_echo_data.json"
|
||||
output_path = "echo_data_response.json"
|
||||
with open(output_path, "w", encoding="utf-8") as out_f:
|
||||
import json
|
||||
json.dump(json.loads(parsed_result.echo_data), out_f, indent=4)
|
||||
|
||||
Reference in New Issue
Block a user