R/RadiometricTargetDTO.r

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


#' RadiometricTargetDTO Class
#'
#' @field uri 
#' @field label 
#' @field properties 
#'
#' @importFrom R6 R6Class
#' @importFrom jsonlite fromJSON toJSON
#' @export
RadiometricTargetDTO <- R6::R6Class(
  'RadiometricTargetDTO',
  public = list(
    `uri` = NULL,
    `label` = NULL,
    `properties` = NULL,
    initialize = function(`uri`, `label`, `properties`){
      if (!missing(`uri`)) {
        stopifnot(is.character(`uri`), length(`uri`) == 1)
        self$`uri` <- `uri`
      }
      if (!missing(`label`)) {
        stopifnot(is.character(`label`), length(`label`) == 1)
        self$`label` <- `label`
      }
      if (!missing(`properties`)) {
        stopifnot(is.list(`properties`), length(`properties`) != 0)
        lapply(`properties`, function(x) stopifnot(R6::is.R6(x)))
        self$`properties` <- `properties`
      }
    },
    toJSON = function() {
      RadiometricTargetDTOObject <- list()
      if (!is.null(self$`uri`)) {
        RadiometricTargetDTOObject[['uri']] <- self$`uri`
      }
      if (!is.null(self$`label`)) {
        RadiometricTargetDTOObject[['label']] <- self$`label`
      }
      if (!is.null(self$`properties`)) {
        RadiometricTargetDTOObject[['properties']] <- lapply(self$`properties`, function(x) x$toJSON())
      }

      RadiometricTargetDTOObject
    },
    fromJSON = function(RadiometricTargetDTOJson) {
      RadiometricTargetDTOObject <- jsonlite::fromJSON(RadiometricTargetDTOJson)
      if (!is.null(RadiometricTargetDTOObject$`uri`)) {
        self$`uri` <- RadiometricTargetDTOObject$`uri`
      }
      if (!is.null(RadiometricTargetDTOObject$`label`)) {
        self$`label` <- RadiometricTargetDTOObject$`label`
      }
      if (!is.null(RadiometricTargetDTOObject$`properties`)) {
        self$`properties` <- lapply(RadiometricTargetDTOObject$`properties`, function(x) {
          propertiesObject <- PropertyDTO$new()
          propertiesObject$fromJSON(jsonlite::toJSON(x, auto_unbox = TRUE, null = "null"))
          propertiesObject
        })
      }
    },
    fromJSONObject = function(RadiometricTargetDTOObject) {
      if (!is.null(RadiometricTargetDTOObject$`uri`)) {
        self$`uri` <- RadiometricTargetDTOObject$`uri`
      }
      if (!is.null(RadiometricTargetDTOObject$`label`)) {
        self$`label` <- RadiometricTargetDTOObject$`label`
      }
      if (!is.null(RadiometricTargetDTOObject$`properties`)) {
        self$`properties` <- lapply(RadiometricTargetDTOObject$`properties`, function(x) {
          propertiesObject <- PropertyDTO$new()
          propertiesObject$fromJSON(jsonlite::toJSON(x, auto_unbox = TRUE, null = "null"))
          propertiesObject
        })
      }
    },
    toJSONString = function() {
      propertiesList = paste(lapply(self$`properties`, function(x) x$toJSONString()),collapse = ",")
       sprintf(
        '{
           "uri": %s,
           "label": %s,
           "properties": [%s]
        }',
        jsonlite::toJSON(self$`uri`,auto_unbox=TRUE, null = "null"),
        jsonlite::toJSON(self$`label`,auto_unbox=TRUE, null = "null"),
        propertiesList
      )
    },
    fromJSONString = function(RadiometricTargetDTOJson) {
      RadiometricTargetDTOObject <- jsonlite::fromJSON(RadiometricTargetDTOJson)
      self$`uri` <- RadiometricTargetDTOObject$`uri`
      self$`label` <- RadiometricTargetDTOObject$`label`
      self$`properties` <- lapply(RadiometricTargetDTOObject$`properties`, function(x) PropertyDTO$new()$fromJSON(jsonlite::toJSON(x, auto_unbox = TRUE)))
    }
  )
)
OpenSILEX/phis-ws-client-r-tool documentation built on Sept. 10, 2020, 8:42 a.m.