R/v1_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 V1MatrixRequest
#' @description V1MatrixRequest Class
#' @format An \code{R6Class} generator object
#' @field filter   \link[hcamatrixapi:v1_MatrixFilter]{  V1MatrixFilter  }  
#'
#' @field fields    list(character)   [optional]
#'
#' @field format   character  [optional]
#'
#' @field feature   character  [optional]
#'
#'
#' @importFrom R6 R6Class
#' @importFrom jsonlite fromJSON toJSON
#' @export
V1MatrixRequest <- R6::R6Class(
  'V1MatrixRequest',
  public = list(
    `filter` = NULL,
    `fields` = NULL,
    `format` = NULL,
    `feature` = NULL,
    initialize = function(`filter`, `fields`=NULL, `format`='loom', `feature`='gene', ...){
      local.optional.var <- list(...)
      if (!missing(`filter`)) {
        stopifnot(R6::is.R6(`filter`))
        self$`filter` <- `filter`
      }
      if (!is.null(`fields`)) {
        stopifnot(is.vector(`fields`), length(`fields`) != 0)
        sapply(`fields`, function(x) stopifnot(is.character(x)))
        self$`fields` <- `fields`
      }
      if (!is.null(`format`)) {
        stopifnot(is.character(`format`), length(`format`) == 1)
        self$`format` <- `format`
      }
      if (!is.null(`feature`)) {
        stopifnot(is.character(`feature`), length(`feature`) == 1)
        self$`feature` <- `feature`
      }
    },
    toJSON = function() {
      V1MatrixRequestObject <- list()
      if (!is.null(self$`filter`)) {
        V1MatrixRequestObject[['filter']] <-
          self$`filter`$toJSON()
      }
      if (!is.null(self$`fields`)) {
        V1MatrixRequestObject[['fields']] <-
          self$`fields`
      }
      if (!is.null(self$`format`)) {
        V1MatrixRequestObject[['format']] <-
          self$`format`
      }
      if (!is.null(self$`feature`)) {
        V1MatrixRequestObject[['feature']] <-
          self$`feature`
      }

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