# 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
#' # NamedArea$new()
#'
#' @format
#' R6 class
#'
#' @title NamedArea 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 NamedArea objects.
#'
#'
#' @field areaClass character
#'
#' @field areaName character
#'
#'
#'
#' @section Methods:
#' \describe{
#'
#' \item{\code{$new()}}{
#'
#' Constructor NamedArea object.
#'
#' }
#' \item{\code{$fromList(NamedAreaList)}}{
#'
#' Create NamedArea object from list.
#'
#' }
#'
#' \item{\code{$toList()}}{
#'
#' Get list representation of NamedArea.
#'
#' }
#' \item{\code{fromJSONString(NamedAreaJson)}}{
#'
#' Create NamedArea object from JSON.
#'
#' }
#' \item{\code{toJSONString(pretty=TRUE)}}{
#'
#' Get JSON representation of NamedArea.
#'
#' }
#' }
#' @importFrom R6 R6Class
#' @importFrom jsonlite fromJSON toJSON
#' @export
NamedArea <- R6::R6Class(
"NamedArea",
public = list(
`areaClass` = NULL,
`areaName` = NULL,
initialize = function(
`areaClass`,
`areaName`) {
if (!missing(`areaClass`)) {
stopifnot(
is.character(`areaClass`),
length(`areaClass`) == 1
)
self[["areaClass"]] <- `areaClass`
}
if (!missing(`areaName`)) {
stopifnot(
is.character(`areaName`),
length(`areaName`) == 1
)
self[["areaName"]] <- `areaName`
}
},
toList = function() {
NamedAreaList <- list()
if (!is.null(self[["areaClass"]])) {
NamedAreaList[["areaClass"]] <-
self[["areaClass"]]
}
if (!is.null(self[["areaName"]])) {
NamedAreaList[["areaName"]] <-
self[["areaName"]]
}
## omit empty nested lists in returned list
NamedAreaList[vapply(
NamedAreaList,
length,
FUN.VALUE = integer(1)
) > 0]
},
fromList = function(NamedAreaList,
typeMapping = NULL) {
self[["areaClass"]] <-
NamedAreaList[["areaClass"]]
self[["areaName"]] <-
NamedAreaList[["areaName"]]
invisible(self)
},
toJSONString = function(pretty = TRUE) {
jsonlite::toJSON(
self$toList(),
simplifyVector = TRUE,
auto_unbox = TRUE,
pretty = pretty
)
},
fromJSONString = function(NamedAreaJson,
typeMapping = NULL) {
NamedAreaList <- jsonlite::fromJSON(
NamedAreaJson,
simplifyVector = FALSE
)
self <- self$fromList(NamedAreaList)
invisible(self)
},
print = function(...) {
## print class name
cat("<NamedArea>\n")
## print all members with values
cat("Fields:\n")
if (typeof(self$areaClass) == "environment") {
cat("\tareaClass:\tobject of class", paste0("<", class(self$areaClass)[1], ">"), "\n")
}
else if (typeof(self$areaClass) == "list") {
cat("\tareaClass:\tlist of length", length(self$areaClass), "\n")
}
else {
cat("\tareaClass:\t", self$areaClass, "\n")
}
if (typeof(self$areaName) == "environment") {
cat("\tareaName:\tobject of class", paste0("<", class(self$areaName)[1], ">"), "\n")
}
else if (typeof(self$areaName) == "list") {
cat("\tareaName:\tlist of length", length(self$areaName), "\n")
}
else {
cat("\tareaName:\t", self$areaName, "\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.