From b616172b637f391b2655a90dff26a79f01f1292c Mon Sep 17 00:00:00 2001 From: Hong Ooi Date: Thu, 15 Feb 2024 23:47:25 +1100 Subject: [PATCH] shared channel support --- NEWS.md | 4 ++++ R/ms_team.R | 9 ++++++--- man/ms_team.Rd | 2 +- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/NEWS.md b/NEWS.md index 1c18522..584e408 100644 --- a/NEWS.md +++ b/NEWS.md @@ -5,6 +5,10 @@ - In the `ms_drive_item$load_dataframe()` method, pass the `...` argument to `read_delim`. - Add the ability to load Excel files (with extension .xls or .xlsx) to the `ms_drive_item$load_dataframe()` method. This requires the readxl package to be installed. +## Teams + +- Add the ability to create shared channels (#174). + ## Planner - Fix a bug in the `ms_plan$get_details()` method. diff --git a/R/ms_team.R b/R/ms_team.R index d48fb60..48b9dd3 100644 --- a/R/ms_team.R +++ b/R/ms_team.R @@ -16,7 +16,7 @@ #' - `sync_fields()`: Synchronise the R object with the team metadata in Microsoft Graph. #' - `list_channels(filter=NULL, n=Inf)`: List the channels for this team. #' - `get_channel(channel_name, channel_id)`: Retrieve a channel. If the name and ID are not specified, returns the primary channel. -#' - `create_channel(channel_name, description, membership)`: Create a new channel. Optionally, you can specify a short text description of the channel, and the type of membership: either standard or private (invitation-only). +#' - `create_channel(channel_name, description, membership)`: Create a new channel. Optionally, you can specify a short text description of the channel, and the type of membership: either standard, shared or private (invitation-only). #' - `delete_channel(channel_name, channel_id, confirm=TRUE)`: Delete a channel; by default, ask for confirmation first. You cannot delete the primary channel of a team. Note that Teams keeps track of all channels ever created, even if you delete them (you can see the deleted channels by going to the "Manage team" pane for a team, then the "Channels" tab, and expanding the "Deleted" entry); therefore, try not to create and delete channels unnecessarily. #' - `list_drives(filter=NULL, n=Inf)`: List the drives (shared document libraries) associated with this team. #' - `get_drive(drive_name, drive_id)`: Retrieve a shared document library for this team. If the name and ID are not specified, this returns the default document library. @@ -88,10 +88,13 @@ public=list( else if(is.null(channel_name) && !is.null(channel_id)) file.path("channels", channel_id) else stop("Do not supply both the channel name and ID", call.=FALSE) - ms_channel$new(self$token, self$tenant, self$do_operation(op), team_id=self$properties$id) + + # Prefer header needed to get shared channels + obj <- self$do_operation(op, httr::add_headers(Prefer="include-unknown-enum-members")) + ms_channel$new(self$token, self$tenant, obj, team_id=self$properties$id) }, - create_channel=function(channel_name, description="", membership=c("standard", "private")) + create_channel=function(channel_name, description="", membership=c("standard", "private", "shared")) { membership <- match.arg(membership) body <- list( diff --git a/man/ms_team.Rd b/man/ms_team.Rd index 26c1bf2..44a9a01 100644 --- a/man/ms_team.Rd +++ b/man/ms_team.Rd @@ -30,7 +30,7 @@ Class representing a team in Microsoft Teams. \item \code{sync_fields()}: Synchronise the R object with the team metadata in Microsoft Graph. \item \code{list_channels(filter=NULL, n=Inf)}: List the channels for this team. \item \code{get_channel(channel_name, channel_id)}: Retrieve a channel. If the name and ID are not specified, returns the primary channel. -\item \code{create_channel(channel_name, description, membership)}: Create a new channel. Optionally, you can specify a short text description of the channel, and the type of membership: either standard or private (invitation-only). +\item \code{create_channel(channel_name, description, membership)}: Create a new channel. Optionally, you can specify a short text description of the channel, and the type of membership: either standard, shared or private (invitation-only). \item \code{delete_channel(channel_name, channel_id, confirm=TRUE)}: Delete a channel; by default, ask for confirmation first. You cannot delete the primary channel of a team. Note that Teams keeps track of all channels ever created, even if you delete them (you can see the deleted channels by going to the "Manage team" pane for a team, then the "Channels" tab, and expanding the "Deleted" entry); therefore, try not to create and delete channels unnecessarily. \item \code{list_drives(filter=NULL, n=Inf)}: List the drives (shared document libraries) associated with this team. \item \code{get_drive(drive_name, drive_id)}: Retrieve a shared document library for this team. If the name and ID are not specified, this returns the default document library.