R/entity_query_response.R

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

#' @docType class
#' @title EntityQueryResponse
#'
#' @description EntityQueryResponse Class
#'
#' @format An \code{R6Class} generator object
#'
#' @field parameters  \link{EntityQueryParameters} 
#'
#' @field resultMetadata  \link{EntityQueryResultMetadata} 
#'
#' @field results  list( \link{Entity} ) 
#'
#' @importFrom R6 R6Class
#' @importFrom jsonlite fromJSON toJSON
#' @export
EntityQueryResponse <- R6::R6Class(
  'EntityQueryResponse',
  public = list(
    `parameters` = NULL,
    `resultMetadata` = NULL,
    `results` = NULL,
    initialize = function(
        `parameters`, `resultMetadata`, `results`, ...
    ) {
      local.optional.var <- list(...)
      if (!missing(`parameters`)) {
        stopifnot(R6::is.R6(`parameters`))
        self$`parameters` <- `parameters`
      }
      if (!missing(`resultMetadata`)) {
        stopifnot(R6::is.R6(`resultMetadata`))
        self$`resultMetadata` <- `resultMetadata`
      }
      if (!missing(`results`)) {
        stopifnot(is.vector(`results`), length(`results`) != 0)
        sapply(`results`, function(x) stopifnot(R6::is.R6(x)))
        self$`results` <- `results`
      }
    },
    toJSON = function() {
      EntityQueryResponseObject <- list()
      if (!is.null(self$`parameters`)) {
        EntityQueryResponseObject[['parameters']] <-
          self$`parameters`$toJSON()
      }
      if (!is.null(self$`resultMetadata`)) {
        EntityQueryResponseObject[['resultMetadata']] <-
          self$`resultMetadata`$toJSON()
      }
      if (!is.null(self$`results`)) {
        EntityQueryResponseObject[['results']] <-
          lapply(self$`results`, function(x) x$toJSON())
      }

      EntityQueryResponseObject
    },
    fromJSON = function(EntityQueryResponseJson) {
      EntityQueryResponseObject <- jsonlite::fromJSON(EntityQueryResponseJson)
      if (!is.null(EntityQueryResponseObject$`parameters`)) {
        parametersObject <- EntityQueryParameters$new()
        parametersObject$fromJSON(jsonlite::toJSON(EntityQueryResponseObject$parameters, auto_unbox = TRUE, digits = NA))
        self$`parameters` <- parametersObject
      }
      if (!is.null(EntityQueryResponseObject$`resultMetadata`)) {
        resultMetadataObject <- EntityQueryResultMetadata$new()
        resultMetadataObject$fromJSON(jsonlite::toJSON(EntityQueryResponseObject$resultMetadata, auto_unbox = TRUE, digits = NA))
        self$`resultMetadata` <- resultMetadataObject
      }
      if (!is.null(EntityQueryResponseObject$`results`)) {
        self$`results` <- ApiClient$new()$deserializeObj(EntityQueryResponseObject$`results`, "array[Entity]", loadNamespace("openapi"))
      }
      self
    },
    toJSONString = function() {
      jsoncontent <- c(
        if (!is.null(self$`parameters`)) {
        sprintf(
        '"parameters":
        %s
        ',
        jsonlite::toJSON(self$`parameters`$toJSON(), auto_unbox=TRUE, digits = NA)
        )},
        if (!is.null(self$`resultMetadata`)) {
        sprintf(
        '"resultMetadata":
        %s
        ',
        jsonlite::toJSON(self$`resultMetadata`$toJSON(), auto_unbox=TRUE, digits = NA)
        )},
        if (!is.null(self$`results`)) {
        sprintf(
        '"results":
        [%s]
',
        paste(sapply(self$`results`, function(x) jsonlite::toJSON(x$toJSON(), auto_unbox=TRUE, digits = NA)), collapse=",")
        )}
      )
      jsoncontent <- paste(jsoncontent, collapse = ",")
      paste('{', jsoncontent, '}', sep = "")
    },
    fromJSONString = function(EntityQueryResponseJson) {
      EntityQueryResponseObject <- jsonlite::fromJSON(EntityQueryResponseJson)
      self$`parameters` <- EntityQueryParameters$new()$fromJSON(jsonlite::toJSON(EntityQueryResponseObject$parameters, auto_unbox = TRUE, digits = NA))
      self$`resultMetadata` <- EntityQueryResultMetadata$new()$fromJSON(jsonlite::toJSON(EntityQueryResponseObject$resultMetadata, auto_unbox = TRUE, digits = NA))
      self$`results` <- ApiClient$new()$deserializeObj(EntityQueryResponseObject$`results`, "array[Entity]", loadNamespace("openapi"))
      self
    }
  )
)
vjcitn/terraClientR documentation built on Dec. 23, 2021, 4:07 p.m.