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

export interface BuddyDelRequest extends ProtocolRequest {
  // 0n. 사용자SEQ(n)...
  userSeqs: number[];
}

export interface BuddyDelResponse extends ProtocolResponse {
  // 0n. 사용자SEQ(n)...
  userSeqs: number[];
}

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

  for (const userSeq of req.userSeqs) {
    bodyList.push({ type: PacketBodyValue.Integer, value: userSeq });
  }

  return bodyList;
};

export const decodeBuddyDel: ProtocolDecoder<BuddyDelResponse> = (
  message: ProtocolMessage
) => {
  const userSeqArray: number[] = [...message.bodyList];
  return {
    userSeqs: userSeqArray
  } as BuddyDelResponse;
};
