import {
  APIRequest,
  MessageAPIResponse,
  APIJsonEncoder,
  APIDecoder
} from '@ucap-webmessenger/api';
import { DeviceType } from '@ucap-webmessenger/core';
import { MessageType } from '../types/message.type';
import { CategoryType } from '../types/category.type';
import { ContentType } from '../types/content.type';

export interface SendRequest extends APIRequest {
  userSeq: number;
  deviceType: DeviceType;
  tokenKey: string;
  type: MessageType;

  userName: string;
  category: CategoryType;
  title: string;
  titleYn: boolean;
  listOrder: ContentType[];
  reservationTime: string;
  smsYn: boolean;

  textContent: { text: string }[];
  recvUserList: { userSeq: number; userName: string }[];
}

export interface SendResponse extends MessageAPIResponse {}

export const encodeSend: APIJsonEncoder<SendRequest> = (req: SendRequest) => {
  return JSON.stringify(req);
};

export const decodeSend: APIDecoder<SendResponse> = (res: any) => {
  return {
    responseCode: res.responseCode,
    responseMsg: res.responseMsg
  } as SendResponse;
};
