blob: 9a4a5cbbd157e3d0f38a70b8cba18b351224f888 [file] [log] [blame]
Marc Kupietzfd9e7492019-11-08 15:45:18 +01001################################################################################
2# Use setClassUnion to define the unholy NULL-data union as a virtual class.
3################################################################################
4setClassUnion("characterOrNULL", c("character", "NULL"))
Marc Kupietza4675722022-02-23 23:55:15 +01005setClassUnion("listOrNULL", c("list", "NULL"))
Marc Kupietzfd9e7492019-11-08 15:45:18 +01006
Marc Kupietze95108e2019-09-18 13:23:58 +02007#' Class KorAPConnection
Marc Kupietz25aebc32019-09-16 18:40:50 +02008#'
Marc Kupietz67edcb52021-09-20 21:54:24 +02009#' `KorAPConnection` objects represent the connection to a KorAP server.
10#' New `KorAPConnection` objects can be created by `new("KorAPConnection")`.
Marc Kupietze95108e2019-09-18 13:23:58 +020011#'
Marc Kupietz0a96b282019-10-01 11:05:31 +020012#' @import R.cache
Marc Kupietze95108e2019-09-18 13:23:58 +020013#' @import utils
14#' @import methods
Marc Kupietza81343d2022-09-06 12:32:10 +020015#' @slot KorAPUrl URL of the web user interface of the KorAP server used in the connection.
16#' @slot apiVersion requested KorAP API version.
17#' @slot indexRevision indexRevision code as reported from API via `X-Index-Revision` HTTP header.
18#' @slot apiUrl full URL of API including version.
19#' @slot accessToken OAuth2 access token.
20#' @slot userAgent user agent string used for connection the API.
21#' @slot timeout tineout in seconds for API requests (this does not influence server internal timeouts)
22#' @slot verbose logical that decides whether operations will default to be verbose.
23#' @slot cache logical that decides if API calls are cached locally.
24#' @slot welcome list containing HTTP response received from KorAP server welcome function.
25
Marc Kupietze95108e2019-09-18 13:23:58 +020026#' @export
Marc Kupietza4675722022-02-23 23:55:15 +010027KorAPConnection <- setClass("KorAPConnection", slots=c(KorAPUrl="character", apiVersion="character", indexRevision="characterOrNULL", apiUrl="character", accessToken="characterOrNULL", userAgent="character", timeout="numeric", verbose="logical", cache="logical", welcome="listOrNULL"))
Marc Kupietze95108e2019-09-18 13:23:58 +020028
29#' @param .Object KorAPConnection object
Marc Kupietza81343d2022-09-06 12:32:10 +020030#' @param KorAPUrl URL of the web user interface of the KorAP server instance you want to access.
Marc Kupietze95108e2019-09-18 13:23:58 +020031#' @param apiVersion which version of KorAP's API you want to connect to.
32#' @param apiUrl URL of the KorAP web service.
Marc Kupietz132f0052023-04-16 14:23:05 +020033#' @param accessToken OAuth2 access token. For queries on corpus parts with restricted
34#' access (e.g. textual queries on IPR protected data), you need to authorize
35#' your application with an access token.
Marc Kupietza4f51d72025-01-25 16:23:18 +010036#' You can obtain an access token using the [auth()] method.
37#'
38#' More details are explained in the
Marc Kupietz132f0052023-04-16 14:23:05 +020039#' [authorization section](https://github.com/KorAP/RKorAPClient#authorization)
40#' of the RKorAPClient Readme on GitHub.
41#'
42#' To use authorization based on an access token
43#' in subsequent queries, initialize your KorAP connection with:
44#'
45#' ```
46#' kco <- new("KorAPConnection", accessToken="<access token>")
47#' ```
48#'
Marc Kupietz4862b862019-11-07 10:13:53 +010049#' In order to make the API
Marc Kupietz67edcb52021-09-20 21:54:24 +020050#' token persistent for the currently used `KorAPUrl` (you can have one
Marc Kupietz132f0052023-04-16 14:23:05 +020051#' token per KorAPUrl / KorAP server instance), use:
52#'
53#' ```
54#' persistAccessToken(kco)
55#' ```
56#'
57#' This will store it in your keyring using the
Marc Kupietz6a02e4c2025-01-09 21:22:30 +010058#' [keyring::keyring-package]. Subsequent new("KorAPConnection") calls will
Marc Kupietz4862b862019-11-07 10:13:53 +010059#' then automatically retrieve the token from your keying. To stop using a
Marc Kupietz67edcb52021-09-20 21:54:24 +020060#' persisted token, call `clearAccessToken(kco)`. Please note that for
Marc Kupietz4862b862019-11-07 10:13:53 +010061#' DeReKo, authorized queries will behave differently inside and outside the
62#' IDS, because of the special license situation. This concerns also cached
63#' results which do not take into account from where a request was issued. If
Marc Kupietz67edcb52021-09-20 21:54:24 +020064#' you experience problems or unexpected results, please try `kco <-
65#' new("KorAPConnection", cache=FALSE)` or use
66#' [clearCache()] to clear the cache completely.
Marc Kupietz132f0052023-04-16 14:23:05 +020067#'
Marc Kupietzd0d3e9b2019-09-24 17:36:03 +020068#' @param userAgent user agent string.
Marc Kupietza81343d2022-09-06 12:32:10 +020069#' @param timeout tineout in seconds for API requests (this does not influence server internal timeouts).
70#' @param verbose logical that decides whether following operations will default to
Marc Kupietz4862b862019-11-07 10:13:53 +010071#' be verbose.
Marc Kupietza81343d2022-09-06 12:32:10 +020072#' @param cache logical that decides if API calls are cached locally. You can clear
Marc Kupietz67edcb52021-09-20 21:54:24 +020073#' the cache with [clearCache()].
74#' @return [KorAPConnection()] object that can be used e.g. with
75#' [corpusQuery()]
Marc Kupietze95108e2019-09-18 13:23:58 +020076#'
77#' @examples
Marc Kupietz6ae76052021-09-21 10:34:00 +020078#' \dontrun{
79#'
Marc Kupietz5a519822019-09-20 21:43:52 +020080#' kcon <- new("KorAPConnection", verbose = TRUE)
Marc Kupietze95108e2019-09-18 13:23:58 +020081#' kq <- corpusQuery(kcon, "Ameisenplage")
Marc Kupietz5a519822019-09-20 21:43:52 +020082#' kq <- fetchAll(kq)
Marc Kupietz05b22772020-02-18 21:58:42 +010083#' }
Marc Kupietz7915dc42019-09-12 17:44:58 +020084#'
Marc Kupietz4862b862019-11-07 10:13:53 +010085#' \dontrun{
Marc Kupietz6ae76052021-09-21 10:34:00 +020086#'
Marc Kupietzb956b812019-11-25 17:53:13 +010087#' kcon <- new("KorAPConnection", verbose = TRUE, accessToken="e739u6eOzkwADQPdVChxFg")
Marc Kupietz4862b862019-11-07 10:13:53 +010088#' kq <- corpusQuery(kcon, "Ameisenplage", metadataOnly=FALSE)
89#' kq <- fetchAll(kq)
90#' kq@collectedMatches$snippet
91#' }
Marc Kupietz7915dc42019-09-12 17:44:58 +020092#'
Marc Kupietze95108e2019-09-18 13:23:58 +020093#' @rdname KorAPConnection-class
Marc Kupietz632cbd42019-09-06 16:04:51 +020094#' @export
Marc Kupietze95108e2019-09-18 13:23:58 +020095setMethod("initialize", "KorAPConnection",
Marc Kupietz6a3185b2021-12-07 10:23:16 +010096 function(.Object, KorAPUrl = "https://korap.ids-mannheim.de/", apiVersion = 'v1.0', apiUrl, accessToken = getAccessToken(KorAPUrl), userAgent = "R-KorAP-Client", timeout=240, verbose = FALSE, cache = TRUE) {
Marc Kupietze95108e2019-09-18 13:23:58 +020097 .Object <- callNextMethod()
98 m <- regexpr("https?://[^?]+", KorAPUrl, perl = TRUE)
99 .Object@KorAPUrl <- regmatches(KorAPUrl, m)
100 if (!endsWith(.Object@KorAPUrl, '/')) {
101 .Object@KorAPUrl <- paste0(.Object@KorAPUrl, "/")
102 }
103 if (missing(apiUrl)) {
104 .Object@apiUrl = paste0(.Object@KorAPUrl, 'api/', apiVersion, '/')
105 } else {
106 .Object@apiUrl = apiUrl
107 }
Marc Kupietzb956b812019-11-25 17:53:13 +0100108 .Object@accessToken = accessToken
Marc Kupietze95108e2019-09-18 13:23:58 +0200109 .Object@apiVersion = apiVersion
Marc Kupietzd0d3e9b2019-09-24 17:36:03 +0200110 .Object@userAgent = userAgent
111 .Object@timeout = timeout
Marc Kupietz5a519822019-09-20 21:43:52 +0200112 .Object@verbose = verbose
Marc Kupietz0a96b282019-10-01 11:05:31 +0200113 .Object@cache = cache
Marc Kupietza4675722022-02-23 23:55:15 +0100114 .Object@welcome = apiCall(.Object, .Object@apiUrl, json = FALSE, cache = FALSE, getHeaders = TRUE)
115 if (!is.null(.Object@welcome)) {
116 message(.Object@welcome[[2]])
117 }
118 .Object@indexRevision <- .Object@welcome[[1]][["x-index-revision"]]
Marc Kupietze95108e2019-09-18 13:23:58 +0200119 .Object
120 })
121
Marc Kupietza96537f2019-11-09 23:07:44 +0100122
Marc Kupietzb956b812019-11-25 17:53:13 +0100123accessTokenServiceName <- "RKorAPClientAccessToken"
Marc Kupietz4862b862019-11-07 10:13:53 +0100124
Marc Kupietzb956b812019-11-25 17:53:13 +0100125setGeneric("persistAccessToken", function(kco, ...) standardGeneric("persistAccessToken") )
Marc Kupietz4862b862019-11-07 10:13:53 +0100126
Marc Kupietza4f51d72025-01-25 16:23:18 +0100127#' Persist current access token in keyring
128#'
129#' @param kco KorAPConnection object
130#' @param accessToken access token to be persisted. If not supplied, the current access token of the KorAPConnection object will be used.
131#' @return KorAPConnection object.
132#'
Marc Kupietzb956b812019-11-25 17:53:13 +0100133#' @aliases persistAccessToken
Marc Kupietza4f51d72025-01-25 16:23:18 +0100134#'
Marc Kupietz4862b862019-11-07 10:13:53 +0100135#' @import keyring
136#' @export
Marc Kupietza4f51d72025-01-25 16:23:18 +0100137#'
Marc Kupietz4862b862019-11-07 10:13:53 +0100138#' @examples
139#' \dontrun{
Marc Kupietzb956b812019-11-25 17:53:13 +0100140#' kco <- new("KorAPConnection", accessToken="e739u6eOzkwADQPdVChxFg")
141#' persistAccessToken(kco)
Marc Kupietza4f51d72025-01-25 16:23:18 +0100142#'
143#' kco <- new("KorAPConnection") %>% auth(app_id="<my application id>") %>% persistAccessToken()
Marc Kupietz4862b862019-11-07 10:13:53 +0100144#' }
145#'
Marc Kupietza4f51d72025-01-25 16:23:18 +0100146#' @seealso [clearAccessToken()], [auth()]
147#'
Marc Kupietzb956b812019-11-25 17:53:13 +0100148setMethod("persistAccessToken", "KorAPConnection", function(kco, accessToken = kco@accessToken) {
149 if (is.null(accessToken))
150 stop("It seems that you have not supplied any access token that could be persisted.", call. = FALSE)
Marc Kupietz4862b862019-11-07 10:13:53 +0100151
Marc Kupietzb956b812019-11-25 17:53:13 +0100152 kco@accessToken <- accessToken
153 key_set_with_value(accessTokenServiceName, kco@KorAPUrl, accessToken)
Marc Kupietza4f51d72025-01-25 16:23:18 +0100154 return(kco)
Marc Kupietz4862b862019-11-07 10:13:53 +0100155})
156
Marc Kupietzb956b812019-11-25 17:53:13 +0100157setGeneric("clearAccessToken", function(kco) standardGeneric("clearAccessToken") )
Marc Kupietz4862b862019-11-07 10:13:53 +0100158
Marc Kupietza4f51d72025-01-25 16:23:18 +0100159#' Clear access token from keyring and KorAPConnection object
160#'
Marc Kupietzb956b812019-11-25 17:53:13 +0100161#' @aliases clearAccessToken
Marc Kupietz4862b862019-11-07 10:13:53 +0100162#' @import keyring
Marc Kupietza4f51d72025-01-25 16:23:18 +0100163#' @param kco KorAPConnection object
164#' @return KorAPConnection object with access token set to `NULL`.
Marc Kupietz4862b862019-11-07 10:13:53 +0100165#' @export
166#' @examples
Marc Kupietz6ae76052021-09-21 10:34:00 +0200167#'
Marc Kupietza4f51d72025-01-25 16:23:18 +0100168#' \dontrun{
Marc Kupietz4862b862019-11-07 10:13:53 +0100169#' kco <- new("KorAPConnection")
Marc Kupietza4f51d72025-01-25 16:23:18 +0100170#' kco <- clearAccessToken(kco)
Marc Kupietz4862b862019-11-07 10:13:53 +0100171#' }
172#'
Marc Kupietza4f51d72025-01-25 16:23:18 +0100173#' @seealso [persistAccessToken()]
174#'
Marc Kupietzb956b812019-11-25 17:53:13 +0100175setMethod("clearAccessToken", "KorAPConnection", function(kco) {
176 key_delete(accessTokenServiceName, kco@KorAPUrl)
Marc Kupietza4f51d72025-01-25 16:23:18 +0100177 kco@accessToken <- NULL
178 kco
Marc Kupietz4862b862019-11-07 10:13:53 +0100179})
180
Marc Kupietza4f51d72025-01-25 16:23:18 +0100181generic_kor_app_id = "99FbPHH7RrN36hbndF7b6f"
182
183
184setGeneric("auth", function(kco, app_id = generic_kor_app_id, scope = "search match_info") standardGeneric("auth") )
185
186#' Authorize RKorAPClient
187#'
188#' @aliases auth
189#'
190#' @description
191#' `r lifecycle::badge("experimental")`
192#'
193#' Authorize RKorAPClient to make KorAP queries and download results on behalf of the user.
194#'
195#' @param kco KorAPConnection object
196#' @param app_id OAuth2 application id. Defaults to the generic KorAP client application id.
197#' @param scope OAuth2 scope. Defaults to "search match_info".
198#' @return KorAPConnection object with access token set in `@accessToken`.
199#'
200#' @importFrom httr2 oauth_client oauth_flow_auth_code
201#' @examples
202#' \dontrun{
203#' kco <- new("KorAPConnection", verbose = TRUE) %>% auth()
204#' df <- collocationAnalysis(kco, "focus([marmot/p=ADJA] {Ameisenplage})", leftContextSize=1, rightContextSize=0)
205#' }
206#'
207#' @seealso [persistAccessToken()], [clearAccessToken()]
208#'
209#' @export
210setMethod("auth", "KorAPConnection", function(kco, app_id = generic_kor_app_id, scope = "search match_info") {
211 if ( kco@KorAPUrl != "https://korap.ids-mannheim.de/" & app_id == generic_kor_app_id) {
212 warning(paste("You can use the default app_id only for the IDS Mannheim KorAP main instance for querying DeReKo. Please provide your own app_id for accesing", kco@KorAPUrl))
213 return(kco)
214 }
215 if (is.null(kco@accessToken) || is.null(kco@welcome)) { # if access token is not set or invalid
216 kco@accessToken <- (
217 httr2::oauth_client(
218 id = app_id,
219 token_url = paste0(kco@apiUrl, "oauth2/token")
220 ) %>%
221 httr2::oauth_flow_auth_code(
222 scope = scope,
223 auth_url = paste0(kco@KorAPUrl, "settings/oauth/authorize"),
224 redirect_uri = "http://localhost:1410"
225 )
226 )$access_token
227 } else {
228 log_info(kco@verbose, "Client authorized. Access token already set.")
229 }
230 return(kco)
231})
232
233
234
Marc Kupietz4862b862019-11-07 10:13:53 +0100235#' @import keyring
Marc Kupietzb956b812019-11-25 17:53:13 +0100236getAccessToken <- function(KorAPUrl) {
Marc Kupietz59e449b2019-12-12 12:53:54 +0100237 keyList <- tryCatch(withCallingHandlers(key_list(service = accessTokenServiceName),
Marc Kupietzddce5562019-11-24 15:45:38 +0100238 warning = function(w) invokeRestart("muffleWarning"),
Marc Kupietz59e449b2019-12-12 12:53:54 +0100239 error = function(e) return(NULL)),
240 error = function(e) { })
Marc Kupietz01c24772021-07-14 18:27:36 +0200241 if (KorAPUrl %in% keyList$username)
Marc Kupietzb956b812019-11-25 17:53:13 +0100242 key_get(accessTokenServiceName, KorAPUrl)
Marc Kupietzfd9e7492019-11-08 15:45:18 +0100243 else
244 NULL
Marc Kupietz4862b862019-11-07 10:13:53 +0100245}
Marc Kupietz0a96b282019-10-01 11:05:31 +0200246
Marc Kupietz581a29b2021-09-04 20:51:04 +0200247
248warnIfNoAccessToken <- function(kco) {
249 if (is.null(kco@accessToken)) {
250 warning(
251 paste0(
252 "In order to receive KWICSs also from corpora with restricted licenses, you need an access token.\n",
253 "To generate an access token, login to KorAP and navigite to KorAP's OAuth settings <",
254 kco@KorAPUrl,
255 "settings/oauth#page-top>"
256 )
257 )
258 }
259}
260
Marc Kupietz0a96b282019-10-01 11:05:31 +0200261KorAPCacheSubDir <- function() {
Marc Kupietz70b2c722020-02-18 13:32:09 +0100262 paste0("RKorAPClient_",
263 gsub(
264 "^([0-9]+\\.[0-9]+).*",
265 "\\1",
266 packageVersion("RKorAPClient"),
267 perl = TRUE
268 ))
Marc Kupietz0a96b282019-10-01 11:05:31 +0200269}
270
Marc Kupietzd0d3e9b2019-09-24 17:36:03 +0200271setGeneric("apiCall", function(kco, ...) standardGeneric("apiCall") )
272
Marc Kupietz4de53ec2019-10-04 09:12:00 +0200273## quiets concerns of R CMD check re: the .'s that appear in pipelines
274if(getRversion() >= "2.15.1") utils::globalVariables(c("."))
275
Marc Kupietzd0d3e9b2019-09-24 17:36:03 +0200276#' @aliases apiCall
277#' @rdname KorAPConnection-class
278#' @param kco KorAPConnection object
279#' @param url request url
Marc Kupietzb2b32a32020-03-24 13:56:50 +0100280#' @param json logical that determines if json result is expected
Marc Kupietzb49afa02020-06-04 15:50:29 +0200281#' @param getHeaders logical that determines if headers and content should be returned (as a list)
Marc Kupietz69cc54a2019-09-30 12:06:54 +0200282#' @importFrom jsonlite fromJSON
Marc Kupietza4675722022-02-23 23:55:15 +0100283#' @importFrom curl has_internet
Marc Kupietz69cc54a2019-09-30 12:06:54 +0200284#' @export
Marc Kupietza4675722022-02-23 23:55:15 +0100285setMethod("apiCall", "KorAPConnection", function(kco, url, json = TRUE, getHeaders = FALSE, cache = kco@cache, timeout=kco@timeout) {
Marc Kupietzb2b32a32020-03-24 13:56:50 +0100286 result <- ""
287 if (cache) {
Marc Kupietzb49afa02020-06-04 15:50:29 +0200288 result <- R.cache::loadCache(dir=KorAPCacheSubDir(), key=list(url, kco@accessToken, kco@indexRevision))
Marc Kupietzb2b32a32020-03-24 13:56:50 +0100289 if (!is.null(result)) {
290 if (!is.null(result$meta))
291 result$meta$cached <- "local"
292 return(result)
Marc Kupietz0a96b282019-10-01 11:05:31 +0200293 }
294 }
Marc Kupietza4675722022-02-23 23:55:15 +0100295
296 # From https://community.rstudio.com/t/internet-resources-should-fail-gracefully/49199/11
297 # Thanks to kvasilopoulos
298 try_GET <- function(x, ...) {
299 tryCatch(
300 GET(url = x, timeout(timeout), ...),
301 error = function(e) conditionMessage(e),
302 warning = function(w) conditionMessage(w)
303 )
304 }
305 is_response <- function(x) {
306 class(x) == "response"
307 }
308
309 # First check internet connection
310 if (!curl::has_internet()) {
311 message("No internet connection.")
312 return(invisible(NULL))
313 }
314
Marc Kupietzb956b812019-11-25 17:53:13 +0100315 if (!is.null(kco@accessToken))
Marc Kupietza4675722022-02-23 23:55:15 +0100316 resp <- try_GET(url, user_agent(kco@userAgent), timeout(timeout), add_headers(Authorization = paste("Bearer", kco@accessToken)))
Marc Kupietz4862b862019-11-07 10:13:53 +0100317 else
Marc Kupietza4675722022-02-23 23:55:15 +0100318 resp <- try_GET(url, user_agent(kco@userAgent), timeout(timeout))
319
320 if (!is_response(resp)) {
321 message(resp)
322 return(invisible(NULL))
323 }
Marc Kupietzb2b32a32020-03-24 13:56:50 +0100324 if (json || status_code(resp) != 200) {
325 if (json && !http_type(resp) %in% c("application/json", "application/ld+json")) {
Marc Kupietz04814f22023-04-16 17:13:27 +0200326 message("API did not return json")
Marc Kupietza4675722022-02-23 23:55:15 +0100327 return(invisible(NULL))
Marc Kupietzb2b32a32020-03-24 13:56:50 +0100328 }
Marc Kupietz04814f22023-04-16 17:13:27 +0200329
330 result <- tryCatch(jsonlite::fromJSON(content(resp, "text", encoding = "UTF-8")), error = function(e) {return(NULL)})
331 if (!is.atomic(result) && !is.null(result$warnings)) {
Marc Kupietza4675722022-02-23 23:55:15 +0100332 msg <- if (nrow(result$warnings) > 1)
Marc Kupietzb2b32a32020-03-24 13:56:50 +0100333 sapply(result$warnings, function(warning) paste(sprintf("%s: %s", warning[1], warning[2]), sep="\n"))
334 else
335 sprintf("%s: %s", result$warnings[1], result$warnings[2])
Marc Kupietza4675722022-02-23 23:55:15 +0100336 message(msg)
Marc Kupietzb2b32a32020-03-24 13:56:50 +0100337 }
Marc Kupietzd0d3e9b2019-09-24 17:36:03 +0200338 }
339 if (status_code(resp) != 200) {
Marc Kupietzb7d8c272020-01-31 18:51:50 +0100340 if (kco@verbose) {
341 cat("\n")
342 }
Marc Kupietza4675722022-02-23 23:55:15 +0100343 msg <- sprintf("%s KorAP API request failed", status_code(resp))
Marc Kupietz04814f22023-04-16 17:13:27 +0200344 if (!is.atomic(result) && !is.null(result$errors)) {
Marc Kupietza4675722022-02-23 23:55:15 +0100345 errormsg <- unlist(result$errors)
346 msg <- sprintf("%s: %s %s", msg, errormsg[5], errormsg[2])
Marc Kupietzb7d8c272020-01-31 18:51:50 +0100347 }
Marc Kupietza4675722022-02-23 23:55:15 +0100348 message(msg)
349 return(invisible(NULL))
Marc Kupietzd0d3e9b2019-09-24 17:36:03 +0200350 }
Marc Kupietzb2b32a32020-03-24 13:56:50 +0100351 if (!json) {
352 result <- content(resp, "text", encoding = "UTF-8")
Marc Kupietz0a96b282019-10-01 11:05:31 +0200353 }
Marc Kupietzb2b32a32020-03-24 13:56:50 +0100354 if (cache) {
Marc Kupietzb49afa02020-06-04 15:50:29 +0200355 R.cache::saveCache(result, key = list(url, kco@accessToken, kco@indexRevision), dir = KorAPCacheSubDir(), compress = TRUE)
Marc Kupietzb2b32a32020-03-24 13:56:50 +0100356 }
Marc Kupietzb49afa02020-06-04 15:50:29 +0200357 if (getHeaders) {
358 list(httr::headers(resp), result)
359 } else {
360 result
361 }
Marc Kupietzd0d3e9b2019-09-24 17:36:03 +0200362})
363
Marc Kupietz0a96b282019-10-01 11:05:31 +0200364setGeneric("clearCache", function(kco) standardGeneric("clearCache") )
365
366#' @aliases clearCache
367#' @rdname KorAPConnection-class
368#' @export
369setMethod("clearCache", "KorAPConnection", function(kco) {
370 R.cache::clearCache(dir=KorAPCacheSubDir())
371})
372
Marc Kupietze95108e2019-09-18 13:23:58 +0200373#' @rdname KorAPConnection-class
374#' @param object KorAPConnection object
375#' @export
376setMethod("show", "KorAPConnection", function(object) {
377 cat("<KorAPConnection>", "\n")
378 cat("apiUrl: ", object@apiUrl, "\n")
379})
380
Marc Kupietzd0d3e9b2019-09-24 17:36:03 +0200381##' Funtion KorAPConnection()
382##'
383##' Wrappper function for new("KorAPConnection")
384##'
385##' @rdname KorAPConnection-constructor
386##' @name KorAPConnection-constructor
387##' @export
388## XKorAPConnection <- function(...) new("KorAPConnection", ...)