# Singlearity Baseball API
#
# Baseball optimization API using machine learning
#
# The version of the OpenAPI document: 0.1.1
#
# Generated by: https://openapi-generator.tech
#' @docType class
#' @title Game
#'
#' @description Game Class
#'
#' @format An \code{R6Class} generator object
#'
#' @field home_lineup \link{Lineup}
#'
#' @field visit_lineup \link{Lineup}
#'
#' @field atmosphere \link{Atmosphere}
#'
#' @field date Date character [optional]
#'
#' @importFrom R6 R6Class
#' @importFrom jsonlite fromJSON toJSON
#' @export
Game <- R6::R6Class(
'Game',
public = list(
`home_lineup` = NULL,
`visit_lineup` = NULL,
`atmosphere` = NULL,
`date` = NULL,
initialize = function(
`home_lineup`, `visit_lineup`, `atmosphere`, `date`='2019-09-29', ...
) {
local.optional.var <- list(...)
if (length(local.optional.var) > 0) {
stop(paste("Unknown argument(s) in initialize of object Game:", paste(names(local.optional.var), collapse=", "), collapse=" "))
}
if (!missing(`home_lineup`)) {
stopifnot(R6::is.R6(`home_lineup`))
self$`home_lineup` <- `home_lineup`
}
if (!missing(`visit_lineup`)) {
stopifnot(R6::is.R6(`visit_lineup`))
self$`visit_lineup` <- `visit_lineup`
}
if (!missing(`atmosphere`)) {
stopifnot(R6::is.R6(`atmosphere`))
self$`atmosphere` <- `atmosphere`
}
if (!is.null(`date`)) {
stopifnot(is.character(`date`), length(`date`) == 1)
self$`date` <- `date`
}
},
toJSON = function() {
GameObject <- list()
if (!is.null(self$`home_lineup`)) {
GameObject[['home_lineup']] <-
self$`home_lineup`$toJSON()
}
if (!is.null(self$`visit_lineup`)) {
GameObject[['visit_lineup']] <-
self$`visit_lineup`$toJSON()
}
if (!is.null(self$`atmosphere`)) {
GameObject[['atmosphere']] <-
self$`atmosphere`$toJSON()
}
if (!is.null(self$`date`)) {
GameObject[['date']] <-
self$`date`
}
GameObject
},
fromJSON = function(GameJson) {
GameObject <- jsonlite::fromJSON(GameJson)
if (!is.null(GameObject$`home_lineup`)) {
home_lineupObject <- Lineup$new()
home_lineupObject$fromJSON(jsonlite::toJSON(GameObject$home_lineup, auto_unbox = TRUE, digits = NA))
self$`home_lineup` <- home_lineupObject
}
if (!is.null(GameObject$`visit_lineup`)) {
visit_lineupObject <- Lineup$new()
visit_lineupObject$fromJSON(jsonlite::toJSON(GameObject$visit_lineup, auto_unbox = TRUE, digits = NA))
self$`visit_lineup` <- visit_lineupObject
}
if (!is.null(GameObject$`atmosphere`)) {
atmosphereObject <- Atmosphere$new()
atmosphereObject$fromJSON(jsonlite::toJSON(GameObject$atmosphere, auto_unbox = TRUE, digits = NA))
self$`atmosphere` <- atmosphereObject
}
if (!is.null(GameObject$`date`)) {
self$`date` <- GameObject$`date`
}
self
},
toJSONString = function() {
jsoncontent <- c(
if (!is.null(self$`home_lineup`)) {
sprintf(
'"home_lineup":
%s
',
jsonlite::toJSON(self$`home_lineup`$toJSON(), auto_unbox=TRUE, digits = NA)
)},
if (!is.null(self$`visit_lineup`)) {
sprintf(
'"visit_lineup":
%s
',
jsonlite::toJSON(self$`visit_lineup`$toJSON(), auto_unbox=TRUE, digits = NA)
)},
if (!is.null(self$`atmosphere`)) {
sprintf(
'"atmosphere":
%s
',
jsonlite::toJSON(self$`atmosphere`$toJSON(), auto_unbox=TRUE, digits = NA)
)},
if (!is.null(self$`date`)) {
sprintf(
'"date":
"%s"
',
self$`date`
)}
)
jsoncontent <- paste(jsoncontent, collapse = ",")
paste('{', jsoncontent, '}', sep = "")
},
fromJSONString = function(GameJson) {
GameObject <- jsonlite::fromJSON(GameJson)
self$`home_lineup` <- Lineup$new()$fromJSON(jsonlite::toJSON(GameObject$home_lineup, auto_unbox = TRUE, digits = NA))
self$`visit_lineup` <- Lineup$new()$fromJSON(jsonlite::toJSON(GameObject$visit_lineup, auto_unbox = TRUE, digits = NA))
self$`atmosphere` <- Atmosphere$new()$fromJSON(jsonlite::toJSON(GameObject$atmosphere, auto_unbox = TRUE, digits = NA))
self$`date` <- GameObject$`date`
self
}
)
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.