ucap-doc/documents/업무/2월/3째주/file-viewer-prj/bundle-image.event-json.ts
2020-02-21 09:35:58 +09:00

36 lines
939 B
TypeScript

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<BundleImageEventJson> = (
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;
}
};