R/FileDescriptionWebPathPostDTO.r

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


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

      FileDescriptionWebPathPostDTOObject
    },
    fromJSON = function(FileDescriptionWebPathPostDTOJson) {
      FileDescriptionWebPathPostDTOObject <- jsonlite::fromJSON(FileDescriptionWebPathPostDTOJson)
      if (!is.null(FileDescriptionWebPathPostDTOObject$`rdfType`)) {
        self$`rdfType` <- FileDescriptionWebPathPostDTOObject$`rdfType`
      }
      if (!is.null(FileDescriptionWebPathPostDTOObject$`date`)) {
        self$`date` <- FileDescriptionWebPathPostDTOObject$`date`
      }
      if (!is.null(FileDescriptionWebPathPostDTOObject$`webPath`)) {
        self$`webPath` <- FileDescriptionWebPathPostDTOObject$`webPath`
      }
      if (!is.null(FileDescriptionWebPathPostDTOObject$`concernedItems`)) {
        self$`concernedItems` <- lapply(FileDescriptionWebPathPostDTOObject$`concernedItems`, function(x) {
          concernedItemsObject <- ConcernedItemDTO$new()
          concernedItemsObject$fromJSON(jsonlite::toJSON(x, auto_unbox = TRUE, null = "null"))
          concernedItemsObject
        })
      }
      if (!is.null(FileDescriptionWebPathPostDTOObject$`provenanceUri`)) {
        self$`provenanceUri` <- FileDescriptionWebPathPostDTOObject$`provenanceUri`
      }
      if (!is.null(FileDescriptionWebPathPostDTOObject$`metadata`)) {
        metadataObject <- TODO_OBJECT_MAPPING$new()
        metadataObject$fromJSON(jsonlite::toJSON(FileDescriptionWebPathPostDTOObject$metadata, auto_unbox = TRUE, null = "null"))
        self$`metadata` <- metadataObject
      }
    },
    fromJSONObject = function(FileDescriptionWebPathPostDTOObject) {
      if (!is.null(FileDescriptionWebPathPostDTOObject$`rdfType`)) {
        self$`rdfType` <- FileDescriptionWebPathPostDTOObject$`rdfType`
      }
      if (!is.null(FileDescriptionWebPathPostDTOObject$`date`)) {
        self$`date` <- FileDescriptionWebPathPostDTOObject$`date`
      }
      if (!is.null(FileDescriptionWebPathPostDTOObject$`webPath`)) {
        self$`webPath` <- FileDescriptionWebPathPostDTOObject$`webPath`
      }
      if (!is.null(FileDescriptionWebPathPostDTOObject$`concernedItems`)) {
        self$`concernedItems` <- lapply(FileDescriptionWebPathPostDTOObject$`concernedItems`, function(x) {
          concernedItemsObject <- ConcernedItemDTO$new()
          concernedItemsObject$fromJSON(jsonlite::toJSON(x, auto_unbox = TRUE, null = "null"))
          concernedItemsObject
        })
      }
      if (!is.null(FileDescriptionWebPathPostDTOObject$`provenanceUri`)) {
        self$`provenanceUri` <- FileDescriptionWebPathPostDTOObject$`provenanceUri`
      }
      if (!is.null(FileDescriptionWebPathPostDTOObject$`metadata`)) {
        metadataObject <- TODO_OBJECT_MAPPING$new()
        metadataObject$fromJSON(jsonlite::toJSON(FileDescriptionWebPathPostDTOObject$metadata, auto_unbox = TRUE, null = "null"))
        self$`metadata` <- metadataObject
      }
    },
    toJSONString = function() {
      concernedItemsList = paste(lapply(self$`concernedItems`, function(x) x$toJSONString()),collapse = ",")
       sprintf(
        '{
           "rdfType": %s,
           "date": %s,
           "webPath": %s,
           "concernedItems": [%s],
           "provenanceUri": %s,
           "metadata": %s
        }',
        jsonlite::toJSON(self$`rdfType`,auto_unbox=TRUE, null = "null"),
        jsonlite::toJSON(self$`date`,auto_unbox=TRUE, null = "null"),
        jsonlite::toJSON(self$`webPath`,auto_unbox=TRUE, null = "null"),
        concernedItemsList,
        jsonlite::toJSON(self$`provenanceUri`,auto_unbox=TRUE, null = "null"),
        self$`metadata`$toJSON()
      )
    },
    fromJSONString = function(FileDescriptionWebPathPostDTOJson) {
      FileDescriptionWebPathPostDTOObject <- jsonlite::fromJSON(FileDescriptionWebPathPostDTOJson)
      self$`rdfType` <- FileDescriptionWebPathPostDTOObject$`rdfType`
      self$`date` <- FileDescriptionWebPathPostDTOObject$`date`
      self$`webPath` <- FileDescriptionWebPathPostDTOObject$`webPath`
      self$`concernedItems` <- lapply(FileDescriptionWebPathPostDTOObject$`concernedItems`, function(x) ConcernedItemDTO$new()$fromJSON(jsonlite::toJSON(x, auto_unbox = TRUE)))
      self$`provenanceUri` <- FileDescriptionWebPathPostDTOObject$`provenanceUri`
      TODO_OBJECT_MAPPINGObject <- TODO_OBJECT_MAPPING$new()
      self$`metadata` <- TODO_OBJECT_MAPPINGObject$fromJSON(jsonlite::toJSON(FileDescriptionWebPathPostDTOObject$metadata, auto_unbox = TRUE))
    }
  )
)
OpenSILEX/phis-ws-client-r-tool documentation built on Sept. 10, 2020, 8:42 a.m.