R/ExperimentPostDTO.r

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


#' ExperimentPostDTO Class
#'
#' @field startDate 
#' @field endDate 
#' @field field 
#' @field campaign 
#' @field place 
#' @field alias 
#' @field comment 
#' @field keywords 
#' @field objective 
#' @field cropSpecies 
#' @field projectsUris 
#' @field groupsUris 
#' @field contacts 
#'
#' @importFrom R6 R6Class
#' @importFrom jsonlite fromJSON toJSON
#' @export
ExperimentPostDTO <- R6::R6Class(
  'ExperimentPostDTO',
  public = list(
    `startDate` = NULL,
    `endDate` = NULL,
    `field` = NULL,
    `campaign` = NULL,
    `place` = NULL,
    `alias` = NULL,
    `comment` = NULL,
    `keywords` = NULL,
    `objective` = NULL,
    `cropSpecies` = NULL,
    `projectsUris` = NULL,
    `groupsUris` = NULL,
    `contacts` = NULL,
    initialize = function(`startDate`, `endDate`, `field`, `campaign`, `place`, `alias`, `comment`, `keywords`, `objective`, `cropSpecies`, `projectsUris`, `groupsUris`, `contacts`){
      if (!missing(`startDate`)) {
        stopifnot(is.character(`startDate`), length(`startDate`) == 1)
        self$`startDate` <- `startDate`
      }
      if (!missing(`endDate`)) {
        stopifnot(is.character(`endDate`), length(`endDate`) == 1)
        self$`endDate` <- `endDate`
      }
      if (!missing(`field`)) {
        stopifnot(is.character(`field`), length(`field`) == 1)
        self$`field` <- `field`
      }
      if (!missing(`campaign`)) {
        stopifnot(is.character(`campaign`), length(`campaign`) == 1)
        self$`campaign` <- `campaign`
      }
      if (!missing(`place`)) {
        stopifnot(is.character(`place`), length(`place`) == 1)
        self$`place` <- `place`
      }
      if (!missing(`alias`)) {
        stopifnot(is.character(`alias`), length(`alias`) == 1)
        self$`alias` <- `alias`
      }
      if (!missing(`comment`)) {
        stopifnot(is.character(`comment`), length(`comment`) == 1)
        self$`comment` <- `comment`
      }
      if (!missing(`keywords`)) {
        stopifnot(is.character(`keywords`), length(`keywords`) == 1)
        self$`keywords` <- `keywords`
      }
      if (!missing(`objective`)) {
        stopifnot(is.character(`objective`), length(`objective`) == 1)
        self$`objective` <- `objective`
      }
      if (!missing(`cropSpecies`)) {
        stopifnot(is.character(`cropSpecies`), length(`cropSpecies`) == 1)
        self$`cropSpecies` <- `cropSpecies`
      }
      if (!missing(`projectsUris`)) {
        stopifnot(is.list(`projectsUris`), length(`projectsUris`) != 0)
        lapply(`projectsUris`, function(x) stopifnot(is.character(x)))
        self$`projectsUris` <- `projectsUris`
      }
      if (!missing(`groupsUris`)) {
        stopifnot(is.list(`groupsUris`), length(`groupsUris`) != 0)
        lapply(`groupsUris`, function(x) stopifnot(is.character(x)))
        self$`groupsUris` <- `groupsUris`
      }
      if (!missing(`contacts`)) {
        stopifnot(is.list(`contacts`), length(`contacts`) != 0)
        lapply(`contacts`, function(x) stopifnot(R6::is.R6(x)))
        self$`contacts` <- `contacts`
      }
    },
    toJSON = function() {
      ExperimentPostDTOObject <- list()
      if (!is.null(self$`startDate`)) {
        ExperimentPostDTOObject[['startDate']] <- self$`startDate`
      }
      if (!is.null(self$`endDate`)) {
        ExperimentPostDTOObject[['endDate']] <- self$`endDate`
      }
      if (!is.null(self$`field`)) {
        ExperimentPostDTOObject[['field']] <- self$`field`
      }
      if (!is.null(self$`campaign`)) {
        ExperimentPostDTOObject[['campaign']] <- self$`campaign`
      }
      if (!is.null(self$`place`)) {
        ExperimentPostDTOObject[['place']] <- self$`place`
      }
      if (!is.null(self$`alias`)) {
        ExperimentPostDTOObject[['alias']] <- self$`alias`
      }
      if (!is.null(self$`comment`)) {
        ExperimentPostDTOObject[['comment']] <- self$`comment`
      }
      if (!is.null(self$`keywords`)) {
        ExperimentPostDTOObject[['keywords']] <- self$`keywords`
      }
      if (!is.null(self$`objective`)) {
        ExperimentPostDTOObject[['objective']] <- self$`objective`
      }
      if (!is.null(self$`cropSpecies`)) {
        ExperimentPostDTOObject[['cropSpecies']] <- self$`cropSpecies`
      }
      if (!is.null(self$`projectsUris`)) {
        ExperimentPostDTOObject[['projectsUris']] <- self$`projectsUris`
      }
      if (!is.null(self$`groupsUris`)) {
        ExperimentPostDTOObject[['groupsUris']] <- self$`groupsUris`
      }
      if (!is.null(self$`contacts`)) {
        ExperimentPostDTOObject[['contacts']] <- lapply(self$`contacts`, function(x) x$toJSON())
      }

      ExperimentPostDTOObject
    },
    fromJSON = function(ExperimentPostDTOJson) {
      ExperimentPostDTOObject <- jsonlite::fromJSON(ExperimentPostDTOJson)
      if (!is.null(ExperimentPostDTOObject$`startDate`)) {
        self$`startDate` <- ExperimentPostDTOObject$`startDate`
      }
      if (!is.null(ExperimentPostDTOObject$`endDate`)) {
        self$`endDate` <- ExperimentPostDTOObject$`endDate`
      }
      if (!is.null(ExperimentPostDTOObject$`field`)) {
        self$`field` <- ExperimentPostDTOObject$`field`
      }
      if (!is.null(ExperimentPostDTOObject$`campaign`)) {
        self$`campaign` <- ExperimentPostDTOObject$`campaign`
      }
      if (!is.null(ExperimentPostDTOObject$`place`)) {
        self$`place` <- ExperimentPostDTOObject$`place`
      }
      if (!is.null(ExperimentPostDTOObject$`alias`)) {
        self$`alias` <- ExperimentPostDTOObject$`alias`
      }
      if (!is.null(ExperimentPostDTOObject$`comment`)) {
        self$`comment` <- ExperimentPostDTOObject$`comment`
      }
      if (!is.null(ExperimentPostDTOObject$`keywords`)) {
        self$`keywords` <- ExperimentPostDTOObject$`keywords`
      }
      if (!is.null(ExperimentPostDTOObject$`objective`)) {
        self$`objective` <- ExperimentPostDTOObject$`objective`
      }
      if (!is.null(ExperimentPostDTOObject$`cropSpecies`)) {
        self$`cropSpecies` <- ExperimentPostDTOObject$`cropSpecies`
      }
      if (!is.null(ExperimentPostDTOObject$`projectsUris`)) {
        self$`projectsUris` <- ExperimentPostDTOObject$`projectsUris`
      }
      if (!is.null(ExperimentPostDTOObject$`groupsUris`)) {
        self$`groupsUris` <- ExperimentPostDTOObject$`groupsUris`
      }
      if (!is.null(ExperimentPostDTOObject$`contacts`)) {
        self$`contacts` <- lapply(ExperimentPostDTOObject$`contacts`, function(x) {
          contactsObject <- ContactPostgreSQL$new()
          contactsObject$fromJSON(jsonlite::toJSON(x, auto_unbox = TRUE, null = "null"))
          contactsObject
        })
      }
    },
    fromJSONObject = function(ExperimentPostDTOObject) {
      if (!is.null(ExperimentPostDTOObject$`startDate`)) {
        self$`startDate` <- ExperimentPostDTOObject$`startDate`
      }
      if (!is.null(ExperimentPostDTOObject$`endDate`)) {
        self$`endDate` <- ExperimentPostDTOObject$`endDate`
      }
      if (!is.null(ExperimentPostDTOObject$`field`)) {
        self$`field` <- ExperimentPostDTOObject$`field`
      }
      if (!is.null(ExperimentPostDTOObject$`campaign`)) {
        self$`campaign` <- ExperimentPostDTOObject$`campaign`
      }
      if (!is.null(ExperimentPostDTOObject$`place`)) {
        self$`place` <- ExperimentPostDTOObject$`place`
      }
      if (!is.null(ExperimentPostDTOObject$`alias`)) {
        self$`alias` <- ExperimentPostDTOObject$`alias`
      }
      if (!is.null(ExperimentPostDTOObject$`comment`)) {
        self$`comment` <- ExperimentPostDTOObject$`comment`
      }
      if (!is.null(ExperimentPostDTOObject$`keywords`)) {
        self$`keywords` <- ExperimentPostDTOObject$`keywords`
      }
      if (!is.null(ExperimentPostDTOObject$`objective`)) {
        self$`objective` <- ExperimentPostDTOObject$`objective`
      }
      if (!is.null(ExperimentPostDTOObject$`cropSpecies`)) {
        self$`cropSpecies` <- ExperimentPostDTOObject$`cropSpecies`
      }
      if (!is.null(ExperimentPostDTOObject$`projectsUris`)) {
        self$`projectsUris` <- ExperimentPostDTOObject$`projectsUris`
      }
      if (!is.null(ExperimentPostDTOObject$`groupsUris`)) {
        self$`groupsUris` <- ExperimentPostDTOObject$`groupsUris`
      }
      if (!is.null(ExperimentPostDTOObject$`contacts`)) {
        self$`contacts` <- lapply(ExperimentPostDTOObject$`contacts`, function(x) {
          contactsObject <- ContactPostgreSQL$new()
          contactsObject$fromJSON(jsonlite::toJSON(x, auto_unbox = TRUE, null = "null"))
          contactsObject
        })
      }
    },
    toJSONString = function() {
      contactsList = paste(lapply(self$`contacts`, function(x) x$toJSONString()),collapse = ",")
       sprintf(
        '{
           "startDate": %s,
           "endDate": %s,
           "field": %s,
           "campaign": %s,
           "place": %s,
           "alias": %s,
           "comment": %s,
           "keywords": %s,
           "objective": %s,
           "cropSpecies": %s,
           "projectsUris": [%s],
           "groupsUris": [%s],
           "contacts": [%s]
        }',
        jsonlite::toJSON(self$`startDate`,auto_unbox=TRUE, null = "null"),
        jsonlite::toJSON(self$`endDate`,auto_unbox=TRUE, null = "null"),
        jsonlite::toJSON(self$`field`,auto_unbox=TRUE, null = "null"),
        jsonlite::toJSON(self$`campaign`,auto_unbox=TRUE, null = "null"),
        jsonlite::toJSON(self$`place`,auto_unbox=TRUE, null = "null"),
        jsonlite::toJSON(self$`alias`,auto_unbox=TRUE, null = "null"),
        jsonlite::toJSON(self$`comment`,auto_unbox=TRUE, null = "null"),
        jsonlite::toJSON(self$`keywords`,auto_unbox=TRUE, null = "null"),
        jsonlite::toJSON(self$`objective`,auto_unbox=TRUE, null = "null"),
        jsonlite::toJSON(self$`cropSpecies`,auto_unbox=TRUE, null = "null"),
        lapply(self$`projectsUris`, function(x) paste(paste0('"', x, '"'), sep=",")),
        lapply(self$`groupsUris`, function(x) paste(paste0('"', x, '"'), sep=",")),
        contactsList
      )
    },
    fromJSONString = function(ExperimentPostDTOJson) {
      ExperimentPostDTOObject <- jsonlite::fromJSON(ExperimentPostDTOJson)
      self$`startDate` <- ExperimentPostDTOObject$`startDate`
      self$`endDate` <- ExperimentPostDTOObject$`endDate`
      self$`field` <- ExperimentPostDTOObject$`field`
      self$`campaign` <- ExperimentPostDTOObject$`campaign`
      self$`place` <- ExperimentPostDTOObject$`place`
      self$`alias` <- ExperimentPostDTOObject$`alias`
      self$`comment` <- ExperimentPostDTOObject$`comment`
      self$`keywords` <- ExperimentPostDTOObject$`keywords`
      self$`objective` <- ExperimentPostDTOObject$`objective`
      self$`cropSpecies` <- ExperimentPostDTOObject$`cropSpecies`
      self$`projectsUris` <- ExperimentPostDTOObject$`projectsUris`
      self$`groupsUris` <- ExperimentPostDTOObject$`groupsUris`
      self$`contacts` <- lapply(ExperimentPostDTOObject$`contacts`, function(x) ContactPostgreSQL$new()$fromJSON(jsonlite::toJSON(x, auto_unbox = TRUE)))
    }
  )
)
OpenSILEX/phis-ws-client-r-tool documentation built on Sept. 10, 2020, 8:42 a.m.