R/ProjectPostDTO.r

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


#' ProjectPostDTO Class
#'
#' @field name 
#' @field shortname 
#' @field relatedProjects 
#' @field financialFunding 
#' @field financialReference 
#' @field description 
#' @field startDate 
#' @field endDate 
#' @field keywords 
#' @field homePage 
#' @field administrativeContacts 
#' @field coordinators 
#' @field scientificContacts 
#' @field objective 
#'
#' @importFrom R6 R6Class
#' @importFrom jsonlite fromJSON toJSON
#' @export
ProjectPostDTO <- R6::R6Class(
  'ProjectPostDTO',
  public = list(
    `name` = NULL,
    `shortname` = NULL,
    `relatedProjects` = NULL,
    `financialFunding` = NULL,
    `financialReference` = NULL,
    `description` = NULL,
    `startDate` = NULL,
    `endDate` = NULL,
    `keywords` = NULL,
    `homePage` = NULL,
    `administrativeContacts` = NULL,
    `coordinators` = NULL,
    `scientificContacts` = NULL,
    `objective` = NULL,
    initialize = function(`name`, `shortname`, `relatedProjects`, `financialFunding`, `financialReference`, `description`, `startDate`, `endDate`, `keywords`, `homePage`, `administrativeContacts`, `coordinators`, `scientificContacts`, `objective`){
      if (!missing(`name`)) {
        stopifnot(is.character(`name`), length(`name`) == 1)
        self$`name` <- `name`
      }
      if (!missing(`shortname`)) {
        stopifnot(is.character(`shortname`), length(`shortname`) == 1)
        self$`shortname` <- `shortname`
      }
      if (!missing(`relatedProjects`)) {
        stopifnot(is.list(`relatedProjects`), length(`relatedProjects`) != 0)
        lapply(`relatedProjects`, function(x) stopifnot(is.character(x)))
        self$`relatedProjects` <- `relatedProjects`
      }
      if (!missing(`financialFunding`)) {
        stopifnot(is.character(`financialFunding`), length(`financialFunding`) == 1)
        self$`financialFunding` <- `financialFunding`
      }
      if (!missing(`financialReference`)) {
        stopifnot(is.character(`financialReference`), length(`financialReference`) == 1)
        self$`financialReference` <- `financialReference`
      }
      if (!missing(`description`)) {
        stopifnot(is.character(`description`), length(`description`) == 1)
        self$`description` <- `description`
      }
      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(`keywords`)) {
        stopifnot(is.list(`keywords`), length(`keywords`) != 0)
        lapply(`keywords`, function(x) stopifnot(is.character(x)))
        self$`keywords` <- `keywords`
      }
      if (!missing(`homePage`)) {
        stopifnot(is.character(`homePage`), length(`homePage`) == 1)
        self$`homePage` <- `homePage`
      }
      if (!missing(`administrativeContacts`)) {
        stopifnot(is.list(`administrativeContacts`), length(`administrativeContacts`) != 0)
        lapply(`administrativeContacts`, function(x) stopifnot(is.character(x)))
        self$`administrativeContacts` <- `administrativeContacts`
      }
      if (!missing(`coordinators`)) {
        stopifnot(is.list(`coordinators`), length(`coordinators`) != 0)
        lapply(`coordinators`, function(x) stopifnot(is.character(x)))
        self$`coordinators` <- `coordinators`
      }
      if (!missing(`scientificContacts`)) {
        stopifnot(is.list(`scientificContacts`), length(`scientificContacts`) != 0)
        lapply(`scientificContacts`, function(x) stopifnot(is.character(x)))
        self$`scientificContacts` <- `scientificContacts`
      }
      if (!missing(`objective`)) {
        stopifnot(is.character(`objective`), length(`objective`) == 1)
        self$`objective` <- `objective`
      }
    },
    toJSON = function() {
      ProjectPostDTOObject <- list()
      if (!is.null(self$`name`)) {
        ProjectPostDTOObject[['name']] <- self$`name`
      }
      if (!is.null(self$`shortname`)) {
        ProjectPostDTOObject[['shortname']] <- self$`shortname`
      }
      if (!is.null(self$`relatedProjects`)) {
        ProjectPostDTOObject[['relatedProjects']] <- self$`relatedProjects`
      }
      if (!is.null(self$`financialFunding`)) {
        ProjectPostDTOObject[['financialFunding']] <- self$`financialFunding`
      }
      if (!is.null(self$`financialReference`)) {
        ProjectPostDTOObject[['financialReference']] <- self$`financialReference`
      }
      if (!is.null(self$`description`)) {
        ProjectPostDTOObject[['description']] <- self$`description`
      }
      if (!is.null(self$`startDate`)) {
        ProjectPostDTOObject[['startDate']] <- self$`startDate`
      }
      if (!is.null(self$`endDate`)) {
        ProjectPostDTOObject[['endDate']] <- self$`endDate`
      }
      if (!is.null(self$`keywords`)) {
        ProjectPostDTOObject[['keywords']] <- self$`keywords`
      }
      if (!is.null(self$`homePage`)) {
        ProjectPostDTOObject[['homePage']] <- self$`homePage`
      }
      if (!is.null(self$`administrativeContacts`)) {
        ProjectPostDTOObject[['administrativeContacts']] <- self$`administrativeContacts`
      }
      if (!is.null(self$`coordinators`)) {
        ProjectPostDTOObject[['coordinators']] <- self$`coordinators`
      }
      if (!is.null(self$`scientificContacts`)) {
        ProjectPostDTOObject[['scientificContacts']] <- self$`scientificContacts`
      }
      if (!is.null(self$`objective`)) {
        ProjectPostDTOObject[['objective']] <- self$`objective`
      }

      ProjectPostDTOObject
    },
    fromJSON = function(ProjectPostDTOJson) {
      ProjectPostDTOObject <- jsonlite::fromJSON(ProjectPostDTOJson)
      if (!is.null(ProjectPostDTOObject$`name`)) {
        self$`name` <- ProjectPostDTOObject$`name`
      }
      if (!is.null(ProjectPostDTOObject$`shortname`)) {
        self$`shortname` <- ProjectPostDTOObject$`shortname`
      }
      if (!is.null(ProjectPostDTOObject$`relatedProjects`)) {
        self$`relatedProjects` <- ProjectPostDTOObject$`relatedProjects`
      }
      if (!is.null(ProjectPostDTOObject$`financialFunding`)) {
        self$`financialFunding` <- ProjectPostDTOObject$`financialFunding`
      }
      if (!is.null(ProjectPostDTOObject$`financialReference`)) {
        self$`financialReference` <- ProjectPostDTOObject$`financialReference`
      }
      if (!is.null(ProjectPostDTOObject$`description`)) {
        self$`description` <- ProjectPostDTOObject$`description`
      }
      if (!is.null(ProjectPostDTOObject$`startDate`)) {
        self$`startDate` <- ProjectPostDTOObject$`startDate`
      }
      if (!is.null(ProjectPostDTOObject$`endDate`)) {
        self$`endDate` <- ProjectPostDTOObject$`endDate`
      }
      if (!is.null(ProjectPostDTOObject$`keywords`)) {
        self$`keywords` <- ProjectPostDTOObject$`keywords`
      }
      if (!is.null(ProjectPostDTOObject$`homePage`)) {
        self$`homePage` <- ProjectPostDTOObject$`homePage`
      }
      if (!is.null(ProjectPostDTOObject$`administrativeContacts`)) {
        self$`administrativeContacts` <- ProjectPostDTOObject$`administrativeContacts`
      }
      if (!is.null(ProjectPostDTOObject$`coordinators`)) {
        self$`coordinators` <- ProjectPostDTOObject$`coordinators`
      }
      if (!is.null(ProjectPostDTOObject$`scientificContacts`)) {
        self$`scientificContacts` <- ProjectPostDTOObject$`scientificContacts`
      }
      if (!is.null(ProjectPostDTOObject$`objective`)) {
        self$`objective` <- ProjectPostDTOObject$`objective`
      }
    },
    fromJSONObject = function(ProjectPostDTOObject) {
      if (!is.null(ProjectPostDTOObject$`name`)) {
        self$`name` <- ProjectPostDTOObject$`name`
      }
      if (!is.null(ProjectPostDTOObject$`shortname`)) {
        self$`shortname` <- ProjectPostDTOObject$`shortname`
      }
      if (!is.null(ProjectPostDTOObject$`relatedProjects`)) {
        self$`relatedProjects` <- ProjectPostDTOObject$`relatedProjects`
      }
      if (!is.null(ProjectPostDTOObject$`financialFunding`)) {
        self$`financialFunding` <- ProjectPostDTOObject$`financialFunding`
      }
      if (!is.null(ProjectPostDTOObject$`financialReference`)) {
        self$`financialReference` <- ProjectPostDTOObject$`financialReference`
      }
      if (!is.null(ProjectPostDTOObject$`description`)) {
        self$`description` <- ProjectPostDTOObject$`description`
      }
      if (!is.null(ProjectPostDTOObject$`startDate`)) {
        self$`startDate` <- ProjectPostDTOObject$`startDate`
      }
      if (!is.null(ProjectPostDTOObject$`endDate`)) {
        self$`endDate` <- ProjectPostDTOObject$`endDate`
      }
      if (!is.null(ProjectPostDTOObject$`keywords`)) {
        self$`keywords` <- ProjectPostDTOObject$`keywords`
      }
      if (!is.null(ProjectPostDTOObject$`homePage`)) {
        self$`homePage` <- ProjectPostDTOObject$`homePage`
      }
      if (!is.null(ProjectPostDTOObject$`administrativeContacts`)) {
        self$`administrativeContacts` <- ProjectPostDTOObject$`administrativeContacts`
      }
      if (!is.null(ProjectPostDTOObject$`coordinators`)) {
        self$`coordinators` <- ProjectPostDTOObject$`coordinators`
      }
      if (!is.null(ProjectPostDTOObject$`scientificContacts`)) {
        self$`scientificContacts` <- ProjectPostDTOObject$`scientificContacts`
      }
      if (!is.null(ProjectPostDTOObject$`objective`)) {
        self$`objective` <- ProjectPostDTOObject$`objective`
      }
    },
    toJSONString = function() {
       sprintf(
        '{
           "name": %s,
           "shortname": %s,
           "relatedProjects": [%s],
           "financialFunding": %s,
           "financialReference": %s,
           "description": %s,
           "startDate": %s,
           "endDate": %s,
           "keywords": [%s],
           "homePage": %s,
           "administrativeContacts": [%s],
           "coordinators": [%s],
           "scientificContacts": [%s],
           "objective": %s
        }',
        jsonlite::toJSON(self$`name`,auto_unbox=TRUE, null = "null"),
        jsonlite::toJSON(self$`shortname`,auto_unbox=TRUE, null = "null"),
        lapply(self$`relatedProjects`, function(x) paste(paste0('"', x, '"'), sep=",")),
        jsonlite::toJSON(self$`financialFunding`,auto_unbox=TRUE, null = "null"),
        jsonlite::toJSON(self$`financialReference`,auto_unbox=TRUE, null = "null"),
        jsonlite::toJSON(self$`description`,auto_unbox=TRUE, null = "null"),
        jsonlite::toJSON(self$`startDate`,auto_unbox=TRUE, null = "null"),
        jsonlite::toJSON(self$`endDate`,auto_unbox=TRUE, null = "null"),
        lapply(self$`keywords`, function(x) paste(paste0('"', x, '"'), sep=",")),
        jsonlite::toJSON(self$`homePage`,auto_unbox=TRUE, null = "null"),
        lapply(self$`administrativeContacts`, function(x) paste(paste0('"', x, '"'), sep=",")),
        lapply(self$`coordinators`, function(x) paste(paste0('"', x, '"'), sep=",")),
        lapply(self$`scientificContacts`, function(x) paste(paste0('"', x, '"'), sep=",")),
        jsonlite::toJSON(self$`objective`,auto_unbox=TRUE, null = "null")
      )
    },
    fromJSONString = function(ProjectPostDTOJson) {
      ProjectPostDTOObject <- jsonlite::fromJSON(ProjectPostDTOJson)
      self$`name` <- ProjectPostDTOObject$`name`
      self$`shortname` <- ProjectPostDTOObject$`shortname`
      self$`relatedProjects` <- ProjectPostDTOObject$`relatedProjects`
      self$`financialFunding` <- ProjectPostDTOObject$`financialFunding`
      self$`financialReference` <- ProjectPostDTOObject$`financialReference`
      self$`description` <- ProjectPostDTOObject$`description`
      self$`startDate` <- ProjectPostDTOObject$`startDate`
      self$`endDate` <- ProjectPostDTOObject$`endDate`
      self$`keywords` <- ProjectPostDTOObject$`keywords`
      self$`homePage` <- ProjectPostDTOObject$`homePage`
      self$`administrativeContacts` <- ProjectPostDTOObject$`administrativeContacts`
      self$`coordinators` <- ProjectPostDTOObject$`coordinators`
      self$`scientificContacts` <- ProjectPostDTOObject$`scientificContacts`
      self$`objective` <- ProjectPostDTOObject$`objective`
    }
  )
)
OpenSILEX/phis-ws-client-r-tool documentation built on Sept. 10, 2020, 8:42 a.m.