R/MultipleSystemResponse.r

# Agave Platform Science API
#
# Power your digital lab and reduce the time from theory to discovery using the Agave Science-as-a-Service API Platform. Agave provides hosted services that allow researchers to manage data, conduct experiments, and publish and share results from anywhere at any time.
#
# Agave Platform version: 2.2.14
# 
# Generated by: https://github.com/swagger-api/swagger-codegen.git


#' MultipleSystemResponse Class
#'
#' 
#'
#' @field message success or failure
#' @field result response body
#' @field status success or failure
#'
#' @importFrom R6 R6Class
#' @importFrom jsonlite fromJSON toJSON
#' @export
MultipleSystemResponse <- R6::R6Class(
  'MultipleSystemResponse',
  public = list(
    `message` = NULL,
    `result` = NULL,
    `status` = NULL,
    initialize = function(`message`, `result`, `status`){
      if (!missing(`message`)) {
        stopifnot(is.character(`message`), length(`message`) == 1)
        self$`message` <- `message`
      }
      if (!missing(`result`)) {
        stopifnot(is.list(`result`), length(`result`) != 0)
        lapply(`result`, function(x) stopifnot(R6::is.R6(x)))
        self$`result` <- `result`
      }
      if (!missing(`status`)) {
        stopifnot(is.character(`status`), length(`status`) == 1)
        self$`status` <- `status`
      }
    },
    asJSON = function() {
      self$toJSON()
    },
    toJSON = function() {
      MultipleSystemResponseObject <- list()
      if (!is.null(self$`message`)) {
        MultipleSystemResponseObject[['message']] <- self$`message`
      }
      else {
        MultipleSystemResponseObject[['message']] <- NULL
      }
      if (!is.null(self$`result`)) {
        MultipleSystemResponseObject[['result']] <- lapply(self$`result`, function(x) x$toJSON())
      }
      else {
        MultipleSystemResponseObject[['result']] <- NULL
      }
      if (!is.null(self$`status`)) {
        MultipleSystemResponseObject[['status']] <- self$`status`
      }
      else {
        MultipleSystemResponseObject[['status']] <- NULL
      }

      MultipleSystemResponseObject
    },
    fromJSON = function(MultipleSystemResponseObject) {
      if (is.character(MultipleSystemResponseObject)) {
        MultipleSystemResponseObject <- jsonlite::fromJSON(MultipleSystemResponseJson)
      }

      if ("result" %in% names(MultipleSystemResponseObject)) {
        MultipleSystemResponseObject <- MultipleSystemResponseObject$result
      }

      if (!is.null(MultipleSystemResponseObject$`message`)) {
        self$`message` <- MultipleSystemResponseObject$`message`
      }
      if (!is.null(MultipleSystemResponseObject$`result`)) {
        self$`result` <- lapply(MultipleSystemResponseObject$`result`, function(x) {
          resultObject <- SystemSummary$new()
          resultObject$fromJSON(jsonlite::toJSON(x, auto_unbox = TRUE))
          resultObject
        })
      }
      if (!is.null(MultipleSystemResponseObject$`status`)) {
        self$`status` <- MultipleSystemResponseObject$`status`
      }
    },
    toJSONString = function() {
       sprintf(
        '{
           "message": %s,
           "result": [%s],
           "status": %s
        }',
        ifelse( is.null(self$`message`),"null",paste0(c('"', self$`message`, '"'))),
        lapply(self$`result`, function(x) paste(x$toJSON(), sep=",")),
        ifelse( is.null(self$`status`),"null",paste0(c('"', self$`status`, '"')))
      )
    },
    fromJSONString = function(MultipleSystemResponseJson) {
      MultipleSystemResponseObject <- jsonlite::fromJSON(MultipleSystemResponseJson)
      self::fromJSON(MultipleSystemResponseObject)

    }
  )
)
agaveplatform/r-sdk documentation built on May 13, 2019, 8:20 a.m.