# 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
#' TeamMatchup Class
#'
#' @field team1
#' @field team2
#' @field startYear
#' @field endYear
#' @field team1Wins
#' @field team2Wins
#' @field ties
#' @field games
#'
#' @importFrom R6 R6Class
#' @importFrom jsonlite fromJSON toJSON
#' @export
TeamMatchup <- R6::R6Class(
'TeamMatchup',
public = list(
`team1` = NULL,
`team2` = NULL,
`startYear` = NULL,
`endYear` = NULL,
`team1Wins` = NULL,
`team2Wins` = NULL,
`ties` = NULL,
`games` = NULL,
initialize = function(`team1`, `team2`, `startYear`, `endYear`, `team1Wins`, `team2Wins`, `ties`, `games`){
if (!missing(`team1`)) {
stopifnot(is.character(`team1`), length(`team1`) == 1)
self$`team1` <- `team1`
}
if (!missing(`team2`)) {
stopifnot(is.character(`team2`), length(`team2`) == 1)
self$`team2` <- `team2`
}
if (!missing(`startYear`)) {
stopifnot(is.numeric(`startYear`), length(`startYear`) == 1)
self$`startYear` <- `startYear`
}
if (!missing(`endYear`)) {
stopifnot(is.numeric(`endYear`), length(`endYear`) == 1)
self$`endYear` <- `endYear`
}
if (!missing(`team1Wins`)) {
stopifnot(is.numeric(`team1Wins`), length(`team1Wins`) == 1)
self$`team1Wins` <- `team1Wins`
}
if (!missing(`team2Wins`)) {
stopifnot(is.numeric(`team2Wins`), length(`team2Wins`) == 1)
self$`team2Wins` <- `team2Wins`
}
if (!missing(`ties`)) {
stopifnot(is.numeric(`ties`), length(`ties`) == 1)
self$`ties` <- `ties`
}
if (!missing(`games`)) {
stopifnot(is.list(`games`), length(`games`) != 0)
lapply(`games`, function(x) stopifnot(R6::is.R6(x)))
self$`games` <- `games`
}
},
toJSON = function() {
TeamMatchupObject <- list()
if (!is.null(self$`team1`)) {
TeamMatchupObject[['team1']] <- self$`team1`
}
if (!is.null(self$`team2`)) {
TeamMatchupObject[['team2']] <- self$`team2`
}
if (!is.null(self$`startYear`)) {
TeamMatchupObject[['startYear']] <- self$`startYear`
}
if (!is.null(self$`endYear`)) {
TeamMatchupObject[['endYear']] <- self$`endYear`
}
if (!is.null(self$`team1Wins`)) {
TeamMatchupObject[['team1Wins']] <- self$`team1Wins`
}
if (!is.null(self$`team2Wins`)) {
TeamMatchupObject[['team2Wins']] <- self$`team2Wins`
}
if (!is.null(self$`ties`)) {
TeamMatchupObject[['ties']] <- self$`ties`
}
if (!is.null(self$`games`)) {
TeamMatchupObject[['games']] <- lapply(self$`games`, function(x) x$toJSON())
}
TeamMatchupObject
},
fromJSON = function(TeamMatchupJson) {
TeamMatchupObject <- jsonlite::fromJSON(TeamMatchupJson)
if (!is.null(TeamMatchupObject$`team1`)) {
self$`team1` <- TeamMatchupObject$`team1`
}
if (!is.null(TeamMatchupObject$`team2`)) {
self$`team2` <- TeamMatchupObject$`team2`
}
if (!is.null(TeamMatchupObject$`startYear`)) {
self$`startYear` <- TeamMatchupObject$`startYear`
}
if (!is.null(TeamMatchupObject$`endYear`)) {
self$`endYear` <- TeamMatchupObject$`endYear`
}
if (!is.null(TeamMatchupObject$`team1Wins`)) {
self$`team1Wins` <- TeamMatchupObject$`team1Wins`
}
if (!is.null(TeamMatchupObject$`team2Wins`)) {
self$`team2Wins` <- TeamMatchupObject$`team2Wins`
}
if (!is.null(TeamMatchupObject$`ties`)) {
self$`ties` <- TeamMatchupObject$`ties`
}
if (!is.null(TeamMatchupObject$`games`)) {
self$`games` <- lapply(TeamMatchupObject$`games`, function(x) {
gamesObject <- TeamMatchupGames$new()
gamesObject$fromJSON(jsonlite::toJSON(x, auto_unbox = TRUE))
gamesObject
})
}
},
toJSONString = function() {
sprintf(
'{
"team1": %s,
"team2": %s,
"startYear": %d,
"endYear": %d,
"team1Wins": %d,
"team2Wins": %d,
"ties": %d,
"games": [%s]
}',
self$`team1`,
self$`team2`,
self$`startYear`,
self$`endYear`,
self$`team1Wins`,
self$`team2Wins`,
self$`ties`,
lapply(self$`games`, function(x) paste(x$toJSON(), sep=","))
)
},
fromJSONString = function(TeamMatchupJson) {
TeamMatchupObject <- jsonlite::fromJSON(TeamMatchupJson)
self$`team1` <- TeamMatchupObject$`team1`
self$`team2` <- TeamMatchupObject$`team2`
self$`startYear` <- TeamMatchupObject$`startYear`
self$`endYear` <- TeamMatchupObject$`endYear`
self$`team1Wins` <- TeamMatchupObject$`team1Wins`
self$`team2Wins` <- TeamMatchupObject$`team2Wins`
self$`ties` <- TeamMatchupObject$`ties`
self$`games` <- lapply(TeamMatchupObject$`games`, function(x) TeamMatchupGames$new()$fromJSON(jsonlite::toJSON(x, auto_unbox = TRUE)))
}
)
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.