42 lines
1.5 KiB
JavaScript
42 lines
1.5 KiB
JavaScript
// Process Groups and Subs
|
|
// Two lists - organized_sub_list and organized_group_list
|
|
|
|
// CODE BELOW
|
|
// @param input fields supplied in the recipe step, as an object
|
|
// @return object matching the output schema
|
|
// Eg: Code for returning time zone for an IP address
|
|
/**/
|
|
const fetch = require("node-fetch")
|
|
|
|
exports.main = async ({ allGroups, allSubLevels }) => {
|
|
let organized_group_list = [];
|
|
let organized_sub_list = [];
|
|
|
|
for(let i = 0; i < allGroups.length; i++){
|
|
organized_group_list.push(allGroups[i].group_uuid)
|
|
}
|
|
|
|
for(let i = 0; i < allSubLevels.length; i++){
|
|
organized_sub_list.push(allSubLevels[i].productName_productLevel_pair)
|
|
}
|
|
|
|
//organized_group_list = `${organized_group_list}`
|
|
organized_sub_list = `${organized_sub_list}`
|
|
return { organized_group_list, organized_sub_list };
|
|
// THIS IS THE OUTPUT IN WORKATO
|
|
}
|
|
|
|
|
|
|
|
// Add sub levels custom prop via HTTP
|
|
// POST
|
|
// https://api.northpass.com/v2/properties/people/bulk
|
|
{"data":[{"attributes":{"properties":{"subscription_levels":"#{_('data.js_eval.1ec2b92b.output.organized_sub_list')}"}},"id":"#{_('data.northpass_connector_2339630_1687360845.c9d81bc3.data.included.first.id')}","type":"person_properties"}]}
|
|
|
|
// Add to groups via HTTP
|
|
// POST
|
|
// https://api.northpass.com/v2/bulk/people/membership
|
|
{"payload":{"person_ids":["#{_('data.northpass_connector_2339630_1687360845.c9d81bc3.data.included.first.id')}"],"group_ids":#{_('data.js_eval.1ec2b92b.output.organized_group_list')}}}
|
|
|
|
// Anthology Sandbox API: BwDUDT3mM6xzubFOgrPZNfL53
|