import moment from "moment"; import sendFormAnswer from "../../api/Ingestion/sendFormAnswer"; async function AssembleIngestionObject( { images, description }, user, situation, code, location, date, time, address ) { const ingestionObject = { responseData: { array_to_json: [ { formcode: code, formsanswersuserinformer: "admin@wpd.com", //user.id, fieldsanswerslongitude: location["longitude"], fieldsanswerslatitude: location["latitude"], fields: [ { fieldsanswerssituation: situation ? situation : "CHUVA FRACA", fieldsanswerseventaddress: address, fieldsanswerseventdate: moment(date).format("DD-MM-YYYY"), fieldsanswerseventtime: moment(time).format("HH:mm"), fieldsanswerscomments: description, }, ], }, ], }, }; return sendFormAnswer(ingestionObject); } const AssembleIngestionPluviometer = async ({ pluviometer, description, images, user, date, time, }) => { const pluviometerObject = { responseData: { array_to_json: [ { formcode: "PLUVIOMETERS_FORM", formsanswersuserinformer: "admin@wpd.com", //user.id, fias: [ { fieldsanswersdate: moment(date).format("DD-MM-YYYY"), fieldsanswersrainamount: pluviometer, fieldsanswerseventtime: moment(time).format("HH:mm"), fielsanswercomment: description, }, ], }, ], }, }; }; async function AssembleIngestionPluvRegistration( date, time, user, address, coordinates ) { const pluvResgistrationObject = { responseData: { array_to_json: [ { formcode: "PLUVIOMETER_REGISTRATION", formsanswersuserinformer: "admin@wpd.com", //user.id, fieldsanswerslongitude: coordinates["longitude"], fieldsanswerslatitude: coordinates["latitude"], fields: [ { fieldsanswerseventaddress: address, fieldsanswerseventdate: moment(date).format("DD-MM-YYYY"), fieldsanswerseventtime: moment(time).format("HH:mm"), fieldsanswersinstitutename: user.institutionName ? user.institutionName : null, fieldsanswerrinstitutetype: user.institutionType ? user.institutionType : null, }, ], }, ], }, }; const a = await sendFormAnswer(pluvResgistrationObject); return a; } export { AssembleIngestionObject, AssembleIngestionPluviometer, AssembleIngestionPluvRegistration, };