R/me.R

# FireCloud
#
# FireCloud API 
#
# The version of the OpenAPI document: 0.1
# 
# Generated by: https://openapi-generator.tech

#' @docType class
#' @title Me
#'
#' @description Me Class
#'
#' @format An \code{R6Class} generator object
#'
#' @field userInfo  \link{UserInfo} [optional]
#'
#' @field enabled  \link{Enabled} [optional]
#'
#' @importFrom R6 R6Class
#' @importFrom jsonlite fromJSON toJSON
#' @export
Me <- R6::R6Class(
  'Me',
  public = list(
    `userInfo` = NULL,
    `enabled` = NULL,
    initialize = function(
        `userInfo`=NULL, `enabled`=NULL, ...
    ) {
      local.optional.var <- list(...)
      if (!is.null(`userInfo`)) {
        stopifnot(R6::is.R6(`userInfo`))
        self$`userInfo` <- `userInfo`
      }
      if (!is.null(`enabled`)) {
        stopifnot(R6::is.R6(`enabled`))
        self$`enabled` <- `enabled`
      }
    },
    toJSON = function() {
      MeObject <- list()
      if (!is.null(self$`userInfo`)) {
        MeObject[['userInfo']] <-
          self$`userInfo`$toJSON()
      }
      if (!is.null(self$`enabled`)) {
        MeObject[['enabled']] <-
          self$`enabled`$toJSON()
      }

      MeObject
    },
    fromJSON = function(MeJson) {
      MeObject <- jsonlite::fromJSON(MeJson)
      if (!is.null(MeObject$`userInfo`)) {
        userInfoObject <- UserInfo$new()
        userInfoObject$fromJSON(jsonlite::toJSON(MeObject$userInfo, auto_unbox = TRUE, digits = NA))
        self$`userInfo` <- userInfoObject
      }
      if (!is.null(MeObject$`enabled`)) {
        enabledObject <- Enabled$new()
        enabledObject$fromJSON(jsonlite::toJSON(MeObject$enabled, auto_unbox = TRUE, digits = NA))
        self$`enabled` <- enabledObject
      }
      self
    },
    toJSONString = function() {
      jsoncontent <- c(
        if (!is.null(self$`userInfo`)) {
        sprintf(
        '"userInfo":
        %s
        ',
        jsonlite::toJSON(self$`userInfo`$toJSON(), auto_unbox=TRUE, digits = NA)
        )},
        if (!is.null(self$`enabled`)) {
        sprintf(
        '"enabled":
        %s
        ',
        jsonlite::toJSON(self$`enabled`$toJSON(), auto_unbox=TRUE, digits = NA)
        )}
      )
      jsoncontent <- paste(jsoncontent, collapse = ",")
      paste('{', jsoncontent, '}', sep = "")
    },
    fromJSONString = function(MeJson) {
      MeObject <- jsonlite::fromJSON(MeJson)
      self$`userInfo` <- UserInfo$new()$fromJSON(jsonlite::toJSON(MeObject$userInfo, auto_unbox = TRUE, digits = NA))
      self$`enabled` <- Enabled$new()$fromJSON(jsonlite::toJSON(MeObject$enabled, auto_unbox = TRUE, digits = NA))
      self
    }
  )
)
vjcitn/terraClientR documentation built on Dec. 23, 2021, 4:07 p.m.