R/Season.r

# OpenSilex API
#
# No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
#
# OpenAPI spec version: 1.0.0-rc+2
# 
# Generated by: https://github.com/swagger-api/swagger-codegen.git


#' Season Class
#'
#' @field season 
#' @field seasonDbId 
#' @field year 
#'
#' @importFrom R6 R6Class
#' @importFrom jsonlite fromJSON toJSON
#' @export
Season <- R6::R6Class(
  'Season',
  public = list(
    `season` = NULL,
    `seasonDbId` = NULL,
    `year` = NULL,
    initialize = function(`season`, `seasonDbId`, `year`){
      if (!missing(`season`)) {
        stopifnot(is.character(`season`), length(`season`) == 1)
        self$`season` <- `season`
      }
      if (!missing(`seasonDbId`)) {
        stopifnot(is.character(`seasonDbId`), length(`seasonDbId`) == 1)
        self$`seasonDbId` <- `seasonDbId`
      }
      if (!missing(`year`)) {
        stopifnot(is.numeric(`year`), length(`year`) == 1)
        self$`year` <- `year`
      }
    },
    toJSON = function() {
      SeasonObject <- list()
      if (!is.null(self$`season`)) {
        SeasonObject[['season']] <- self$`season`
      }
      if (!is.null(self$`seasonDbId`)) {
        SeasonObject[['seasonDbId']] <- self$`seasonDbId`
      }
      if (!is.null(self$`year`)) {
        SeasonObject[['year']] <- self$`year`
      }

      SeasonObject
    },
    fromJSON = function(SeasonJson) {
      SeasonObject <- jsonlite::fromJSON(SeasonJson)
      if (!is.null(SeasonObject$`season`)) {
        self$`season` <- SeasonObject$`season`
      }
      if (!is.null(SeasonObject$`seasonDbId`)) {
        self$`seasonDbId` <- SeasonObject$`seasonDbId`
      }
      if (!is.null(SeasonObject$`year`)) {
        self$`year` <- SeasonObject$`year`
      }
    },
    fromJSONObject = function(SeasonObject) {
      if (!is.null(SeasonObject$`season`)) {
        self$`season` <- SeasonObject$`season`
      }
      if (!is.null(SeasonObject$`seasonDbId`)) {
        self$`seasonDbId` <- SeasonObject$`seasonDbId`
      }
      if (!is.null(SeasonObject$`year`)) {
        self$`year` <- SeasonObject$`year`
      }
    },
    toJSONString = function() {
       sprintf(
        '{
           "season": %s,
           "seasonDbId": %s,
           "year": %s
        }',
        ifelse(is.null(self$`season`), "null",jsonlite::toJSON(self$`season`,auto_unbox=TRUE, null = "null")),
        ifelse(is.null(self$`seasonDbId`), "null",jsonlite::toJSON(self$`seasonDbId`,auto_unbox=TRUE, null = "null")),
        ifelse(is.null(self$`year`), "null",as.numeric(jsonlite::toJSON(self$`year`,auto_unbox=TRUE, null = "null")))
      )
    },
    fromJSONString = function(SeasonJson) {
      SeasonObject <- jsonlite::fromJSON(SeasonJson)
      self$`season` <- SeasonObject$`season`
      self$`seasonDbId` <- SeasonObject$`seasonDbId`
      self$`year` <- SeasonObject$`year`
    }
  )
)
OpenSILEX/opensilexClientToolsR documentation built on Jan. 28, 2022, 5:03 a.m.