R/RadiometricTargetPostDTO.r

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


#' RadiometricTargetPostDTO Class
#'
#' @field label 
#' @field properties 
#'
#' @importFrom R6 R6Class
#' @importFrom jsonlite fromJSON toJSON
#' @export
RadiometricTargetPostDTO <- R6::R6Class(
  'RadiometricTargetPostDTO',
  public = list(
    `label` = NULL,
    `properties` = NULL,
    initialize = function(`label`, `properties`){
      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() {
      RadiometricTargetPostDTOObject <- list()
      if (!is.null(self$`label`)) {
        RadiometricTargetPostDTOObject[['label']] <- self$`label`
      }
      if (!is.null(self$`properties`)) {
        RadiometricTargetPostDTOObject[['properties']] <- lapply(self$`properties`, function(x) x$toJSON())
      }

      RadiometricTargetPostDTOObject
    },
    fromJSON = function(RadiometricTargetPostDTOJson) {
      RadiometricTargetPostDTOObject <- jsonlite::fromJSON(RadiometricTargetPostDTOJson)
      if (!is.null(RadiometricTargetPostDTOObject$`label`)) {
        self$`label` <- RadiometricTargetPostDTOObject$`label`
      }
      if (!is.null(RadiometricTargetPostDTOObject$`properties`)) {
        self$`properties` <- lapply(RadiometricTargetPostDTOObject$`properties`, function(x) {
          propertiesObject <- PropertyPostDTO$new()
          propertiesObject$fromJSON(jsonlite::toJSON(x, auto_unbox = TRUE, null = "null"))
          propertiesObject
        })
      }
    },
    fromJSONObject = function(RadiometricTargetPostDTOObject) {
      if (!is.null(RadiometricTargetPostDTOObject$`label`)) {
        self$`label` <- RadiometricTargetPostDTOObject$`label`
      }
      if (!is.null(RadiometricTargetPostDTOObject$`properties`)) {
        self$`properties` <- lapply(RadiometricTargetPostDTOObject$`properties`, function(x) {
          propertiesObject <- PropertyPostDTO$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(
        '{
           "label": %s,
           "properties": [%s]
        }',
        jsonlite::toJSON(self$`label`,auto_unbox=TRUE, null = "null"),
        propertiesList
      )
    },
    fromJSONString = function(RadiometricTargetPostDTOJson) {
      RadiometricTargetPostDTOObject <- jsonlite::fromJSON(RadiometricTargetPostDTOJson)
      self$`label` <- RadiometricTargetPostDTOObject$`label`
      self$`properties` <- lapply(RadiometricTargetPostDTOObject$`properties`, function(x) PropertyPostDTO$new()$fromJSON(jsonlite::toJSON(x, auto_unbox = TRUE)))
    }
  )
)
OpenSILEX/phis-ws-client-r-tool documentation built on Sept. 10, 2020, 8:42 a.m.