refactor(io): added new method addChild

This commit is contained in:
Leifer Mendez
2022-11-30 21:04:45 +01:00
18 changed files with 9863 additions and 15 deletions

View File

@@ -10,6 +10,7 @@ const { toSerialize } = require('./toSerialize')
const addAnswer =
(inCtx) =>
(answer, options, cb = null, nested = []) => {
answer = Array.isArray(answer) ? answer.join('\n') : answer
/**
* Todas las opciones referentes a el mensaje en concreto options:{}
* @returns

View File

@@ -0,0 +1,15 @@
const { toSerialize } = require('./toSerialize')
/**
* @deprecate
* @param answer string
* @param options {media:string, buttons:[], capture:true default false}
* @returns
*/
const addChild = (flowIn = null) => {
if (!flowIn?.toJson) {
throw new Error('DEBE SER UN FLOW CON toJSON()')
}
return toSerialize(flowIn.toJson())
}
module.exports = { addChild }

View File

@@ -1,7 +1,8 @@
const { addAnswer } = require('./addAnswer')
const { addKeyword } = require('./addKeyword')
const { addChild } = require('./addChild')
const { toSerialize } = require('./toSerialize')
const { toCtx } = require('./toCtx')
const { toJson } = require('./toJson')
module.exports = { addAnswer, addKeyword, toCtx, toJson, toSerialize }
module.exports = { addAnswer, addKeyword, addChild, toCtx, toJson, toSerialize }