import { NotificationMethod } from '@ucap-webmessenger/core';

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

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

export interface RegViewResponse extends ProtocolResponse {
  // 0 알림방법(n)
  notificationMethod?: NotificationMethod;
  // 1 모바일알림(n)
  mobileNotification?: number;
  // 2 폰트종류(s)
  fontFamily?: string;
  // 3 폰트크기(n)
  fontSize?: number;
  // 4 알림받음/받지않음(n)
  receiveNotification?: number;
  // 5 알림방법(n)
  notificationMethod0?: number;
  // 6 알림창 설정(n)
  notificationExposureTime?: number;
  // 7 타임존(s)
  timeZone?: string;
  // 8 타임존값(s)
  timeZoneValue?: string;
  // 9 부재중시간설정(n)
  absenceTime?: number;
  // 10 메뉴 언어(n)
  menuLanguage?: number;
  // 11 인사정보 언어(n)
  hrInformationLanguage?: number;
  // 12 번역키
  translationKey?: string;
}

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

  return bodyList;
};

export const decodeRegView: ProtocolDecoder<RegViewResponse> = (
  message: ProtocolMessage
) => {
  return decodeProtocolMessage(message, {
    notificationMethod: message.bodyList[0] as NotificationMethod,
    mobileNotification: message.bodyList[1],
    fontFamily: message.bodyList[2],
    fontSize: message.bodyList[3],
    receiveNotification: message.bodyList[4],
    notificationMethod0: message.bodyList[5],
    notificationExposureTime: message.bodyList[6],
    timeZone: message.bodyList[7],
    timeZoneValue: message.bodyList[8],
    absenceTime: message.bodyList[9],
    menuLanguage: message.bodyList[10],
    hrInformationLanguage: message.bodyList[11],
    translationKey: message.bodyList[12]
  } as RegViewResponse);
};
