Skip to content

Commit

Permalink
#133 deleteDOI
Browse files Browse the repository at this point in the history
  • Loading branch information
eblondel committed May 14, 2024
1 parent 87d4df0 commit ed4fbcb
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 0 deletions.
29 changes: 29 additions & 0 deletions R/ZenodoManager.R
Original file line number Diff line number Diff line change
Expand Up @@ -1174,6 +1174,35 @@ ZenodoManager <- R6Class("ZenodoManager",
return(out)
},

#'@description Reserves a DOI for a deposition (draft record)
#' @param record the record for which DOI has to be deleted, object of class \code{ZenodoRecord}
#'@return object of class \code{ZenodoRecord}
deleteDOI = function(record){
request <- sprintf("records/%s/draft/pids/doi", record$id)
zenReq <- ZenodoRequest$new(private$url, "DELETE", request, data = NULL,
token = self$getToken(),
logger = self$loggerType)
zenReq$execute()
out <- NULL
if(zenReq$getStatus() == 200){
out <- ZenodoRecord$new(obj = zenReq$getResponse())
infoMsg = sprintf("Successful deleted DOI for record %s", record$id)
cli::cli_alert_success(infoMsg)
self$INFO(infoMsg)
}else{
out <- zenReq$getResponse()
errMsg = sprintf("Error while deleting DOI for record %s: %s", record$id, out$message)
cli::cli_alert_danger(errMsg)
self$ERROR(errMsg)
for(error in out$errors){
errMsg = sprintf("Error: %s - %s", error$field, error$message)
cli::cli_alert_danger(errMsg)
self$ERROR(errMsg)
}
}
return(out)
},

#' @description Deposits a record version on Zenodo. For details about the behavior of this function,
#' see \href{https://developers.zenodo.org/#new-version}{https://developers.zenodo.org/#new-version}
#' @param record the record version to deposit, object of class \code{ZenodoRecord}
Expand Down
21 changes: 21 additions & 0 deletions man/ZenodoManager.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit ed4fbcb

Please sign in to comment.