R/DataPostDTO.r

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


#' DataPostDTO Class
#'
#' @field provenanceUri 
#' @field objectUri 
#' @field variableUri 
#' @field date 
#' @field value 
#'
#' @importFrom R6 R6Class
#' @importFrom jsonlite fromJSON toJSON
#' @export
DataPostDTO <- R6::R6Class(
  'DataPostDTO',
  public = list(
    `provenanceUri` = NULL,
    `objectUri` = NULL,
    `variableUri` = NULL,
    `date` = NULL,
    `value` = NULL,
    initialize = function(`provenanceUri`, `objectUri`, `variableUri`, `date`, `value`){
      if (!missing(`provenanceUri`)) {
        stopifnot(is.character(`provenanceUri`), length(`provenanceUri`) == 1)
        self$`provenanceUri` <- `provenanceUri`
      }
      if (!missing(`objectUri`)) {
        stopifnot(is.character(`objectUri`), length(`objectUri`) == 1)
        self$`objectUri` <- `objectUri`
      }
      if (!missing(`variableUri`)) {
        stopifnot(is.character(`variableUri`), length(`variableUri`) == 1)
        self$`variableUri` <- `variableUri`
      }
      if (!missing(`date`)) {
        stopifnot(is.character(`date`), length(`date`) == 1)
        self$`date` <- `date`
      }
      if (!missing(`value`)) {
        stopifnot(R6::is.R6(`value`))
        self$`value` <- `value`
      }
    },
    toJSON = function() {
      DataPostDTOObject <- list()
      if (!is.null(self$`provenanceUri`)) {
        DataPostDTOObject[['provenanceUri']] <- self$`provenanceUri`
      }
      if (!is.null(self$`objectUri`)) {
        DataPostDTOObject[['objectUri']] <- self$`objectUri`
      }
      if (!is.null(self$`variableUri`)) {
        DataPostDTOObject[['variableUri']] <- self$`variableUri`
      }
      if (!is.null(self$`date`)) {
        DataPostDTOObject[['date']] <- self$`date`
      }
      if (!is.null(self$`value`)) {
        DataPostDTOObject[['value']] <- self$`value`$toJSON()
      }

      DataPostDTOObject
    },
    fromJSON = function(DataPostDTOJson) {
      DataPostDTOObject <- jsonlite::fromJSON(DataPostDTOJson)
      if (!is.null(DataPostDTOObject$`provenanceUri`)) {
        self$`provenanceUri` <- DataPostDTOObject$`provenanceUri`
      }
      if (!is.null(DataPostDTOObject$`objectUri`)) {
        self$`objectUri` <- DataPostDTOObject$`objectUri`
      }
      if (!is.null(DataPostDTOObject$`variableUri`)) {
        self$`variableUri` <- DataPostDTOObject$`variableUri`
      }
      if (!is.null(DataPostDTOObject$`date`)) {
        self$`date` <- DataPostDTOObject$`date`
      }
      if (!is.null(DataPostDTOObject$`value`)) {
        valueObject <- TODO_OBJECT_MAPPING$new()
        valueObject$fromJSON(jsonlite::toJSON(DataPostDTOObject$value, auto_unbox = TRUE, null = "null"))
        self$`value` <- valueObject
      }
    },
    fromJSONObject = function(DataPostDTOObject) {
      if (!is.null(DataPostDTOObject$`provenanceUri`)) {
        self$`provenanceUri` <- DataPostDTOObject$`provenanceUri`
      }
      if (!is.null(DataPostDTOObject$`objectUri`)) {
        self$`objectUri` <- DataPostDTOObject$`objectUri`
      }
      if (!is.null(DataPostDTOObject$`variableUri`)) {
        self$`variableUri` <- DataPostDTOObject$`variableUri`
      }
      if (!is.null(DataPostDTOObject$`date`)) {
        self$`date` <- DataPostDTOObject$`date`
      }
      if (!is.null(DataPostDTOObject$`value`)) {
        valueObject <- TODO_OBJECT_MAPPING$new()
        valueObject$fromJSON(jsonlite::toJSON(DataPostDTOObject$value, auto_unbox = TRUE, null = "null"))
        self$`value` <- valueObject
      }
    },
    toJSONString = function() {
       sprintf(
        '{
           "provenanceUri": %s,
           "objectUri": %s,
           "variableUri": %s,
           "date": %s,
           "value": %s
        }',
        jsonlite::toJSON(self$`provenanceUri`,auto_unbox=TRUE, null = "null"),
        jsonlite::toJSON(self$`objectUri`,auto_unbox=TRUE, null = "null"),
        jsonlite::toJSON(self$`variableUri`,auto_unbox=TRUE, null = "null"),
        jsonlite::toJSON(self$`date`,auto_unbox=TRUE, null = "null"),
        self$`value`$toJSON()
      )
    },
    fromJSONString = function(DataPostDTOJson) {
      DataPostDTOObject <- jsonlite::fromJSON(DataPostDTOJson)
      self$`provenanceUri` <- DataPostDTOObject$`provenanceUri`
      self$`objectUri` <- DataPostDTOObject$`objectUri`
      self$`variableUri` <- DataPostDTOObject$`variableUri`
      self$`date` <- DataPostDTOObject$`date`
      TODO_OBJECT_MAPPINGObject <- TODO_OBJECT_MAPPING$new()
      self$`value` <- TODO_OBJECT_MAPPINGObject$fromJSON(jsonlite::toJSON(DataPostDTOObject$value, auto_unbox = TRUE))
    }
  )
)
OpenSILEX/phis-ws-client-r-tool documentation built on Sept. 10, 2020, 8:42 a.m.