R/key_value_pair.R

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

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

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