R/TeamSeason.r

# College Football Data API
#
# This is an API for accessing all sorts of college football data.  It currently has a wide array of data ranging from play by play to player statistics to game scores and more.
#
# OpenAPI spec version: 2.3.5
# Contact: admin@collegefootballdata.com
# Generated by: https://github.com/swagger-api/swagger-codegen.git


#' TeamSeason Class
#'
#' @field school 
#' @field year 
#' @field games 
#' @field wins 
#' @field losses 
#' @field ties 
#' @field preseason_rank 
#' @field postseason_rank 
#' @field srs 
#' @field sp_overall 
#' @field sp_offense 
#' @field sp_defense 
#'
#' @importFrom R6 R6Class
#' @importFrom jsonlite fromJSON toJSON
#' @export
TeamSeason <- R6::R6Class(
  'TeamSeason',
  public = list(
    `school` = NULL,
    `year` = NULL,
    `games` = NULL,
    `wins` = NULL,
    `losses` = NULL,
    `ties` = NULL,
    `preseason_rank` = NULL,
    `postseason_rank` = NULL,
    `srs` = NULL,
    `sp_overall` = NULL,
    `sp_offense` = NULL,
    `sp_defense` = NULL,
    initialize = function(`school`, `year`, `games`, `wins`, `losses`, `ties`, `preseason_rank`, `postseason_rank`, `srs`, `sp_overall`, `sp_offense`, `sp_defense`){
      if (!missing(`school`)) {
        stopifnot(is.character(`school`), length(`school`) == 1)
        self$`school` <- `school`
      }
      if (!missing(`year`)) {
        stopifnot(is.character(`year`), length(`year`) == 1)
        self$`year` <- `year`
      }
      if (!missing(`games`)) {
        stopifnot(is.numeric(`games`), length(`games`) == 1)
        self$`games` <- `games`
      }
      if (!missing(`wins`)) {
        stopifnot(is.numeric(`wins`), length(`wins`) == 1)
        self$`wins` <- `wins`
      }
      if (!missing(`losses`)) {
        stopifnot(is.numeric(`losses`), length(`losses`) == 1)
        self$`losses` <- `losses`
      }
      if (!missing(`ties`)) {
        stopifnot(is.numeric(`ties`), length(`ties`) == 1)
        self$`ties` <- `ties`
      }
      if (!missing(`preseason_rank`)) {
        stopifnot(is.numeric(`preseason_rank`), length(`preseason_rank`) == 1)
        self$`preseason_rank` <- `preseason_rank`
      }
      if (!missing(`postseason_rank`)) {
        stopifnot(is.numeric(`postseason_rank`), length(`postseason_rank`) == 1)
        self$`postseason_rank` <- `postseason_rank`
      }
      if (!missing(`srs`)) {
        self$`srs` <- `srs`
      }
      if (!missing(`sp_overall`)) {
        self$`sp_overall` <- `sp_overall`
      }
      if (!missing(`sp_offense`)) {
        self$`sp_offense` <- `sp_offense`
      }
      if (!missing(`sp_defense`)) {
        self$`sp_defense` <- `sp_defense`
      }
    },
    toJSON = function() {
      TeamSeasonObject <- list()
      if (!is.null(self$`school`)) {
        TeamSeasonObject[['school']] <- self$`school`
      }
      if (!is.null(self$`year`)) {
        TeamSeasonObject[['year']] <- self$`year`
      }
      if (!is.null(self$`games`)) {
        TeamSeasonObject[['games']] <- self$`games`
      }
      if (!is.null(self$`wins`)) {
        TeamSeasonObject[['wins']] <- self$`wins`
      }
      if (!is.null(self$`losses`)) {
        TeamSeasonObject[['losses']] <- self$`losses`
      }
      if (!is.null(self$`ties`)) {
        TeamSeasonObject[['ties']] <- self$`ties`
      }
      if (!is.null(self$`preseason_rank`)) {
        TeamSeasonObject[['preseason_rank']] <- self$`preseason_rank`
      }
      if (!is.null(self$`postseason_rank`)) {
        TeamSeasonObject[['postseason_rank']] <- self$`postseason_rank`
      }
      if (!is.null(self$`srs`)) {
        TeamSeasonObject[['srs']] <- self$`srs`
      }
      if (!is.null(self$`sp_overall`)) {
        TeamSeasonObject[['sp_overall']] <- self$`sp_overall`
      }
      if (!is.null(self$`sp_offense`)) {
        TeamSeasonObject[['sp_offense']] <- self$`sp_offense`
      }
      if (!is.null(self$`sp_defense`)) {
        TeamSeasonObject[['sp_defense']] <- self$`sp_defense`
      }

      TeamSeasonObject
    },
    fromJSON = function(TeamSeasonJson) {
      TeamSeasonObject <- jsonlite::fromJSON(TeamSeasonJson)
      if (!is.null(TeamSeasonObject$`school`)) {
        self$`school` <- TeamSeasonObject$`school`
      }
      if (!is.null(TeamSeasonObject$`year`)) {
        self$`year` <- TeamSeasonObject$`year`
      }
      if (!is.null(TeamSeasonObject$`games`)) {
        self$`games` <- TeamSeasonObject$`games`
      }
      if (!is.null(TeamSeasonObject$`wins`)) {
        self$`wins` <- TeamSeasonObject$`wins`
      }
      if (!is.null(TeamSeasonObject$`losses`)) {
        self$`losses` <- TeamSeasonObject$`losses`
      }
      if (!is.null(TeamSeasonObject$`ties`)) {
        self$`ties` <- TeamSeasonObject$`ties`
      }
      if (!is.null(TeamSeasonObject$`preseason_rank`)) {
        self$`preseason_rank` <- TeamSeasonObject$`preseason_rank`
      }
      if (!is.null(TeamSeasonObject$`postseason_rank`)) {
        self$`postseason_rank` <- TeamSeasonObject$`postseason_rank`
      }
      if (!is.null(TeamSeasonObject$`srs`)) {
        self$`srs` <- TeamSeasonObject$`srs`
      }
      if (!is.null(TeamSeasonObject$`sp_overall`)) {
        self$`sp_overall` <- TeamSeasonObject$`sp_overall`
      }
      if (!is.null(TeamSeasonObject$`sp_offense`)) {
        self$`sp_offense` <- TeamSeasonObject$`sp_offense`
      }
      if (!is.null(TeamSeasonObject$`sp_defense`)) {
        self$`sp_defense` <- TeamSeasonObject$`sp_defense`
      }
    },
    toJSONString = function() {
       sprintf(
        '{
           "school": %s,
           "year": %s,
           "games": %d,
           "wins": %d,
           "losses": %d,
           "ties": %d,
           "preseason_rank": %d,
           "postseason_rank": %d,
           "srs": %s,
           "sp_overall": %s,
           "sp_offense": %s,
           "sp_defense": %s
        }',
        self$`school`,
        self$`year`,
        self$`games`,
        self$`wins`,
        self$`losses`,
        self$`ties`,
        self$`preseason_rank`,
        self$`postseason_rank`,
        self$`srs`,
        self$`sp_overall`,
        self$`sp_offense`,
        self$`sp_defense`
      )
    },
    fromJSONString = function(TeamSeasonJson) {
      TeamSeasonObject <- jsonlite::fromJSON(TeamSeasonJson)
      self$`school` <- TeamSeasonObject$`school`
      self$`year` <- TeamSeasonObject$`year`
      self$`games` <- TeamSeasonObject$`games`
      self$`wins` <- TeamSeasonObject$`wins`
      self$`losses` <- TeamSeasonObject$`losses`
      self$`ties` <- TeamSeasonObject$`ties`
      self$`preseason_rank` <- TeamSeasonObject$`preseason_rank`
      self$`postseason_rank` <- TeamSeasonObject$`postseason_rank`
      self$`srs` <- TeamSeasonObject$`srs`
      self$`sp_overall` <- TeamSeasonObject$`sp_overall`
      self$`sp_offense` <- TeamSeasonObject$`sp_offense`
      self$`sp_defense` <- TeamSeasonObject$`sp_defense`
    }
  )
)
saiemgilani/cfbd-api-R documentation built on Feb. 16, 2021, 12:07 a.m.