Skip to content

Commit

Permalink
Merge branch 'lawremi-send_draft'
Browse files Browse the repository at this point in the history
  • Loading branch information
jimhester committed Jan 29, 2016
2 parents cbffaea + 8ae332d commit 81950d5
Showing 1 changed file with 9 additions and 11 deletions.
20 changes: 9 additions & 11 deletions R/draft.R
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ draft <- function(id = ? is_string,
user_id = "me" ? is_string,
format = c("full", "minimal", "raw")) {
format <- match.arg(format)
gmailr_GET(c("drafts", id), user_id, query = list(format=format))
gmailr_GET(c("drafts", id), user_id, query = list(format=format), class = "gmail_draft")
}

#' Get a list of drafts
Expand Down Expand Up @@ -64,21 +64,19 @@ create_draft <- function(mail = ?~ as.character,
#' Send a draft
#'
#' Send a draft to the recipients in the To, CC, and Bcc headers.
#' @param id the draft id to send
#' @param upload_type type of upload request
#' @param draft the draft to send
#' @inheritParams message
#' @references \url{https://developers.google.com/gmail/api/v1/reference/users/drafts/send}
#' @export
#' @examples
#' \dontrun{
#' send_draft(12345)
#' draft <- create_draft(mime(From="you@@me.com", To="any@@one.com",
#' Subject="hello", "how are you doing?"))
#' send_draft(draft)
#' }
send_draft <- function(id = ? is_string,
upload_type = c("media", "multipart", "resumable"),
send_draft <- function(draft = ? has_class(draft, "gmail_draft"),
user_id = "me" ? is_string) {
upload_type <- match.arg(upload_type)
gmailr_POST("drafts", user_id, class = "gmail_draft",
query = rename(upload_type),
body = c("id" = id),
encode = "json")
gmailr_POST(c("drafts", "send"), user_id, class = "gmail_draft",
body = draft,
encode = "json")
}

0 comments on commit 81950d5

Please sign in to comment.