R/ImageMetadataDTO.r

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


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

      ImageMetadataDTOObject
    },
    fromJSON = function(ImageMetadataDTOJson) {
      ImageMetadataDTOObject <- jsonlite::fromJSON(ImageMetadataDTOJson)
      if (!is.null(ImageMetadataDTOObject$`rdfType`)) {
        self$`rdfType` <- ImageMetadataDTOObject$`rdfType`
      }
      if (!is.null(ImageMetadataDTOObject$`concernedItems`)) {
        self$`concernedItems` <- lapply(ImageMetadataDTOObject$`concernedItems`, function(x) {
          concernedItemsObject <- ConcernedItemDTO$new()
          concernedItemsObject$fromJSON(jsonlite::toJSON(x, auto_unbox = TRUE, null = "null"))
          concernedItemsObject
        })
      }
      if (!is.null(ImageMetadataDTOObject$`configuration`)) {
        configurationObject <- ShootingConfigurationDTO$new()
        configurationObject$fromJSON(jsonlite::toJSON(ImageMetadataDTOObject$configuration, auto_unbox = TRUE, null = "null"))
        self$`configuration` <- configurationObject
      }
      if (!is.null(ImageMetadataDTOObject$`fileInfo`)) {
        fileInfoObject <- FileInformationDTO$new()
        fileInfoObject$fromJSON(jsonlite::toJSON(ImageMetadataDTOObject$fileInfo, auto_unbox = TRUE, null = "null"))
        self$`fileInfo` <- fileInfoObject
      }
    },
    fromJSONObject = function(ImageMetadataDTOObject) {
      if (!is.null(ImageMetadataDTOObject$`rdfType`)) {
        self$`rdfType` <- ImageMetadataDTOObject$`rdfType`
      }
      if (!is.null(ImageMetadataDTOObject$`concernedItems`)) {
        self$`concernedItems` <- lapply(ImageMetadataDTOObject$`concernedItems`, function(x) {
          concernedItemsObject <- ConcernedItemDTO$new()
          concernedItemsObject$fromJSON(jsonlite::toJSON(x, auto_unbox = TRUE, null = "null"))
          concernedItemsObject
        })
      }
      if (!is.null(ImageMetadataDTOObject$`configuration`)) {
        configurationObject <- ShootingConfigurationDTO$new()
        configurationObject$fromJSON(jsonlite::toJSON(ImageMetadataDTOObject$configuration, auto_unbox = TRUE, null = "null"))
        self$`configuration` <- configurationObject
      }
      if (!is.null(ImageMetadataDTOObject$`fileInfo`)) {
        fileInfoObject <- FileInformationDTO$new()
        fileInfoObject$fromJSON(jsonlite::toJSON(ImageMetadataDTOObject$fileInfo, auto_unbox = TRUE, null = "null"))
        self$`fileInfo` <- fileInfoObject
      }
    },
    toJSONString = function() {
      concernedItemsList = paste(lapply(self$`concernedItems`, function(x) x$toJSONString()),collapse = ",")
       sprintf(
        '{
           "rdfType": %s,
           "concernedItems": [%s],
           "configuration": %s,
           "fileInfo": %s
        }',
        jsonlite::toJSON(self$`rdfType`,auto_unbox=TRUE, null = "null"),
        concernedItemsList,
        self$`configuration`$toJSON(),
        self$`fileInfo`$toJSON()
      )
    },
    fromJSONString = function(ImageMetadataDTOJson) {
      ImageMetadataDTOObject <- jsonlite::fromJSON(ImageMetadataDTOJson)
      self$`rdfType` <- ImageMetadataDTOObject$`rdfType`
      self$`concernedItems` <- lapply(ImageMetadataDTOObject$`concernedItems`, function(x) ConcernedItemDTO$new()$fromJSON(jsonlite::toJSON(x, auto_unbox = TRUE)))
      ShootingConfigurationDTOObject <- ShootingConfigurationDTO$new()
      self$`configuration` <- ShootingConfigurationDTOObject$fromJSON(jsonlite::toJSON(ImageMetadataDTOObject$configuration, auto_unbox = TRUE))
      FileInformationDTOObject <- FileInformationDTO$new()
      self$`fileInfo` <- FileInformationDTOObject$fromJSON(jsonlite::toJSON(ImageMetadataDTOObject$fileInfo, auto_unbox = TRUE))
    }
  )
)
OpenSILEX/phis-ws-client-r-tool documentation built on Sept. 10, 2020, 8:42 a.m.