R/Status.r

# sunagriAPI
#
# An instance of OpenSILEX WebService
#
# OpenAPI spec version: 3.3.0
# 
# Generated by: https://github.com/swagger-api/swagger-codegen.git


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

      StatusObject
    },
    fromJSON = function(StatusJson) {
      StatusObject <- jsonlite::fromJSON(StatusJson)
      if (!is.null(StatusObject$`message`)) {
        self$`message` <- StatusObject$`message`
      }
      if (!is.null(StatusObject$`exception`)) {
        exceptionObject <- StatusException$new()
        exceptionObject$fromJSON(jsonlite::toJSON(StatusObject$exception, auto_unbox = TRUE, null = "null"))
        self$`exception` <- exceptionObject
      }
    },
    fromJSONObject = function(StatusObject) {
      if (!is.null(StatusObject$`message`)) {
        self$`message` <- StatusObject$`message`
      }
      if (!is.null(StatusObject$`exception`)) {
        exceptionObject <- StatusException$new()
        exceptionObject$fromJSON(jsonlite::toJSON(StatusObject$exception, auto_unbox = TRUE, null = "null"))
        self$`exception` <- exceptionObject
      }
    },
    toJSONString = function() {
       sprintf(
        '{
           "message": %s,
           "exception": %s
        }',
        jsonlite::toJSON(self$`message`,auto_unbox=TRUE, null = "null"),
        self$`exception`$toJSON()
      )
    },
    fromJSONString = function(StatusJson) {
      StatusObject <- jsonlite::fromJSON(StatusJson)
      self$`message` <- StatusObject$`message`
      StatusExceptionObject <- StatusException$new()
      self$`exception` <- StatusExceptionObject$fromJSON(jsonlite::toJSON(StatusObject$exception, auto_unbox = TRUE))
    }
  )
)
OpenSILEX/phis-ws-client-r-tool documentation built on Sept. 10, 2020, 8:42 a.m.