import { StatusCode, JsonAnalization } from '@ucap-webmessenger/api'; import { EventJsonDecoder } from './event-json'; export interface BundleImageEventJson { statusCode?: StatusCode; errorMessage?: string; roomSeq?: number; attachmentSeq?: number; fileCount?: number; baseUrl?: string; thumbUrls?: string[]; } export const decodeBundleImageEventJson: EventJsonDecoder = ( message: string ) => { try { const json = JsonAnalization.receiveAnalization(message); return { statusCode: json.StatusCode, errorMessage: json.ErrorMessage, roomSeq: Number(json.RoomID), attachmentSeq: Number(json.AttSEQ), fileCount: Number(json.FileCount), baseUrl: json.BaseURL, thumbUrls: json.ThumbURL } as BundleImageEventJson; } catch (e) { return { statusCode: StatusCode.Fail, errorMessage: e.toString() } as BundleImageEventJson; } };