Skip Navigation

SrwSyncApi

Sabre Red 360 Software Development Kit provides a capability to execute several sabre services from a Red App web module.

Acquiring SrwSyncApi

In order to obtain SrwApi and use you need to import it, e.g.

import {SrwSyncApi} from "sabre-ngv-app/app/services/impl/SrwSyncApi";

Then inside your source obtain the service as follows:

const srwApi = getService(SrwSyncApi);

Available methods

There are several methods available in SrwApi, below you can find detailed list of them.

sws
sws(xml: string, action: string): string;

Type Parameteres:

  • xml - string containing xml request

  • action - action code for request

Returns:
service response as JSON parsed to string

swsWithLock
swsWithLock(xml: string, action: string, lockId: number): string;

Type Parameteres:

  • xml - string containing xml request

  • action - action code for request

  • lockId - lock id to be used while sending request to SWS

Returns:
service response as JSON parsed to string

lock
lock(): string;

Returns:
service response as JSON parsed to string

lockWithTimeout
lockWithTimeout(timeout: number): string;

Type Parameteres:

  • timeout - specifies acquired lock timeout, after which it will be invalidated

Returns:
service response as JSON parsed to string

tryLock
tryLock(duration: number, lockWaitingTimeout: number): string;

Type Parameteres:

  • duration - specifies for how long acquired lock will remain valid

  • lockWaitingTimeout - specifies for how long the caller is willing to wait for lock as it may not be available immediately

Returns:
service response as JSON parsed to string

unlock
unlock(lockId: number): string;

Type Parameteres:

  • lockId - lock to be unlocked

Returns:
service response as JSON parsed to string

showInEmu
showInEmu(text: string, isCommand: boolean): string;

Type Parameteres:

  • text - text or command to be shown in emulator

  • isCommand - specifies if provided text should be shown as command (plain text otherwise)

Returns:
service response as JSON parsed to string

executeInEmu
executeInEmu(command: string, showCommand: boolean, showResponse: boolean): string;

Type Parameteres:

  • command - command to be executed in emulator

  • showCommand - specifies if provided command should be shown in emulator

  • showResponse - specifies if command response should be shown in emulator

Returns:
service response as JSON parsed to string

rest2Sg
rest2Sg(url: string, httpMethod: HttpMethod, authTokenType: AuthTokenType, payload: string, contentType: string): string;

Type Parameters:

  • url - path to Sabre REST service ex. "/v1/lists/utilities/aircraft/equipment"

  • httpMethod - 'GET' 'POST' 'PUT' 'DELETE' 'HEAD' 'CONNECT' 'OPTIONS' 'TRACE' 'PATCH'

  • authTokenType - 'SESSION' or 'SESSIONLESS'

  • payload - JSON formatted string

  • contentType - content, application/json in most cases

Returns
service response as JSON parsed to string

rest2SgWithLock
rest2SgWithLock(url: string, httpMethod: HttpMethod, authTokenType: AuthTokenType, payload: string, contentType: string, lockId: number): string;

Type Parameters:

  • url - path to Sabre REST service ex. "/v1/lists/utilities/aircraft/equipment"

  • httpMethod - 'GET' 'POST' 'PUT' 'DELETE' 'HEAD' 'CONNECT' 'OPTIONS' 'TRACE' 'PATCH'

  • authTokenType - 'SESSION' or 'SESSIONLESS'

  • payload - JSON formatted string

  • contentType - content, application/json in most cases

  • lockId - lock to be used when sending request

Returns
service response as JSON parsed to string

rest2SgWithHeaders
rest2SgWithHeaders(url: string, httpMethod: HttpMethod, authTokenType: AuthTokenType, payload: string, contentType: string, headers: string): string;

Type Parameters:

  • url - path to Sabre REST service ex. "/v1/lists/utilities/aircraft/equipment"

  • httpMethod - 'GET' 'POST' 'PUT' 'DELETE' 'HEAD' 'CONNECT' 'OPTIONS' 'TRACE' 'PATCH'

  • authTokenType - 'SESSION' or 'SESSIONLESS'

  • payload - JSON formatted string

  • contentType - content, application/json in most cases

  • headers - JSON formatted string

Returns
service response as JSON parsed to string

rest2SgWithHeadersAndLock
rest2SgWithHeadersAndLock(url: string, httpMethod: HttpMethod, authTokenType: AuthTokenType, payload: string, contentType: string, headers: string, lockId: number): string;

Type Parameters:

  • url - path to Sabre REST service ex. "/v1/lists/utilities/aircraft/equipment"

  • httpMethod - 'GET' 'POST' 'PUT' 'DELETE' 'HEAD' 'CONNECT' 'OPTIONS' 'TRACE' 'PATCH'

  • authTokenType - 'SESSION' or 'SESSIONLESS'

  • payload - JSON formatted string

  • contentType - content, application/json in most cases

  • headers - JSON formatted string

  • lockId - lock to be used

Returns
service response as JSON parsed to string

Authorization

In order to be able to use specific services through SrwApi, your Red App needs to have authorization for those services in it’s redapp.xml file.

SWS:

<Authorization name="com.sabre.edge.cf.sws.SWS" threshold="[threshold]" metric="[metric]"/>

Locking/Unlocking:

<Authorization name="com.sabre.edge.cf.host.Locking" threshold="[threshold]" metric="[metric]" />

ShowInEmu:

<Authorization name="com.sabre.edge.cf.emu.ShowInEmulator" threshold="[threshold]" metric="[metric]" />

ExecuteInEmu:

<Authorization name="com.sabre.edge.cf.emu.ExecuteInEmulator" threshold="[threshold]" metric="[metric]" />

Rest2SG:

To be able to connect to a 2SG REST endpoint, e.g.:

/v1/lists/utilities/aircraft/equipment

Or:

/v1/historical/flights/{destination}/seasonality

You need to add authorization to redapp.xml:

<CFBundle>
    <RedApp id="rest-comm-sabre-sample">
        <Authorization name="com.sabre.edge.cf.rest2sg.Rest2Sg">
            <Action name="/v1/lists/utilities/aircraft/equipment" threshold="1" />
            <Action name="/v1/historical/flights/{destination}/seasonality" threshold="1" />
        </Authorization>
    </RedApp>
</CFBundle>

Otherwise there will be an AUTH error response from 2SG.