2019-11-14 10:31:23 +09:00
|
|
|
import {
|
|
|
|
APIRequest,
|
2019-11-14 13:30:28 +09:00
|
|
|
MessageAPIResponse,
|
|
|
|
APIJsonEncoder,
|
|
|
|
APIDecoder
|
2019-11-14 10:31:23 +09:00
|
|
|
} from '@ucap-webmessenger/api';
|
|
|
|
import { DeviceType } from '@ucap-webmessenger/core';
|
|
|
|
|
|
|
|
export interface UnreadCountRequest extends APIRequest {
|
|
|
|
userSeq: number;
|
|
|
|
deviceType: DeviceType;
|
|
|
|
tokenKey: string;
|
|
|
|
}
|
|
|
|
|
2019-11-14 13:30:28 +09:00
|
|
|
export interface UnreadCountResponse extends MessageAPIResponse {
|
2019-11-14 10:31:23 +09:00
|
|
|
unreadCount: number;
|
|
|
|
}
|
|
|
|
|
2019-11-14 13:30:28 +09:00
|
|
|
export const encodeUnreadCount: APIJsonEncoder<UnreadCountRequest> = (
|
2019-11-14 10:31:23 +09:00
|
|
|
req: UnreadCountRequest
|
|
|
|
) => {
|
2019-11-14 13:30:28 +09:00
|
|
|
return JSON.stringify(req);
|
2019-11-14 10:31:23 +09:00
|
|
|
};
|
|
|
|
|
|
|
|
export const decodeUnreadCount: APIDecoder<UnreadCountResponse> = (
|
|
|
|
res: any
|
|
|
|
) => {
|
|
|
|
return {
|
|
|
|
responseCode: res.responseCode,
|
|
|
|
responseMsg: res.responseMsg,
|
|
|
|
unreadCount: res.unreadCount
|
|
|
|
} as UnreadCountResponse;
|
|
|
|
};
|