Skip to content

Commit

Permalink
#133 getDepositionById with accept invenioRdm json format
Browse files Browse the repository at this point in the history
  • Loading branch information
eblondel committed May 13, 2024
1 parent 5eec0d7 commit 13de804
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
3 changes: 1 addition & 2 deletions R/ZenodoManager.R
Original file line number Diff line number Diff line change
Expand Up @@ -1109,8 +1109,7 @@ ZenodoManager <- R6Class("ZenodoManager",
zenReq$execute()
out <- NULL
if(zenReq$getStatus() %in% c(200,201)){
resp = zenReq$getResponse()
out <- self$getDepositionById(resp$id)
out <- ZenodoRecord$new(obj = zenReq$getResponse())
infoMsg = "Successful record deposition"
cli::cli_alert_success(infoMsg)
self$INFO(infoMsg)
Expand Down
2 changes: 1 addition & 1 deletion R/ZenodoRecord.R
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ ZenodoRecord <- R6Class("ZenodoRecord",
self$created = obj$created
self$doi = obj$doi
self$doi_url = obj$doi_url
self$files = lapply(obj$files, function(file){
self$files = lapply(obj$files$entries, function(file){
list(
filename = if(!is.null(file$filename)) file$filename else file$key,
filesize = if(!is.null(file$filesize)) file$filesize else file$size,
Expand Down
9 changes: 6 additions & 3 deletions R/ZenodoRequest.R
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ ZenodoRequest <- R6Class("ZenodoRequest",
self$INFO(sprintf("Fetching %s", req))
headers <- c(
"User-Agent" = private$agent,
"Authorization" = paste("Bearer",private$token)
"Authorization" = paste("Bearer",private$token),
"Accept" = "application/vnd.inveniordm.v1+json"
)

responseContent <- NULL
Expand Down Expand Up @@ -104,8 +105,9 @@ ZenodoRequest <- R6Class("ZenodoRequest",
#headers
headers <- c(
"User-Agent" = private$agent,
"Authorization" = paste("Bearer",private$token),
"Content-Type" = contentType,
"Authorization" = paste("Bearer",private$token)
"Accept" = "application/vnd.inveniordm.v1+json"
)

#send request
Expand Down Expand Up @@ -141,8 +143,9 @@ ZenodoRequest <- R6Class("ZenodoRequest",
#headers
headers <- c(
"User-Agent" = private$agent,
"Authorization" = paste("Bearer",private$token),
"Content-Type" = if(regexpr("draft/files", req)>0) "application/octet-stream" else "application/json",
"Authorization" = paste("Bearer",private$token)
"Accept" = if(regexpr("draft/files", req)>0) NULL else "application/vnd.inveniordm.v1+json"
)

#send request
Expand Down

0 comments on commit 13de804

Please sign in to comment.