UNPKG

@onereach/channel-transformer

Version:

Convert data model between different channels (Slack, Microsoft Teams, Generic...)

20 lines (16 loc) 531 B
import { ISMSMessage } from "../types"; import { getMethods } from "./methods"; import { IGenericWrapper } from "../../generic/types"; export const transformGenericToSMS = (msg: IGenericWrapper) => { const { children = [] } = msg; const messages: Array<ISMSMessage> = children.reduce((acc, child) => { const res = getMethods(child.type)(child); Array.isArray(res) ? acc.push(...res) : acc.push(res); return acc; }, []); return { messages }; };