Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Return file version #181

Merged
merged 4 commits into from
Oct 14, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -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")),
Expand All @@ -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")
ijlyttle marked this conversation as resolved.
Show resolved Hide resolved
)
URL: https://github.com/r-box/boxr/
BugReports: https://github.com/r-box/boxr/issues
Expand Down
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions R/boxr_misc.R
Original file line number Diff line number Diff line change
Expand Up @@ -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].
#'
Expand All @@ -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
Expand Down
2 changes: 2 additions & 0 deletions R/boxr_s3_classes.R
Original file line number Diff line number Diff line change
Expand Up @@ -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,
ijlyttle marked this conversation as resolved.
Show resolved Hide resolved
version_no = as.numeric(x$etag) + 1,
version_id = x$file_version$id %|0|% NA_character_,
stringsAsFactors = FALSE
)
}
Expand Down
4 changes: 2 additions & 2 deletions man/box_ls.Rd

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

12 changes: 11 additions & 1 deletion tests/testthat/test_12_ls.R
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
)

})