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


#' Player Class
#'
#' @field id 
#' @field first_name 
#' @field last_name 
#' @field team 
#' @field height 
#' @field weight 
#' @field jersey 
#' @field year 
#' @field position 
#' @field city 
#' @field state 
#' @field country 
#'
#' @importFrom R6 R6Class
#' @importFrom jsonlite fromJSON toJSON
#' @export
Player <- R6::R6Class(
  'Player',
  public = list(
    `id` = NULL,
    `first_name` = NULL,
    `last_name` = NULL,
    `team` = NULL,
    `height` = NULL,
    `weight` = NULL,
    `jersey` = NULL,
    `year` = NULL,
    `position` = NULL,
    `city` = NULL,
    `state` = NULL,
    `country` = NULL,
    initialize = function(`id`, `first_name`, `last_name`, `team`, `height`, `weight`, `jersey`, `year`, `position`, `city`, `state`, `country`){
      if (!missing(`id`)) {
        stopifnot(is.numeric(`id`), length(`id`) == 1)
        self$`id` <- `id`
      }
      if (!missing(`first_name`)) {
        stopifnot(is.character(`first_name`), length(`first_name`) == 1)
        self$`first_name` <- `first_name`
      }
      if (!missing(`last_name`)) {
        stopifnot(is.character(`last_name`), length(`last_name`) == 1)
        self$`last_name` <- `last_name`
      }
      if (!missing(`team`)) {
        stopifnot(is.character(`team`), length(`team`) == 1)
        self$`team` <- `team`
      }
      if (!missing(`height`)) {
        stopifnot(is.numeric(`height`), length(`height`) == 1)
        self$`height` <- `height`
      }
      if (!missing(`weight`)) {
        stopifnot(is.numeric(`weight`), length(`weight`) == 1)
        self$`weight` <- `weight`
      }
      if (!missing(`jersey`)) {
        stopifnot(is.numeric(`jersey`), length(`jersey`) == 1)
        self$`jersey` <- `jersey`
      }
      if (!missing(`year`)) {
        stopifnot(is.numeric(`year`), length(`year`) == 1)
        self$`year` <- `year`
      }
      if (!missing(`position`)) {
        stopifnot(is.character(`position`), length(`position`) == 1)
        self$`position` <- `position`
      }
      if (!missing(`city`)) {
        stopifnot(is.character(`city`), length(`city`) == 1)
        self$`city` <- `city`
      }
      if (!missing(`state`)) {
        stopifnot(is.character(`state`), length(`state`) == 1)
        self$`state` <- `state`
      }
      if (!missing(`country`)) {
        stopifnot(is.character(`country`), length(`country`) == 1)
        self$`country` <- `country`
      }
    },
    toJSON = function() {
      PlayerObject <- list()
      if (!is.null(self$`id`)) {
        PlayerObject[['id']] <- self$`id`
      }
      if (!is.null(self$`first_name`)) {
        PlayerObject[['first_name']] <- self$`first_name`
      }
      if (!is.null(self$`last_name`)) {
        PlayerObject[['last_name']] <- self$`last_name`
      }
      if (!is.null(self$`team`)) {
        PlayerObject[['team']] <- self$`team`
      }
      if (!is.null(self$`height`)) {
        PlayerObject[['height']] <- self$`height`
      }
      if (!is.null(self$`weight`)) {
        PlayerObject[['weight']] <- self$`weight`
      }
      if (!is.null(self$`jersey`)) {
        PlayerObject[['jersey']] <- self$`jersey`
      }
      if (!is.null(self$`year`)) {
        PlayerObject[['year']] <- self$`year`
      }
      if (!is.null(self$`position`)) {
        PlayerObject[['position']] <- self$`position`
      }
      if (!is.null(self$`city`)) {
        PlayerObject[['city']] <- self$`city`
      }
      if (!is.null(self$`state`)) {
        PlayerObject[['state']] <- self$`state`
      }
      if (!is.null(self$`country`)) {
        PlayerObject[['country']] <- self$`country`
      }

      PlayerObject
    },
    fromJSON = function(PlayerJson) {
      PlayerObject <- jsonlite::fromJSON(PlayerJson)
      if (!is.null(PlayerObject$`id`)) {
        self$`id` <- PlayerObject$`id`
      }
      if (!is.null(PlayerObject$`first_name`)) {
        self$`first_name` <- PlayerObject$`first_name`
      }
      if (!is.null(PlayerObject$`last_name`)) {
        self$`last_name` <- PlayerObject$`last_name`
      }
      if (!is.null(PlayerObject$`team`)) {
        self$`team` <- PlayerObject$`team`
      }
      if (!is.null(PlayerObject$`height`)) {
        self$`height` <- PlayerObject$`height`
      }
      if (!is.null(PlayerObject$`weight`)) {
        self$`weight` <- PlayerObject$`weight`
      }
      if (!is.null(PlayerObject$`jersey`)) {
        self$`jersey` <- PlayerObject$`jersey`
      }
      if (!is.null(PlayerObject$`year`)) {
        self$`year` <- PlayerObject$`year`
      }
      if (!is.null(PlayerObject$`position`)) {
        self$`position` <- PlayerObject$`position`
      }
      if (!is.null(PlayerObject$`city`)) {
        self$`city` <- PlayerObject$`city`
      }
      if (!is.null(PlayerObject$`state`)) {
        self$`state` <- PlayerObject$`state`
      }
      if (!is.null(PlayerObject$`country`)) {
        self$`country` <- PlayerObject$`country`
      }
    },
    toJSONString = function() {
       sprintf(
        '{
           "id": %d,
           "first_name": %s,
           "last_name": %s,
           "team": %s,
           "height": %d,
           "weight": %d,
           "jersey": %d,
           "year": %d,
           "position": %s,
           "city": %s,
           "state": %s,
           "country": %s
        }',
        self$`id`,
        self$`first_name`,
        self$`last_name`,
        self$`team`,
        self$`height`,
        self$`weight`,
        self$`jersey`,
        self$`year`,
        self$`position`,
        self$`city`,
        self$`state`,
        self$`country`
      )
    },
    fromJSONString = function(PlayerJson) {
      PlayerObject <- jsonlite::fromJSON(PlayerJson)
      self$`id` <- PlayerObject$`id`
      self$`first_name` <- PlayerObject$`first_name`
      self$`last_name` <- PlayerObject$`last_name`
      self$`team` <- PlayerObject$`team`
      self$`height` <- PlayerObject$`height`
      self$`weight` <- PlayerObject$`weight`
      self$`jersey` <- PlayerObject$`jersey`
      self$`year` <- PlayerObject$`year`
      self$`position` <- PlayerObject$`position`
      self$`city` <- PlayerObject$`city`
      self$`state` <- PlayerObject$`state`
      self$`country` <- PlayerObject$`country`
    }
  )
)
saiemgilani/cfbd-api-R documentation built on Feb. 16, 2021, 12:07 a.m.