New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

ubp-crs-adapter

Package Overview
Dependencies
Maintainers
1
Versions
84
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ubp-crs-adapter

This library provides connections to different travel CRSs. It also let you read and write data from/to them.

  • 0.0.31
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
3
decreased by-66.67%
Maintainers
1
Weekly downloads
 
Created
Source

UBP CRS Adapter

This project provides a JS module to enable a web-application to communicate with a CRS (TOMA, SABRE, CETS, ...).

How to install

There are different ways to use this package.

per package manager

npm install ubp-crs-adapter --save

import UbpCrsAdapter from 'ubp-crs-adapter';

let ubpCrsAdapter = new UbpCrsAdapter(adapterOptions);
<script src="https://assets.gcloud.fti-group.com/tstr-crs-adapter/latest/ubpCrsAdapter.min.js"></script>

<script>
  var ubpCrsAdapter = new UbpCrsAdapter.default(adapterOptions);
</script>

Interface

To connect to a CRS use:

ubpCrsAdapter.connect(connectionType, connectionOptions);

When you are connected you can get the data from the CRS via:

ubpCrsAdapter.getData().then((crsData) => {});

The crsData you get will look like that:

{
    agencyNumber: string,
    operator: string,
    numberOfTravellers: string,
    travelType: string,
    services: Array<ServiceObject>,
    remark: string,
}

Or you can set data to the CRS via:

ubpCrsAdapter.setData(adapterData);

The adapterData object is defined like followed:

{
    travelType: string,
    numberOfTravellers: string,
    services: Array<ServiceObject>,
    remark: string,
}

And also you can close the opened iFrame in the CRS:

ubpCrsAdapter.exit()
Additional information
  • every method returns a promise
  • the numberOfTravellers will be auto-calculated related to traveller data in the service lines
  • be aware that some services will set values to the remark field
  • setData triggers automatically an exit which will close the "CRS overlay/popup" (if there is any)
  • keep in mind that you have to close any separated opened windows by yourself!

Supported adapterOptions

You can check the default options with UbpCrsAdapter.DEFAULT_OPTIONS. This options will be applied on every underlying adapter.

namedefault valuedescription
debugfalsewhether or not showing the debug output
useDateFormat'DDMMYYYY'date format which you want to use on the setData object (according to momentjs date format)
useTimeFormat'HHmm'time format which you want to use on the setData object (according to momentjs date format)
onSetDatavoid 0callback which is invoked with the data object, which will be sent to the CRS

Supported CRS

You can check the currently supported CRSs with UbpCrsAdapter.CRS_TYPES. Currently this module supports the connection to following CRS masks:

CRSconnectionTypeconnectionOptionsexample
CETSUbpCrsAdapter.CRS_TYPES.cets
TOMA (old)UbpCrsAdapter.CRS_TYPES.tomaproviderKey'ABC'
TOMA (new)UbpCrsAdapter.CRS_TYPES.toma2externalCatalogVersion (*)'catalogue.version'
connectionUrl'https://url-to-amadeus-selling.plattform'
popupId'popup_id0123456789abcdef'
MerlinUbpCrsAdapter.CRS_TYPES.merlin
MyJackUbpCrsAdapter.CRS_TYPES.myjacktoken'0123456789abcdef'
dataBridgeUrl'example://url.where-the-adapter/can-get-the-crs-data/when-not-in-http-context'
Jack+UbpCrsAdapter.CRS_TYPES.jackplustoken'0123456789abcdef'
CosmoUbpCrsAdapter.CRS_TYPES.cosmodataSourceUrl'example://url.where-the-crs/can-get-the-adapter-data'
environment'test' or 'live'
exportId'0123-456789-abcdef'
CosmoNautUbpCrsAdapter.CRS_TYPES.cosmonautdataSourceUrl'example://url.where-the-crs/can-get-the-adapter-data'
environment'test' or 'live'
exportId'0123-456789-abcdef'

(*) optional

For some connections you need credentials or other connection data, which you can set in the connectionOptions.

[TOMA 2] connectionUrl is needed, when the adapter is not directly used in the first child window of the TOMA application

[MyJack] dataBridgeUrl is needed, if the adapter is used in a non HTTP context. This has to be a site which serves the CRS data per postMessage with the payload { name: 'bewotecDataTransfer', error: 'in case of error ...', data: 'CRS data' }

[Cosmo / CosmoNaut] dataSourceUrl is an url from where the CRS can get the IBE data from

.services object structure

Depending on the .services[*].type the structure of a <ServiceObject> differs.

Supported service types

You can check the currently supported service types with UbpCrsAdapter.SERVICE_TYPES.

carhotelroundtripcamper
CETSXX
TOMA (old)XXXX
TOMA (new)XXXX
MerlinXXXX
MyJackXXXX
JackPlusXXXX
CosmoXXXX
CosmoNautXXXX
typefieldsexample
car.vehicleTypeCode'E4'
.rentalCode'DEU85'
.pickUpLocation'BER3'
.pickUpDate'28122017'
.pickUpTime'0915'
.dropOffLocation'MUC'
.dropOffDate'04012018'
.dropOffTime'1720' (deprecated)
.duration'9' (in days)
.durationInMinutes'12960'
.pickUpHotelName'Best Hotel'
.pickUpHotelAddress'hotel street 1, 12345 hotel city'
.pickUpHotelPhoneNumber'+49 172 678 0832 09'
.dropOffHotelName'Very Best Hotel'
.dropOffHotelAddress'hotel drive 34a, famous place'
.dropOffHotelPhoneNumber'04031989213'
.extras['<extraName><count>', 'navigationSystem', 'childCareSeat0', 'childCareSeat3']
typefieldsexample
hotel.roomCode'DZ'
.mealCode'U'
.roomQuantity'2'
.roomOccupancy'4'
.destination'LAX20S'
.dateFrom'20092017'
.dateTo'20092017'
.children[ { name: 'john', age: '11' }, ... ]
typefieldsexample
roundTrip.bookingId'E2784NQXTHEN'
.destination'YYZ'
.startDate'05122017'
.endDate'16122017'
.travellers[ { gender: <gender>, name: 'john doe', age: '32' }, ... ]

<gender> is one of 'female', 'male', 'child', 'infant'

typefieldsexample
camper.renterCode'PRT02'
.camperCode'FS'
.pickUpLocation'LIS1'
.pickUpDate'10102017'
.dropOffLocation'LIS2'
.dropOffDate'17102017'
.duration'7'
.milesIncludedPerDay'300'
.milesPackagesIncluded'3'
.extras['<extraName>.<count>', 'extra.2', 'special']

note: if .dropOffDate is not set, it will be calculated with .pickUpDate + .duration

Additionally every service has a .marked field which is by default falsy. But if this service is either "marked" in the crs or detected as "marked" (depends on the type) it will be true.

Debugging

Sadly the debugging in some CRS is not possible but the adapter nevertheless provides some debugging output - either you set the adapter option .debug to true or you add the parameter "debug" to your URL. It will open an extra window for debug outputs.

How to test ...

... the code

Write a test and execute npm run test - the unit tests will tell you, if everything is fine. Personal goal: Try to increase the test coverage to ~100%.

... the adapter

We prepared a test file, which can be opened directly in the CRS systems. The file is located in test/manual: crsTest.html

It depends on the CRS how to use the test file.

... in (old) TOMA

precondition: the Amadeus application is started and the TOMA mask is visible

If you already have an "browser view" open (basically after an external search), you can drag'n'drop the test file directly into that view. Alternatively you can open the test file in parallel to the TOMA mask in an IE and use the test file from there.

... in (new) TOMA SPC

precondition: the Amadeus portal is open, the TOMA mask is visible and the test file is served under a whitelisted domain

For serving the test file locally we provide a command for it: npm run serve The file is than available via https://localhost:1337 and already whitelisted by Amadeus for their test system. But you should open this URL in your browser first to accept any unknown certificates!

Then you have to request an already embedded IBE (like the drive IBE) and replace the iFrame URL with the URL of the test file. This is because Amadeus whitelist the domains which have access to the CRS.

... in CETS

precondition: the CETS application is started

You have to open the "browser view" (basically via an external search) - than you can drag'n'drop the test file directly into that view.

... in Merlin

precondition: the Sabre portal "ShopHolidays" is open, the Merlin mask is visible and the import is enabled

Open the test file in parallel to the Merlin mask in another Tab.

... in myJack / Jack+

precondition: the Bewotec application (myJack/Jack+) is open, the Expert mask is visible

Open the test file in parallel to the Expert mask in a browser.

You have questions or problems with the implementation?

Check the FAQs first!

Keywords

FAQs

Package last updated on 02 Mar 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc