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


#' Team Class
#'
#' @field id 
#' @field school 
#' @field mascot 
#' @field abbreviation 
#' @field alt_name_1 
#' @field alt_name_2 
#' @field alt_name_3 
#' @field conference 
#' @field division 
#' @field color 
#' @field alt_color 
#' @field logos 
#'
#' @importFrom R6 R6Class
#' @importFrom jsonlite fromJSON toJSON
#' @export
Team <- R6::R6Class(
  'Team',
  public = list(
    `id` = NULL,
    `school` = NULL,
    `mascot` = NULL,
    `abbreviation` = NULL,
    `alt_name_1` = NULL,
    `alt_name_2` = NULL,
    `alt_name_3` = NULL,
    `conference` = NULL,
    `division` = NULL,
    `color` = NULL,
    `alt_color` = NULL,
    `logos` = NULL,
    initialize = function(`id`, `school`, `mascot`, `abbreviation`, `alt_name_1`, `alt_name_2`, `alt_name_3`, `conference`, `division`, `color`, `alt_color`, `logos`){
      if (!missing(`id`)) {
        stopifnot(is.numeric(`id`), length(`id`) == 1)
        self$`id` <- `id`
      }
      if (!missing(`school`)) {
        stopifnot(is.character(`school`), length(`school`) == 1)
        self$`school` <- `school`
      }
      if (!missing(`mascot`)) {
        stopifnot(is.character(`mascot`), length(`mascot`) == 1)
        self$`mascot` <- `mascot`
      }
      if (!missing(`abbreviation`)) {
        stopifnot(is.character(`abbreviation`), length(`abbreviation`) == 1)
        self$`abbreviation` <- `abbreviation`
      }
      if (!missing(`alt_name_1`)) {
        stopifnot(is.character(`alt_name_1`), length(`alt_name_1`) == 1)
        self$`alt_name_1` <- `alt_name_1`
      }
      if (!missing(`alt_name_2`)) {
        stopifnot(is.character(`alt_name_2`), length(`alt_name_2`) == 1)
        self$`alt_name_2` <- `alt_name_2`
      }
      if (!missing(`alt_name_3`)) {
        stopifnot(is.character(`alt_name_3`), length(`alt_name_3`) == 1)
        self$`alt_name_3` <- `alt_name_3`
      }
      if (!missing(`conference`)) {
        stopifnot(is.character(`conference`), length(`conference`) == 1)
        self$`conference` <- `conference`
      }
      if (!missing(`division`)) {
        stopifnot(is.character(`division`), length(`division`) == 1)
        self$`division` <- `division`
      }
      if (!missing(`color`)) {
        stopifnot(is.character(`color`), length(`color`) == 1)
        self$`color` <- `color`
      }
      if (!missing(`alt_color`)) {
        stopifnot(is.character(`alt_color`), length(`alt_color`) == 1)
        self$`alt_color` <- `alt_color`
      }
      if (!missing(`logos`)) {
        stopifnot(is.list(`logos`), length(`logos`) != 0)
        lapply(`logos`, function(x) stopifnot(is.character(x)))
        self$`logos` <- `logos`
      }
    },
    toJSON = function() {
      TeamObject <- list()
      if (!is.null(self$`id`)) {
        TeamObject[['id']] <- self$`id`
      }
      if (!is.null(self$`school`)) {
        TeamObject[['school']] <- self$`school`
      }
      if (!is.null(self$`mascot`)) {
        TeamObject[['mascot']] <- self$`mascot`
      }
      if (!is.null(self$`abbreviation`)) {
        TeamObject[['abbreviation']] <- self$`abbreviation`
      }
      if (!is.null(self$`alt_name_1`)) {
        TeamObject[['alt_name_1']] <- self$`alt_name_1`
      }
      if (!is.null(self$`alt_name_2`)) {
        TeamObject[['alt_name_2']] <- self$`alt_name_2`
      }
      if (!is.null(self$`alt_name_3`)) {
        TeamObject[['alt_name_3']] <- self$`alt_name_3`
      }
      if (!is.null(self$`conference`)) {
        TeamObject[['conference']] <- self$`conference`
      }
      if (!is.null(self$`division`)) {
        TeamObject[['division']] <- self$`division`
      }
      if (!is.null(self$`color`)) {
        TeamObject[['color']] <- self$`color`
      }
      if (!is.null(self$`alt_color`)) {
        TeamObject[['alt_color']] <- self$`alt_color`
      }
      if (!is.null(self$`logos`)) {
        TeamObject[['logos']] <- self$`logos`
      }

      TeamObject
    },
    fromJSON = function(TeamJson) {
      TeamObject <- jsonlite::fromJSON(TeamJson)
      if (!is.null(TeamObject$`id`)) {
        self$`id` <- TeamObject$`id`
      }
      if (!is.null(TeamObject$`school`)) {
        self$`school` <- TeamObject$`school`
      }
      if (!is.null(TeamObject$`mascot`)) {
        self$`mascot` <- TeamObject$`mascot`
      }
      if (!is.null(TeamObject$`abbreviation`)) {
        self$`abbreviation` <- TeamObject$`abbreviation`
      }
      if (!is.null(TeamObject$`alt_name_1`)) {
        self$`alt_name_1` <- TeamObject$`alt_name_1`
      }
      if (!is.null(TeamObject$`alt_name_2`)) {
        self$`alt_name_2` <- TeamObject$`alt_name_2`
      }
      if (!is.null(TeamObject$`alt_name_3`)) {
        self$`alt_name_3` <- TeamObject$`alt_name_3`
      }
      if (!is.null(TeamObject$`conference`)) {
        self$`conference` <- TeamObject$`conference`
      }
      if (!is.null(TeamObject$`division`)) {
        self$`division` <- TeamObject$`division`
      }
      if (!is.null(TeamObject$`color`)) {
        self$`color` <- TeamObject$`color`
      }
      if (!is.null(TeamObject$`alt_color`)) {
        self$`alt_color` <- TeamObject$`alt_color`
      }
      if (!is.null(TeamObject$`logos`)) {
        self$`logos` <- TeamObject$`logos`
      }
    },
    toJSONString = function() {
       sprintf(
        '{
           "id": %d,
           "school": %s,
           "mascot": %s,
           "abbreviation": %s,
           "alt_name_1": %s,
           "alt_name_2": %s,
           "alt_name_3": %s,
           "conference": %s,
           "division": %s,
           "color": %s,
           "alt_color": %s,
           "logos": [%s]
        }',
        self$`id`,
        self$`school`,
        self$`mascot`,
        self$`abbreviation`,
        self$`alt_name_1`,
        self$`alt_name_2`,
        self$`alt_name_3`,
        self$`conference`,
        self$`division`,
        self$`color`,
        self$`alt_color`,
        lapply(self$`logos`, function(x) paste(paste0('"', x, '"'), sep=","))
      )
    },
    fromJSONString = function(TeamJson) {
      TeamObject <- jsonlite::fromJSON(TeamJson)
      self$`id` <- TeamObject$`id`
      self$`school` <- TeamObject$`school`
      self$`mascot` <- TeamObject$`mascot`
      self$`abbreviation` <- TeamObject$`abbreviation`
      self$`alt_name_1` <- TeamObject$`alt_name_1`
      self$`alt_name_2` <- TeamObject$`alt_name_2`
      self$`alt_name_3` <- TeamObject$`alt_name_3`
      self$`conference` <- TeamObject$`conference`
      self$`division` <- TeamObject$`division`
      self$`color` <- TeamObject$`color`
      self$`alt_color` <- TeamObject$`alt_color`
      self$`logos` <- TeamObject$`logos`
    }
  )
)
saiemgilani/cfbd-api-R documentation built on Feb. 16, 2021, 12:07 a.m.