R/ProjectDTO.r

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


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

      ProjectDTOObject
    },
    fromJSON = function(ProjectDTOJson) {
      ProjectDTOObject <- jsonlite::fromJSON(ProjectDTOJson)
      if (!is.null(ProjectDTOObject$`uri`)) {
        self$`uri` <- ProjectDTOObject$`uri`
      }
      if (!is.null(ProjectDTOObject$`name`)) {
        self$`name` <- ProjectDTOObject$`name`
      }
      if (!is.null(ProjectDTOObject$`shortname`)) {
        self$`shortname` <- ProjectDTOObject$`shortname`
      }
      if (!is.null(ProjectDTOObject$`financialFunding`)) {
        financialFundingObject <- RdfResourceDTO$new()
        financialFundingObject$fromJSON(jsonlite::toJSON(ProjectDTOObject$financialFunding, auto_unbox = TRUE, null = "null"))
        self$`financialFunding` <- financialFundingObject
      }
      if (!is.null(ProjectDTOObject$`financialReference`)) {
        self$`financialReference` <- ProjectDTOObject$`financialReference`
      }
      if (!is.null(ProjectDTOObject$`description`)) {
        self$`description` <- ProjectDTOObject$`description`
      }
      if (!is.null(ProjectDTOObject$`startDate`)) {
        self$`startDate` <- ProjectDTOObject$`startDate`
      }
      if (!is.null(ProjectDTOObject$`endDate`)) {
        self$`endDate` <- ProjectDTOObject$`endDate`
      }
      if (!is.null(ProjectDTOObject$`homePage`)) {
        self$`homePage` <- ProjectDTOObject$`homePage`
      }
      if (!is.null(ProjectDTOObject$`objective`)) {
        self$`objective` <- ProjectDTOObject$`objective`
      }
    },
    fromJSONObject = function(ProjectDTOObject) {
      if (!is.null(ProjectDTOObject$`uri`)) {
        self$`uri` <- ProjectDTOObject$`uri`
      }
      if (!is.null(ProjectDTOObject$`name`)) {
        self$`name` <- ProjectDTOObject$`name`
      }
      if (!is.null(ProjectDTOObject$`shortname`)) {
        self$`shortname` <- ProjectDTOObject$`shortname`
      }
      if (!is.null(ProjectDTOObject$`financialFunding`)) {
        financialFundingObject <- RdfResourceDTO$new()
        financialFundingObject$fromJSON(jsonlite::toJSON(ProjectDTOObject$financialFunding, auto_unbox = TRUE, null = "null"))
        self$`financialFunding` <- financialFundingObject
      }
      if (!is.null(ProjectDTOObject$`financialReference`)) {
        self$`financialReference` <- ProjectDTOObject$`financialReference`
      }
      if (!is.null(ProjectDTOObject$`description`)) {
        self$`description` <- ProjectDTOObject$`description`
      }
      if (!is.null(ProjectDTOObject$`startDate`)) {
        self$`startDate` <- ProjectDTOObject$`startDate`
      }
      if (!is.null(ProjectDTOObject$`endDate`)) {
        self$`endDate` <- ProjectDTOObject$`endDate`
      }
      if (!is.null(ProjectDTOObject$`homePage`)) {
        self$`homePage` <- ProjectDTOObject$`homePage`
      }
      if (!is.null(ProjectDTOObject$`objective`)) {
        self$`objective` <- ProjectDTOObject$`objective`
      }
    },
    toJSONString = function() {
       sprintf(
        '{
           "uri": %s,
           "name": %s,
           "shortname": %s,
           "financialFunding": %s,
           "financialReference": %s,
           "description": %s,
           "startDate": %s,
           "endDate": %s,
           "homePage": %s,
           "objective": %s
        }',
        jsonlite::toJSON(self$`uri`,auto_unbox=TRUE, null = "null"),
        jsonlite::toJSON(self$`name`,auto_unbox=TRUE, null = "null"),
        jsonlite::toJSON(self$`shortname`,auto_unbox=TRUE, null = "null"),
        self$`financialFunding`$toJSON(),
        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"),
        jsonlite::toJSON(self$`homePage`,auto_unbox=TRUE, null = "null"),
        jsonlite::toJSON(self$`objective`,auto_unbox=TRUE, null = "null")
      )
    },
    fromJSONString = function(ProjectDTOJson) {
      ProjectDTOObject <- jsonlite::fromJSON(ProjectDTOJson)
      self$`uri` <- ProjectDTOObject$`uri`
      self$`name` <- ProjectDTOObject$`name`
      self$`shortname` <- ProjectDTOObject$`shortname`
      RdfResourceDTOObject <- RdfResourceDTO$new()
      self$`financialFunding` <- RdfResourceDTOObject$fromJSON(jsonlite::toJSON(ProjectDTOObject$financialFunding, auto_unbox = TRUE))
      self$`financialReference` <- ProjectDTOObject$`financialReference`
      self$`description` <- ProjectDTOObject$`description`
      self$`startDate` <- ProjectDTOObject$`startDate`
      self$`endDate` <- ProjectDTOObject$`endDate`
      self$`homePage` <- ProjectDTOObject$`homePage`
      self$`objective` <- ProjectDTOObject$`objective`
    }
  )
)
OpenSILEX/phis-ws-client-r-tool documentation built on Sept. 10, 2020, 8:42 a.m.