-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add basic query function for chronontology
- Loading branch information
1 parent
2023a48
commit 642223b
Showing
5 changed files
with
63 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#' Basic Query for iDAI.chronontology | ||
#' | ||
#' | ||
#' | ||
#' @param value (chr) The value you want to search for in all chronontology-periods. | ||
#' | ||
#' @return A list of results as handed out by iDAI.chronontology. | ||
#' | ||
#' @export | ||
#' | ||
#' @examples | ||
#' roman_periods <- query_chronontology(value = "roman") | ||
#' names <- unlist(lapply(roman_periods, function(x) x$resource$names$en)) | ||
query_chronontology <- function(value = "roman") { | ||
stopifnot(is.character(value)) | ||
|
||
url <- "https://chronontology.dainst.org" | ||
headers <- list(`Content-Type` = "application/json", | ||
Accept = "application/json") | ||
ChronClient <- crul::HttpClient$new(url = url, headers = headers) | ||
|
||
response <- ChronClient$get(path = paste0('data/period/?q=', value, '&size=1')) | ||
response <- response$parse("UTF-8") | ||
list <- jsonlite::fromJSON(response, FALSE) | ||
|
||
if (list$total > length(list$results)) { | ||
response <- ChronClient$get(path = paste0('data/', type, '/?q=', value, '&size=', list$total)) | ||
response <- response$parse("UTF-8") | ||
list <- jsonlite::fromJSON(response, FALSE) | ||
} | ||
|
||
result <- list$results | ||
|
||
return(result) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.