# OpenSilex API
#
# No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
#
# OpenAPI spec version: 1.0.0-rc+2
#
# Generated by: https://github.com/swagger-api/swagger-codegen.git
#' MenuItemDTO Class
#'
#' @field id
#' @field label
#' @field children
#' @field route
#'
#' @importFrom R6 R6Class
#' @importFrom jsonlite fromJSON toJSON
#' @export
MenuItemDTO <- R6::R6Class(
'MenuItemDTO',
public = list(
`id` = NULL,
`label` = NULL,
`children` = NULL,
`route` = NULL,
initialize = function(`id`, `label`, `children`, `route`){
if (!missing(`id`)) {
stopifnot(is.character(`id`), length(`id`) == 1)
self$`id` <- `id`
}
if (!missing(`label`)) {
stopifnot(is.character(`label`), length(`label`) == 1)
self$`label` <- `label`
}
if (!missing(`children`)) {
stopifnot(is.list(`children`), length(`children`) != 0)
lapply(`children`, function(x) stopifnot(R6::is.R6(x)))
self$`children` <- `children`
}
if (!missing(`route`)) {
stopifnot(R6::is.R6(`route`))
self$`route` <- `route`
}
},
toJSON = function() {
MenuItemDTOObject <- list()
if (!is.null(self$`id`)) {
MenuItemDTOObject[['id']] <- self$`id`
}
if (!is.null(self$`label`)) {
MenuItemDTOObject[['label']] <- self$`label`
}
if (!is.null(self$`children`)) {
MenuItemDTOObject[['children']] <- lapply(self$`children`, function(x) x$toJSON())
}
if (!is.null(self$`route`)) {
MenuItemDTOObject[['route']] <- self$`route`$toJSON()
}
MenuItemDTOObject
},
fromJSON = function(MenuItemDTOJson) {
MenuItemDTOObject <- jsonlite::fromJSON(MenuItemDTOJson)
if (!is.null(MenuItemDTOObject$`id`)) {
self$`id` <- MenuItemDTOObject$`id`
}
if (!is.null(MenuItemDTOObject$`label`)) {
self$`label` <- MenuItemDTOObject$`label`
}
if (!is.null(MenuItemDTOObject$`children`)) {
self$`children` <- lapply(MenuItemDTOObject$`children`, function(x) {
childrenObject <- MenuItemDTO$new()
childrenObject$fromJSON(jsonlite::toJSON(x, auto_unbox = TRUE, null = "null"))
childrenObject
})
}
if (!is.null(MenuItemDTOObject$`route`)) {
routeObject <- RouteDTO$new()
routeObject$fromJSON(jsonlite::toJSON(MenuItemDTOObject$route, auto_unbox = TRUE, null = "null"))
self$`route` <- routeObject
}
},
fromJSONObject = function(MenuItemDTOObject) {
if (!is.null(MenuItemDTOObject$`id`)) {
self$`id` <- MenuItemDTOObject$`id`
}
if (!is.null(MenuItemDTOObject$`label`)) {
self$`label` <- MenuItemDTOObject$`label`
}
if (!is.null(MenuItemDTOObject$`children`)) {
self$`children` <- lapply(MenuItemDTOObject$`children`, function(x) {
childrenObject <- MenuItemDTO$new()
childrenObject$fromJSON(jsonlite::toJSON(x, auto_unbox = TRUE, null = "null"))
childrenObject
})
}
if (!is.null(MenuItemDTOObject$`route`)) {
routeObject <- RouteDTO$new()
routeObject$fromJSON(jsonlite::toJSON(MenuItemDTOObject$route, auto_unbox = TRUE, null = "null"))
self$`route` <- routeObject
}
},
toJSONString = function() {
childrenList = paste(lapply(self$`children`, function(x) x$toJSONString()),collapse = ",")
sprintf(
'{
"id": %s,
"label": %s,
"children": [%s],
"route": %s
}',
ifelse(is.null(self$`id`), "null",jsonlite::toJSON(self$`id`,auto_unbox=TRUE, null = "null")),
ifelse(is.null(self$`label`), "null",jsonlite::toJSON(self$`label`,auto_unbox=TRUE, null = "null")),
childrenList,
jsonlite::toJSON(self$`route`$toJSON(),auto_unbox=TRUE, null = "null")
)
},
fromJSONString = function(MenuItemDTOJson) {
MenuItemDTOObject <- jsonlite::fromJSON(MenuItemDTOJson)
self$`id` <- MenuItemDTOObject$`id`
self$`label` <- MenuItemDTOObject$`label`
self$`children` <- lapply(MenuItemDTOObject$`children`, function(x) MenuItemDTO$new()$fromJSON(jsonlite::toJSON(x, auto_unbox = TRUE)))
RouteDTOObject <- RouteDTO$new()
self$`route` <- RouteDTOObject$fromJSON(jsonlite::toJSON(MenuItemDTOObject$route, auto_unbox = TRUE))
}
)
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.