R/validation_error.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 ValidationError
#'
#' @description ValidationError Class
#'
#' @format An \code{R6Class} generator object
#'
#' @field loc Location list( character ) 
#'
#' @field msg Message character 
#'
#' @field type Error Type character 
#'
#' @importFrom R6 R6Class
#' @importFrom jsonlite fromJSON toJSON
#' @export
ValidationError <- R6::R6Class(
  'ValidationError',
  public = list(
    `loc` = NULL,
    `msg` = NULL,
    `type` = NULL,
    initialize = function(
        `loc`, `msg`, `type`, ...
    ) {
      local.optional.var <- list(...)
      if (length(local.optional.var) > 0) {
        stop(paste("Unknown argument(s) in initialize of object ValidationError:", paste(names(local.optional.var), collapse=", "), collapse=" "))
      }
      if (!missing(`loc`)) {
        stopifnot(is.vector(`loc`), length(`loc`) != 0)
        sapply(`loc`, function(x) stopifnot(is.character(x)))
        self$`loc` <- `loc`
      }
      if (!missing(`msg`)) {
        stopifnot(is.character(`msg`), length(`msg`) == 1)
        self$`msg` <- `msg`
      }
      if (!missing(`type`)) {
        stopifnot(is.character(`type`), length(`type`) == 1)
        self$`type` <- `type`
      }
    },
    toJSON = function() {
      ValidationErrorObject <- list()
      if (!is.null(self$`loc`)) {
        ValidationErrorObject[['loc']] <-
          self$`loc`
      }
      if (!is.null(self$`msg`)) {
        ValidationErrorObject[['msg']] <-
          self$`msg`
      }
      if (!is.null(self$`type`)) {
        ValidationErrorObject[['type']] <-
          self$`type`
      }

      ValidationErrorObject
    },
    fromJSON = function(ValidationErrorJson) {
      ValidationErrorObject <- jsonlite::fromJSON(ValidationErrorJson)
      if (!is.null(ValidationErrorObject$`loc`)) {
        self$`loc` <- ApiClient$new()$deserializeObj(ValidationErrorObject$`loc`, "array[character]", loadNamespace("singlearity"))
      }
      if (!is.null(ValidationErrorObject$`msg`)) {
        self$`msg` <- ValidationErrorObject$`msg`
      }
      if (!is.null(ValidationErrorObject$`type`)) {
        self$`type` <- ValidationErrorObject$`type`
      }
      self
    },
    toJSONString = function() {
      jsoncontent <- c(
        if (!is.null(self$`loc`)) {
        sprintf(
        '"loc":
           [%s]
        ',
        paste(unlist(lapply(self$`loc`, function(x) paste0('"', x, '"'))), collapse=",")
        )},
        if (!is.null(self$`msg`)) {
        sprintf(
        '"msg":
          "%s"
                ',
        self$`msg`
        )},
        if (!is.null(self$`type`)) {
        sprintf(
        '"type":
          "%s"
                ',
        self$`type`
        )}
      )
      jsoncontent <- paste(jsoncontent, collapse = ",")
      paste('{', jsoncontent, '}', sep = "")
    },
    fromJSONString = function(ValidationErrorJson) {
      ValidationErrorObject <- jsonlite::fromJSON(ValidationErrorJson)
      self$`loc` <- ApiClient$new()$deserializeObj(ValidationErrorObject$`loc`, "array[character]", loadNamespace("singlearity"))
      self$`msg` <- ValidationErrorObject$`msg`
      self$`type` <- ValidationErrorObject$`type`
      self
    }
  )
)
singlearity-sports/singlearity-R documentation built on April 21, 2022, 3:48 a.m.