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


#' InlineResponse200 Class
#'
#' @field first_name 
#' @field last_name 
#' @field seasons 
#'
#' @importFrom R6 R6Class
#' @importFrom jsonlite fromJSON toJSON
#' @export
InlineResponse200 <- R6::R6Class(
  'InlineResponse200',
  public = list(
    `first_name` = NULL,
    `last_name` = NULL,
    `seasons` = NULL,
    initialize = function(`first_name`, `last_name`, `seasons`){
      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(`seasons`)) {
        stopifnot(is.list(`seasons`), length(`seasons`) != 0)
        lapply(`seasons`, function(x) stopifnot(R6::is.R6(x)))
        self$`seasons` <- `seasons`
      }
    },
    toJSON = function() {
      InlineResponse200Object <- list()
      if (!is.null(self$`first_name`)) {
        InlineResponse200Object[['first_name']] <- self$`first_name`
      }
      if (!is.null(self$`last_name`)) {
        InlineResponse200Object[['last_name']] <- self$`last_name`
      }
      if (!is.null(self$`seasons`)) {
        InlineResponse200Object[['seasons']] <- lapply(self$`seasons`, function(x) x$toJSON())
      }

      InlineResponse200Object
    },
    fromJSON = function(InlineResponse200Json) {
      InlineResponse200Object <- jsonlite::fromJSON(InlineResponse200Json)
      if (!is.null(InlineResponse200Object$`first_name`)) {
        self$`first_name` <- InlineResponse200Object$`first_name`
      }
      if (!is.null(InlineResponse200Object$`last_name`)) {
        self$`last_name` <- InlineResponse200Object$`last_name`
      }
      if (!is.null(InlineResponse200Object$`seasons`)) {
        self$`seasons` <- lapply(InlineResponse200Object$`seasons`, function(x) {
          seasonsObject <- TeamSeason$new()
          seasonsObject$fromJSON(jsonlite::toJSON(x, auto_unbox = TRUE))
          seasonsObject
        })
      }
    },
    toJSONString = function() {
       sprintf(
        '{
           "first_name": %s,
           "last_name": %s,
           "seasons": [%s]
        }',
        self$`first_name`,
        self$`last_name`,
        lapply(self$`seasons`, function(x) paste(x$toJSON(), sep=","))
      )
    },
    fromJSONString = function(InlineResponse200Json) {
      InlineResponse200Object <- jsonlite::fromJSON(InlineResponse200Json)
      self$`first_name` <- InlineResponse200Object$`first_name`
      self$`last_name` <- InlineResponse200Object$`last_name`
      self$`seasons` <- lapply(InlineResponse200Object$`seasons`, function(x) TeamSeason$new()$fromJSON(jsonlite::toJSON(x, auto_unbox = TRUE)))
    }
  )
)
saiemgilani/cfbd-api-R documentation built on Feb. 16, 2021, 12:07 a.m.