R/Crs.r

# OpenSilex API
#
# No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
#
# OpenAPI spec version: 1.0.0-rc+2
# 
# Generated by: https://github.com/swagger-api/swagger-codegen.git


#' Crs Class
#'
#' @field type 
#' @field properties 
#'
#' @importFrom R6 R6Class
#' @importFrom jsonlite fromJSON toJSON
#' @export
Crs <- R6::R6Class(
  'Crs',
  public = list(
    `type` = NULL,
    `properties` = NULL,
    initialize = function(`type`, `properties`){
      if (!missing(`type`)) {
        stopifnot(is.character(`type`), length(`type`) == 1)
        self$`type` <- `type`
      }
      if (!missing(`properties`)) {
        stopifnot(R6::is.R6(`properties`))
        self$`properties` <- `properties`
      }
    },
    toJSON = function() {
      CrsObject <- list()
      if (!is.null(self$`type`)) {
        CrsObject[['type']] <- self$`type`
      }
      if (!is.null(self$`properties`)) {
        CrsObject[['properties']] <- self$`properties`$toJSON()
      }

      CrsObject
    },
    fromJSON = function(CrsJson) {
      CrsObject <- jsonlite::fromJSON(CrsJson)
      if (!is.null(CrsObject$`type`)) {
        self$`type` <- CrsObject$`type`
      }
      if (!is.null(CrsObject$`properties`)) {
        propertiesObject <- ObjectDTO$new()
        propertiesObject$fromJSON(jsonlite::toJSON(CrsObject$properties, auto_unbox = TRUE, null = "null"))
        self$`properties` <- propertiesObject
      }
    },
    fromJSONObject = function(CrsObject) {
      if (!is.null(CrsObject$`type`)) {
        self$`type` <- CrsObject$`type`
      }
      if (!is.null(CrsObject$`properties`)) {
        propertiesObject <- ObjectDTO$new()
        propertiesObject$fromJSON(jsonlite::toJSON(CrsObject$properties, auto_unbox = TRUE, null = "null"))
        self$`properties` <- propertiesObject
      }
    },
    toJSONString = function() {
       sprintf(
        '{
           "type": %s,
           "properties": %s
        }',
        ifelse(is.null(self$`type`), "null",jsonlite::toJSON(self$`type`,auto_unbox=TRUE, null = "null")),
        jsonlite::toJSON(self$`properties`$toJSON(),auto_unbox=TRUE, null = "null")
      )
    },
    fromJSONString = function(CrsJson) {
      CrsObject <- jsonlite::fromJSON(CrsJson)
      self$`type` <- CrsObject$`type`
      ObjectDTOObject <- ObjectDTO$new()
      self$`properties` <- ObjectDTOObject$fromJSON(jsonlite::toJSON(CrsObject$properties, auto_unbox = TRUE))
    }
  )
)
OpenSILEX/opensilexClientToolsR documentation built on Jan. 28, 2022, 5:03 a.m.