Skip to content

Commit

Permalink
add custom prefer: header for all teams calls
Browse files Browse the repository at this point in the history
  • Loading branch information
hongooi73 committed Feb 22, 2024
1 parent b616172 commit e9a247d
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 8 deletions.
2 changes: 1 addition & 1 deletion R/ms_channel.R
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@
#' }
#' @format An R6 object of class `ms_channel`, inheriting from `ms_object`.
#' @export
ms_channel <- R6::R6Class("ms_channel", inherit=ms_object,
ms_channel <- R6::R6Class("ms_channel", inherit=ms_teams_object,

public=list(

Expand Down
2 changes: 1 addition & 1 deletion R/ms_chat.R
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
#' }
#' @format An R6 object of class `ms_chat`, inheriting from `ms_object`.
#' @export
ms_chat <- R6::R6Class("ms_chat", inherit=ms_object,
ms_chat <- R6::R6Class("ms_chat", inherit=ms_teams_object,

public=list(

Expand Down
2 changes: 1 addition & 1 deletion R/ms_chat_message.R
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
#' }
#' @format An R6 object of class `ms_chat_message`, inheriting from `ms_object`.
#' @export
ms_chat_message <- R6::R6Class("ms_chat_message", inherit=ms_object,
ms_chat_message <- R6::R6Class("ms_chat_message", inherit=ms_teams_object,

public=list(

Expand Down
6 changes: 2 additions & 4 deletions R/ms_team.R
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
#' }
#' @format An R6 object of class `ms_team`, inheriting from `ms_object`.
#' @export
ms_team <- R6::R6Class("ms_team", inherit=ms_object,
ms_team <- R6::R6Class("ms_team", inherit=ms_teams_object,

public=list(

Expand Down Expand Up @@ -89,9 +89,7 @@ public=list(
file.path("channels", channel_id)
else stop("Do not supply both the channel name and ID", call.=FALSE)

# 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)
ms_channel$new(self$token, self$tenant, self$do_operation(op), team_id=self$properties$id)
},

create_channel=function(channel_name, description="", membership=c("standard", "private", "shared"))
Expand Down
2 changes: 1 addition & 1 deletion R/ms_team_member.R
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
#' [Microsoft Teams API reference](https://learn.microsoft.com/en-us/graph/api/resources/teams-api-overview?view=graph-rest-1.0)
#' @format An R6 object of class `ms_team_member`, inheriting from `ms_object`.
#' @export
ms_team_member <- R6::R6Class("ms_team_member", inherit=ms_object,
ms_team_member <- R6::R6Class("ms_team_member", inherit=ms_teams_object,

public=list(

Expand Down
11 changes: 11 additions & 0 deletions R/ms_teams_object.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Prefer header needed to work with shared channels
ms_teams_object <- R6::R6Class("ms_teams_object", inherit=ms_object,

public=list(

do_operation=function(op="", ...)
{
outlook_headers <- httr::add_headers(Prefer="include-unknown-enum-members")
super$do_operation(op, ..., outlook_headers)
}
))

0 comments on commit e9a247d

Please sign in to comment.