#' Create a new OrganizationSummary
#'
#' @description
#' OrganizationSummary Class
#'
#' @docType class
#' @title OrganizationSummary
#' @description OrganizationSummary Class
#' @format An \code{R6Class} generator object
#' @field id integer
#' @field name character
#' @importFrom R6 R6Class
#' @importFrom jsonlite fromJSON toJSON
#' @keywords internal
OrganizationSummary <- R6::R6Class(
"OrganizationSummary",
public = list(
`id` = NULL,
`name` = NULL,
#' @description
#' Initialize a new OrganizationSummary class.
#'
#' @param id id
#' @param name name
#' @param ... Other optional arguments.
initialize = function(`id`, `name`, ...) {
if (!missing(`id`)) {
if (!(is.numeric(`id`) && length(`id`) == 1)) {
stop(paste("Error! Invalid data for `id`. Must be an integer:", `id`))
}
self$`id` <- `id`
}
if (!missing(`name`)) {
if (!(is.character(`name`) && length(`name`) == 1)) {
stop(paste("Error! Invalid data for `name`. Must be a string:", `name`))
}
self$`name` <- `name`
}
},
#' @description
#' To JSON String
#'
#' @return OrganizationSummary in JSON format
toJSON = function() {
OrganizationSummaryObject <- list()
if (!is.null(self$`id`)) {
OrganizationSummaryObject[["id"]] <-
self$`id`
}
if (!is.null(self$`name`)) {
OrganizationSummaryObject[["name"]] <-
self$`name`
}
OrganizationSummaryObject
},
#' @description
#' Deserialize JSON string into an instance of OrganizationSummary
#'
#' @param input_json the JSON input
#' @return the instance of OrganizationSummary
fromJSON = function(input_json) {
this_object <- jsonlite::fromJSON(input_json)
if (!is.null(this_object$`id`)) {
self$`id` <- this_object$`id`
}
if (!is.null(this_object$`name`)) {
self$`name` <- this_object$`name`
}
self
},
#' @description
#' To JSON String
#'
#' @return OrganizationSummary in JSON format
toJSONString = function() {
jsoncontent <- c(
if (!is.null(self$`id`)) {
sprintf(
'"id":
%d
',
self$`id`
)
},
if (!is.null(self$`name`)) {
sprintf(
'"name":
"%s"
',
self$`name`
)
}
)
jsoncontent <- paste(jsoncontent, collapse = ",")
json_string <- as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = "")))
},
#' @description
#' Deserialize JSON string into an instance of OrganizationSummary
#'
#' @param input_json the JSON input
#' @return the instance of OrganizationSummary
fromJSONString = function(input_json) {
this_object <- jsonlite::fromJSON(input_json)
self$`id` <- this_object$`id`
self$`name` <- this_object$`name`
self
},
#' @description
#' Validate JSON input with respect to OrganizationSummary and throw an exception if invalid
#'
#' @param input the JSON input
validateJSON = function(input) {
input_json <- jsonlite::fromJSON(input)
# check the required field `id`
if (!is.null(input_json$`id`)) {
if (!(is.numeric(input_json$`id`) && length(input_json$`id`) == 1)) {
stop(paste("Error! Invalid data for `id`. Must be an integer:", input_json$`id`))
}
} else {
stop(paste("The JSON input `", input, "` is invalid for OrganizationSummary: the required field `id` is missing."))
}
# check the required field `name`
if (!is.null(input_json$`name`)) {
if (!(is.character(input_json$`name`) && length(input_json$`name`) == 1)) {
stop(paste("Error! Invalid data for `name`. Must be a string:", input_json$`name`))
}
} else {
stop(paste("The JSON input `", input, "` is invalid for OrganizationSummary: the required field `name` is missing."))
}
},
#' @description
#' To string (JSON format)
#'
#' @return String representation of OrganizationSummary
toString = function() {
self$toJSONString()
},
#' @description
#' Return true if the values in all fields are valid.
#'
#' @return true if the values in all fields are valid.
isValid = function() {
# check if the required `id` is null
if (is.null(self$`id`)) {
return(FALSE)
}
# check if the required `name` is null
if (is.null(self$`name`)) {
return(FALSE)
}
TRUE
},
#' @description
#' Return a list of invalid fields (if any).
#'
#' @return A list of invalid fields (if any).
getInvalidFields = function() {
invalid_fields <- list()
# check if the required `id` is null
if (is.null(self$`id`)) {
invalid_fields["id"] <- "Non-nullable required field `id` cannot be null."
}
# check if the required `name` is null
if (is.null(self$`name`)) {
invalid_fields["name"] <- "Non-nullable required field `name` cannot be null."
}
invalid_fields
},
#' @description
#' Print the object
print = function() {
print(jsonlite::prettify(self$toJSONString()))
invisible(self)
}
),
# Lock the class to prevent modifications to the method or field
lock_class = TRUE
)
## Uncomment below to unlock the class to allow modifications of the method or field
# OrganizationSummary$unlock()
#
## Below is an example to define the print function
# OrganizationSummary$set("public", "print", function(...) {
# print(jsonlite::prettify(self$toJSONString()))
# invisible(self)
# })
## Uncomment below to lock the class to prevent modifications to the method or field
# OrganizationSummary$lock()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.