Skip to content

Commit 35ff528

Browse files
committed
ensure that one space in account gives same structure of result object as when two or more spaces are present
1 parent 44e5e5c commit 35ff528

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

R/spaces.R

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,18 @@ spaces_GET <- function(spaces_key = NULL, spaces_secret = NULL, ...) {
9292
#' @rdname spaces
9393
spaces <- function(spaces_key = NULL, spaces_secret = NULL, ...) {
9494
res <- spaces_GET(spaces_key = spaces_key, spaces_secret = spaces_secret, ...)
95+
96+
# when only one space is present, res$Buckets only contains the Name and
97+
# CreationDate. If more than one space is present, then each space will
98+
# have a Bucket list object with the Name and CreationDate
99+
if (identical(names(res$Buckets), c("Name", "CreationDate"))) {
100+
res$Buckets <- list(
101+
Bucket = list(
102+
Name = res$Buckets$Name,
103+
CreationDate = res$Buckets$CreationDate
104+
)
105+
)
106+
}
95107
sp <- lapply(res$Buckets, structure, class = "space")
96108
setNames(sp, vapply(res$Buckets, function(x) x$Name, character(1)))
97109
}

0 commit comments

Comments
 (0)