Figured out Workato recipe with Python node to reduce the scope of the original anthology flow.

This commit is contained in:
Norm Rasmussen
2023-11-05 20:52:25 -05:00
parent 2912377102
commit 1342c10ac8
29 changed files with 2040 additions and 595 deletions

View File

@ -12,12 +12,12 @@ const fetch = require("node-fetch")
exports.main = async ({ user_email }) => {
let all_domains = [
'@newanthology.com',
'@knowledgestate.edu',
'@creighton.edu',
'@tc.columbia.edu',
'@mstc.edu',
'@gvltec.edu',
'newanthology.com',
'knowledgestate.edu',
'creighton.edu',
'tc.columbia.edu',
'mstc.edu',
'gvltec.edu',
]
let user_domain = user_email.slice(user_email.indexOf('@'));

View File

@ -0,0 +1,41 @@
// 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