@@ -52,9 +52,9 @@ download_cert_pdf <- function(report_link, cert_id){
5252 }
5353}
5454
55- # ' Retrieves the download link for a certificate file from either Zenodo or OSF .
55+ # ' Retrieves the download link for a certificate file from Zenodo, OSF, or ResearchEquals .
5656# '
57- # ' @param report_link URL of the report to access, either from Zenodo or OSF .
57+ # ' @param report_link URL of the report to access, either from Zenodo, OSF, or ResearchEquals .
5858# ' @param cert_id ID of the certificate, used for logging and warnings.
5959# '
6060# ' @return The download link for the certificate file as a string if found; otherwise, NULL.
@@ -67,6 +67,11 @@ get_cert_link <- function(report_link, cert_id){
6767 else if (grepl(" OSF" , report_link , ignore.case = TRUE )) {
6868 cert_download_url <- get_osf_cert_link(report_link , cert_id )
6969 }
70+
71+ # use issuer prefix for LibSci, see https://web.archive.org/web/20250504015818/https://www.libscie.org/blog/working-openly-1/minting-dois-for-research-modules-147/
72+ else if (grepl(" 10.53962" , report_link , ignore.case = TRUE )) {
73+ cert_download_url <- get_researchequals_cert_link(report_link , cert_id )
74+ }
7075
7176 else (
7277 return (NULL )
@@ -216,6 +221,30 @@ get_zenodo_cert_link <- function(report_link, cert_id, api_key = "") {
216221}
217222
218223
224+ # ' Accesses a codecheck's ResearchEquals record via its report link and download the main file of the module
225+ # '
226+ # ' @param report_link URL of the ResearchEquals report to access.
227+ # ' @param cert_id ID of the certificate, used for logging and warnings.
228+ # '
229+ # ' @importFrom httr GET status_code content
230+ # ' @importFrom jsonlite fromJSON
231+ # '
232+ # ' @return The download link for the certificate file as a string if found; otherwise, NULL.
233+ get_researchequals_cert_link <- function (report_link , cert_id ) {
234+ # Download link example: https://www.researchequals.com/api/modules/main/wxh7-8yjd
235+ # Let's guess the ID from the report_link
236+
237+ # Checking for redirects and retrieving the record_id from there
238+ response <- httr :: GET(report_link )
239+ final_url <- response $ url
240+ record_id <- basename(final_url )
241+
242+ # Set the base URL for the ResearchEquals API
243+ record_url <- paste0(CONFIG $ CERT_LINKS [[" researchequals_api" ]], record_id )
244+
245+ return (record_url )
246+ }
247+
219248
220249# ' Downloads a ZIP file from the given URL, searches for "codecheck.pdf" within its contents,
221250# ' renames it to "cert.pdf," and saves it in the specified directory.
0 commit comments