Skip to main content

ICommandMessageService

ICommandMessageService 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 ICommandMessageService, 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.

Introduction

To use the ICommandMessageService API 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" />
</RedApp>

In order to be used, the ICommandMessageService has to be imported:

import { ICommandMessageService } from 'sabre-ngv-commsg/services/ICommandMessageService';

Once imported, it can be obtained in a standard way:

const service: ICommandMessageService = getService(ICommandMessageService);

Overview

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(rq: CommandMessageAirAvailabilityInputRq): Promise<CommandMessageAirAvailabilityRs>

abstract send<T extends CommandMessageBasicRs = CommandMessageBasicRs>(rq: CommandMessageRq): Promise<T>

abstract send<T extends CommandMessageBasicRs = CommandMessageBasicRs>(command: string): Promise<T>

Structure of basic types in 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 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 if the request that triggered the extension point returned a
     * successful response.
     */
    Success: boolean;
    /**
     * Contains details about request processing e.g. error or information
     * messages. This field is optional and may not contain any data.
     */
    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";

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.

Note
Detailed information about the ICommandMessageService types is available in TypeScript API Documentation.

Usage

  1. Send the text command.

export class CommandMessageServiceUsageExample {

	private commandMessageService: ICommandMessageService = getService(ICommandMessageService);

    async sendCommand(): void {
        const sampleCommand = "STAT";

        // send request and extract response
        const rs: CommandMessageBasicRs = await commandMessageService.send(sampleCommand);

        // do something with response
        if(rs.Status) {
            // do something
        }
    }
}
  1. Send the text command with showRq and/or showRs

export class CommandMessageServiceUsageExample {

	private commandMessageService: ICommandMessageService = getService(ICommandMessageService);

    async sendCommand(): void {
        const sampleCommand = "STAT";

        // create request
        const request: CommandMessageRq = {
            rq: sampleCommand,
            showRq: false,
            showRs: true
        }

        // send request and extract response
        const rs: CommandMessageBasicRs = await commandMessageService.send(request);

        // do something with response
        if(rs.Status) {
            // do something
        }
    }
}
  1. Send the structure.

export class CommandMessageServiceUsageExample {

    private commandMessageService: ICommandMessageService = getService(ICommandMessageService);

    async sendRequestObject(): void {

        const requestObj: CommandMessageQueuePlaceRq =
            {
                QueuePlaceRq: {
                    Queue: [
                        {
                            QueueNumber: '123',
                            PrefatoryInstructionCode: '11',
                            PseudoCityCode: 'pcc'
                        }
                    ]
                }
            };

        // send request and extract response
        const rs: CommandMessageBasicRs = await this.commandMessageService.send(requestObj);

        // do something with response
        if(rs.Status) {
            // do something
        }
    }
}