diff --git a/R/cr_md_fetch.R b/R/cr_md_fetch.R index ddad1682..6167ca5e 100644 --- a/R/cr_md_fetch.R +++ b/R/cr_md_fetch.R @@ -1,24 +1,3 @@ -#' Get Crossref metadata from API -#' -#' @param dois character vector with DOIs -#' @param .progress show progress bar, use "none" if no progress should be -#' displayed -#' -#' @importFrom rcrossref cr_works -#' -#' @export -get_cr_md <- function(dois, .progress = "text") { - checkmate::assert_character(dois, any.missing = FALSE, unique = TRUE) - tt <- rcrossref::cr_works(dois = dois, .progress = .progress)[["data"]] - if (!is.null(tt)) { - out <- tt %>% - mutate(issued = lubridate::parse_date_time(issued, c("y", "ymd", "ym"))) %>% - mutate(issued_year = lubridate::year(issued)) - } else { - out <- NULL - } - out -} #' License checker #' #' Retrieves records from Crossref metadata where diff --git a/R/import.R b/R/import.R new file mode 100644 index 00000000..8a99b129 --- /dev/null +++ b/R/import.R @@ -0,0 +1,23 @@ +#' Get Crossref metadata from API +#' +#' @param dois character vector with DOIs +#' @param .progress show progress bar, use "none" if no progress should be +#' displayed +#' +#' @family ETL import +#' @export +get_cr_md <- function(dois, .progress = "text") { + # TODO this can be replaced by class validation + # TODO not sure where the best place for the unique assertion is + checkmate::assert_character(dois, any.missing = FALSE, unique = TRUE) + + tt <- rcrossref::cr_works(dois = dois, .progress = .progress)[["data"]] + if (!is.null(tt)) { + out <- tt %>% + mutate(issued = lubridate::parse_date_time(issued, c("y", "ymd", "ym"))) %>% + mutate(issued_year = lubridate::year(issued)) + } else { + out <- NULL + } + out +}