/**
 * -------------------------------------------------------------------------------------------
 * 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 { PlannerBucket , PlannerPlan , PlannerTask } from '@microsoft/microsoft-graph-types' ; param { ( PlannerTask ) } newTask returns { Promise < any > } memberof export function addPlannerTask ( graph , newTask ) { return graph . api ( '/planner/tasks' ) . header ( 'Cache-Control' , 'no-store' ) . middlewareOptions ( prepScopes ( 'Group.ReadWrite.All' ) ) . post ( newTask ) ; } param { string } taskId param { * } people param { string } eTag returns { Promise < any > } memberof export function assignPeopleToPlannerTask ( graph , taskId , people , eTag ) { return setPlannerTaskDetails ( graph , taskId , { assignments : people } , eTag ) ; } param { string } taskId param { string } eTag returns { Promise < any > } memberof export function removePlannerTask ( graph , taskId , eTag ) { return graph . api ( `/planner/tasks/${ taskId }` ) . header ( 'Cache-Control' , 'no-store' ) . header ( 'If-Match' , eTag ) . middlewareOptions ( prepScopes ( 'Group.ReadWrite.All' ) ) . delete ( ) ; } param { string } taskId param { string } eTag returns { Promise < any > } memberof export function setPlannerTaskComplete ( graph , taskId , eTag ) { return setPlannerTaskDetails ( graph , taskId , { percentComplete : 100 } , eTag ) ; } param { string } taskId param { string } eTag returns { Promise < any > } memberof export function setPlannerTaskIncomplete ( graph , taskId , eTag ) { return setPlannerTaskDetails ( graph , taskId , { percentComplete : 0 } , eTag ) ; } param { string } taskId param { ( PlannerTask ) } details param { string } eTag returns { Promise < any > } memberof export async function setPlannerTaskDetails ( graph , taskId , details , eTag ) { return await graph . api ( `/planner/tasks/${ taskId }` ) . header ( 'Cache-Control' , 'no-store' ) . middlewareOptions ( prepScopes ( 'Group.ReadWrite.All' ) ) . header ( 'If-Match' , eTag ) . patch ( JSON . stringify ( details ) ) ; } param { string } groupId returns { ( Promise < PlannerPlan [ ] > ) } memberof export async function getPlansForGroup ( graph , groupId ) { const scopes = 'Group.Read.All' ; const uri = `/groups/${ groupId }/planner/plans` ; const plans = await graph . api ( uri ) . header ( 'Cache-Control' , 'no-store' ) . middlewareOptions ( prepScopes ( scopes ) ) . get ( ) ; return plans ? plans . value : null ; } param { string } planId returns { ( Promise < PlannerPlan > ) } memberof export async function getSinglePlannerPlan ( graph , planId ) { const plan = await graph . api ( `/planner/plans/${ planId }` ) . header ( 'Cache-Control' , 'no-store' ) . middlewareOptions ( prepScopes ( 'Group.Read.All' ) ) . get ( ) ; return plan ; } param { string } planId returns { ( Promise < PlannerBucket [ ] > ) } memberof export async function getBucketsForPlannerPlan ( graph , planId ) { const buckets = await graph . api ( `/planner/plans/${ planId }/buckets` ) . header ( 'Cache-Control' , 'no-store' ) . middlewareOptions ( prepScopes ( 'Group.Read.All' ) ) . get ( ) ; return buckets && buckets . value ; } returns { ( Promise < PlannerPlan [ ] > ) } memberof export async function getAllMyPlannerPlans ( graph ) { const plans = await graph . api ( '/me/planner/plans' ) . header ( 'Cache-Control' , 'no-store' ) . middlewareOptions ( prepScopes ( 'Group.Read.All' ) ) . get ( ) ; return plans && plans . value ; } param { string } bucketId returns { ( Promise < PlannerTask [ ] [ ] > ) } memberof export async function getTasksForPlannerBucket ( graph , bucketId ) { const tasks = await graph . api ( `/planner/buckets/${ bucketId }/tasks` ) . header ( 'Cache-Control' , 'no-store' ) . middlewareOptions ( prepScopes ( 'Group.Read.All' ) ) . get ( ) ; return tasks && tasks . value ; }