How travelport-ukraine/uapi-json works
Main Components
• Client Interface: This is how users interact with the library (e.g., by calling functions like createAirService, createHotelService, etc. from the exported module in index.js).
• Service Factories: Four primary service constructors exist – AirService, HotelService, UtilsService, and TerminalService – each encapsulating functionality for their respective travel domains.
• Request Layer: Found inside the “src/Request” directory, this component is responsible for building, validating, and parsing SOAP requests and responses.
– Core logic files (e.g., AirService.js, HotelsService.js, etc.) that orchestrate service actions.
– Parsers, Validators, and Error handlers specific to each service.
– Template files (using Handlebars JavaScript files) that define the SOAP XML request formats.
– Transformers to process or reformat the data.
• Utility/Helper Layer: Files under “src/utils” and “src/config.js” provide shared functionalities such as error handling, configuration, and helper methods for parsing and transformation.
• Test Suite: The “test” directory shows unit and integration tests validating the behavior of these components.
• Documentation and Examples: The “docs” and “examples” folders provide user guidance and runnable demos.
Relationships and Data Flow
• At the top level, the client code initializes service instances (like AirService) with configuration settings.
• Each service instance uses the Request layer to construct and send SOAP requests.
• Before the request is made, the service calls:
– Validator components to ensure input correctness.
– Template engines (via Handlebars templates) to generate the required XML message.
• Once a SOAP response is received, parser components in each service transform the XML response data into JSON and potentially trigger error handling routines.
• Error classes and helper modules across the service layers help in catching and handling errors consistently.
Architectural Patterns and Design Principles
• Modularity: Services are clearly compartmentalized into separate directories (Air, Hotels, Terminal, Utils).
• Separation of Concerns: Each layer handles its specific responsibility – request preparation, validation, business logic, response parsing, and error handling.
• Extensibility: The use of templates, validators, and transformers makes it easy to adapt or extend the library for extra functionalities or changes in API format.
• Testability: A dedicated “test” suite confirms adherence to expected behaviors, enabling continuous integration.
Relevant Technologies and Tools
• Node.js environment with npm for package management.
• Handlebars for template-based SOAP XML generation.
• Mocha (or similar testing frameworks) for unit and integration tests.
• Travis CI for continuous integration and services like Codecov to track test coverage.