R/v0_matrix_request.R

# HCA Matrix Service
#
# Human Cell Atlas Matrix Service API
#
# The version of the OpenAPI document: 1.0.0
# 
# Generated by: https://openapi-generator.tech

#' @docType class
#' @title V0MatrixRequest
#' @description V0MatrixRequest Class
#' @format An \code{R6Class} generator object
#' @field bundle_fqids    list(character)   [optional]
#'
#' @field bundle_fqids_url   character  [optional]
#'
#' @field format   \link[hcamatrixapi:v0_MatrixFormat]{  V0MatrixFormat  }  [optional]
#'
#'
#' @importFrom R6 R6Class
#' @importFrom jsonlite fromJSON toJSON
#' @export
V0MatrixRequest <- R6::R6Class(
  'V0MatrixRequest',
  public = list(
    `bundle_fqids` = NULL,
    `bundle_fqids_url` = NULL,
    `format` = NULL,
    initialize = function(`bundle_fqids`=NULL, `bundle_fqids_url`=NULL, `format`=NULL, ...){
      local.optional.var <- list(...)
      if (!is.null(`bundle_fqids`)) {
        stopifnot(is.vector(`bundle_fqids`), length(`bundle_fqids`) != 0)
        sapply(`bundle_fqids`, function(x) stopifnot(is.character(x)))
        self$`bundle_fqids` <- `bundle_fqids`
      }
      if (!is.null(`bundle_fqids_url`)) {
        stopifnot(is.character(`bundle_fqids_url`), length(`bundle_fqids_url`) == 1)
        self$`bundle_fqids_url` <- `bundle_fqids_url`
      }
      if (!is.null(`format`)) {
        stopifnot(R6::is.R6(`format`))
        self$`format` <- `format`
      }
    },
    toJSON = function() {
      V0MatrixRequestObject <- list()
      if (!is.null(self$`bundle_fqids`)) {
        V0MatrixRequestObject[['bundle_fqids']] <-
          self$`bundle_fqids`
      }
      if (!is.null(self$`bundle_fqids_url`)) {
        V0MatrixRequestObject[['bundle_fqids_url']] <-
          self$`bundle_fqids_url`
      }
      if (!is.null(self$`format`)) {
        V0MatrixRequestObject[['format']] <-
          self$`format`$toJSON()
      }

      V0MatrixRequestObject
    },
    fromJSON = function(V0MatrixRequestJson) {
      V0MatrixRequestObject <- jsonlite::fromJSON(V0MatrixRequestJson)
      if (!is.null(V0MatrixRequestObject$`bundle_fqids`)) {
        self$`bundle_fqids` <- ApiClient$new()$deserializeObj(V0MatrixRequestObject$`bundle_fqids`, "array[character]", "package:hcamatrixapi")
      }
      if (!is.null(V0MatrixRequestObject$`bundle_fqids_url`)) {
        self$`bundle_fqids_url` <- V0MatrixRequestObject$`bundle_fqids_url`
      }
      if (!is.null(V0MatrixRequestObject$`format`)) {
        formatObject <- V0MatrixFormat$new()
        formatObject$fromJSON(jsonlite::toJSON(V0MatrixRequestObject$format, auto_unbox = TRUE, digits = NA))
        self$`format` <- formatObject
      }
    },
    toJSONString = function() {
      jsoncontent <- c(
        if (!is.null(self$`bundle_fqids`)) {
        sprintf(
        '"bundle_fqids":
           [%s]
        ',
        paste(unlist(lapply(self$`bundle_fqids`, function(x) paste0('"', x, '"'))), collapse=",")
        )},
        if (!is.null(self$`bundle_fqids_url`)) {
        sprintf(
        '"bundle_fqids_url":
          "%s"
                ',
        self$`bundle_fqids_url`
        )},
        if (!is.null(self$`format`)) {
        sprintf(
        '"format":
        %s
        ',
        jsonlite::toJSON(self$`format`$toJSON(), auto_unbox=TRUE, digits = NA)
        )}
      )
      jsoncontent <- paste(jsoncontent, collapse = ",")
      paste('{', jsoncontent, '}', sep = "")
    },
    fromJSONString = function(V0MatrixRequestJson) {
      V0MatrixRequestObject <- jsonlite::fromJSON(V0MatrixRequestJson)
      self$`bundle_fqids` <- ApiClient$new()$deserializeObj(V0MatrixRequestObject$`bundle_fqids`, "array[character]","package:hcamatrixapi")
      self$`bundle_fqids_url` <- V0MatrixRequestObject$`bundle_fqids_url`
      self$`format` <- V0MatrixFormat$new()$fromJSON(jsonlite::toJSON(V0MatrixRequestObject$format, auto_unbox = TRUE, digits = NA))
      self
    }
  )
)
Bioconductor/hcamatrixapi documentation built on Nov. 6, 2019, 12:10 a.m.