74 lines
1.7 KiB
TypeScript
Raw Normal View History

2019-09-18 15:02:21 +09:00
import { DeviceType } from '@ucap-webmessenger/core';
2019-09-20 11:39:09 +09:00
import {
APIRequest,
APIResponse,
APIEncoder,
APIDecoder,
2019-11-05 13:46:17 +09:00
ParameterUtil,
StatusCode
2019-09-20 11:39:09 +09:00
} from '@ucap-webmessenger/api';
2019-09-18 15:02:21 +09:00
export interface FileTalkShareRequest extends APIRequest {
userSeq: number;
2019-09-18 15:02:21 +09:00
deviceType: DeviceType;
token: string;
attachmentsSeq?: string;
2019-11-05 13:46:17 +09:00
roomSeq?: string;
2019-09-18 15:02:21 +09:00
synapKey?: string;
}
export interface FileTalkShareResponse extends APIResponse {
2019-11-05 13:46:17 +09:00
roomSeq?: string;
fileName?: string;
fileExt?: string;
fileType?: string;
thumbnailUrl?: string;
attachmentSeq?: string;
attachmentSize?: string;
attachmentRegDate?: string;
companyCode?: string;
synapKey?: string;
returnJson?: any;
2019-09-18 15:02:21 +09:00
}
2019-09-20 11:39:09 +09:00
2019-11-05 13:46:17 +09:00
const fileTalkShareEncodeMap = {
userSeq: 'p_user_seq',
deviceType: 'p_device_type',
token: 'p_token',
attachmentsSeq: 'p_att_seq',
roomSeq: 'p_room_id',
synapKey: 'p_synap_key'
};
2019-09-20 11:39:09 +09:00
export const encodeFileTalkShare: APIEncoder<FileTalkShareRequest> = (
req: FileTalkShareRequest
) => {
return ParameterUtil.encode(fileTalkShareEncodeMap, req);
};
export const decodeFileTalkShare: APIDecoder<FileTalkShareResponse> = (
res: any
) => {
2019-11-05 13:46:17 +09:00
try {
return {
statusCode: res.StatusCode,
roomSeq: res.RoomID,
fileName: res.FileName,
fileExt: res.FileExt,
fileType: res.FileType,
thumbnailUrl: res.ThumbURL,
attachmentSeq: res.AttSEQ,
attachmentSize: res.AttSize,
attachmentRegDate: res.AttRegDate,
companyCode: res.CompanyCode,
synapKey: res.SynapKey,
returnJson: JSON.stringify(res)
2019-11-05 13:46:17 +09:00
} as FileTalkShareResponse;
} catch (e) {
return {
statusCode: StatusCode.Fail,
errorMessage: e
} as FileTalkShareResponse;
}
2019-09-20 11:39:09 +09:00
};