diff --git a/DESCRIPTION b/DESCRIPTION index 173cdb28..e609bfe5 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: boxr Type: Package Title: Interface for the 'Box.com API' -Version: 0.3.5.9011 +Version: 0.3.5.9012 Authors@R: c( person("Brendan", "Rocks", email = "foss@brendanrocks.com", role = c("aut")), @@ -20,7 +20,8 @@ Authors@R: c( comment = c(ORCID = "0000-0002-6714-8611") ), person("Vincent", "Fulco", role = "ctb"), - person("Alec", "Wong", role = "ctb") + person("Alec", "Wong", role = "ctb"), + person("Alex", "Brodersen", role = "ctb") ) URL: https://github.com/r-box/boxr/ BugReports: https://github.com/r-box/boxr/issues diff --git a/NEWS.md b/NEWS.md index 6d0f4af3..6c701b6a 100644 --- a/NEWS.md +++ b/NEWS.md @@ -27,6 +27,8 @@ * uses `httr::RETRY()` for API requests to handle momentary issues with network connectivity. Thanks @jameslamb and @chircollab! +* `box_ls()` provides the current `version_id` by default. (#181, @alexbrodersen) + ## Bug Fixes * `box_auth_service()` more resilient to bad-request failures. (#166) diff --git a/R/boxr_misc.R b/R/boxr_misc.R index 5bcf9fd5..01f7a995 100644 --- a/R/boxr_misc.R +++ b/R/boxr_misc.R @@ -6,9 +6,9 @@ #' @param limit `integer`, maximum number of entries to retrieve per query-page. #' @param max `integer`, maximum number of entries to retrieve in total. #' @param fields `character`, fields to return; the default -#' value, `NULL`, will return all possible columns: `modified_at`, +#' value, `NULL`, will return all possible fields from API: `modified_at`, #' `content_modified_at`, `name`, `id`, `type`, `sha1` ,`size`, -#' `owned_by`, `path_collection`, `description`. +#' `owned_by`, `path_collection`, `description`, `file_version`. #' #' @return Object with S3 class [`boxr_object_list`][boxr_S3_classes]. #' @@ -33,7 +33,7 @@ box_ls <- function(dir_id = box_getwd(), limit = 100, max = Inf, fields = NULL) fields_all <- c("modified_at" ,"content_modified_at", "name", "id", "type", - "sha1" ,"size", "owned_by", "path_collection", "description") + "sha1" ,"size", "owned_by", "path_collection", "description", "file_version") if (is.null(fields)) { fields <- fields_all diff --git a/R/boxr_s3_classes.R b/R/boxr_s3_classes.R index 3894e02d..02ab8dfc 100644 --- a/R/boxr_s3_classes.R +++ b/R/boxr_s3_classes.R @@ -158,6 +158,8 @@ as.data.frame.boxr_object_list <- function(x, ...) { content_modified_at = box_datetime(x$content_modified_at) %|0|% as.POSIXct(NA), sha1 = x$sha1 %|0|% NA_character_, version = as.numeric(x$etag) + 1, + version_no = as.numeric(x$etag) + 1, + version_id = x$file_version$id %|0|% NA_character_, stringsAsFactors = FALSE ) } diff --git a/man/box_ls.Rd b/man/box_ls.Rd index 9b2ed116..57630d28 100644 --- a/man/box_ls.Rd +++ b/man/box_ls.Rd @@ -14,9 +14,9 @@ box_ls(dir_id = box_getwd(), limit = 100, max = Inf, fields = NULL) \item{max}{\code{integer}, maximum number of entries to retrieve in total.} \item{fields}{\code{character}, fields to return; the default -value, \code{NULL}, will return all possible columns: \code{modified_at}, +value, \code{NULL}, will return all possible fields from API: \code{modified_at}, \code{content_modified_at}, \code{name}, \code{id}, \code{type}, \code{sha1} ,\code{size}, -\code{owned_by}, \code{path_collection}, \code{description}.} +\code{owned_by}, \code{path_collection}, \code{description}, \code{file_version}.} } \value{ Object with S3 class \code{\link[=boxr_S3_classes]{boxr_object_list}}. diff --git a/tests/testthat/test_12_ls.R b/tests/testthat/test_12_ls.R index 507115a6..c8172b3e 100644 --- a/tests/testthat/test_12_ls.R +++ b/tests/testthat/test_12_ls.R @@ -62,9 +62,19 @@ test_that("file listing works", { files_box_page <- box_ls(id_ls, limit = 5) %>% get_filenames() - + # test expect_identical(files_box, files_local) expect_identical(files_box_page, files_local) + + # make sure we are getting all the names back from box_ls() + expect_named( + box_ls(id_ls) %>% as.data.frame(), + c( + "name", "type", "id", "size", "description", "owner", "path", + "modified_at", "content_modified_at", "sha1", + "version", "version_no", "version_id" + ) + ) })