From 2c9491a5da54d4b2e4edf889d2cc3b2be1c10526 Mon Sep 17 00:00:00 2001 From: eblondel Date: Wed, 22 Mar 2023 21:45:24 +0100 Subject: [PATCH] fix #119 (ref made to #118) --- NEWS.md | 2 ++ R/ZenodoManager.R | 4 +++- man/ZenodoManager.Rd | 3 +++ 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/NEWS.md b/NEWS.md index 4d067bb..9b6d947 100644 --- a/NEWS.md +++ b/NEWS.md @@ -7,6 +7,8 @@ * [#95](https://github.com/eblondel/zen4R/95) Support progress when uploading files * [#114](https://github.com/eblondel/zen4R/issues/114) Avoid re-downloading existing files * [#117](https://github.com/eblondel/zen4R/issues/117) Support single (organisation) name argument in `addContributor` +* [#119](https://github.com/eblondel/zen4R/issues/119) Support sandbox argument for ZenodoManager for easy use + ## [zen4R 0.8](https://cran.r-project.org/package=zen4R) | [![CRAN_Status_Badge](https://img.shields.io/badge/CRAN-published-blue.svg)](https://cran.r-project.org/package=zen4R) diff --git a/R/ZenodoManager.R b/R/ZenodoManager.R index d0d79d0..26f0349 100644 --- a/R/ZenodoManager.R +++ b/R/ZenodoManager.R @@ -78,14 +78,16 @@ ZenodoManager <- R6Class("ZenodoManager", #' @param url Zenodo API URL. By default, the url is set to "https://zenodo.org/api". For tests, #' the Zenodo sandbox API URL can be used: https://sandbox.zenodo.org/api #' @param token the user token. By default an attempt will be made to retrieve token using \link{zenodo_pat} + #' @param sandbox Indicates if the Zenodo sandbox platform should be used. Default is \code{FALSE} #' @param logger logger type. The logger can be either NULL, "INFO" (with minimum logs), or "DEBUG" #' (for complete curl http calls logs) #' @param keyring_backend The \pkg{keyring} backend used to store user token. The \code{keyring_backend} #' can be set to use a different backend for storing the Zenodo token with \pkg{keyring} (Default value is 'env'). - initialize = function(url = "https://zenodo.org/api", token = zenodo_pat(), logger = NULL, + initialize = function(url = "https://zenodo.org/api", token = zenodo_pat(), sandbox = FALSE, logger = NULL, keyring_backend = 'env'){ super$initialize(logger = logger) private$url = url + if(sandbox) url = "https://sandbox.zenodo.org/api" if(url == "https://sandbox.zenodo.org/api") private$sandbox = TRUE if(!is.null(token)) if(nzchar(token)){ if(!keyring_backend %in% names(keyring:::known_backends)){ diff --git a/man/ZenodoManager.Rd b/man/ZenodoManager.Rd index 6b6ac6b..a19e3b8 100644 --- a/man/ZenodoManager.Rd +++ b/man/ZenodoManager.Rd @@ -146,6 +146,7 @@ initializes the Zenodo Manager \if{html}{\out{
}}\preformatted{ZenodoManager$new( url = "https://zenodo.org/api", token = zenodo_pat(), + sandbox = FALSE, logger = NULL, keyring_backend = "env" )}\if{html}{\out{
}} @@ -159,6 +160,8 @@ the Zenodo sandbox API URL can be used: https://sandbox.zenodo.org/api} \item{\code{token}}{the user token. By default an attempt will be made to retrieve token using \link{zenodo_pat}} +\item{\code{sandbox}}{Indicates if the Zenodo sandbox platform should be used. Default is \code{FALSE}} + \item{\code{logger}}{logger type. The logger can be either NULL, "INFO" (with minimum logs), or "DEBUG" (for complete curl http calls logs)}