R/Week.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


#' Week Class
#'
#' @field season 
#' @field week 
#' @field seasonType 
#' @field firstGameStart 
#' @field lastGameStart 
#'
#' @importFrom R6 R6Class
#' @importFrom jsonlite fromJSON toJSON
#' @export
Week <- R6::R6Class(
  'Week',
  public = list(
    `season` = NULL,
    `week` = NULL,
    `seasonType` = NULL,
    `firstGameStart` = NULL,
    `lastGameStart` = NULL,
    initialize = function(`season`, `week`, `seasonType`, `firstGameStart`, `lastGameStart`){
      if (!missing(`season`)) {
        stopifnot(is.numeric(`season`), length(`season`) == 1)
        self$`season` <- `season`
      }
      if (!missing(`week`)) {
        stopifnot(is.numeric(`week`), length(`week`) == 1)
        self$`week` <- `week`
      }
      if (!missing(`seasonType`)) {
        stopifnot(is.character(`seasonType`), length(`seasonType`) == 1)
        self$`seasonType` <- `seasonType`
      }
      if (!missing(`firstGameStart`)) {
        stopifnot(is.character(`firstGameStart`), length(`firstGameStart`) == 1)
        self$`firstGameStart` <- `firstGameStart`
      }
      if (!missing(`lastGameStart`)) {
        stopifnot(is.character(`lastGameStart`), length(`lastGameStart`) == 1)
        self$`lastGameStart` <- `lastGameStart`
      }
    },
    toJSON = function() {
      WeekObject <- list()
      if (!is.null(self$`season`)) {
        WeekObject[['season']] <- self$`season`
      }
      if (!is.null(self$`week`)) {
        WeekObject[['week']] <- self$`week`
      }
      if (!is.null(self$`seasonType`)) {
        WeekObject[['seasonType']] <- self$`seasonType`
      }
      if (!is.null(self$`firstGameStart`)) {
        WeekObject[['firstGameStart']] <- self$`firstGameStart`
      }
      if (!is.null(self$`lastGameStart`)) {
        WeekObject[['lastGameStart']] <- self$`lastGameStart`
      }

      WeekObject
    },
    fromJSON = function(WeekJson) {
      WeekObject <- jsonlite::fromJSON(WeekJson)
      if (!is.null(WeekObject$`season`)) {
        self$`season` <- WeekObject$`season`
      }
      if (!is.null(WeekObject$`week`)) {
        self$`week` <- WeekObject$`week`
      }
      if (!is.null(WeekObject$`seasonType`)) {
        self$`seasonType` <- WeekObject$`seasonType`
      }
      if (!is.null(WeekObject$`firstGameStart`)) {
        self$`firstGameStart` <- WeekObject$`firstGameStart`
      }
      if (!is.null(WeekObject$`lastGameStart`)) {
        self$`lastGameStart` <- WeekObject$`lastGameStart`
      }
    },
    toJSONString = function() {
       sprintf(
        '{
           "season": %d,
           "week": %d,
           "seasonType": %s,
           "firstGameStart": %s,
           "lastGameStart": %s
        }',
        self$`season`,
        self$`week`,
        self$`seasonType`,
        self$`firstGameStart`,
        self$`lastGameStart`
      )
    },
    fromJSONString = function(WeekJson) {
      WeekObject <- jsonlite::fromJSON(WeekJson)
      self$`season` <- WeekObject$`season`
      self$`week` <- WeekObject$`week`
      self$`seasonType` <- WeekObject$`seasonType`
      self$`firstGameStart` <- WeekObject$`firstGameStart`
      self$`lastGameStart` <- WeekObject$`lastGameStart`
    }
  )
)
saiemgilani/cfbd-api-R documentation built on Feb. 16, 2021, 12:07 a.m.