57 lines
1.3 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-10-28 18:03:27 +09:00
ParameterUtil,
JsonAnalization,
StatusCode
2019-09-20 11:39:09 +09:00
} from '@ucap-webmessenger/api';
2019-09-18 15:02:21 +09:00
export interface MassTalkDownloadRequest extends APIRequest {
2019-10-11 18:03:01 +09:00
userSeq: number;
2019-09-18 15:02:21 +09:00
deviceType: DeviceType;
token: string;
2019-10-11 18:03:01 +09:00
eventMassSeq?: number;
2019-09-18 15:02:21 +09:00
}
export interface MassTalkDownloadResponse extends APIResponse {
2019-10-11 18:03:01 +09:00
content?: string;
userName?: string;
regDate?: string;
2019-09-18 15:02:21 +09:00
}
2019-09-20 11:39:09 +09:00
2019-10-11 18:03:01 +09:00
const massTalkDownloadEncodeMap = {
userSeq: 'p_user_seq',
deviceType: 'p_device_type',
token: 'p_token',
eventMassSeq: 'p_event_mass_seq'
};
2019-09-20 11:39:09 +09:00
export const encodeMassTalkDownload: APIEncoder<MassTalkDownloadRequest> = (
req: MassTalkDownloadRequest
) => {
return ParameterUtil.encode(massTalkDownloadEncodeMap, req);
};
export const decodeMassTalkDownload: APIDecoder<MassTalkDownloadResponse> = (
res: any
) => {
2019-10-28 18:03:27 +09:00
try {
2019-11-06 13:48:06 +09:00
const json = JsonAnalization.receiveAnalization(res);
2019-10-28 18:03:27 +09:00
return {
statusCode: json.StatusCode,
errorMessage: json.ErrorMessage,
content: json.Content,
userName: json.UserName,
regDate: json.RegDate
} as MassTalkDownloadResponse;
} catch (e) {
return {
statusCode: StatusCode.Fail,
errorMessage: e
} as MassTalkDownloadResponse;
}
2019-09-20 11:39:09 +09:00
};