R/AnnotationPostDTO.r

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


#' AnnotationPostDTO Class
#'
#' @field creator 
#' @field motivatedBy 
#' @field bodyValues 
#' @field targets 
#'
#' @importFrom R6 R6Class
#' @importFrom jsonlite fromJSON toJSON
#' @export
AnnotationPostDTO <- R6::R6Class(
  'AnnotationPostDTO',
  public = list(
    `creator` = NULL,
    `motivatedBy` = NULL,
    `bodyValues` = NULL,
    `targets` = NULL,
    initialize = function(`creator`, `motivatedBy`, `bodyValues`, `targets`){
      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`
      }
    },
    toJSON = function() {
      AnnotationPostDTOObject <- list()
      if (!is.null(self$`creator`)) {
        AnnotationPostDTOObject[['creator']] <- self$`creator`
      }
      if (!is.null(self$`motivatedBy`)) {
        AnnotationPostDTOObject[['motivatedBy']] <- self$`motivatedBy`
      }
      if (!is.null(self$`bodyValues`)) {
        AnnotationPostDTOObject[['bodyValues']] <- self$`bodyValues`
      }
      if (!is.null(self$`targets`)) {
        AnnotationPostDTOObject[['targets']] <- self$`targets`
      }

      AnnotationPostDTOObject
    },
    fromJSON = function(AnnotationPostDTOJson) {
      AnnotationPostDTOObject <- jsonlite::fromJSON(AnnotationPostDTOJson)
      if (!is.null(AnnotationPostDTOObject$`creator`)) {
        self$`creator` <- AnnotationPostDTOObject$`creator`
      }
      if (!is.null(AnnotationPostDTOObject$`motivatedBy`)) {
        self$`motivatedBy` <- AnnotationPostDTOObject$`motivatedBy`
      }
      if (!is.null(AnnotationPostDTOObject$`bodyValues`)) {
        self$`bodyValues` <- AnnotationPostDTOObject$`bodyValues`
      }
      if (!is.null(AnnotationPostDTOObject$`targets`)) {
        self$`targets` <- AnnotationPostDTOObject$`targets`
      }
    },
    fromJSONObject = function(AnnotationPostDTOObject) {
      if (!is.null(AnnotationPostDTOObject$`creator`)) {
        self$`creator` <- AnnotationPostDTOObject$`creator`
      }
      if (!is.null(AnnotationPostDTOObject$`motivatedBy`)) {
        self$`motivatedBy` <- AnnotationPostDTOObject$`motivatedBy`
      }
      if (!is.null(AnnotationPostDTOObject$`bodyValues`)) {
        self$`bodyValues` <- AnnotationPostDTOObject$`bodyValues`
      }
      if (!is.null(AnnotationPostDTOObject$`targets`)) {
        self$`targets` <- AnnotationPostDTOObject$`targets`
      }
    },
    toJSONString = function() {
       sprintf(
        '{
           "creator": %s,
           "motivatedBy": %s,
           "bodyValues": [%s],
           "targets": [%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=","))
      )
    },
    fromJSONString = function(AnnotationPostDTOJson) {
      AnnotationPostDTOObject <- jsonlite::fromJSON(AnnotationPostDTOJson)
      self$`creator` <- AnnotationPostDTOObject$`creator`
      self$`motivatedBy` <- AnnotationPostDTOObject$`motivatedBy`
      self$`bodyValues` <- AnnotationPostDTOObject$`bodyValues`
      self$`targets` <- AnnotationPostDTOObject$`targets`
    }
  )
)
OpenSILEX/phis-ws-client-r-tool documentation built on Sept. 10, 2020, 8:42 a.m.