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

export interface DelRequest extends ProtocolRequest {
  /** 동료그룹SEQ(n) */
  groupSeq: number;
}

export interface DelResponse extends ProtocolResponse {
  /** 동료그룹SEQ(n) */
  groupSeq: number;
}

export interface DelNotification extends ProtocolNotification {
  /** 동료그룹SEQ(n) */
  groupSeq: number;
}

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

  bodyList.push({ type: PacketBodyValue.Integer, value: req.groupSeq });

  return bodyList;
};

export const decodeDel: ProtocolDecoder<DelResponse> = (
  message: ProtocolMessage
) => {
  return decodeProtocolMessage(message, {
    groupSeq: message.bodyList[0]
  } as DelResponse);
};

export const decodeDelNotification: ProtocolDecoder<DelNotification> = (
  message: ProtocolMessage
) => {
  return decodeProtocolMessage(message, {
    groupSeq: message.bodyList[0]
  } as DelNotification);
};
