# Netherlands Biodiversity API
#
# Access to the digitised Natural History collection at the Naturalis Biodiversity Center
#
# OpenAPI spec version: v2
# Contact: support@naturalis.nl
# Generated by: https://github.com/swagger-api/swagger-codegen.git
#'
#' @docType class
#'
#' @format R6 class
#'
#' @usage
#' # Agent$new()
#'
#' @format
#' R6 class
#'
#' @title Agent Class
#'
#' @description
#' For more information on the NBA object model, please refer to the
#' official NBA documentation at
#' \href{https://docs.biodiversitydata.nl}{https://docs.biodiversitydata.nl} and
#' the NBA model and endpoints reference at
#' \href{https://docs.biodiversitydata.nl/endpoints-reference}{https://docs.biodiversitydata.nl/endpoints-reference}.
#'
#' @details Model class for Agent objects.
#'
#'
#' @field agentText character
#'
#'
#'
#' @section Methods:
#' \describe{
#'
#' \item{\code{$new()}}{
#'
#' Constructor Agent object.
#'
#' }
#' \item{\code{$fromList(AgentList)}}{
#'
#' Create Agent object from list.
#'
#' }
#'
#' \item{\code{$toList()}}{
#'
#' Get list representation of Agent.
#'
#' }
#' \item{\code{fromJSONString(AgentJson)}}{
#'
#' Create Agent object from JSON.
#'
#' }
#' \item{\code{toJSONString(pretty=TRUE)}}{
#'
#' Get JSON representation of Agent.
#'
#' }
#' }
#' @importFrom R6 R6Class
#' @importFrom jsonlite fromJSON toJSON
#' @export
Agent <- R6::R6Class(
"Agent",
public = list(
`agentText` = NULL,
initialize = function(
`agentText`) {
if (!missing(`agentText`)) {
stopifnot(
is.character(`agentText`),
length(`agentText`) == 1
)
self[["agentText"]] <- `agentText`
}
},
toList = function() {
AgentList <- list()
if (!is.null(self[["agentText"]])) {
AgentList[["agentText"]] <-
self[["agentText"]]
}
## omit empty nested lists in returned list
AgentList[vapply(
AgentList,
length,
FUN.VALUE = integer(1)
) > 0]
},
fromList = function(AgentList,
typeMapping = NULL) {
self[["agentText"]] <-
AgentList[["agentText"]]
invisible(self)
},
toJSONString = function(pretty = TRUE) {
jsonlite::toJSON(
self$toList(),
simplifyVector = TRUE,
auto_unbox = TRUE,
pretty = pretty
)
},
fromJSONString = function(AgentJson,
typeMapping = NULL) {
AgentList <- jsonlite::fromJSON(
AgentJson,
simplifyVector = FALSE
)
self <- self$fromList(AgentList)
invisible(self)
},
print = function(...) {
## print class name
cat("<Agent>\n")
## print all members with values
cat("Fields:\n")
if (typeof(self$agentText) == "environment") {
cat("\tagentText:\tobject of class", paste0("<", class(self$agentText)[1], ">"), "\n")
}
else if (typeof(self$agentText) == "list") {
cat("\tagentText:\tlist of length", length(self$agentText), "\n")
}
else {
cat("\tagentText:\t", self$agentText, "\n")
}
## print all methods
cat("Methods:\n")
cat("\tfromJSONString\n")
cat("\ttoJSONString\n")
cat("\tfromList\n")
cat("\ttoList\n")
cat("\tprint\n")
invisible(self)
}
)
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.