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,
|
|
|
|
JsonAnalization,
|
|
|
|
StatusCode
|
2019-09-20 11:39:09 +09:00
|
|
|
} from '@ucap-webmessenger/api';
|
2019-11-05 13:46:17 +09:00
|
|
|
import { JsonObject } from 'type-fest';
|
2019-09-18 15:02:21 +09:00
|
|
|
|
|
|
|
export interface FileTalkShareRequest extends APIRequest {
|
|
|
|
userSeq: string;
|
|
|
|
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 {
|
|
|
|
const json: JsonObject | Error = JsonAnalization.receiveAnalization(res);
|
|
|
|
return {
|
|
|
|
statusCode: json.StatusCode,
|
|
|
|
roomSeq: json.RoomID,
|
|
|
|
fileName: json.FileName,
|
|
|
|
fileExt: json.FileExt,
|
|
|
|
fileType: json.FileType,
|
|
|
|
thumbnailUrl: json.ThumbURL,
|
|
|
|
attachmentSeq: json.AttSEQ,
|
|
|
|
attachmentSize: json.AttSize,
|
|
|
|
attachmentRegDate: json.AttRegDate,
|
|
|
|
companyCode: json.CompanyCode,
|
|
|
|
synapKey: json.SynapKey,
|
|
|
|
returnJson: res
|
|
|
|
} as FileTalkShareResponse;
|
|
|
|
} catch (e) {
|
|
|
|
return {
|
|
|
|
statusCode: StatusCode.Fail,
|
|
|
|
errorMessage: e
|
|
|
|
} as FileTalkShareResponse;
|
|
|
|
}
|
2019-09-20 11:39:09 +09:00
|
|
|
};
|