Skip to content

Commit

Permalink
Merge 1b01e1d into b41a4e8
Browse files Browse the repository at this point in the history
  • Loading branch information
kazuya030 committed Jan 2, 2016
2 parents b41a4e8 + 1b01e1d commit 11b889b
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 15 deletions.
4 changes: 1 addition & 3 deletions R/message.R
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ message <- function(id = ? is_string,
#' @export
#' @param search query to use, same format as gmail search box.
#' @param num_results the number of results to return.
#' @param page_token retrieve a specific page of results
#' @param label_ids restrict search to given labels
#' @param include_spam_trash boolean whether to include the spam and trash folders in the search
#' @inheritParams thread
Expand All @@ -38,10 +37,9 @@ messages <- function(search = NULL ? nullable(is_string)(search),
num_results = NULL ? nullable(is_number)(num_results),
label_ids = NULL ? nullable(is_strings)(label_ids),
include_spam_trash = NULL ? nullable(is_boolean)(include_spam_trash),
page_token = NULL ? nullable(is_string)(page_token),
user_id = "me" ? is_string) {

page_and_trim("messages", user_id, num_results, search, page_token, label_ids, include_spam_trash)
page_and_trim("messages", user_id, num_results, search, label_ids, include_spam_trash)
}

#' Send a single message to the trash
Expand Down
4 changes: 2 additions & 2 deletions R/thread.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
#'
#' first_10_threads = threads(10)
#' }
threads <- function(search = NULL, num_results = NULL, page_token = NULL, label_ids = NULL, include_spam_trash = NULL, user_id = "me"){
page_and_trim("threads", user_id, num_results, search, page_token, label_ids, include_spam_trash)
threads <- function(search = NULL, num_results = NULL, label_ids = NULL, include_spam_trash = NULL, user_id = "me"){
page_and_trim("threads", user_id, num_results, search, label_ids, include_spam_trash)
}

#' Get a single thread
Expand Down
7 changes: 4 additions & 3 deletions R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@ dots <- function (...) { eval(substitute(alist(...))) }
page_and_trim <- function(type, user_id, num_results, ...){

num_results <- num_results %||% 100
itr <- function(...){
itr <- function(..., page_token = NULL){
req <- GET(gmail_path(user_id, type),
query = not_null(rename(...)), config(token = get_token()))
query = not_null(rename(..., page_token = page_token)), config(token=get_token()))
stop_for_status(req)
content(req, "parsed")
}
Expand Down Expand Up @@ -78,7 +78,8 @@ page_and_trim <- function(type, user_id, num_results, ...){
res <- itr(...)
all_results <- list(res)
while(sum(counts(all_results)) < num_results && !is.null(res[["nextPageToken"]])){
res <- itr(...)
pageToken = res[["nextPageToken"]]
res <- itr(page_token = pageToken, ...)
all_results[[length(all_results) + 1]] <- res
}
structure(trim(all_results, num_results), class=paste0("gmail_", type))
Expand Down
4 changes: 1 addition & 3 deletions man/messages.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 2 additions & 4 deletions man/threads.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 11b889b

Please sign in to comment.