{ "kind": "open-flow-workflow", "version": 1, "name": "Create and Update an Iterable User", "content": { "modelVersion": 14, "document": { "bindings": {}, "graph": { "nodes": { "n_7154675f17c485ca": { "name": "Enter user details", "kind": "start", "inputDefs": [ { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "region" }, { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "email" }, { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "name" } ] }, "n_ad3d08ca4a1609f3": { "inputs": { "region": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_7154675f17c485ca", "output": "region" } ] }, "email": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_7154675f17c485ca", "output": "email" } ] }, "name": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_7154675f17c485ca", "output": "name" } ] } }, "name": "Prepare user requests", "kind": "task", "task": { "inputs": [ { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "region" }, { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "email" }, { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "name" } ], "outputs": [ { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "email" }, { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "name" }, { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "updateUrl" }, { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "getUrl" }, { "jsonSchema": { "type": "object", "additionalProperties": true }, "nullable": false, "handle": "first" }, { "jsonSchema": { "type": "object", "additionalProperties": true }, "nullable": false, "handle": "second" } ], "name": "Prepare user requests", "moduleId": "n_37cc00c22e0c518f", "capabilities": [ { "kind": "connector", "mode": "independent", "actions": [] } ] } }, "n_f0228252a49ca144": { "inputs": { "url": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_ad3d08ca4a1609f3", "output": "updateUrl" } ] }, "body": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_ad3d08ca4a1609f3", "output": "first" } ] }, "auth.token": { "kind": "unset" } }, "name": "Create or update user", "kind": "task", "task": { "inputs": [ { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "url" }, { "jsonSchema": {}, "nullable": true, "handle": "body" }, { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "auth.token" } ], "outputs": [ { "jsonSchema": {}, "nullable": true, "handle": "body" }, { "jsonSchema": { "type": "integer" }, "nullable": false, "handle": "statusCode" }, { "jsonSchema": { "type": "object", "additionalProperties": { "type": "string" } }, "nullable": false, "handle": "headers" } ], "name": "Create or update user", "executor": { "method": "POST", "query": { "mode": "fields", "names": [] }, "headers": { "mode": "fields", "names": [] }, "bodyFormat": "json", "authentication": { "type": "apiKey", "name": "Api-Key", "in": "header" }, "responseFormat": "json", "statusPolicy": "success", "kind": "http-request" } } }, "n_40a5e8bc9267d7cf": { "inputs": { "body": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_f0228252a49ca144", "output": "body" } ] } }, "name": "Confirm user write", "kind": "task", "task": { "inputs": [ { "jsonSchema": {}, "nullable": true, "handle": "body" } ], "outputs": [ { "jsonSchema": { "type": "boolean" }, "nullable": false, "handle": "ok" } ], "name": "Confirm user write", "moduleId": "n_395b7165732ae1f5", "capabilities": [ { "kind": "connector", "mode": "independent", "actions": [] } ] } }, "n_5bf0309073e2622c": { "inputs": { "url": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_ad3d08ca4a1609f3", "output": "updateUrl" } ] }, "body": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_ad3d08ca4a1609f3", "output": "second" } ] }, "auth.token": { "kind": "unset" } }, "name": "Update user name", "kind": "task", "task": { "inputs": [ { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "url" }, { "jsonSchema": {}, "nullable": true, "handle": "body" }, { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "auth.token" } ], "outputs": [ { "jsonSchema": {}, "nullable": true, "handle": "body" }, { "jsonSchema": { "type": "integer" }, "nullable": false, "handle": "statusCode" }, { "jsonSchema": { "type": "object", "additionalProperties": { "type": "string" } }, "nullable": false, "handle": "headers" } ], "name": "Update user name", "executor": { "method": "POST", "query": { "mode": "fields", "names": [] }, "headers": { "mode": "fields", "names": [] }, "bodyFormat": "json", "authentication": { "type": "apiKey", "name": "Api-Key", "in": "header" }, "responseFormat": "json", "statusPolicy": "success", "kind": "http-request" } } }, "n_8271a1e71f4a6460": { "inputs": { "body": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_5bf0309073e2622c", "output": "body" } ] } }, "name": "Confirm name write", "kind": "task", "task": { "inputs": [ { "jsonSchema": {}, "nullable": true, "handle": "body" } ], "outputs": [ { "jsonSchema": { "type": "boolean" }, "nullable": false, "handle": "ok" } ], "name": "Confirm name write", "moduleId": "n_0d9bbb41b223b9e4", "capabilities": [ { "kind": "connector", "mode": "independent", "actions": [] } ] } }, "n_e7e0ed0039e5c87e": { "inputs": { "url": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_ad3d08ca4a1609f3", "output": "getUrl" } ] }, "auth.token": { "kind": "unset" } }, "name": "Read user", "kind": "task", "task": { "inputs": [ { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "url" }, { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "auth.token" } ], "outputs": [ { "jsonSchema": {}, "nullable": true, "handle": "body" }, { "jsonSchema": { "type": "integer" }, "nullable": false, "handle": "statusCode" }, { "jsonSchema": { "type": "object", "additionalProperties": { "type": "string" } }, "nullable": false, "handle": "headers" } ], "name": "Read user", "executor": { "method": "GET", "query": { "mode": "fields", "names": [] }, "headers": { "mode": "fields", "names": [] }, "bodyFormat": "none", "authentication": { "type": "apiKey", "name": "Api-Key", "in": "header" }, "responseFormat": "json", "statusPolicy": "success", "kind": "http-request" } } }, "n_e735d6558ad85832": { "inputs": { "body": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_e7e0ed0039e5c87e", "output": "body" } ] }, "email": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_ad3d08ca4a1609f3", "output": "email" } ] }, "name": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_ad3d08ca4a1609f3", "output": "name" } ] } }, "name": "Verify user", "kind": "task", "task": { "inputs": [ { "jsonSchema": {}, "nullable": true, "handle": "body" }, { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "email" }, { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "name" } ], "outputs": [ { "jsonSchema": { "type": "object", "additionalProperties": true }, "nullable": false, "handle": "user" } ], "name": "Verify user", "moduleId": "n_5ba616abc58daa0b", "capabilities": [ { "kind": "connector", "mode": "independent", "actions": [] } ] } }, "n_eb66aa6e71a49b53": { "name": "Iterable user", "kind": "outputs", "outputDefs": [ { "jsonSchema": { "type": "object", "additionalProperties": true }, "nullable": false, "handle": "user" } ], "outputMappings": { "user": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_e735d6558ad85832", "output": "user" } ] } } } }, "edges": [ { "source": "n_7154675f17c485ca", "target": "n_ad3d08ca4a1609f3" }, { "source": "n_ad3d08ca4a1609f3", "target": "n_f0228252a49ca144" }, { "source": "n_f0228252a49ca144", "target": "n_40a5e8bc9267d7cf" }, { "source": "n_40a5e8bc9267d7cf", "target": "n_5bf0309073e2622c" }, { "source": "n_5bf0309073e2622c", "target": "n_8271a1e71f4a6460" }, { "source": "n_8271a1e71f4a6460", "target": "n_e7e0ed0039e5c87e" }, { "source": "n_e7e0ed0039e5c87e", "target": "n_e735d6558ad85832" }, { "source": "n_e735d6558ad85832", "target": "n_eb66aa6e71a49b53" } ] } }, "modules": { "n_37cc00c22e0c518f": { "name": "Prepare user requests", "imports": [], "source": "export default function setup({region,email,name}){if(!['us','eu'].includes(region))throw Error('Choose us or eu');if(typeof email!=='string'||!/^\\S+@\\S+\\.\\S+$/.test(email.trim()))throw Error('Enter a valid email');if(typeof name!=='string'||!name.trim())throw Error('Enter a name');email=email.trim();name=name.trim();const base=region==='us'?'https://api.iterable.com':'https://api.eu.iterable.com';return{email,name,updateUrl:base+'/api/users/update',getUrl:base+'/api/users/getByEmail?'+new URLSearchParams({email}),first:{email},second:{email,dataFields:{Name:name}}};}\n" }, "n_395b7165732ae1f5": { "name": "Confirm user write", "imports": [], "source": "export default function check({body}){if(!body||body.code!=='Success')throw Error('Iterable did not confirm the user update');return{ok:true};}\n" }, "n_0d9bbb41b223b9e4": { "name": "Confirm name write", "imports": [], "source": "export default function check({body}){if(!body||body.code!=='Success')throw Error('Iterable did not confirm the user update');return{ok:true};}\n" }, "n_5ba616abc58daa0b": { "name": "Verify user", "imports": [], "source": "export default function verify({body,email,name}){const user=body?.user;if(!user||typeof user!=='object'||user.email!==email||user.dataFields?.Name!==name)throw Error('Iterable did not return the expected user and Name');return{user};}\n" } } }, "presentation": { "designer": { "version": 1, "flow": { "direction": "vertical" } } } }