R/atmosphere.R

# 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 Atmosphere
#'
#' @description Atmosphere Class
#'
#' @format An \code{R6Class} generator object
#'
#' @field venue  \link{Venue} 
#'
#' @field home_team  \link{Team} 
#'
#' @field temperature Temperature integer [optional]
#'
#' @importFrom R6 R6Class
#' @importFrom jsonlite fromJSON toJSON
#' @export
Atmosphere <- R6::R6Class(
  'Atmosphere',
  public = list(
    `venue` = NULL,
    `home_team` = NULL,
    `temperature` = NULL,
    initialize = function(
        `venue`, `home_team`, `temperature`=70, ...
    ) {
      local.optional.var <- list(...)
      if (length(local.optional.var) > 0) {
        stop(paste("Unknown argument(s) in initialize of object Atmosphere:", paste(names(local.optional.var), collapse=", "), collapse=" "))
      }
      if (!missing(`venue`)) {
        stopifnot(R6::is.R6(`venue`))
        self$`venue` <- `venue`
      }
      if (!missing(`home_team`)) {
        stopifnot(R6::is.R6(`home_team`))
        self$`home_team` <- `home_team`
      }
      if (!is.null(`temperature`)) {
        stopifnot(is.numeric(`temperature`), length(`temperature`) == 1)
        self$`temperature` <- `temperature`
      }
    },
    toJSON = function() {
      AtmosphereObject <- list()
      if (!is.null(self$`venue`)) {
        AtmosphereObject[['venue']] <-
          self$`venue`$toJSON()
      }
      if (!is.null(self$`home_team`)) {
        AtmosphereObject[['home_team']] <-
          self$`home_team`$toJSON()
      }
      if (!is.null(self$`temperature`)) {
        AtmosphereObject[['temperature']] <-
          self$`temperature`
      }

      AtmosphereObject
    },
    fromJSON = function(AtmosphereJson) {
      AtmosphereObject <- jsonlite::fromJSON(AtmosphereJson)
      if (!is.null(AtmosphereObject$`venue`)) {
        venueObject <- Venue$new()
        venueObject$fromJSON(jsonlite::toJSON(AtmosphereObject$venue, auto_unbox = TRUE, digits = NA))
        self$`venue` <- venueObject
      }
      if (!is.null(AtmosphereObject$`home_team`)) {
        home_teamObject <- Team$new()
        home_teamObject$fromJSON(jsonlite::toJSON(AtmosphereObject$home_team, auto_unbox = TRUE, digits = NA))
        self$`home_team` <- home_teamObject
      }
      if (!is.null(AtmosphereObject$`temperature`)) {
        self$`temperature` <- AtmosphereObject$`temperature`
      }
      self
    },
    toJSONString = function() {
      jsoncontent <- c(
        if (!is.null(self$`venue`)) {
        sprintf(
        '"venue":
        %s
        ',
        jsonlite::toJSON(self$`venue`$toJSON(), auto_unbox=TRUE, digits = NA)
        )},
        if (!is.null(self$`home_team`)) {
        sprintf(
        '"home_team":
        %s
        ',
        jsonlite::toJSON(self$`home_team`$toJSON(), auto_unbox=TRUE, digits = NA)
        )},
        if (!is.null(self$`temperature`)) {
        sprintf(
        '"temperature":
          %d
                ',
        self$`temperature`
        )}
      )
      jsoncontent <- paste(jsoncontent, collapse = ",")
      paste('{', jsoncontent, '}', sep = "")
    },
    fromJSONString = function(AtmosphereJson) {
      AtmosphereObject <- jsonlite::fromJSON(AtmosphereJson)
      self$`venue` <- Venue$new()$fromJSON(jsonlite::toJSON(AtmosphereObject$venue, auto_unbox = TRUE, digits = NA))
      self$`home_team` <- Team$new()$fromJSON(jsonlite::toJSON(AtmosphereObject$home_team, auto_unbox = TRUE, digits = NA))
      self$`temperature` <- AtmosphereObject$`temperature`
      self
    }
  )
)
singlearity-sports/singlearity-R documentation built on April 21, 2022, 3:48 a.m.