auths
objectreturn
or this.key = 'value'
, pass input data to your code viaparams
, and maintain state across executions with$checkpoint.async
(event, steps, auths) => {
}
import fetch from 'node-fetch';
// set date filter to now - 7
let lastWeek = new Date();
lastWeek.setDate(lastWeek.getDate() - 7);
/*
Bug found 2/9/2012, just the Z coming back broke shit, so remove it.
*/
let lastWeekStr = `${lastWeek.getFullYear()}-${lastWeek.getMonth()+1}-${lastWeek.getDate()}`;
console.log('lastWeek',lastWeekStr);
const rootUrl = `https://graph.microsoft.com/v1.0/me/todo/lists/AQMkADAwATMzAGZmAS04MDU4LWQ4ZjctMDACLTAwCgAuAAAD2b-xt4VpMU28CRdh70oBigEAzwpFFkTJnUqSIr7l4olnFgACofznJAAAAA==/tasks?$filter=status eq 'completed' and completedDateTime/dateTime ge '${lastWeekStr}'`;
async function getCompletedToDos(todos = [], url = rootUrl) {
let result = await fetch(url, {
headers: {
'Authorization':`Bearer ${auths.microsoft_graph_api.oauth_access_token}`
}
});
let data = await result.json();
console.log(data);
data.value.forEach(d => {
todos.push({
title:d.title,
completed:d.completedDateTime.dateTime
})
});
if(data['@odata.nextLink']) {
return await getCompletedToDos(todos, data['@odata.nextLink']);
} else return todos;
}
return await getCompletedToDos();
auths
objectreturn
or this.key = 'value'
, pass input data to your code viaparams
, and maintain state across executions with$checkpoint.async
(event, steps) => {
}
if(steps.getCompletedToDos.$return_value.length === 0) $end('No completed tasks');
auths
objectreturn
or this.key = 'value'
, pass input data to your code viaparams
, and maintain state across executions with$checkpoint.async
(event, steps) => {
}
let html = `
<h2>Look What You Did!</h2>
<p>
Life is hard, but somehow this week you managed to scratch off a few items from your task list! You should
feel great about finishing the following:
</p>
<ul>
`;
steps.getCompletedToDos.$return_value.forEach(todo => {
html += `
<li>${todo.title}</li>
`
});
html += '</ul>';
return html;
async
params => {
}
const options = {
subject: params.subject,
text: params.text,
}
if (params.html) {
options.html = params.html
}
if (params.include_collaborators) {
options.include_collaborators = params.include_collaborators
}
$send.email(options)