/**
 * -------------------------------------------------------------------------------------------
 * Copyright (c) Microsoft Corporation.  All Rights Reserved.  Licensed under the MIT License.
 * See License in the project root for license information.
 * -------------------------------------------------------------------------------------------
 */ import { IGraph , prepScopes } from '@microsoft/mgt-element' ; import { OutlookTask , OutlookTaskFolder , OutlookTaskGroup } from '@microsoft/microsoft-graph-types-beta' ; param { * } newTask returns { Promise < OutlookTask > } memberof export async function addTodoTask ( graph , newTask ) { const { parentFolderId = null } = newTask ; if ( parentFolderId ) { return await graph . api ( `/me/outlook/taskFolders/${ parentFolderId }/tasks` ) . header ( 'Cache-Control' , 'no-store' ) . middlewareOptions ( prepScopes ( 'Tasks.ReadWrite' ) ) . post ( newTask ) ; } else { return await graph . api ( '/me/outlook/tasks' ) . header ( 'Cache-Control' , 'no-store' ) . middlewareOptions ( prepScopes ( 'Tasks.ReadWrite' ) ) . post ( newTask ) ; } } returns { Promise < OutlookTaskGroup [ ] > } memberof export async function getAllMyTodoGroups ( graph ) { const groups = await graph . api ( '/me/outlook/taskGroups' ) . header ( 'Cache-Control' , 'no-store' ) . middlewareOptions ( prepScopes ( 'Tasks.Read' ) ) . get ( ) ; return groups && groups . value ; } param { string } folderId returns { Promise < OutlookTask [ ] > } memberof export async function getAllTodoTasksForFolder ( graph , folderId ) { const tasks = await graph . api ( `/me/outlook/taskFolders/${ folderId }/tasks` ) . header ( 'Cache-Control' , 'no-store' ) . middlewareOptions ( prepScopes ( 'Tasks.Read' ) ) . get ( ) ; return tasks && tasks . value ; } param { string } groupId returns { Promise < OutlookTaskFolder [ ] > } memberof export async function getFoldersForTodoGroup ( graph , groupId ) { const folders = await graph . api ( `/me/outlook/taskGroups/${ groupId }/taskFolders` ) . header ( 'Cache-Control' , 'no-store' ) . middlewareOptions ( prepScopes ( 'Tasks.Read' ) ) . get ( ) ; return folders && folders . value ; } param { string } groupId returns { Promise < OutlookTaskGroup > } memberof export async function getSingleTodoGroup ( graph , groupId ) { const group = await graph . api ( `/me/outlook/taskGroups/${ groupId }` ) . header ( 'Cache-Control' , 'no-store' ) . middlewareOptions ( prepScopes ( 'Tasks.Read' ) ) . get ( ) ; return group ; } param { string } taskId param { string } eTag returns { Promise < any > } memberof export async function removeTodoTask ( graph , taskId , eTag ) { return await graph . api ( `/me/outlook/tasks/${ taskId }` ) . header ( 'Cache-Control' , 'no-store' ) . header ( 'If-Match' , eTag ) . middlewareOptions ( prepScopes ( 'Tasks.ReadWrite' ) ) . delete ( ) ; } param { string } taskId param { string } eTag returns { Promise < OutlookTask > } memberof export async function setTodoTaskComplete ( graph , taskId , eTag ) { return await setTodoTaskDetails ( graph , taskId , { isReminderOn : false , status : 'completed' } , eTag ) ; } param { string } taskId param { string } eTag returns { Promise < OutlookTask > } memberof export async function setTodoTaskIncomplete ( graph , taskId , eTag ) { return await setTodoTaskDetails ( graph , taskId , { isReminderOn : true , status : 'notStarted' } , eTag ) ; } param { string } taskId param { * } task param { string } eTag returns { Promise < OutlookTask > } memberof export async function setTodoTaskDetails ( graph , taskId , task , eTag ) { return await graph . api ( `/me/outlook/tasks/${ taskId }` ) . header ( 'Cache-Control' , 'no-store' ) . header ( 'If-Match' , eTag ) . middlewareOptions ( prepScopes ( 'Tasks.ReadWrite' ) ) . patch ( task ) ; }