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


#' VariableGetDTO Class
#'
#' @field uri 
#' @field name 
#' @field entity 
#' @field entity_of_interest 
#' @field characteristic 
#' @field method 
#' @field unit 
#'
#' @importFrom R6 R6Class
#' @importFrom jsonlite fromJSON toJSON
#' @export
VariableGetDTO <- R6::R6Class(
  'VariableGetDTO',
  public = list(
    `uri` = NULL,
    `name` = NULL,
    `entity` = NULL,
    `entity_of_interest` = NULL,
    `characteristic` = NULL,
    `method` = NULL,
    `unit` = NULL,
    initialize = function(`uri`, `name`, `entity`, `entity_of_interest`, `characteristic`, `method`, `unit`){
      if (!missing(`uri`)) {
        stopifnot(is.character(`uri`), length(`uri`) == 1)
        self$`uri` <- `uri`
      }
      if (!missing(`name`)) {
        stopifnot(is.character(`name`), length(`name`) == 1)
        self$`name` <- `name`
      }
      if (!missing(`entity`)) {
        stopifnot(R6::is.R6(`entity`))
        self$`entity` <- `entity`
      }
      if (!missing(`entity_of_interest`)) {
        stopifnot(R6::is.R6(`entity_of_interest`))
        self$`entity_of_interest` <- `entity_of_interest`
      }
      if (!missing(`characteristic`)) {
        stopifnot(R6::is.R6(`characteristic`))
        self$`characteristic` <- `characteristic`
      }
      if (!missing(`method`)) {
        stopifnot(R6::is.R6(`method`))
        self$`method` <- `method`
      }
      if (!missing(`unit`)) {
        stopifnot(R6::is.R6(`unit`))
        self$`unit` <- `unit`
      }
    },
    toJSON = function() {
      VariableGetDTOObject <- list()
      if (!is.null(self$`uri`)) {
        VariableGetDTOObject[['uri']] <- self$`uri`
      }
      if (!is.null(self$`name`)) {
        VariableGetDTOObject[['name']] <- self$`name`
      }
      if (!is.null(self$`entity`)) {
        VariableGetDTOObject[['entity']] <- self$`entity`$toJSON()
      }
      if (!is.null(self$`entity_of_interest`)) {
        VariableGetDTOObject[['entity_of_interest']] <- self$`entity_of_interest`$toJSON()
      }
      if (!is.null(self$`characteristic`)) {
        VariableGetDTOObject[['characteristic']] <- self$`characteristic`$toJSON()
      }
      if (!is.null(self$`method`)) {
        VariableGetDTOObject[['method']] <- self$`method`$toJSON()
      }
      if (!is.null(self$`unit`)) {
        VariableGetDTOObject[['unit']] <- self$`unit`$toJSON()
      }

      VariableGetDTOObject
    },
    fromJSON = function(VariableGetDTOJson) {
      VariableGetDTOObject <- jsonlite::fromJSON(VariableGetDTOJson)
      if (!is.null(VariableGetDTOObject$`uri`)) {
        self$`uri` <- VariableGetDTOObject$`uri`
      }
      if (!is.null(VariableGetDTOObject$`name`)) {
        self$`name` <- VariableGetDTOObject$`name`
      }
      if (!is.null(VariableGetDTOObject$`entity`)) {
        entityObject <- EntityGetDTO$new()
        entityObject$fromJSON(jsonlite::toJSON(VariableGetDTOObject$entity, auto_unbox = TRUE, null = "null"))
        self$`entity` <- entityObject
      }
      if (!is.null(VariableGetDTOObject$`entity_of_interest`)) {
        entity_of_interestObject <- NamedResourceDTO$new()
        entity_of_interestObject$fromJSON(jsonlite::toJSON(VariableGetDTOObject$entity_of_interest, auto_unbox = TRUE, null = "null"))
        self$`entity_of_interest` <- entity_of_interestObject
      }
      if (!is.null(VariableGetDTOObject$`characteristic`)) {
        characteristicObject <- CharacteristicGetDTO$new()
        characteristicObject$fromJSON(jsonlite::toJSON(VariableGetDTOObject$characteristic, auto_unbox = TRUE, null = "null"))
        self$`characteristic` <- characteristicObject
      }
      if (!is.null(VariableGetDTOObject$`method`)) {
        methodObject <- MethodGetDTO$new()
        methodObject$fromJSON(jsonlite::toJSON(VariableGetDTOObject$method, auto_unbox = TRUE, null = "null"))
        self$`method` <- methodObject
      }
      if (!is.null(VariableGetDTOObject$`unit`)) {
        unitObject <- UnitGetDTO$new()
        unitObject$fromJSON(jsonlite::toJSON(VariableGetDTOObject$unit, auto_unbox = TRUE, null = "null"))
        self$`unit` <- unitObject
      }
    },
    fromJSONObject = function(VariableGetDTOObject) {
      if (!is.null(VariableGetDTOObject$`uri`)) {
        self$`uri` <- VariableGetDTOObject$`uri`
      }
      if (!is.null(VariableGetDTOObject$`name`)) {
        self$`name` <- VariableGetDTOObject$`name`
      }
      if (!is.null(VariableGetDTOObject$`entity`)) {
        entityObject <- EntityGetDTO$new()
        entityObject$fromJSON(jsonlite::toJSON(VariableGetDTOObject$entity, auto_unbox = TRUE, null = "null"))
        self$`entity` <- entityObject
      }
      if (!is.null(VariableGetDTOObject$`entity_of_interest`)) {
        entity_of_interestObject <- NamedResourceDTO$new()
        entity_of_interestObject$fromJSON(jsonlite::toJSON(VariableGetDTOObject$entity_of_interest, auto_unbox = TRUE, null = "null"))
        self$`entity_of_interest` <- entity_of_interestObject
      }
      if (!is.null(VariableGetDTOObject$`characteristic`)) {
        characteristicObject <- CharacteristicGetDTO$new()
        characteristicObject$fromJSON(jsonlite::toJSON(VariableGetDTOObject$characteristic, auto_unbox = TRUE, null = "null"))
        self$`characteristic` <- characteristicObject
      }
      if (!is.null(VariableGetDTOObject$`method`)) {
        methodObject <- MethodGetDTO$new()
        methodObject$fromJSON(jsonlite::toJSON(VariableGetDTOObject$method, auto_unbox = TRUE, null = "null"))
        self$`method` <- methodObject
      }
      if (!is.null(VariableGetDTOObject$`unit`)) {
        unitObject <- UnitGetDTO$new()
        unitObject$fromJSON(jsonlite::toJSON(VariableGetDTOObject$unit, auto_unbox = TRUE, null = "null"))
        self$`unit` <- unitObject
      }
    },
    toJSONString = function() {
       sprintf(
        '{
           "uri": %s,
           "name": %s,
           "entity": %s,
           "entity_of_interest": %s,
           "characteristic": %s,
           "method": %s,
           "unit": %s
        }',
        ifelse(is.null(self$`uri`), "null",jsonlite::toJSON(self$`uri`,auto_unbox=TRUE, null = "null")),
        ifelse(is.null(self$`name`), "null",jsonlite::toJSON(self$`name`,auto_unbox=TRUE, null = "null")),
        jsonlite::toJSON(self$`entity`$toJSON(),auto_unbox=TRUE, null = "null"),
        jsonlite::toJSON(self$`entity_of_interest`$toJSON(),auto_unbox=TRUE, null = "null"),
        jsonlite::toJSON(self$`characteristic`$toJSON(),auto_unbox=TRUE, null = "null"),
        jsonlite::toJSON(self$`method`$toJSON(),auto_unbox=TRUE, null = "null"),
        jsonlite::toJSON(self$`unit`$toJSON(),auto_unbox=TRUE, null = "null")
      )
    },
    fromJSONString = function(VariableGetDTOJson) {
      VariableGetDTOObject <- jsonlite::fromJSON(VariableGetDTOJson)
      self$`uri` <- VariableGetDTOObject$`uri`
      self$`name` <- VariableGetDTOObject$`name`
      EntityGetDTOObject <- EntityGetDTO$new()
      self$`entity` <- EntityGetDTOObject$fromJSON(jsonlite::toJSON(VariableGetDTOObject$entity, auto_unbox = TRUE))
      NamedResourceDTOObject <- NamedResourceDTO$new()
      self$`entity_of_interest` <- NamedResourceDTOObject$fromJSON(jsonlite::toJSON(VariableGetDTOObject$entity_of_interest, auto_unbox = TRUE))
      CharacteristicGetDTOObject <- CharacteristicGetDTO$new()
      self$`characteristic` <- CharacteristicGetDTOObject$fromJSON(jsonlite::toJSON(VariableGetDTOObject$characteristic, auto_unbox = TRUE))
      MethodGetDTOObject <- MethodGetDTO$new()
      self$`method` <- MethodGetDTOObject$fromJSON(jsonlite::toJSON(VariableGetDTOObject$method, auto_unbox = TRUE))
      UnitGetDTOObject <- UnitGetDTO$new()
      self$`unit` <- UnitGetDTOObject$fromJSON(jsonlite::toJSON(VariableGetDTOObject$unit, auto_unbox = TRUE))
    }
  )
)
OpenSILEX/opensilexClientToolsR documentation built on Jan. 28, 2022, 5:03 a.m.