R/metadata.R

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

#' @docType class
#' @title Metadata
#'
#' @description Metadata Class
#'
#' @format An \code{R6Class} generator object
#'
#' @field version  character 
#'
#' @field api-version  character 
#'
#' @field country  character [optional]
#'
#' @field friendly-name  character [optional]
#'
#' @importFrom R6 R6Class
#' @importFrom jsonlite fromJSON toJSON
#' @export
Metadata <- R6::R6Class(
  'Metadata',
  public = list(
    `version` = NULL,
    `api-version` = NULL,
    `country` = NULL,
    `friendly-name` = NULL,
    initialize = function(
        `version`, `api-version`, `country`=NULL, `friendly-name`=NULL, ...
    ) {
      local.optional.var <- list(...)
      if (!missing(`version`)) {
        stopifnot(is.character(`version`), length(`version`) == 1)
        self$`version` <- `version`
      }
      if (!missing(`api-version`)) {
        stopifnot(is.character(`api-version`), length(`api-version`) == 1)
        self$`api-version` <- `api-version`
      }
      if (!is.null(`country`)) {
        stopifnot(is.character(`country`), length(`country`) == 1)
        self$`country` <- `country`
      }
      if (!is.null(`friendly-name`)) {
        stopifnot(is.character(`friendly-name`), length(`friendly-name`) == 1)
        self$`friendly-name` <- `friendly-name`
      }
    },
    toJSON = function() {
      MetadataObject <- list()
      if (!is.null(self$`version`)) {
        MetadataObject[['version']] <-
          self$`version`
      }
      if (!is.null(self$`api-version`)) {
        MetadataObject[['api-version']] <-
          self$`api-version`
      }
      if (!is.null(self$`country`)) {
        MetadataObject[['country']] <-
          self$`country`
      }
      if (!is.null(self$`friendly-name`)) {
        MetadataObject[['friendly-name']] <-
          self$`friendly-name`
      }

      MetadataObject
    },
    fromJSON = function(MetadataJson) {
      MetadataObject <- jsonlite::fromJSON(MetadataJson)
      if (!is.null(MetadataObject$`version`)) {
        self$`version` <- MetadataObject$`version`
      }
      if (!is.null(MetadataObject$`api-version`)) {
        self$`api-version` <- MetadataObject$`api-version`
      }
      if (!is.null(MetadataObject$`country`)) {
        self$`country` <- MetadataObject$`country`
      }
      if (!is.null(MetadataObject$`friendly-name`)) {
        self$`friendly-name` <- MetadataObject$`friendly-name`
      }
      self
    },
    toJSONString = function() {
      jsoncontent <- c(
        if (!is.null(self$`version`)) {
        sprintf(
        '"version":
          "%s"
                ',
        self$`version`
        )},
        if (!is.null(self$`api-version`)) {
        sprintf(
        '"api-version":
          "%s"
                ',
        self$`api-version`
        )},
        if (!is.null(self$`country`)) {
        sprintf(
        '"country":
          "%s"
                ',
        self$`country`
        )},
        if (!is.null(self$`friendly-name`)) {
        sprintf(
        '"friendly-name":
          "%s"
                ',
        self$`friendly-name`
        )}
      )
      jsoncontent <- paste(jsoncontent, collapse = ",")
      paste('{', jsoncontent, '}', sep = "")
    },
    fromJSONString = function(MetadataJson) {
      MetadataObject <- jsonlite::fromJSON(MetadataJson)
      self$`version` <- MetadataObject$`version`
      self$`api-version` <- MetadataObject$`api-version`
      self$`country` <- MetadataObject$`country`
      self$`friendly-name` <- MetadataObject$`friendly-name`
      self
    }
  )
)
vjcitn/terraClientR documentation built on Dec. 23, 2021, 4:07 p.m.