import { isNullOrUndefined } from "util" ; import { ImperativeError } from "@zowe/imperative" ; import { IZosmfTsoResponse } from "./doc/zosmf/IZosmfTsoResponse" ; import { IStartStopResponse } from "./doc/IStartStopResponse" ; import { TsoValidator } from "./TsoValidator" ; import { IStartStopResponses } from "./doc/IStartStopResponses" ; import { ICollectedResponses } from "./doc/ICollectedResponses" ; import { IZosmfPingResponse } from "./doc/zosmf/IZosmfPingResponse" ; import { IPingResponse } from "./doc/IPingResponse" ; export class export class TsoResponseService { param { IZosmfTsoResponse } zosmfResponse see { IZosmfTsoResponse } returns { IStartStopResponse } see { IStartStopResponse } memberOf public static populateStartAndStop ( zosmfResponse ) { TsoValidator . validateStartZosmfResponse ( zosmfResponse ) ; const startResponse = { success : false , zosmfTsoResponse : zosmfResponse , servletKey : zosmfResponse . servletKey } ; if ( zosmfResponse . servletKey != null ) { startResponse . success = true ; } else if ( zosmfResponse . msgData ) { startResponse . failureResponse = new ImperativeError ( { msg : zosmfResponse . msgData [ 0 ] . messageText } ) ; } return startResponse ; } param { IZosmfTsoResponse } zosmfResponse see { IZosmfTsoResponse } param { ICollectedResponses } collectedResponses see { ICollectedResponses } returns { IStartStopResponse } see { IStartStopResponse } memberOf public static populateStartAndStopCollectAll ( zosmfResponse , collectedResponses ? ) { TsoValidator . validateStartZosmfResponse ( zosmfResponse ) ; const startResponse = { success : false , zosmfTsoResponse : zosmfResponse , collectedResponses : isNullOrUndefined ( collectedResponses ) ? null : collectedResponses . tsos , servletKey : zosmfResponse . servletKey , messages : isNullOrUndefined ( collectedResponses ) ? "" : collectedResponses . messages } ; if ( zosmfResponse . servletKey != null ) { startResponse . success = true ; } else if ( zosmfResponse . msgData ) { startResponse . failureResponse = new ImperativeError ( { msg : zosmfResponse . msgData [ 0 ] . messageText } ) ; } return startResponse ; } param { IZosmfPingResponse } zosmfResponse see { IZosmfPingResponse } returns { PingResponse } memberOf public static populatePing ( zosmfResponse ) { TsoValidator . validatePingZosmfResponse ( zosmfResponse ) ; const PingResponse = { success : false , zosmfPingResponse : null , servletKey : null } ; if ( ! isNullOrUndefined ( zosmfResponse . servletKey ) ) { PingResponse . success = true ; PingResponse . zosmfPingResponse = zosmfResponse ; PingResponse . servletKey = zosmfResponse . servletKey ; } return PingResponse ; } }