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


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

      URITypesDTOObject
    },
    fromJSON = function(URITypesDTOJson) {
      URITypesDTOObject <- jsonlite::fromJSON(URITypesDTOJson)
      if (!is.null(URITypesDTOObject$`uri`)) {
        self$`uri` <- URITypesDTOObject$`uri`
      }
      if (!is.null(URITypesDTOObject$`rdf_types`)) {
        self$`rdf_types` <- URITypesDTOObject$`rdf_types`
      }
    },
    fromJSONObject = function(URITypesDTOObject) {
      if (!is.null(URITypesDTOObject$`uri`)) {
        self$`uri` <- URITypesDTOObject$`uri`
      }
      if (!is.null(URITypesDTOObject$`rdf_types`)) {
        self$`rdf_types` <- URITypesDTOObject$`rdf_types`
      }
    },
    toJSONString = function() {
       sprintf(
        '{
           "uri": %s,
           "rdf_types": [%s]
        }',
        ifelse(is.null(self$`uri`), "null",jsonlite::toJSON(self$`uri`,auto_unbox=TRUE, null = "null")),
        ifelse(is.null(self$`rdf_types`) || length(self$`rdf_types`) == 0, "" ,lapply(self$`rdf_types`, function(x) paste(paste0('"', x, '"'), sep=",")))
      )
    },
    fromJSONString = function(URITypesDTOJson) {
      URITypesDTOObject <- jsonlite::fromJSON(URITypesDTOJson)
      self$`uri` <- URITypesDTOObject$`uri`
      self$`rdf_types` <- URITypesDTOObject$`rdf_types`
    }
  )
)
OpenSILEX/opensilexClientToolsR documentation built on Jan. 28, 2022, 5:03 a.m.