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


#' PlayerUsage Class
#'
#' @field season 
#' @field id 
#' @field name 
#' @field position 
#' @field team 
#' @field conference 
#' @field usage 
#'
#' @importFrom R6 R6Class
#' @importFrom jsonlite fromJSON toJSON
#' @export
PlayerUsage <- R6::R6Class(
  'PlayerUsage',
  public = list(
    `season` = NULL,
    `id` = NULL,
    `name` = NULL,
    `position` = NULL,
    `team` = NULL,
    `conference` = NULL,
    `usage` = NULL,
    initialize = function(`season`, `id`, `name`, `position`, `team`, `conference`, `usage`){
      if (!missing(`season`)) {
        stopifnot(is.numeric(`season`), length(`season`) == 1)
        self$`season` <- `season`
      }
      if (!missing(`id`)) {
        stopifnot(is.numeric(`id`), length(`id`) == 1)
        self$`id` <- `id`
      }
      if (!missing(`name`)) {
        stopifnot(is.character(`name`), length(`name`) == 1)
        self$`name` <- `name`
      }
      if (!missing(`position`)) {
        stopifnot(is.character(`position`), length(`position`) == 1)
        self$`position` <- `position`
      }
      if (!missing(`team`)) {
        stopifnot(is.character(`team`), length(`team`) == 1)
        self$`team` <- `team`
      }
      if (!missing(`conference`)) {
        stopifnot(is.character(`conference`), length(`conference`) == 1)
        self$`conference` <- `conference`
      }
      if (!missing(`usage`)) {
        stopifnot(R6::is.R6(`usage`))
        self$`usage` <- `usage`
      }
    },
    toJSON = function() {
      PlayerUsageObject <- list()
      if (!is.null(self$`season`)) {
        PlayerUsageObject[['season']] <- self$`season`
      }
      if (!is.null(self$`id`)) {
        PlayerUsageObject[['id']] <- self$`id`
      }
      if (!is.null(self$`name`)) {
        PlayerUsageObject[['name']] <- self$`name`
      }
      if (!is.null(self$`position`)) {
        PlayerUsageObject[['position']] <- self$`position`
      }
      if (!is.null(self$`team`)) {
        PlayerUsageObject[['team']] <- self$`team`
      }
      if (!is.null(self$`conference`)) {
        PlayerUsageObject[['conference']] <- self$`conference`
      }
      if (!is.null(self$`usage`)) {
        PlayerUsageObject[['usage']] <- self$`usage`$toJSON()
      }

      PlayerUsageObject
    },
    fromJSON = function(PlayerUsageJson) {
      PlayerUsageObject <- jsonlite::fromJSON(PlayerUsageJson)
      if (!is.null(PlayerUsageObject$`season`)) {
        self$`season` <- PlayerUsageObject$`season`
      }
      if (!is.null(PlayerUsageObject$`id`)) {
        self$`id` <- PlayerUsageObject$`id`
      }
      if (!is.null(PlayerUsageObject$`name`)) {
        self$`name` <- PlayerUsageObject$`name`
      }
      if (!is.null(PlayerUsageObject$`position`)) {
        self$`position` <- PlayerUsageObject$`position`
      }
      if (!is.null(PlayerUsageObject$`team`)) {
        self$`team` <- PlayerUsageObject$`team`
      }
      if (!is.null(PlayerUsageObject$`conference`)) {
        self$`conference` <- PlayerUsageObject$`conference`
      }
      if (!is.null(PlayerUsageObject$`usage`)) {
        usageObject <- PlayerUsageUsage$new()
        usageObject$fromJSON(jsonlite::toJSON(PlayerUsageObject$usage, auto_unbox = TRUE))
        self$`usage` <- usageObject
      }
    },
    toJSONString = function() {
       sprintf(
        '{
           "season": %d,
           "id": %d,
           "name": %s,
           "position": %s,
           "team": %s,
           "conference": %s,
           "usage": %s
        }',
        self$`season`,
        self$`id`,
        self$`name`,
        self$`position`,
        self$`team`,
        self$`conference`,
        self$`usage`$toJSON()
      )
    },
    fromJSONString = function(PlayerUsageJson) {
      PlayerUsageObject <- jsonlite::fromJSON(PlayerUsageJson)
      self$`season` <- PlayerUsageObject$`season`
      self$`id` <- PlayerUsageObject$`id`
      self$`name` <- PlayerUsageObject$`name`
      self$`position` <- PlayerUsageObject$`position`
      self$`team` <- PlayerUsageObject$`team`
      self$`conference` <- PlayerUsageObject$`conference`
      PlayerUsageUsageObject <- PlayerUsageUsage$new()
      self$`usage` <- PlayerUsageUsageObject$fromJSON(jsonlite::toJSON(PlayerUsageObject$usage, auto_unbox = TRUE))
    }
  )
)
saiemgilani/cfbd-api-R documentation built on Feb. 16, 2021, 12:07 a.m.