From cb4bd27375bc6dfa45ff8c6c483a448a6f2bceab Mon Sep 17 00:00:00 2001 From: eblondel Date: Wed, 29 Jun 2022 00:54:23 +0200 Subject: [PATCH] fix #23 --- R/GNOpenAPIManager.R | 30 ++++++++++++++++++++++++++++++ man/GNOpenAPIManager.Rd | 27 ++++++++++++++++++++++++++- 2 files changed, 56 insertions(+), 1 deletion(-) diff --git a/R/GNOpenAPIManager.R b/R/GNOpenAPIManager.R index 6f3c341..1e42d1c 100644 --- a/R/GNOpenAPIManager.R +++ b/R/GNOpenAPIManager.R @@ -460,6 +460,36 @@ GNOpenAPIManager <- R6Class("GNOpenAPIManager", self$ERROR(content(req)) } return(out) + }, + + #'@description Publishes thumbnail based on URL + #'@param id metadata identifier + #'@param url thumbnail URL + #'@param desc thumbnail description + #'@return \code{TRUE} if published, \code{FALSE} otherwise + publishThumbnail = function(id, url, desc = ""){ + out <- FALSE + self$INFO(sprintf("Publish thumbnail '%s' to record '%s'...", url, id)) + path = sprintf("/api/records/%s/processes/thumbnail-add?thumbnail_url=%s&thumbnail_desc=%s&process=thumbnail-add&id=%s", + id, url, desc, id) + req <- GNUtils$POST( + url = self$getUrl(), + path = path, + token = private$getToken(), cookies = private$cookies, + user = private$user, + pwd = private$getPwd(), + content = NULL, contentType = "application/json", + verbose = self$verbose.debug + ) + if(status_code(req) == 204){ + self$INFO("Successfully published thumbnail!") + response <- content(req) + out <- response + }else{ + self$ERROR(sprintf("Error while publishing thumbnail - %s", message_for_status(status_code(req)))) + self$ERROR(content(req)) + } + return(out) } ) diff --git a/man/GNOpenAPIManager.Rd b/man/GNOpenAPIManager.Rd index fea53e4..cd94fdc 100644 --- a/man/GNOpenAPIManager.Rd +++ b/man/GNOpenAPIManager.Rd @@ -45,6 +45,7 @@ Emmanuel Blondel \item \href{#method-GNOpenAPIManager-updateMetadata}{\code{GNOpenAPIManager$updateMetadata()}} \item \href{#method-GNOpenAPIManager-deleteMetadata}{\code{GNOpenAPIManager$deleteMetadata()}} \item \href{#method-GNOpenAPIManager-uploadAttachment}{\code{GNOpenAPIManager$uploadAttachment()}} +\item \href{#method-GNOpenAPIManager-publishThumbnail}{\code{GNOpenAPIManager$publishThumbnail()}} \item \href{#method-GNOpenAPIManager-clone}{\code{GNOpenAPIManager$clone()}} } } @@ -432,7 +433,31 @@ Uploads attachment \if{html}{\out{}} } \subsection{Returns}{ -the URL of the uploaded attachment, \code{NULL} otherwise +a named list of the uploaded attachment, including the url, size, id and type, \code{NULL} otherwise +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-GNOpenAPIManager-publishThumbnail}{}}} +\subsection{Method \code{publishThumbnail()}}{ +Publishes thumbnail based on URL +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{GNOpenAPIManager$publishThumbnail(id, url, desc = "")}\if{html}{\out{
}} +} + +\subsection{Arguments}{ +\if{html}{\out{
}} +\describe{ +\item{\code{id}}{metadata identifier} + +\item{\code{url}}{thumbnail URL} + +\item{\code{desc}}{thumbnail description} +} +\if{html}{\out{
}} +} +\subsection{Returns}{ +response if ok, \code{NULL} otherwise } } \if{html}{\out{
}}