import {
  ProtocolRequest,
  ProtocolResponse,
  ProtocolEncoder,
  PacketBody,
  ProtocolDecoder,
  ProtocolMessage,
  decodeProtocolMessage
} from '@ucap-webmessenger/protocol';

// tslint:disable-next-line: no-empty-interface
export interface ViewRequest extends ProtocolRequest {}

export interface ViewResponse extends ProtocolResponse {
  // 알람여부(y)
  receiveAlarm?: boolean;
  // 알람VIEW여부(y)
  displayAlarm?: boolean;
  // 그룹알람여부(y)
  receiveGroupAlarm?: boolean;
  // PC알람여부(y)
  receivePcAlarm?: boolean;
}

export const encodeView: ProtocolEncoder<ViewRequest> = (req: ViewRequest) => {
  const bodyList: PacketBody[] = [];

  return bodyList;
};

export const decodeView: ProtocolDecoder<ViewResponse> = (
  message: ProtocolMessage
) => {
  return decodeProtocolMessage(message, {
    receiveAlarm: message.bodyList[0] === 'Y' ? true : false,
    displayAlarm: message.bodyList[1] === 'Y' ? true : false,
    receiveGroupAlarm: message.bodyList[2] === 'Y' ? true : false,
    receivePcAlarm: message.bodyList[3] === 'Y' ? true : false
  } as ViewResponse);
};
