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


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

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