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


#' FactorUpdateDTO Class
#'
#' @field uri 
#' @field name 
#' @field category 
#' @field description 
#' @field levels 
#' @field exact_match 
#' @field close_match 
#' @field broad_match 
#' @field narrow_match 
#'
#' @importFrom R6 R6Class
#' @importFrom jsonlite fromJSON toJSON
#' @export
FactorUpdateDTO <- R6::R6Class(
  'FactorUpdateDTO',
  public = list(
    `uri` = NULL,
    `name` = NULL,
    `category` = NULL,
    `description` = NULL,
    `levels` = NULL,
    `exact_match` = NULL,
    `close_match` = NULL,
    `broad_match` = NULL,
    `narrow_match` = NULL,
    initialize = function(`uri`, `name`, `category`, `description`, `levels`, `exact_match`, `close_match`, `broad_match`, `narrow_match`){
      if (!missing(`uri`)) {
        stopifnot(is.character(`uri`), length(`uri`) == 1)
        self$`uri` <- `uri`
      }
      if (!missing(`name`)) {
        stopifnot(is.character(`name`), length(`name`) == 1)
        self$`name` <- `name`
      }
      if (!missing(`category`)) {
        stopifnot(is.character(`category`), length(`category`) == 1)
        self$`category` <- `category`
      }
      if (!missing(`description`)) {
        stopifnot(is.character(`description`), length(`description`) == 1)
        self$`description` <- `description`
      }
      if (!missing(`levels`)) {
        stopifnot(is.list(`levels`), length(`levels`) != 0)
        lapply(`levels`, function(x) stopifnot(R6::is.R6(x)))
        self$`levels` <- `levels`
      }
      if (!missing(`exact_match`)) {
        stopifnot(is.list(`exact_match`), length(`exact_match`) != 0)
        lapply(`exact_match`, function(x) stopifnot(is.character(x)))
        self$`exact_match` <- `exact_match`
      }
      if (!missing(`close_match`)) {
        stopifnot(is.list(`close_match`), length(`close_match`) != 0)
        lapply(`close_match`, function(x) stopifnot(is.character(x)))
        self$`close_match` <- `close_match`
      }
      if (!missing(`broad_match`)) {
        stopifnot(is.list(`broad_match`), length(`broad_match`) != 0)
        lapply(`broad_match`, function(x) stopifnot(is.character(x)))
        self$`broad_match` <- `broad_match`
      }
      if (!missing(`narrow_match`)) {
        stopifnot(is.list(`narrow_match`), length(`narrow_match`) != 0)
        lapply(`narrow_match`, function(x) stopifnot(is.character(x)))
        self$`narrow_match` <- `narrow_match`
      }
    },
    toJSON = function() {
      FactorUpdateDTOObject <- list()
      if (!is.null(self$`uri`)) {
        FactorUpdateDTOObject[['uri']] <- self$`uri`
      }
      if (!is.null(self$`name`)) {
        FactorUpdateDTOObject[['name']] <- self$`name`
      }
      if (!is.null(self$`category`)) {
        FactorUpdateDTOObject[['category']] <- self$`category`
      }
      if (!is.null(self$`description`)) {
        FactorUpdateDTOObject[['description']] <- self$`description`
      }
      if (!is.null(self$`levels`)) {
        FactorUpdateDTOObject[['levels']] <- lapply(self$`levels`, function(x) x$toJSON())
      }
      if (!is.null(self$`exact_match`)) {
        FactorUpdateDTOObject[['exact_match']] <- self$`exact_match`
      }
      if (!is.null(self$`close_match`)) {
        FactorUpdateDTOObject[['close_match']] <- self$`close_match`
      }
      if (!is.null(self$`broad_match`)) {
        FactorUpdateDTOObject[['broad_match']] <- self$`broad_match`
      }
      if (!is.null(self$`narrow_match`)) {
        FactorUpdateDTOObject[['narrow_match']] <- self$`narrow_match`
      }

      FactorUpdateDTOObject
    },
    fromJSON = function(FactorUpdateDTOJson) {
      FactorUpdateDTOObject <- jsonlite::fromJSON(FactorUpdateDTOJson)
      if (!is.null(FactorUpdateDTOObject$`uri`)) {
        self$`uri` <- FactorUpdateDTOObject$`uri`
      }
      if (!is.null(FactorUpdateDTOObject$`name`)) {
        self$`name` <- FactorUpdateDTOObject$`name`
      }
      if (!is.null(FactorUpdateDTOObject$`category`)) {
        self$`category` <- FactorUpdateDTOObject$`category`
      }
      if (!is.null(FactorUpdateDTOObject$`description`)) {
        self$`description` <- FactorUpdateDTOObject$`description`
      }
      if (!is.null(FactorUpdateDTOObject$`levels`)) {
        self$`levels` <- lapply(FactorUpdateDTOObject$`levels`, function(x) {
          levelsObject <- FactorLevelCreationDTO$new()
          levelsObject$fromJSON(jsonlite::toJSON(x, auto_unbox = TRUE, null = "null"))
          levelsObject
        })
      }
      if (!is.null(FactorUpdateDTOObject$`exact_match`)) {
        self$`exact_match` <- FactorUpdateDTOObject$`exact_match`
      }
      if (!is.null(FactorUpdateDTOObject$`close_match`)) {
        self$`close_match` <- FactorUpdateDTOObject$`close_match`
      }
      if (!is.null(FactorUpdateDTOObject$`broad_match`)) {
        self$`broad_match` <- FactorUpdateDTOObject$`broad_match`
      }
      if (!is.null(FactorUpdateDTOObject$`narrow_match`)) {
        self$`narrow_match` <- FactorUpdateDTOObject$`narrow_match`
      }
    },
    fromJSONObject = function(FactorUpdateDTOObject) {
      if (!is.null(FactorUpdateDTOObject$`uri`)) {
        self$`uri` <- FactorUpdateDTOObject$`uri`
      }
      if (!is.null(FactorUpdateDTOObject$`name`)) {
        self$`name` <- FactorUpdateDTOObject$`name`
      }
      if (!is.null(FactorUpdateDTOObject$`category`)) {
        self$`category` <- FactorUpdateDTOObject$`category`
      }
      if (!is.null(FactorUpdateDTOObject$`description`)) {
        self$`description` <- FactorUpdateDTOObject$`description`
      }
      if (!is.null(FactorUpdateDTOObject$`levels`)) {
        self$`levels` <- lapply(FactorUpdateDTOObject$`levels`, function(x) {
          levelsObject <- FactorLevelCreationDTO$new()
          levelsObject$fromJSON(jsonlite::toJSON(x, auto_unbox = TRUE, null = "null"))
          levelsObject
        })
      }
      if (!is.null(FactorUpdateDTOObject$`exact_match`)) {
        self$`exact_match` <- FactorUpdateDTOObject$`exact_match`
      }
      if (!is.null(FactorUpdateDTOObject$`close_match`)) {
        self$`close_match` <- FactorUpdateDTOObject$`close_match`
      }
      if (!is.null(FactorUpdateDTOObject$`broad_match`)) {
        self$`broad_match` <- FactorUpdateDTOObject$`broad_match`
      }
      if (!is.null(FactorUpdateDTOObject$`narrow_match`)) {
        self$`narrow_match` <- FactorUpdateDTOObject$`narrow_match`
      }
    },
    toJSONString = function() {
      levelsList = paste(lapply(self$`levels`, function(x) x$toJSONString()),collapse = ",")
       sprintf(
        '{
           "uri": %s,
           "name": %s,
           "category": %s,
           "description": %s,
           "levels": [%s],
           "exact_match": [%s],
           "close_match": [%s],
           "broad_match": [%s],
           "narrow_match": [%s]
        }',
        ifelse(is.null(self$`uri`), "null",jsonlite::toJSON(self$`uri`,auto_unbox=TRUE, null = "null")),
        ifelse(is.null(self$`name`), "null",jsonlite::toJSON(self$`name`,auto_unbox=TRUE, null = "null")),
        ifelse(is.null(self$`category`), "null",jsonlite::toJSON(self$`category`,auto_unbox=TRUE, null = "null")),
        ifelse(is.null(self$`description`), "null",jsonlite::toJSON(self$`description`,auto_unbox=TRUE, null = "null")),
        levelsList,
        ifelse(is.null(self$`exact_match`) || length(self$`exact_match`) == 0, "" ,lapply(self$`exact_match`, function(x) paste(paste0('"', x, '"'), sep=","))),
        ifelse(is.null(self$`close_match`) || length(self$`close_match`) == 0, "" ,lapply(self$`close_match`, function(x) paste(paste0('"', x, '"'), sep=","))),
        ifelse(is.null(self$`broad_match`) || length(self$`broad_match`) == 0, "" ,lapply(self$`broad_match`, function(x) paste(paste0('"', x, '"'), sep=","))),
        ifelse(is.null(self$`narrow_match`) || length(self$`narrow_match`) == 0, "" ,lapply(self$`narrow_match`, function(x) paste(paste0('"', x, '"'), sep=",")))
      )
    },
    fromJSONString = function(FactorUpdateDTOJson) {
      FactorUpdateDTOObject <- jsonlite::fromJSON(FactorUpdateDTOJson)
      self$`uri` <- FactorUpdateDTOObject$`uri`
      self$`name` <- FactorUpdateDTOObject$`name`
      self$`category` <- FactorUpdateDTOObject$`category`
      self$`description` <- FactorUpdateDTOObject$`description`
      self$`levels` <- lapply(FactorUpdateDTOObject$`levels`, function(x) FactorLevelCreationDTO$new()$fromJSON(jsonlite::toJSON(x, auto_unbox = TRUE)))
      self$`exact_match` <- FactorUpdateDTOObject$`exact_match`
      self$`close_match` <- FactorUpdateDTOObject$`close_match`
      self$`broad_match` <- FactorUpdateDTOObject$`broad_match`
      self$`narrow_match` <- FactorUpdateDTOObject$`narrow_match`
    }
  )
)
OpenSILEX/opensilexClientToolsR documentation built on Jan. 28, 2022, 5:03 a.m.