R/pfb_response.R

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

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

      PFBResponseObject
    },
    fromJSON = function(PFBResponseJson) {
      PFBResponseObject <- jsonlite::fromJSON(PFBResponseJson)
      if (!is.null(PFBResponseObject$`url`)) {
        self$`url` <- PFBResponseObject$`url`
      }
      if (!is.null(PFBResponseObject$`jobId`)) {
        self$`jobId` <- PFBResponseObject$`jobId`
      }
      if (!is.null(PFBResponseObject$`workspace`)) {
        workspaceObject <- PFBResponseWorkspace$new()
        workspaceObject$fromJSON(jsonlite::toJSON(PFBResponseObject$workspace, auto_unbox = TRUE, digits = NA))
        self$`workspace` <- workspaceObject
      }
      self
    },
    toJSONString = function() {
      jsoncontent <- c(
        if (!is.null(self$`url`)) {
        sprintf(
        '"url":
          "%s"
                ',
        self$`url`
        )},
        if (!is.null(self$`jobId`)) {
        sprintf(
        '"jobId":
          "%s"
                ',
        self$`jobId`
        )},
        if (!is.null(self$`workspace`)) {
        sprintf(
        '"workspace":
        %s
        ',
        jsonlite::toJSON(self$`workspace`$toJSON(), auto_unbox=TRUE, digits = NA)
        )}
      )
      jsoncontent <- paste(jsoncontent, collapse = ",")
      paste('{', jsoncontent, '}', sep = "")
    },
    fromJSONString = function(PFBResponseJson) {
      PFBResponseObject <- jsonlite::fromJSON(PFBResponseJson)
      self$`url` <- PFBResponseObject$`url`
      self$`jobId` <- PFBResponseObject$`jobId`
      self$`workspace` <- PFBResponseWorkspace$new()$fromJSON(jsonlite::toJSON(PFBResponseObject$workspace, auto_unbox = TRUE, digits = NA))
      self
    }
  )
)
vjcitn/terraClientR documentation built on Dec. 23, 2021, 4:07 p.m.