機械翻訳について

requestHelperを使用したリクエスト・オブジェクトの生成

アプリケーション・レベルのイベントにサブスクライブしたり、アプリケーション・レベルの操作を実行するために、外部アプリケーションは、UIイベント・フレームワークによって提供されるサブスクライブAPIまたはパブリッシュAPIを起動する必要があります。

これらのAPIでは、リスニング対象のイベントの詳細を含むリクエスト・オブジェクト、または実行される操作を想定します。 UEFには、各イベントpt操作に固有のリクエスト・オブジェクトを生成するためのrequestHelperオブジェクトが用意されています。

requestHelperオブジェクトの構造

IRequestHelper {
    createSubscriptionRequest(eventName: EventName): IEventRequest;
    createPublishRequest(operationName: OperationName): IOperationRequest;
}
IEventRequest {
    getEventName(): string;
}
IOperationRequest {
     getOperationName(): string;
}

コード・サンプル

次に、イベント・サブスクリプションのリクエスト・オブジェクトの生成例を示します。

Typescriptの例を次に示します:

const frameworkProvider: IUiEventsFrameworkProvider = await CX_SVC_UI_EVENTS_FRAMEWORK.uiEventsFramework.initialize('MyFirstExtensionID','V1');
    const globalContext: IGlobalContext = await frameworkProvider.getGlobalContext();
    const requestObject: IEventRequest = frameworkProvider.requestHelper.createSubscriptionRequest('cxEventBusTabOpenEvent');
    globalContext.subscribe(requestObject,(response: IEventResponse) => {
      // custom code
    });

Javascriptの例を次に示します:

const frameworkProvider = await CX_SVC_UI_EVENTS_FRAMEWORK.uiEventsFramework.initialize('MyFirstExtensionID','V1');
const globalContext = await frameworkProvider.getGlobalContext();    
const requestObject = frameworkProvider.requestHelper.createSubscriptionRequest('cxEventBusTabOpenEvent');
globalContext.subscribe(requestObject,(response) => {
    // custom code
});

実行および操作のためのリクエスト・オブジェクトの生成例を次に示します。

Typescriptの例を次に示します:

const frameworkProvider: IUiEventsFrameworkProvider = await CX_SVC_UI_EVENTS_FRAMEWORK.uiEventsFramework.initialize('MyFirstExtensionID','V1');
    const globalContext: IGlobalContext = await frameworkProvider.getGlobalContext();
    const restCallRequest: IServiceConnectionRequest = (frameworkProvider.requestHelper.createPublishRequest('InvokeServiceConnection') as IServiceConnectionRequest);
    restCallRequest.setServiceConnectionId('interactions/update_interactions');
    restCallRequest.setParameters({ "interactions_Id": "12345" });
    restCallRequest.setBody({ "StatusCd": "ORA_SVC_CLOSED" });
    globalContext.publish(restCallRequest).then((message: IOperationResponse) => {
    	// custom code
    }).catch((error: IErrorData) => {
    	// custom code
    }); 

Javascriptの例を次に示します:

const frameworkProvider = await CX_SVC_UI_EVENTS_FRAMEWORK.uiEventsFramework.initialize('MyFirstExtensionID','V1');
    const globalContext = await frameworkProvider.getGlobalContext(); 
    const restCallRequest = (frameworkProvider.requestHelper.createPublishRequest('InvokeServiceConnection'));
    restCallRequest.setServiceConnectionId('interactions/update_interactions');
    restCallRequest.setParameters({ "interactions_Id": "12345" });
    restCallRequest.setBody({ "StatusCd": "ORA_SVC_CLOSED" }); 
    globalContext.publish(restCallRequest).then((message) => {
          // custom code
          const response = message.getResponseData();
          console.log(response.getStatus());
          console.log(response.getBody());
    }).catch((error) => {
          // custom code
    });