Build a refile plan that adds items to a collection
ztRefile.RdFetches each item's current memberships at plan time and produces patch
rows whose collections payload is the union with addTo — the Zotero
API replaces the whole membership list, so the merge is mandatory.
Arguments
- config
A
zotConfig()object.- itemKeys
Character vector of item keys.
- library
"user"or a group id.- addTo
Collection key to add.
Details
Planning performs one current API read per key. It does not write, and it omits missing items and items already in the destination collection. Memberships can change after planning; rebuild or review the plan before execution when concurrent changes are possible.
Examples
Memberships <- list(K1 = list("OLD"), K2 = list("TARGET"))
Performer <- function(config, method, path, query, body, version) {
Key <- sub(".*/items/", "", path)
list(
status = 200L, headers = list(),
body = list(version = 1L, data = list(collections = Memberships[[Key]]))
)
}
Config <- structure(
list(userID = "42", key = "example", apiBase = "https://example.invalid",
performer = Performer),
class = "zotConfig"
)
ztRefile(Config, itemKeys = c("K1", "K2"), library = "user",
addTo = "TARGET")
#> action library itemKey payload
#> <char> <char> <char> <list>
#> 1: patch user K1 <list[1]>