R/default_api.R

# OmicIDX
#
#     The OmicIDX API documentation is available in three forms:  - [RapiDoc](/docs) - [OpenAPI/Swagger Interactive](/swaggerdoc) - [ReDoc (more readable in some ways)](/redoc)  
#
# The version of the OpenAPI document: 0.99.1
# 
# Generated by: https://openapi-generator.tech

#' @docType class
#' @title Default operations
#' @description omicidxClientR.Default
#' @format An \code{R6Class} generator object
#' @field apiClient Handles the client-server communication.
#'
#' @section Methods:
#' \describe{
#' \strong{ FacetsByIndexFacetsEntityGet } \emph{ Facets By Index }
#' Return the available facet fields for an entity
#'
#' \itemize{
#' \item \emph{ @param } entity \link{AnyType}
#'
#'
#' \item status code : 200 | Successful Response
#'
#' \item return type : array[character] 
#' \item response headers :
#'
#' \tabular{ll}{
#' }
#' \item status code : 422 | Validation Error
#'
#' \item return type : HTTPValidationError 
#' \item response headers :
#'
#' \tabular{ll}{
#' }
#' }
#'
#' }
#'
#'
#' @examples
#' \dontrun{
#' ####################  FacetsByIndexFacetsEntityGet  ####################
#'
#' library(omicidxClientR)
#' var.entity <- AnyType$new() # AnyType | 
#'
#' #Facets By Index
#' api.instance <- DefaultApi$new()
#'
#' result <- api.instance$FacetsByIndexFacetsEntityGet(var.entity)
#'
#'
#' }
#' @importFrom R6 R6Class
#' @importFrom base64enc base64encode
#' @export
DefaultApi <- R6::R6Class(
  'DefaultApi',
  public = list(
    apiClient = NULL,
    initialize = function(apiClient){
      if (!missing(apiClient)) {
        self$apiClient <- apiClient
      }
      else {
        self$apiClient <- ApiClient$new()
      }
    },
    FacetsByIndexFacetsEntityGet = function(entity, ...){
      apiResponse <- self$FacetsByIndexFacetsEntityGetWithHttpInfo(entity, ...)
      resp <- apiResponse$response
      if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
        apiResponse$content
      } else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) {
        apiResponse
      } else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
        apiResponse
      } else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
        apiResponse
      }
    },

    FacetsByIndexFacetsEntityGetWithHttpInfo = function(entity, ...){
      args <- list(...)
      queryParams <- list()
      headerParams <- c()

      if (missing(`entity`)) {
        stop("Missing required parameter `entity`.")
      }

      body <- NULL
      urlPath <- "/facets/{entity}"
      if (!missing(`entity`)) {
        urlPath <- gsub(paste0("\\{", "entity", "\\}"), URLencode(as.character(`entity`), reserved = TRUE), urlPath)
      }


      resp <- self$apiClient$CallApi(url = paste0(self$apiClient$basePath, urlPath),
                                 method = "GET",
                                 queryParams = queryParams,
                                 headerParams = headerParams,
                                 body = body,
                                 ...)

      if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
        deserializedRespObj <- tryCatch(
          self$apiClient$deserialize(resp, "array[character]", loadNamespace("omicidxClientR")),
          error = function(e){
             stop("Failed to deserialize response")
          }
        )
        ApiResponse$new(deserializedRespObj, resp)
      } else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) {
        ApiResponse$new(paste("Server returned " , httr::status_code(resp) , " response status code."), resp)
      } else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
        ApiResponse$new("API client error", resp)
      } else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
        ApiResponse$new("API server error", resp)
      }
    }
  )
)
sdgamboa/omicidxClientR documentation built on Dec. 22, 2021, 11:12 p.m.