Skip to contents

Reads the group memberships of the configured user and the current version of every library. The personal library appears first as "user"; each group appears under its numeric identifier, the value accepted by the library argument of the other functions.

Usage

zotLibraries(config)

Arguments

config

A zotConfig() object.

Value

A data.table with library, type ("user" or "group"), name and version.

Details

One request lists the groups and one limit = 1 request per library reads its Last-Modified-Version header. The personal library has no name in the API; its name is NA.

Examples

Performer <- function(config, method, path, query, body, version) {
  if (grepl("/groups$", path)) {
    return(list(status = 200L, headers = list(`total-results` = "1"),
                body = list(list(id = 555L, data = list(name = "Team")))))
  }
  list(status = 200L, headers = list(`last-modified-version` = "12"),
       body = list())
}
Config <- structure(
  list(userID = "42", key = "example", apiBase = "https://example.invalid",
       performer = Performer),
  class = "zotConfig"
)
zotLibraries(Config)
#>    library   type   name version
#>     <char> <char> <char>  <char>
#> 1:    user   user   <NA>      12
#> 2:     555  group   Team      12