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


#' InfrastructureFacilityCreationDTO Class
#'
#' @field uri 
#' @field rdf_type 
#' @field name 
#' @field organizations 
#' @field address 
#' @field relations 
#' @field rdf_type_name 
#'
#' @importFrom R6 R6Class
#' @importFrom jsonlite fromJSON toJSON
#' @export
InfrastructureFacilityCreationDTO <- R6::R6Class(
  'InfrastructureFacilityCreationDTO',
  public = list(
    `uri` = NULL,
    `rdf_type` = NULL,
    `name` = NULL,
    `organizations` = NULL,
    `address` = NULL,
    `relations` = NULL,
    `rdf_type_name` = NULL,
    initialize = function(`uri`, `rdf_type`, `name`, `organizations`, `address`, `relations`, `rdf_type_name`){
      if (!missing(`uri`)) {
        stopifnot(is.character(`uri`), length(`uri`) == 1)
        self$`uri` <- `uri`
      }
      if (!missing(`rdf_type`)) {
        stopifnot(is.character(`rdf_type`), length(`rdf_type`) == 1)
        self$`rdf_type` <- `rdf_type`
      }
      if (!missing(`name`)) {
        stopifnot(is.character(`name`), length(`name`) == 1)
        self$`name` <- `name`
      }
      if (!missing(`organizations`)) {
        stopifnot(is.list(`organizations`), length(`organizations`) != 0)
        lapply(`organizations`, function(x) stopifnot(is.character(x)))
        self$`organizations` <- `organizations`
      }
      if (!missing(`address`)) {
        stopifnot(R6::is.R6(`address`))
        self$`address` <- `address`
      }
      if (!missing(`relations`)) {
        stopifnot(is.list(`relations`), length(`relations`) != 0)
        lapply(`relations`, function(x) stopifnot(R6::is.R6(x)))
        self$`relations` <- `relations`
      }
      if (!missing(`rdf_type_name`)) {
        stopifnot(is.character(`rdf_type_name`), length(`rdf_type_name`) == 1)
        self$`rdf_type_name` <- `rdf_type_name`
      }
    },
    toJSON = function() {
      InfrastructureFacilityCreationDTOObject <- list()
      if (!is.null(self$`uri`)) {
        InfrastructureFacilityCreationDTOObject[['uri']] <- self$`uri`
      }
      if (!is.null(self$`rdf_type`)) {
        InfrastructureFacilityCreationDTOObject[['rdf_type']] <- self$`rdf_type`
      }
      if (!is.null(self$`name`)) {
        InfrastructureFacilityCreationDTOObject[['name']] <- self$`name`
      }
      if (!is.null(self$`organizations`)) {
        InfrastructureFacilityCreationDTOObject[['organizations']] <- self$`organizations`
      }
      if (!is.null(self$`address`)) {
        InfrastructureFacilityCreationDTOObject[['address']] <- self$`address`$toJSON()
      }
      if (!is.null(self$`relations`)) {
        InfrastructureFacilityCreationDTOObject[['relations']] <- lapply(self$`relations`, function(x) x$toJSON())
      }
      if (!is.null(self$`rdf_type_name`)) {
        InfrastructureFacilityCreationDTOObject[['rdf_type_name']] <- self$`rdf_type_name`
      }

      InfrastructureFacilityCreationDTOObject
    },
    fromJSON = function(InfrastructureFacilityCreationDTOJson) {
      InfrastructureFacilityCreationDTOObject <- jsonlite::fromJSON(InfrastructureFacilityCreationDTOJson)
      if (!is.null(InfrastructureFacilityCreationDTOObject$`uri`)) {
        self$`uri` <- InfrastructureFacilityCreationDTOObject$`uri`
      }
      if (!is.null(InfrastructureFacilityCreationDTOObject$`rdf_type`)) {
        self$`rdf_type` <- InfrastructureFacilityCreationDTOObject$`rdf_type`
      }
      if (!is.null(InfrastructureFacilityCreationDTOObject$`name`)) {
        self$`name` <- InfrastructureFacilityCreationDTOObject$`name`
      }
      if (!is.null(InfrastructureFacilityCreationDTOObject$`organizations`)) {
        self$`organizations` <- InfrastructureFacilityCreationDTOObject$`organizations`
      }
      if (!is.null(InfrastructureFacilityCreationDTOObject$`address`)) {
        addressObject <- FacilityAddressDTO$new()
        addressObject$fromJSON(jsonlite::toJSON(InfrastructureFacilityCreationDTOObject$address, auto_unbox = TRUE, null = "null"))
        self$`address` <- addressObject
      }
      if (!is.null(InfrastructureFacilityCreationDTOObject$`relations`)) {
        self$`relations` <- lapply(InfrastructureFacilityCreationDTOObject$`relations`, function(x) {
          relationsObject <- RDFObjectRelationDTO$new()
          relationsObject$fromJSON(jsonlite::toJSON(x, auto_unbox = TRUE, null = "null"))
          relationsObject
        })
      }
      if (!is.null(InfrastructureFacilityCreationDTOObject$`rdf_type_name`)) {
        self$`rdf_type_name` <- InfrastructureFacilityCreationDTOObject$`rdf_type_name`
      }
    },
    fromJSONObject = function(InfrastructureFacilityCreationDTOObject) {
      if (!is.null(InfrastructureFacilityCreationDTOObject$`uri`)) {
        self$`uri` <- InfrastructureFacilityCreationDTOObject$`uri`
      }
      if (!is.null(InfrastructureFacilityCreationDTOObject$`rdf_type`)) {
        self$`rdf_type` <- InfrastructureFacilityCreationDTOObject$`rdf_type`
      }
      if (!is.null(InfrastructureFacilityCreationDTOObject$`name`)) {
        self$`name` <- InfrastructureFacilityCreationDTOObject$`name`
      }
      if (!is.null(InfrastructureFacilityCreationDTOObject$`organizations`)) {
        self$`organizations` <- InfrastructureFacilityCreationDTOObject$`organizations`
      }
      if (!is.null(InfrastructureFacilityCreationDTOObject$`address`)) {
        addressObject <- FacilityAddressDTO$new()
        addressObject$fromJSON(jsonlite::toJSON(InfrastructureFacilityCreationDTOObject$address, auto_unbox = TRUE, null = "null"))
        self$`address` <- addressObject
      }
      if (!is.null(InfrastructureFacilityCreationDTOObject$`relations`)) {
        self$`relations` <- lapply(InfrastructureFacilityCreationDTOObject$`relations`, function(x) {
          relationsObject <- RDFObjectRelationDTO$new()
          relationsObject$fromJSON(jsonlite::toJSON(x, auto_unbox = TRUE, null = "null"))
          relationsObject
        })
      }
      if (!is.null(InfrastructureFacilityCreationDTOObject$`rdf_type_name`)) {
        self$`rdf_type_name` <- InfrastructureFacilityCreationDTOObject$`rdf_type_name`
      }
    },
    toJSONString = function() {
      relationsList = paste(lapply(self$`relations`, function(x) x$toJSONString()),collapse = ",")
       sprintf(
        '{
           "uri": %s,
           "rdf_type": %s,
           "name": %s,
           "organizations": [%s],
           "address": %s,
           "relations": [%s],
           "rdf_type_name": %s
        }',
        ifelse(is.null(self$`uri`), "null",jsonlite::toJSON(self$`uri`,auto_unbox=TRUE, null = "null")),
        ifelse(is.null(self$`rdf_type`), "null",jsonlite::toJSON(self$`rdf_type`,auto_unbox=TRUE, null = "null")),
        ifelse(is.null(self$`name`), "null",jsonlite::toJSON(self$`name`,auto_unbox=TRUE, null = "null")),
        ifelse(is.null(self$`organizations`) || length(self$`organizations`) == 0, "" ,lapply(self$`organizations`, function(x) paste(paste0('"', x, '"'), sep=","))),
        jsonlite::toJSON(self$`address`$toJSON(),auto_unbox=TRUE, null = "null"),
        relationsList,
        ifelse(is.null(self$`rdf_type_name`), "null",jsonlite::toJSON(self$`rdf_type_name`,auto_unbox=TRUE, null = "null"))
      )
    },
    fromJSONString = function(InfrastructureFacilityCreationDTOJson) {
      InfrastructureFacilityCreationDTOObject <- jsonlite::fromJSON(InfrastructureFacilityCreationDTOJson)
      self$`uri` <- InfrastructureFacilityCreationDTOObject$`uri`
      self$`rdf_type` <- InfrastructureFacilityCreationDTOObject$`rdf_type`
      self$`name` <- InfrastructureFacilityCreationDTOObject$`name`
      self$`organizations` <- InfrastructureFacilityCreationDTOObject$`organizations`
      FacilityAddressDTOObject <- FacilityAddressDTO$new()
      self$`address` <- FacilityAddressDTOObject$fromJSON(jsonlite::toJSON(InfrastructureFacilityCreationDTOObject$address, auto_unbox = TRUE))
      self$`relations` <- lapply(InfrastructureFacilityCreationDTOObject$`relations`, function(x) RDFObjectRelationDTO$new()$fromJSON(jsonlite::toJSON(x, auto_unbox = TRUE)))
      self$`rdf_type_name` <- InfrastructureFacilityCreationDTOObject$`rdf_type_name`
    }
  )
)
OpenSILEX/opensilexClientToolsR documentation built on Jan. 28, 2022, 5:03 a.m.