Breadcrumb
- Sabre Red 360 Software Development Kit Help
- Web Red Apps
- Sabre Red 360 Services
- CommandMessageService
CommandMessageService
CommandMessageService exposes methods that give you the ability to send requests to the back-end. It works both in the desktop and in the web browser. When using CommandMessageService, text request is sent as if user sends it manually by entering text into the command line. The request and response are displayed on the screen. In the desktop version the throttling feature is supported. Throttling can be set by means of the redapp.xml file.
To use the CommandMessageService API in desktop you need to authorize your Red App in the following statement:
<RedApp id="redapp-id">
<Authorization name="com.sabre.edge.dynamo.cf.service.CommandMessageService"
threshold="1" /> (1)
</RedApp>
-
On a desktop request, go through CommandMessageService.
Methods
/**
* Send commandFlow which contains request object with data.
* Request is pass to communication framework on desktop or invoke as plain request on web.
*/
abstract send(rq: CommandMessageQueuePlaceRq): Promise<CommandMessageQueuePlaceRs>
abstract send<T extends CommandMessageBasicRs = CommandMessageBasicRs>(rq: CommandMessageRq): Promise<T>
abstract send<T extends CommandMessageBasicRs = CommandMessageBasicRs>(command: string): Promise<T>
Structure of objects in Command API
The following new objects have been added to the Command Message API.
CommandMessageRq
/**
* CommandMessageRq. This is a basic type for Command Message Request.
*/
export interface CommandMessageRq {
/**
* Command to send
*/
rq: string;
/**
* Optional property, if set to false the request won't show up in dynamo editor
*/
showRq?: boolean;
/**
* Optional property, if set to false the response won't show up in dynamo editor
*/
showRs?: boolean;
}
CommandMessageBasicRs
/**
* CommandMessageBasicRs. This is a basic type for Command Message.
* API response objects. All of the response Command Message objects are subtypes of
* CommandMessageBasicRs.
*/
export interface CommandMessageBasicRs {
/**
* Return instance of {#link CommandMessageStatus}
* @return CommandMessageStatus
*/
Status: CommandMessageStatus;
}
CommandMessageStatus
/**
* CommandMessageStatus. Contains information about processing request.
*/
export interface CommandMessageStatus {
/**
* Indicates that the request was processed correctly.
*/
Success: boolean;
/**
* Contains the details linked to request processing such as error message, etc.
*/
Messages?: CommandMessageStatusInfo[];
}
CommandMessageStatusInfo
/**
* CommandMessageStatusInfo. Contains extra information about the result of the
* processing request.
*/
export interface CommandMessageStatusInfo {
/**
* The text message contains extra information.
*/
Text: string;
/**
* Type of the message
*/
Type?: CommandMessageStatusInfoType;
}
CommandMessageStatusInfoType
/** * Contains information about type of the message. */ export type CommandMessageStatusInfoType = "GENERAL" | "INFO" | "WARNING" | "ERROR" | "TEXTRS";
Note: As a general rule, we do recommend using data from services available in SR360 rather than consuming messages of the TEXTRS type. We recommend that TEXTRS-type messages are used only when the data you want to consume are not available in any of the SR360 services response.
CommandMessageQueuePlaceRs
/**
* Represent CommandMessageQueuePlaceRs object.
*/
export interface CommandMessageQueuePlaceRs extends CommandMessageBasicRs {
}
QueuePlaceRq
/**
* Represent QueuePlaceRq object.
*/
export interface QueuePlaceRq {
Queue: Queue[];
}
Queue
/**
* Contains related information to place the PNR in the Queue.
*/
export interface Queue {
PrefatoryInstructionCode: string;
PseudoCityCode: string;
QueueName?: string;
QueueNumber?: string;
}
Usage
-
Send the text command.
export class CommandMessageServiceUsageExample {
private commandMessageService: ICommandMessageService = getService(ICommandMessageService);
async sendCommand(): void {
let sampleCommand = "STAT";
// send request and extract response
var rs: CommandMessageBasicRs = await commandMessageService.send(sampleCommand);
// do something with response
if(rs.Status) {
// do something
}
}
}
-
Send the text command with showRq and/or showRs
export class CommandMessageServiceUsageExample {
private commandMessageService: ICommandMessageService = getService(ICommandMessageService);
async sendCommand(): void {
let sampleCommand = "STAT";
// create request
var request: CommandMessageRq = {
rq: sampleCommand,
showRq: false,
showRs: true
}
// send request and extract response
var rs: CommandMessageBasicRs = await commandMessageService.send(request);
// do something with response
if(rs.Status) {
// do something
}
}
}
-
Send the structure.
export class CommandMessageServiceUsageExample {
private commandMessageService: ICommandMessageService = getService(ICommandMessageService);
async sendRequestObject(): void {
let requestObj: CommandMessageQueuePlaceRq =
{
QueuePlaceRq: {
Queue: [
{
QueueNumber: '123',
PrefatoryInstructionCode: '11',
PseudoCityCode: 'pcc'
}
]
}
};
// send request and extract response
var rs: CommandMessageBasicRs = await this.commandMessageService.send(requestObj);
// do something with response
if(rs.Status) {
// do something
}
}
}