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


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

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