Skip to content

Commit

Permalink
ensure that one space in account gives same structure of result objec…
Browse files Browse the repository at this point in the history
…t as when two or more spaces are present
  • Loading branch information
rpodcast committed Oct 12, 2017
1 parent 44e5e5c commit 35ff528
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions R/spaces.R
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,18 @@ spaces_GET <- function(spaces_key = NULL, spaces_secret = NULL, ...) {
#' @rdname spaces
spaces <- function(spaces_key = NULL, spaces_secret = NULL, ...) {
res <- spaces_GET(spaces_key = spaces_key, spaces_secret = spaces_secret, ...)

# when only one space is present, res$Buckets only contains the Name and
# CreationDate. If more than one space is present, then each space will
# have a Bucket list object with the Name and CreationDate
if (identical(names(res$Buckets), c("Name", "CreationDate"))) {
res$Buckets <- list(
Bucket = list(
Name = res$Buckets$Name,
CreationDate = res$Buckets$CreationDate
)
)
}
sp <- lapply(res$Buckets, structure, class = "space")
setNames(sp, vapply(res$Buckets, function(x) x$Name, character(1)))
}
Expand Down

0 comments on commit 35ff528

Please sign in to comment.