encoder and decoder are added
This commit is contained in:
parent
eef36fcb44
commit
9ae1ed25c4
|
@ -4,8 +4,11 @@ import {
|
|||
APIResponse,
|
||||
APIEncoder,
|
||||
APIDecoder,
|
||||
ParameterUtil
|
||||
ParameterUtil,
|
||||
StatusCode,
|
||||
JsonAnalization
|
||||
} from '@ucap-webmessenger/api';
|
||||
import { JsonObject } from 'type-fest';
|
||||
|
||||
export interface FileTalkSaveRequest extends APIRequest {
|
||||
userSeq: string;
|
||||
|
@ -21,31 +24,72 @@ export interface FileTalkSaveRequest extends APIRequest {
|
|||
}
|
||||
|
||||
export interface FileTalkSaveResponse extends APIResponse {
|
||||
RoomID?: string;
|
||||
FileName?: string;
|
||||
FileExt?: string;
|
||||
FileType?: string;
|
||||
ThumbURL?: string;
|
||||
AttSEQ?: string;
|
||||
AttSize?: string;
|
||||
AttRegDate?: string;
|
||||
ImageWidth?: string;
|
||||
ImageHeight?: string;
|
||||
CompanyCode?: string;
|
||||
VoiceTime?: string;
|
||||
SynapKey?: string;
|
||||
roomID?: string;
|
||||
fileName?: string;
|
||||
fileExt?: string;
|
||||
fileType?: string;
|
||||
thumbnailUrl?: string;
|
||||
attachmentSeq?: string;
|
||||
attachmentSize?: string;
|
||||
attachmentRegDate?: string;
|
||||
imageWidth?: string;
|
||||
imageHeight?: string;
|
||||
companyCode?: string;
|
||||
voiceTime?: string;
|
||||
synapKey?: string;
|
||||
returnJson?: any;
|
||||
}
|
||||
|
||||
const fileTalkSaveEncodeMap = {};
|
||||
const fileTalkSaveEncodeMap = {
|
||||
userSeq: 'p_user_seq',
|
||||
deviceType: 'p_device_type',
|
||||
token: 'p_token',
|
||||
file: 'file',
|
||||
fileName: 'p_file_name',
|
||||
thumb: 'thumb',
|
||||
voice: 'p_voice',
|
||||
voiceTime: 'p_voice_time',
|
||||
roomId: 'p_room_id',
|
||||
type: 'p_type'
|
||||
};
|
||||
|
||||
export const encodeFileTalkSave: APIEncoder<FileTalkSaveRequest> = (
|
||||
req: FileTalkSaveRequest
|
||||
) => {
|
||||
return ParameterUtil.encode(fileTalkSaveEncodeMap, req);
|
||||
const extraParams: any = {};
|
||||
if (!!req.voice) {
|
||||
extraParams.voice = req.voice ? 'Y' : 'N';
|
||||
}
|
||||
|
||||
return ParameterUtil.encode(fileTalkSaveEncodeMap, req, extraParams);
|
||||
};
|
||||
|
||||
export const decodeFileTalkSave: APIDecoder<FileTalkSaveResponse> = (
|
||||
res: any
|
||||
) => {
|
||||
return {} as FileTalkSaveResponse;
|
||||
try {
|
||||
const json: JsonObject | Error = JsonAnalization.receiveAnalization(res);
|
||||
return {
|
||||
statusCode: json.StatusCode,
|
||||
roomID: json.RoomID,
|
||||
fileName: json.FileName,
|
||||
fileExt: json.FileExt,
|
||||
fileType: json.FileType,
|
||||
thumbnailUrl: json.ThumbURL,
|
||||
attachmentSeq: json.AttSEQ,
|
||||
attachmentSize: json.AttSize,
|
||||
attachmentRegDate: json.AttRegDate,
|
||||
imageWidth: json.ImageWidth,
|
||||
imageHeight: json.ImageHeight,
|
||||
companyCode: json.CompanyCode,
|
||||
voiceTime: json.VoiceTime,
|
||||
synapKey: json.SynapKey,
|
||||
returnJson: res
|
||||
} as FileTalkSaveResponse;
|
||||
} catch (e) {
|
||||
return {
|
||||
statusCode: StatusCode.Fail,
|
||||
errorMessage: e
|
||||
} as FileTalkSaveResponse;
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue
Block a user