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


#' ProfileUpdateDTO Class
#'
#' @field uri 
#' @field name 
#' @field credentials 
#'
#' @importFrom R6 R6Class
#' @importFrom jsonlite fromJSON toJSON
#' @export
ProfileUpdateDTO <- R6::R6Class(
  'ProfileUpdateDTO',
  public = list(
    `uri` = NULL,
    `name` = NULL,
    `credentials` = NULL,
    initialize = function(`uri`, `name`, `credentials`){
      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(`credentials`)) {
        stopifnot(is.list(`credentials`), length(`credentials`) != 0)
        lapply(`credentials`, function(x) stopifnot(is.character(x)))
        self$`credentials` <- `credentials`
      }
    },
    toJSON = function() {
      ProfileUpdateDTOObject <- list()
      if (!is.null(self$`uri`)) {
        ProfileUpdateDTOObject[['uri']] <- self$`uri`
      }
      if (!is.null(self$`name`)) {
        ProfileUpdateDTOObject[['name']] <- self$`name`
      }
      if (!is.null(self$`credentials`)) {
        ProfileUpdateDTOObject[['credentials']] <- self$`credentials`
      }

      ProfileUpdateDTOObject
    },
    fromJSON = function(ProfileUpdateDTOJson) {
      ProfileUpdateDTOObject <- jsonlite::fromJSON(ProfileUpdateDTOJson)
      if (!is.null(ProfileUpdateDTOObject$`uri`)) {
        self$`uri` <- ProfileUpdateDTOObject$`uri`
      }
      if (!is.null(ProfileUpdateDTOObject$`name`)) {
        self$`name` <- ProfileUpdateDTOObject$`name`
      }
      if (!is.null(ProfileUpdateDTOObject$`credentials`)) {
        self$`credentials` <- ProfileUpdateDTOObject$`credentials`
      }
    },
    fromJSONObject = function(ProfileUpdateDTOObject) {
      if (!is.null(ProfileUpdateDTOObject$`uri`)) {
        self$`uri` <- ProfileUpdateDTOObject$`uri`
      }
      if (!is.null(ProfileUpdateDTOObject$`name`)) {
        self$`name` <- ProfileUpdateDTOObject$`name`
      }
      if (!is.null(ProfileUpdateDTOObject$`credentials`)) {
        self$`credentials` <- ProfileUpdateDTOObject$`credentials`
      }
    },
    toJSONString = function() {
       sprintf(
        '{
           "uri": %s,
           "name": %s,
           "credentials": [%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$`credentials`) || length(self$`credentials`) == 0, "" ,lapply(self$`credentials`, function(x) paste(paste0('"', x, '"'), sep=",")))
      )
    },
    fromJSONString = function(ProfileUpdateDTOJson) {
      ProfileUpdateDTOObject <- jsonlite::fromJSON(ProfileUpdateDTOJson)
      self$`uri` <- ProfileUpdateDTOObject$`uri`
      self$`name` <- ProfileUpdateDTOObject$`name`
      self$`credentials` <- ProfileUpdateDTOObject$`credentials`
    }
  )
)
OpenSILEX/opensilexClientToolsR documentation built on Jan. 28, 2022, 5:03 a.m.