import { IGenericSection } from "../../../generic/types";
import { IMSTeamsEvent } from "../../types";
import { getMethods } from "../methods";

export const transformMessage = (
  { messageType = 'message', attachments = [], body = {}}
  : IMSTeamsEvent): IGenericSection => {
  const section: IGenericSection = {
    type: 'section',
    props: {
      msteams: {
        type: messageType,
      }
    },
    children: []
  };


  if (attachments?.length) 
    section.children.push(getMethods('attachments')(attachments));

  section.children.push(getMethods(body?.contentType)(body));
  
  return section;
};