R/player.R

# Singlearity Baseball API
#
# Baseball optimization API using machine learning
#
# The version of the OpenAPI document: 0.1.1
# 
# Generated by: https://openapi-generator.tech

#' @docType class
#' @title Player
#'
#' @description Player Class
#'
#' @format An \code{R6Class} generator object
#'
#' @field full_name Full Name character 
#'
#' @field position Position character 
#'
#' @field mlb_id Mlb Id integer 
#'
#' @field debut_date Debut Date character 
#'
#' @field team_id Team Id integer 
#'
#' @field team_abbrev Team Abbrev character 
#'
#' @field active Active character 
#'
#' @field bat_side Bat Side character 
#'
#' @field pitch_hand Pitch Hand character 
#'
#' @field birth_country Birth Country character 
#'
#' @field birth_date Birth Date character 
#'
#' @field current_age Current Age integer 
#'
#' @field photo_url Photo Url character 
#'
#' @importFrom R6 R6Class
#' @importFrom jsonlite fromJSON toJSON
#' @export
Player <- R6::R6Class(
  'Player',
  public = list(
    `full_name` = NULL,
    `position` = NULL,
    `mlb_id` = NULL,
    `debut_date` = NULL,
    `team_id` = NULL,
    `team_abbrev` = NULL,
    `active` = NULL,
    `bat_side` = NULL,
    `pitch_hand` = NULL,
    `birth_country` = NULL,
    `birth_date` = NULL,
    `current_age` = NULL,
    `photo_url` = NULL,
    initialize = function(
        `full_name`, `position`, `mlb_id`, `debut_date`, `team_id`, `team_abbrev`, `active`, `bat_side`, `pitch_hand`, `birth_country`, `birth_date`, `current_age`, `photo_url`, ...
    ) {
      local.optional.var <- list(...)
      if (length(local.optional.var) > 0) {
        stop(paste("Unknown argument(s) in initialize of object Player:", paste(names(local.optional.var), collapse=", "), collapse=" "))
      }
      if (!missing(`full_name`)) {
        stopifnot(is.character(`full_name`), length(`full_name`) == 1)
        self$`full_name` <- `full_name`
      }
      if (!missing(`position`)) {
        stopifnot(is.character(`position`), length(`position`) == 1)
        self$`position` <- `position`
      }
      if (!missing(`mlb_id`)) {
        stopifnot(is.numeric(`mlb_id`), length(`mlb_id`) == 1)
        self$`mlb_id` <- `mlb_id`
      }
      if (!missing(`debut_date`)) {
        stopifnot(is.character(`debut_date`), length(`debut_date`) == 1)
        self$`debut_date` <- `debut_date`
      }
      if (!missing(`team_id`)) {
        stopifnot(is.numeric(`team_id`), length(`team_id`) == 1)
        self$`team_id` <- `team_id`
      }
      if (!missing(`team_abbrev`)) {
        stopifnot(is.character(`team_abbrev`), length(`team_abbrev`) == 1)
        self$`team_abbrev` <- `team_abbrev`
      }
      if (!missing(`active`)) {
        self$`active` <- `active`
      }
      if (!missing(`bat_side`)) {
        stopifnot(is.character(`bat_side`), length(`bat_side`) == 1)
        self$`bat_side` <- `bat_side`
      }
      if (!missing(`pitch_hand`)) {
        stopifnot(is.character(`pitch_hand`), length(`pitch_hand`) == 1)
        self$`pitch_hand` <- `pitch_hand`
      }
      if (!missing(`birth_country`)) {
        stopifnot(is.character(`birth_country`), length(`birth_country`) == 1)
        self$`birth_country` <- `birth_country`
      }
      if (!missing(`birth_date`)) {
        stopifnot(is.character(`birth_date`), length(`birth_date`) == 1)
        self$`birth_date` <- `birth_date`
      }
      if (!missing(`current_age`)) {
        stopifnot(is.numeric(`current_age`), length(`current_age`) == 1)
        self$`current_age` <- `current_age`
      }
      if (!missing(`photo_url`)) {
        stopifnot(is.character(`photo_url`), length(`photo_url`) == 1)
        self$`photo_url` <- `photo_url`
      }
    },
    toJSON = function() {
      PlayerObject <- list()
      if (!is.null(self$`full_name`)) {
        PlayerObject[['full_name']] <-
          self$`full_name`
      }
      if (!is.null(self$`position`)) {
        PlayerObject[['position']] <-
          self$`position`
      }
      if (!is.null(self$`mlb_id`)) {
        PlayerObject[['mlb_id']] <-
          self$`mlb_id`
      }
      if (!is.null(self$`debut_date`)) {
        PlayerObject[['debut_date']] <-
          self$`debut_date`
      }
      if (!is.null(self$`team_id`)) {
        PlayerObject[['team_id']] <-
          self$`team_id`
      }
      if (!is.null(self$`team_abbrev`)) {
        PlayerObject[['team_abbrev']] <-
          self$`team_abbrev`
      }
      if (!is.null(self$`active`)) {
        PlayerObject[['active']] <-
          self$`active`
      }
      if (!is.null(self$`bat_side`)) {
        PlayerObject[['bat_side']] <-
          self$`bat_side`
      }
      if (!is.null(self$`pitch_hand`)) {
        PlayerObject[['pitch_hand']] <-
          self$`pitch_hand`
      }
      if (!is.null(self$`birth_country`)) {
        PlayerObject[['birth_country']] <-
          self$`birth_country`
      }
      if (!is.null(self$`birth_date`)) {
        PlayerObject[['birth_date']] <-
          self$`birth_date`
      }
      if (!is.null(self$`current_age`)) {
        PlayerObject[['current_age']] <-
          self$`current_age`
      }
      if (!is.null(self$`photo_url`)) {
        PlayerObject[['photo_url']] <-
          self$`photo_url`
      }

      PlayerObject
    },
    fromJSON = function(PlayerJson) {
      PlayerObject <- jsonlite::fromJSON(PlayerJson)
      if (!is.null(PlayerObject$`full_name`)) {
        self$`full_name` <- PlayerObject$`full_name`
      }
      if (!is.null(PlayerObject$`position`)) {
        self$`position` <- PlayerObject$`position`
      }
      if (!is.null(PlayerObject$`mlb_id`)) {
        self$`mlb_id` <- PlayerObject$`mlb_id`
      }
      if (!is.null(PlayerObject$`debut_date`)) {
        self$`debut_date` <- PlayerObject$`debut_date`
      }
      if (!is.null(PlayerObject$`team_id`)) {
        self$`team_id` <- PlayerObject$`team_id`
      }
      if (!is.null(PlayerObject$`team_abbrev`)) {
        self$`team_abbrev` <- PlayerObject$`team_abbrev`
      }
      if (!is.null(PlayerObject$`active`)) {
        self$`active` <- PlayerObject$`active`
      }
      if (!is.null(PlayerObject$`bat_side`)) {
        self$`bat_side` <- PlayerObject$`bat_side`
      }
      if (!is.null(PlayerObject$`pitch_hand`)) {
        self$`pitch_hand` <- PlayerObject$`pitch_hand`
      }
      if (!is.null(PlayerObject$`birth_country`)) {
        self$`birth_country` <- PlayerObject$`birth_country`
      }
      if (!is.null(PlayerObject$`birth_date`)) {
        self$`birth_date` <- PlayerObject$`birth_date`
      }
      if (!is.null(PlayerObject$`current_age`)) {
        self$`current_age` <- PlayerObject$`current_age`
      }
      if (!is.null(PlayerObject$`photo_url`)) {
        self$`photo_url` <- PlayerObject$`photo_url`
      }
      self
    },
    toJSONString = function() {
      jsoncontent <- c(
        if (!is.null(self$`full_name`)) {
        sprintf(
        '"full_name":
          "%s"
                ',
        self$`full_name`
        )},
        if (!is.null(self$`position`)) {
        sprintf(
        '"position":
          "%s"
                ',
        self$`position`
        )},
        if (!is.null(self$`mlb_id`)) {
        sprintf(
        '"mlb_id":
          %d
                ',
        self$`mlb_id`
        )},
        if (!is.null(self$`debut_date`)) {
        sprintf(
        '"debut_date":
          "%s"
                ',
        self$`debut_date`
        )},
        if (!is.null(self$`team_id`)) {
        sprintf(
        '"team_id":
          %d
                ',
        self$`team_id`
        )},
        if (!is.null(self$`team_abbrev`)) {
        sprintf(
        '"team_abbrev":
          "%s"
                ',
        self$`team_abbrev`
        )},
        if (!is.null(self$`active`)) {
        sprintf(
        '"active":
          "%s"
                ',
        self$`active`
        )},
        if (!is.null(self$`bat_side`)) {
        sprintf(
        '"bat_side":
          "%s"
                ',
        self$`bat_side`
        )},
        if (!is.null(self$`pitch_hand`)) {
        sprintf(
        '"pitch_hand":
          "%s"
                ',
        self$`pitch_hand`
        )},
        if (!is.null(self$`birth_country`)) {
        sprintf(
        '"birth_country":
          "%s"
                ',
        self$`birth_country`
        )},
        if (!is.null(self$`birth_date`)) {
        sprintf(
        '"birth_date":
          "%s"
                ',
        self$`birth_date`
        )},
        if (!is.null(self$`current_age`)) {
        sprintf(
        '"current_age":
          %d
                ',
        self$`current_age`
        )},
        if (!is.null(self$`photo_url`)) {
        sprintf(
        '"photo_url":
          "%s"
                ',
        self$`photo_url`
        )}
      )
      jsoncontent <- paste(jsoncontent, collapse = ",")
      paste('{', jsoncontent, '}', sep = "")
    },
    fromJSONString = function(PlayerJson) {
      PlayerObject <- jsonlite::fromJSON(PlayerJson)
      self$`full_name` <- PlayerObject$`full_name`
      self$`position` <- PlayerObject$`position`
      self$`mlb_id` <- PlayerObject$`mlb_id`
      self$`debut_date` <- PlayerObject$`debut_date`
      self$`team_id` <- PlayerObject$`team_id`
      self$`team_abbrev` <- PlayerObject$`team_abbrev`
      self$`active` <- PlayerObject$`active`
      self$`bat_side` <- PlayerObject$`bat_side`
      self$`pitch_hand` <- PlayerObject$`pitch_hand`
      self$`birth_country` <- PlayerObject$`birth_country`
      self$`birth_date` <- PlayerObject$`birth_date`
      self$`current_age` <- PlayerObject$`current_age`
      self$`photo_url` <- PlayerObject$`photo_url`
      self
    }
  )
)
singlearity-sports/singlearity-R documentation built on April 21, 2022, 3:48 a.m.