R/AnnotationDTO.r

# sunagriAPI
#
# An instance of OpenSILEX WebService
#
# OpenAPI spec version: 3.3.0
# 
# Generated by: https://github.com/swagger-api/swagger-codegen.git


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

      AnnotationDTOObject
    },
    fromJSON = function(AnnotationDTOJson) {
      AnnotationDTOObject <- jsonlite::fromJSON(AnnotationDTOJson)
      if (!is.null(AnnotationDTOObject$`creator`)) {
        self$`creator` <- AnnotationDTOObject$`creator`
      }
      if (!is.null(AnnotationDTOObject$`motivatedBy`)) {
        self$`motivatedBy` <- AnnotationDTOObject$`motivatedBy`
      }
      if (!is.null(AnnotationDTOObject$`bodyValues`)) {
        self$`bodyValues` <- AnnotationDTOObject$`bodyValues`
      }
      if (!is.null(AnnotationDTOObject$`targets`)) {
        self$`targets` <- AnnotationDTOObject$`targets`
      }
      if (!is.null(AnnotationDTOObject$`uri`)) {
        self$`uri` <- AnnotationDTOObject$`uri`
      }
      if (!is.null(AnnotationDTOObject$`creationDate`)) {
        self$`creationDate` <- AnnotationDTOObject$`creationDate`
      }
    },
    fromJSONObject = function(AnnotationDTOObject) {
      if (!is.null(AnnotationDTOObject$`creator`)) {
        self$`creator` <- AnnotationDTOObject$`creator`
      }
      if (!is.null(AnnotationDTOObject$`motivatedBy`)) {
        self$`motivatedBy` <- AnnotationDTOObject$`motivatedBy`
      }
      if (!is.null(AnnotationDTOObject$`bodyValues`)) {
        self$`bodyValues` <- AnnotationDTOObject$`bodyValues`
      }
      if (!is.null(AnnotationDTOObject$`targets`)) {
        self$`targets` <- AnnotationDTOObject$`targets`
      }
      if (!is.null(AnnotationDTOObject$`uri`)) {
        self$`uri` <- AnnotationDTOObject$`uri`
      }
      if (!is.null(AnnotationDTOObject$`creationDate`)) {
        self$`creationDate` <- AnnotationDTOObject$`creationDate`
      }
    },
    toJSONString = function() {
       sprintf(
        '{
           "creator": %s,
           "motivatedBy": %s,
           "bodyValues": [%s],
           "targets": [%s],
           "uri": %s,
           "creationDate": %s
        }',
        jsonlite::toJSON(self$`creator`,auto_unbox=TRUE, null = "null"),
        jsonlite::toJSON(self$`motivatedBy`,auto_unbox=TRUE, null = "null"),
        lapply(self$`bodyValues`, function(x) paste(paste0('"', x, '"'), sep=",")),
        lapply(self$`targets`, function(x) paste(paste0('"', x, '"'), sep=",")),
        jsonlite::toJSON(self$`uri`,auto_unbox=TRUE, null = "null"),
        jsonlite::toJSON(self$`creationDate`,auto_unbox=TRUE, null = "null")
      )
    },
    fromJSONString = function(AnnotationDTOJson) {
      AnnotationDTOObject <- jsonlite::fromJSON(AnnotationDTOJson)
      self$`creator` <- AnnotationDTOObject$`creator`
      self$`motivatedBy` <- AnnotationDTOObject$`motivatedBy`
      self$`bodyValues` <- AnnotationDTOObject$`bodyValues`
      self$`targets` <- AnnotationDTOObject$`targets`
      self$`uri` <- AnnotationDTOObject$`uri`
      self$`creationDate` <- AnnotationDTOObject$`creationDate`
    }
  )
)
OpenSILEX/phis-ws-client-r-tool documentation built on Sept. 10, 2020, 8:42 a.m.