import { InWxVerifyDispatchEvent } from './entity/msg/in/event/InWxVerifyDispatchEvent' ; import { InTaskEvent } from './entity/msg/in/event/InTaskEvent' ; import { InSpeechRecognitionResults } from './entity/msg/in/InSpeechRecognitionResults' ; import { InMsg } from './entity/msg/in/InMsg' ; import { InImageMsg } from './entity/msg/in/InImageMsg' ; import { InTextMsg } from './entity/msg/in/InTextMsg' ; import { InNotDefinedMsg } from './entity/msg/in/InNotDefinedMsg' ; import { InVideoMsg } from './entity/msg/in/InVideoMsg' ; import { InShortVideoMsg } from './entity/msg/in/InShortVideoMsg' ; import { InLocationMsg } from './entity/msg/in/InLocationMsg' ; import { InLinkMsg } from './entity/msg/in/InLinkMsg' ; import { InVoiceMsg } from './entity/msg/in/InVoiceMsg' ; import { InFollowEvent } from './entity/msg/in/event/InFollowEvent' ; import { InQrCodeEvent } from './entity/msg/in/event/InQrCodeEvent' ; import { InLocationEvent } from './entity/msg/in/event/InLocationEvent' ; import { InNotDefinedEvent } from './entity/msg/in/event/InNotDefinedEvent' ; import { InMenuEvent } from './entity/msg/in/event/InMenuEvent' ; import { ScanCodeInfo } from './entity/msg/in/event/ScanCodeInfo' ; import { InTemplateMsgEvent } from './entity/msg/in/event/InTemplateMsgEvent' ; import { InMassEvent } from './entity/msg/in/event/InMassEvent' ; import { InCustomEvent } from './entity/msg/in/event/InCustomEvent' ; import { InVerifySuccessEvent } from './entity/msg/in/event/InVerifySuccessEvent' ; import { InVerifyFailEvent } from './entity/msg/in/event/InVerifyFailEvent' ; import { InPoiCheckNotifyEvent } from './entity/msg/in/event/InPoiCheckNotifyEvent' ; import { InWifiEvent } from './entity/msg/in/event/InWifiEvent' ; import { InCardPassCheckEvent } from './entity/msg/in/card/InCardPassCheckEvent' ; import { InUpdateMemberCardEvent } from './entity/msg/in/card/InUpdateMemberCardEvent' ; import { InUserPayFromCardEvent } from './entity/msg/in/card/InUserPayFromCardEvent' ; import { InMerChantOrderEvent } from './entity/msg/in/card/InMerChantOrderEvent' ; import { InCardPayOrderEvent } from './entity/msg/in/card/InCardPayOrderEvent' ; import { InCardSkuRemindEvent } from './entity/msg/in/card/InCardSkuRemindEvent' ; import { InUserConsumeCardEvent } from './entity/msg/in/card/InUserConsumeCardEvent' ; import { InUserGetCardEvent } from './entity/msg/in/card/InUserGetCardEvent' ; import { InUserGiftingCardEvent } from './entity/msg/in/card/InUserGiftingCardEvent' ; import { InUserCardEvent } from './entity/msg/in/card/InUserCardEvent' ; import { InShakearoundUserShakeEvent } from './entity/msg/in/event/InShakearoundUserShakeEvent' ; import { InEnterAgentEvent } from './entity/msg/in/event/InEnterAgentEvent' ; import { InBatchJobResultEvent } from './entity/msg/in/event/InBatchJobResultEvent' ; import { InUpdateTagEvent } from './entity/msg/in/event/InUpdateTagEvent' ; import { InUpdatePartyEvent } from './entity/msg/in/event/InUpdatePartyEvent' ; import { InUpdateUserEvent } from './entity/msg/in/event/InUpdateUserEvent' ; import { BaseMsg } from './entity/msg/BaseMsg' ; import { InSuiteTicket } from './entity/msg/in/InSuiteTicket' ; import { InAuthEvent } from './entity/msg/in/InAuthEvent' ; import { InBatchJobResult } from './entity/msg/in/InBatchJobResult' ; import { InExternalContact } from './entity/msg/in/InExternalContact' ; import { InExternalContactEvent } from './entity/msg/in/event/InExternalContactEvent' ; import { InRegisterCorp } from './entity/msg/in/InRegisterCorp' ; import { InComponentVerifyTicket } from './entity/msg/in/InComponentVerifyTicket' ; import { InAuthMpEvent } from './entity/msg/in/InAuthMpEvent' ; import { InCardMerchantCheckResultEvent } from './entity/msg/in/card/InCardMerchantCheckResultEvent' ; export class InMsgParser { public static parse ( obj ) { return this . doParse ( obj ) ; } private static doParse ( obj ) { if ( 'text' === obj . MsgType ) return this . parseInTextMsg ( obj ) ; if ( 'image' === obj . MsgType ) return this . parseInImageMsg ( obj ) ; if ( 'video' === obj . MsgType ) return this . parseInVideoMsg ( obj ) ; if ( 'shortvideo' === obj . MsgType ) return this . parseInShortVideoMsg ( obj ) ; if ( 'location' === obj . MsgType ) return this . parseInLocationMsg ( obj ) ; if ( 'link' === obj . MsgType ) return this . parseInLinkMsg ( obj ) ; if ( 'voice' === obj . MsgType ) return this . parseInVoiceMsgAndInSpeechRecognitionResults ( obj ) ; if ( 'event' === obj . MsgType ) return this . parseInEvent ( obj ) ; if ( InSuiteTicket . INFO_TYPE === obj . InfoType ) return this . parseInSuiteTicket ( obj ) ; if ( InComponentVerifyTicket . INFO_TYPE === obj . InfoType ) return this . paseInComponentVerifyTicket ( obj ) ; if ( InBatchJobResult . INFO_TYPE === obj . InfoType ) return this . parseInBatchJobResult ( obj ) ; if ( InAuthEvent . CREATE_AUTH === obj . InfoType || InAuthEvent . CHANGE_AUTH === obj . InfoType || InAuthEvent . CANCEL_AUTH === obj . InfoType ) return this . InAuthEvent ( obj ) ; if ( InAuthMpEvent . CREATE_AUTH === obj . InfoType || InAuthMpEvent . CHANGE_AUTH === obj . InfoType || InAuthMpEvent . CANCEL_AUTH === obj . InfoType ) return this . InAuthMpEvent ( obj ) ; if ( InExternalContact . INFO_TYPE === obj . InfoType ) return this . parseInExternalContact ( obj ) ; if ( InRegisterCorp . INFO_TYPE === obj . InfoType ) return this . parseInRegisterCorp ( obj ) ; console . debug ( `无法识别的消息类型 ${ obj . MsgType }\n微信公众号开发文档:https://developers.weixin.qq.com/doc/offiaccount/Getting_Started/Overview.html\n企业微信号开发文档:https://work.weixin.qq.com/api/doc` ) ; return new InNotDefinedMsg ( obj . ToUserName , obj . FromUserName , obj . CreateTime , obj . MsgType ) ; } private static parseInTextMsg ( obj ) { let msg = new InTextMsg ( obj . ToUserName , obj . FromUserName , obj . CreateTime , obj . MsgType ) ; msg . setContent = obj . Content ; msg . setMsgId = obj . MsgId ; msg . setAgentId = obj . AgentID ; return msg ; } private static parseInImageMsg ( obj ) { let msg = new InImageMsg ( obj . ToUserName , obj . FromUserName , obj . CreateTime , obj . MsgType ) ; msg . setPicUrl = obj . PicUrl ; msg . setMediaId = obj . MediaId ; msg . setMsgId = obj . MsgId ; msg . setAgentId = obj . AgentID ; return msg ; } private static parseInVideoMsg ( obj ) { let msg = new InVideoMsg ( obj . ToUserName , obj . FromUserName , obj . CreateTime , obj . MsgType ) ; msg . setThumbMediaId = obj . ThumbMediaId ; msg . setMediaId = obj . MediaId ; msg . setMsgId = obj . MsgId ; msg . setAgentId = obj . AgentID ; return msg ; } private static parseInShortVideoMsg ( obj ) { let msg = new InShortVideoMsg ( obj . ToUserName , obj . FromUserName , obj . CreateTime , obj . MsgType ) ; msg . setThumbMediaId = obj . ThumbMediaId ; msg . setMediaId = obj . MediaId ; msg . setMsgId = obj . MsgId ; msg . setAgentId = obj . AgentID ; return msg ; } private static parseInLocationMsg ( obj ) { let msg = new InLocationMsg ( obj . ToUserName , obj . FromUserName , obj . CreateTime , obj . MsgType ) ; msg . setLocation_X = obj . Location_X ; msg . setLocation_Y = obj . Location_Y ; msg . setScale = obj . Scale ; msg . setLabel = obj . Label ; msg . setMsgId = obj . MsgId ; msg . setAgentId = obj . AgentID ; return msg ; } private static parseInLinkMsg ( obj ) { let msg = new InLinkMsg ( obj . ToUserName , obj . FromUserName , obj . CreateTime , obj . MsgType ) ; msg . setTitle = obj . Title ; msg . setDescription = obj . Description ; msg . setUrl = obj . Url ; msg . setMsgId = obj . MsgId ; msg . setAgentId = obj . AgentID ; return msg ; } private static parseInVoiceMsgAndInSpeechRecognitionResults ( obj ) { let recognition = obj . Recognition ; let mediaId = obj . MediaId ; let format = obj . Format ; let msgId = obj . MsgId ; let agentId = obj . AgentID ; if ( recognition ) { let msg = new InVoiceMsg ( obj . ToUserName , obj . FromUserName , obj . CreateTime , obj . MsgType ) ; msg . setMediaId = mediaId ; msg . setFormat = format ; msg . setMsgId = msgId ; msg . setAgentId = agentId ; return msg ; } else { let msg = new InSpeechRecognitionResults ( obj . ToUserName , obj . FromUserName , obj . CreateTime , obj . MsgType ) ; msg . setMediaId = mediaId ; msg . setFormat = format ; msg . setMsgId = msgId ; msg . setAgentId = agentId ; msg . setRecognition = recognition ; return msg ; } } private static parseInEvent ( obj ) { let event = obj . Event ; let eventKey = obj . EventKey ; let agentId = obj . AgentID ; let menuId = obj . MenuId ; if ( 'unsubscribe' == event ) { let e = new InFollowEvent ( obj . ToUserName , obj . FromUserName , obj . CreateTime , event ) ; e . setEventKey = eventKey ; e . setAgentId = agentId ; return e ; } let ticket = obj . Ticket ; if ( 'subscribe' == event && eventKey && eventKey . startsWith ( 'qrscene_' ) ) { let e = new InQrCodeEvent ( obj . ToUserName , obj . FromUserName , obj . CreateTime , event ) ; e . setEventKey = eventKey ; e . setTicket = ticket ; return e ; } if ( 'SCAN' == event ) { let e = new InQrCodeEvent ( obj . ToUserName , obj . FromUserName , obj . CreateTime , event ) ; e . setEventKey = eventKey ; e . setTicket = ticket ; return e ; } if ( InFollowEvent . EVENT_INFOLLOW_SUBSCRIBE == event ) { let e = new InFollowEvent ( obj . ToUserName , obj . FromUserName , obj . CreateTime , event ) ; e . setEventKey = eventKey ; e . setAgentId = agentId ; return e ; } if ( InEnterAgentEvent . EVENT == event ) { let e = new InEnterAgentEvent ( obj . ToUserName , obj . FromUserName , obj . CreateTime , event ) ; e . setEventKey = eventKey ; e . setAgentId = agentId ; return e ; } if ( InLocationEvent . EVENT == event ) { let e = new InLocationEvent ( obj . ToUserName , obj . FromUserName , obj . CreateTime , event ) ; e . setLatitude = obj . Latitude ; e . setLongitude = obj . Longitude ; e . setPrecision = obj . Precision ; e . setAgentId = agentId ; return e ; } if ( InMenuEvent . EVENT_INMENU_CLICK == event . toUpperCase ( ) ) { let e = new InMenuEvent ( obj . ToUserName , obj . FromUserName , obj . CreateTime , event ) ; e . setEventKey = eventKey ; e . setAgentId = agentId ; return e ; } if ( InMenuEvent . EVENT_INMENU_VIEW == event . toUpperCase ( ) ) { let e = new InMenuEvent ( obj . ToUserName , obj . FromUserName , obj . CreateTime , event ) ; e . setEventKey = eventKey ; e . setAgentId = agentId ; e . setMenuId = menuId ; return e ; } if ( 'scancode_push' == event || 'scancode_waitmsg' == event ) { let e = new InMenuEvent ( obj . ToUserName , obj . FromUserName , obj . CreateTime , event ) ; e . setEventKey = eventKey ; e . setAgentId = agentId ; let scanType = obj . ScanCodeInfo . ScanType ; let scanResult = obj . ScanCodeInfo . ScanResult ; e . setScanCodeInfo = new ScanCodeInfo ( scanType , scanResult ) ; return e ; } if ( InMenuEvent . EVENT_INMENU_PIC_SYSPHOTO == event ) { let e = new InMenuEvent ( obj . ToUserName , obj . FromUserName , obj . CreateTime , event ) ; e . setEventKey = eventKey ; e . setAgentId = agentId ; return e ; } if ( InMenuEvent . EVENT_INMENU_PIC_PHOTO_OR_ALBUM == event ) { let e = new InMenuEvent ( obj . ToUserName , obj . FromUserName , obj . CreateTime , event ) ; e . setEventKey = eventKey ; e . setAgentId = agentId ; return e ; } if ( InMenuEvent . EVENT_INMENU_PIC_WEIXIN == event ) { let e = new InMenuEvent ( obj . ToUserName , obj . FromUserName , obj . CreateTime , event ) ; e . setEventKey = eventKey ; e . setAgentId = agentId ; return e ; } if ( InMenuEvent . EVENT_INMENU_LOCATION_SELECT == event ) { let e = new InMenuEvent ( obj . ToUserName , obj . FromUserName , obj . CreateTime , event ) ; e . setEventKey = eventKey ; e . setAgentId = agentId ; return e ; } if ( InMenuEvent . EVENT_INMENU_MEDIA_ID == event ) { let e = new InMenuEvent ( obj . ToUserName , obj . FromUserName , obj . CreateTime , event ) ; e . setEventKey = eventKey ; return e ; } if ( InMenuEvent . EVENT_INMENU_VIEW_LIMITED == event ) { let e = new InMenuEvent ( obj . ToUserName , obj . FromUserName , obj . CreateTime , event ) ; e . setEventKey = eventKey ; return e ; } if ( InMenuEvent . EVENT_INMENU_VIEW_MINIPROGRAM == event ) { let e = new InMenuEvent ( obj . ToUserName , obj . FromUserName , obj . CreateTime , event ) ; e . setEventKey = eventKey ; e . setMenuId = menuId ; return e ; } if ( InMenuEvent . EVENT_INMENU_VIEW_MINIPROGRAM == event ) { let e = new InWxVerifyDispatchEvent ( obj . ToUserName , obj . FromUserName , obj . CreateTime , event ) ; e . setProvider = obj . Provider ; e . setContact = obj . Contact ; e . setDispatchTime = obj . DispatchTime ; return e ; } if ( InTemplateMsgEvent . EVENT == event ) { let e = new InTemplateMsgEvent ( obj . ToUserName , obj . FromUserName , obj . CreateTime , event ) ; e . setMsgId = obj . MsgID ; e . setStatus = obj . Status ; return e ; } if ( InMassEvent . EVENT == event ) { let e = new InMassEvent ( obj . ToUserName , obj . FromUserName , obj . CreateTime , event ) ; e . setMsgId = obj . MsgID ; e . setStatus = obj . Status ; e . setTotalCount = obj . TotalCount ; e . setFilterCount = obj . FilterCount ; e . setSentCount = obj . SentCount ; e . setErrorCount = obj . ErrorCount ; return e ; } if ( InCustomEvent . EVENT_INCUSTOM_KF_CREATE_SESSION == event ) { let e = new InCustomEvent ( obj . ToUserName , obj . FromUserName , obj . CreateTime , event ) ; e . setKfAccount = obj . KfAccount ; return e ; } if ( InCustomEvent . EVENT_INCUSTOM_KF_CLOSE_SESSION == event ) { let e = new InCustomEvent ( obj . ToUserName , obj . FromUserName , obj . CreateTime , event ) ; e . setKfAccount = obj . KfAccount ; return e ; } if ( InCustomEvent . EVENT_INCUSTOM_KF_SWITCH_SESSION == event ) { let e = new InCustomEvent ( obj . ToUserName , obj . FromUserName , obj . CreateTime , event ) ; e . setKfAccount = obj . KfAccount ; e . setToKfAccount == obj . ToKfAccount ; return e ; } if ( 'ShakearoundUserShake' == event ) { let e = new InShakearoundUserShakeEvent ( obj . ToUserName , obj . FromUserName , obj . CreateTime , event ) ; e . setEvent = event ; e . setUuid = obj . ChosenBeacon . Uuid ; e . setMajor = obj . ChosenBeacon . Major ; e . setMinor = obj . ChosenBeacon . Minor ; e . setDistance = obj . ChosenBeacon . Distance ; e . setAroundBeaconList = obj . AroundBeacons ; return e ; } if ( 'qualification_verify_success' == event || 'naming_verify_success' == event || 'annual_renew' == event || 'verify_expired' == event ) { let e = new InVerifySuccessEvent ( obj . ToUserName , obj . FromUserName , obj . CreateTime , event ) ; e . setExpiredTime == obj . expiredTime ; return e ; } if ( 'qualification_verify_fail' == event || 'naming_verify_fail' == event ) { let e = new InVerifyFailEvent ( obj . ToUserName , obj . FromUserName , obj . CreateTime , event ) ; e . setFailTime = obj . failTime ; e . setFailReason = obj . failReason ; return e ; } if ( InPoiCheckNotifyEvent . EVENT == event ) { let e = new InPoiCheckNotifyEvent ( obj . ToUserName , obj . FromUserName , obj . CreateTime , event ) ; e . setUniqId = obj . UniqId ; e . setPoiId = obj . PoiId ; e . setResult = obj . Result ; e . setMsg = obj . Msg ; return e ; } if ( InWifiEvent . EVENT == event ) { let e = new InWifiEvent ( obj . ToUserName , obj . FromUserName , obj . CreateTime , event ) ; e . setConnectTime = obj . ConnectTime ; e . setExpireTime = obj . ExpireTime ; e . setVendorId = obj . VendorId ; e . setDeviceNo = obj . DeviceNo ; e . setShopId = obj . ShopId ; return e ; } if ( InUserCardEvent . EVENT_USER_VIEW == event ) { let e = new InUserCardEvent ( obj . ToUserName , obj . FromUserName , obj . CreateTime , event ) ; e . setCardId = obj . CardId ; e . setUserCardCode = obj . UserCardCode ; return e ; } if ( InUserCardEvent . EVENT_MEMBERCARD == event ) { let e = new InUserCardEvent ( obj . ToUserName , obj . FromUserName , obj . CreateTime , event ) ; e . setCardId = obj . CardId ; e . setUserCardCode = obj . UserCardCode ; return e ; } if ( InUpdateMemberCardEvent . EVENT == event ) { let e = new InUpdateMemberCardEvent ( obj . ToUserName , obj . FromUserName , obj . CreateTime , event ) ; e . setCardId = obj . CardId ; e . setUserCardCode = obj . UserCardCode ; e . setModifyBonus = obj . ModifyBonus ; e . setModifyBalance = obj . ModifyBalance ; return e ; } if ( InUserPayFromCardEvent . EVENT == event ) { let e = new InUserPayFromCardEvent ( obj . ToUserName , obj . FromUserName , obj . CreateTime , event ) ; e . setCardId = obj . CardId ; e . setUserCardCode = obj . UserCardCode ; e . setLocationId = obj . LocationId ; e . setTransId = obj . TransId ; e . setFee = obj . Fee ; e . setOriginalFee = obj . OriginalFee ; return e ; } if ( InMerChantOrderEvent . EVENT == event ) { let e = new InMerChantOrderEvent ( obj . ToUserName , obj . FromUserName , obj . CreateTime , event ) ; e . setOrderId = obj . OrderId ; e . setOrderStatus = obj . OrderStatus ; e . setProductId = obj . ProductId ; e . setSkuInfo = obj . SkuInfo ; return e ; } if ( InCardPassCheckEvent . EVENT_PASS == event ) { let e = new InCardPassCheckEvent ( obj . ToUserName , obj . FromUserName , obj . CreateTime , event ) ; e . setCardId = obj . CardId ; e . setRefuseReason = obj . RefuseReason ; return e ; } if ( InCardPassCheckEvent . EVENT_NOT_PASS == event ) { let e = new InCardPassCheckEvent ( obj . ToUserName , obj . FromUserName , obj . CreateTime , event ) ; e . setCardId = obj . CardId ; e . setRefuseReason = obj . RefuseReason ; return e ; } if ( InCardPayOrderEvent . EVENT == event ) { let e = new InCardPayOrderEvent ( obj . ToUserName , obj . FromUserName , obj . CreateTime , event ) ; e . setOrderId = obj . OrderId ; e . setStatus = obj . Status ; e . setCreateOrderTime = obj . CreateOrderTime ; e . setPayFinishTime = obj . PayFinishTime ; e . setDesc = obj . Desc ; e . setFreeCoinCount = obj . FreeCoinCount ; e . setPayCoinCount = obj . PayCoinCount ; e . setRefundFreeCoinCount = obj . RefundFreeCoinCount ; e . setRefundPayCoinCount = obj . RefundPayCoinCount ; e . setOrderType = obj . OrderType ; e . setOrderType = obj . OrderType ; e . setMemo = obj . Memo ; e . setReceiptInfo = obj . ReceiptInfo ; return e ; } if ( InCardSkuRemindEvent . EVENT == event ) { let e = new InCardSkuRemindEvent ( obj . ToUserName , obj . FromUserName , obj . CreateTime , event ) ; e . setCardId = obj . CardId ; e . setDetail = obj . Detail ; return e ; } if ( InUserConsumeCardEvent . EVENT == event ) { let e = new InUserConsumeCardEvent ( obj . ToUserName , obj . FromUserName , obj . CreateTime , event ) ; e . setCardId = obj . CardId ; e . setUserCardCode = obj . UserCardCode ; e . setConsumeSource = obj . ConsumeSource ; e . setLocationName = obj . LocationName ; e . setStaffOpenId = obj . StaffOpenId ; e . setVerifyCode = obj . VerifyCode ; e . setRemarkAmount = obj . RemarkAmount ; e . setOuterStr = obj . OuterStr ; return e ; } if ( InUserCardEvent . EVENT_USER_DEL == event ) { let e = new InUserCardEvent ( obj . ToUserName , obj . FromUserName , obj . CreateTime , event ) ; e . setCardId = obj . CardId ; e . setUserCardCode = obj . UserCardCode ; return e ; } if ( InUserCardEvent . EVENT_USER_ENTER == event ) { let e = new InUserCardEvent ( obj . ToUserName , obj . FromUserName , obj . CreateTime , event ) ; e . setCardId = obj . CardId ; e . setUserCardCode = obj . UserCardCode ; return e ; } if ( InUserGetCardEvent . EVENT == event ) { let e = new InUserGetCardEvent ( obj . ToUserName , obj . FromUserName , obj . CreateTime , event ) ; e . setCardId = obj . CardId ; e . setIsGiveByFriend = obj . IsGiveByFriend ; e . setUserCardCode = obj . UserCardCode ; e . setFriendUserName = obj . FriendUserName ; e . setOuterId = obj . OuterId ; e . setOldUserCardCode = obj . OldUserCardCode ; e . setOuterStr = obj . OuterStr ; e . setIsRestoreMemberCard = obj . IsRestoreMemberCard ; e . setIsRecommendByFriend = obj . IsRecommendByFriend ; return e ; } if ( InUserGiftingCardEvent . EVENT == event ) { let e = new InUserGiftingCardEvent ( obj . ToUserName , obj . FromUserName , obj . CreateTime , event ) ; e . setCardId = obj . CardId ; e . setUserCardCode = obj . UserCardCode ; e . setIsReturnBack = obj . IsReturnBack ; e . setFriendUserName = obj . FriendUserName ; e . setIsChatRoom = obj . IsChatRoom ; return e ; } if ( InTaskEvent . EVENT == event ) { let e = new InTaskEvent ( obj . ToUserName , obj . FromUserName , obj . CreateTime , event ) ; e . setEventKey = eventKey ; e . setTaskId = obj . TaskId ; e . setAgentId = obj . AgentId ; return e ; } if ( InCardMerchantCheckResultEvent . EVENT == event ) { let e = new InCardMerchantCheckResultEvent ( obj . ToUserName , obj . FromUserName , obj . CreateTime , event ) ; e . setMerchantId = obj . MerchantId ; e . setIsPass = obj . IsPass ; e . setReason = obj . Reason ; return e ; } if ( InBatchJobResultEvent . EVENT == event ) { let e = new InBatchJobResultEvent ( obj . ToUserName , obj . FromUserName , obj . CreateTime , event ) ; let batchJob = obj . BatchJob ; e . setEventCode = batchJob . ErrCode ; e . setEventMsg = batchJob . ErrMsg ; e . setJobId = batchJob . JobId ; e . setJobType = batchJob . JobType ; return e ; } if ( InUpdateUserEvent . EVENT == event ) { let changeType = obj . ChangeType ; if ( InUpdateTagEvent . CHANGE_TYPE == changeType ) { let e = new InUpdateTagEvent ( obj . ToUserName , obj . FromUserName , obj . CreateTime , event ) ; e . setTagId = obj . TagId ; e . setAddUserItems = obj . AddUserItems ; e . setDelUserItems = obj . DelUserItems ; e . setAddPartyItems = obj . AddPartyItems ; e . setDelPartyItems = obj . DelPartyItems ; return e ; } else if ( InUpdatePartyEvent . CREATE_PARTY == changeType ) { let e = new InUpdatePartyEvent ( obj . ToUserName , obj . FromUserName , obj . CreateTime , event ) ; e . setChangeType = changeType ; e . setId = obj . Id ; e . setName = obj . Name ; e . setParentId = obj . ParentId ; e . setOrder = obj . Order ; return e ; } else if ( InUpdatePartyEvent . UPDATE_PARTY == changeType ) { let e = new InUpdatePartyEvent ( obj . ToUserName , obj . FromUserName , obj . CreateTime , event ) ; e . setChangeType = changeType ; e . setId = obj . Id ; e . setName = obj . Name ; e . setParentId = obj . ParentId ; return e ; } else if ( InUpdatePartyEvent . DELETE_PARTY == changeType ) { let e = new InUpdatePartyEvent ( obj . ToUserName , obj . FromUserName , obj . CreateTime , event ) ; e . setChangeType = changeType ; e . setId = obj . Id ; return e ; } else if ( InUpdateUserEvent . CREATE_USER == changeType ) { let e = new InUpdateUserEvent ( obj . ToUserName , obj . FromUserName , obj . CreateTime , event ) ; e . setChangeType = changeType ; e . setUserId = obj . UserID ; e . setName = obj . Name ; e . setDepartment = obj . Department ; e . setIsLeaderInDept = obj . IsLeaderInDept ; e . setPosition = obj . Position ; e . setMobile = obj . Mobile ; e . setGender = obj . Gender ; e . setEmail = obj . Email ; e . setStatus = obj . Status ; e . setAvatar = obj . Avatar ; e . setAlias = obj . Alias ; e . setTelephone = obj . Telephone ; e . setAlias = obj . Alias ; e . setAddress = obj . Address ; e . setExtAttr = obj . ExtAttr ; return e ; } else if ( InUpdateUserEvent . UPDATE_USER == changeType ) { let e = new InUpdateUserEvent ( obj . ToUserName , obj . FromUserName , obj . CreateTime , event ) ; e . setChangeType = changeType ; e . setUserId = obj . UserID ; e . setNewUserId = obj . NewUserID ; e . setName = obj . Name ; e . setDepartment = obj . Department ; e . setIsLeaderInDept = obj . IsLeaderInDept ; e . setPosition = obj . Position ; e . setMobile = obj . Mobile ; e . setGender = obj . Gender ; e . setEmail = obj . Email ; e . setStatus = obj . Status ; e . setAvatar = obj . Avatar ; e . setAlias = obj . Alias ; e . setTelephone = obj . Telephone ; e . setAlias = obj . Alias ; e . setAddress = obj . Address ; e . setExtAttr = obj . ExtAttr ; return e ; } else if ( InUpdateUserEvent . DELETE_USER == changeType ) { let e = new InUpdateUserEvent ( obj . ToUserName , obj . FromUserName , obj . CreateTime , event ) ; e . setChangeType = changeType ; e . setUserId = obj . UserID ; return e ; } } if ( InExternalContactEvent . EVENT == event ) { let e = new InExternalContactEvent ( obj . ToUserName , obj . FromUserName , obj . CreateTime , event ) ; e . changeType = obj . ChangeType ; e . userId = obj . UserID ; e . externalUserId = obj . ExternalUserID ; e . setState = obj . State ; e . welcomeCode = obj . WelcomeCode ; return e ; } console . error ( `无法识别的事件类型 ${ event }，请前往 https://gitee.com/javen205/TNWX/issues 提 issues` ) ; return new InNotDefinedEvent ( obj . ToUserName , obj . FromUserName , obj . CreateTime , event ) ; } private static parseInSuiteTicket ( obj ) { return new InSuiteTicket ( obj . SuiteId , obj . InfoType , obj . TimeStamp , obj . SuiteTicket ) ; } private static paseInComponentVerifyTicket ( obj ) { return new InComponentVerifyTicket ( obj . AppId , obj . InfoType , obj . CreateTime , obj . ComponentVerifyTicket ) ; } private static InAuthEvent ( obj ) { let infoType = obj . InfoType ; if ( InAuthEvent . CREATE_AUTH === infoType ) return new InAuthEvent ( obj . SuiteId , obj . InfoType , obj . TimeStamp , obj . AuthCode ) ; if ( InAuthEvent . CHANGE_AUTH === infoType || InAuthEvent . CANCEL_AUTH === infoType ) return new InAuthEvent ( obj . SuiteId , obj . InfoType , obj . TimeStamp , undefined , obj . AuthCorpId ) ; } private static InAuthMpEvent ( obj ) { let infoType = obj . InfoType ; if ( InAuthMpEvent . CANCEL_AUTH === infoType ) return new InAuthMpEvent ( obj . AppId , obj . InfoType , obj . CreateTime , obj . AuthorizerAppid ) ; if ( InAuthMpEvent . CHANGE_AUTH === infoType || InAuthMpEvent . CREATE_AUTH === infoType ) return new InAuthMpEvent ( obj . AppId , obj . InfoType , obj . CreateTime , obj . AuthorizerAppid , obj . AuthorizationCode , obj . AuthorizationCodeExpiredTime , obj . PreAuthCode ) ; } private static parseInBatchJobResult ( obj ) { let batchJob = obj . BatchJob ; return new InBatchJobResult ( obj . ServiceCorpId , obj . InfoType , obj . TimeStamp , obj . AuthCorpId , batchJob . JobId , batchJob . JobType ) ; } private static parseInExternalContact ( obj ) { return new InExternalContact ( obj . SuiteId , obj . AuthCorpId , obj . InfoType , obj . TimeStamp , obj . ChangeType , obj . UserID , obj . ExternalUserID , obj . WelcomeCode ) ; } private static parseInRegisterCorp ( obj ) { let contactSync = obj . ContactSync ; return new InRegisterCorp ( obj . ServiceCorpId , obj . InfoType , obj . TimeStamp , obj . RegisterCode , obj . AuthCorpId , contactSync . AccessToken , contactSync . ExpiresIn , obj . AuthUserInfo . UserId , obj . State , obj . TemplateId ) ; } }