R/ClientSubscriptionRequest.r

# Agave Platform Science API
#
# Power your digital lab and reduce the time from theory to discovery using the Agave Science-as-a-Service API Platform. Agave provides hosted services that allow researchers to manage data, conduct experiments, and publish and share results from anywhere at any time.
#
# Agave Platform version: 2.2.14
# 
# Generated by: https://github.com/swagger-api/swagger-codegen.git


#' ClientSubscriptionRequest Class
#'
#' 
#'
#' @field apiName The name of the API.
#' @field apiProvider The user who registered the API.
#' @field apiVersion The current major version of the API. This is appended to the api_context to create the base API url.
#' @field tier 
#'
#' @importFrom R6 R6Class
#' @importFrom jsonlite fromJSON toJSON
#' @export
ClientSubscriptionRequest <- R6::R6Class(
  'ClientSubscriptionRequest',
  public = list(
    `apiName` = NULL,
    `apiProvider` = NULL,
    `apiVersion` = NULL,
    `tier` = NULL,
    initialize = function(`apiName`, `apiProvider`, `apiVersion`, `tier`){
      if (!missing(`apiName`)) {
        stopifnot(is.character(`apiName`), length(`apiName`) == 1)
        self$`apiName` <- `apiName`
      }
      if (!missing(`apiProvider`)) {
        stopifnot(is.character(`apiProvider`), length(`apiProvider`) == 1)
        self$`apiProvider` <- `apiProvider`
      }
      if (!missing(`apiVersion`)) {
        stopifnot(is.character(`apiVersion`), length(`apiVersion`) == 1)
        self$`apiVersion` <- `apiVersion`
      }
      if (!missing(`tier`)) {
        stopifnot(R6::is.R6(`tier`))
        self$`tier` <- `tier`
      }
    },
    asJSON = function() {
      self$toJSON()
    },
    toJSON = function() {
      ClientSubscriptionRequestObject <- list()
      if (!is.null(self$`apiName`)) {
        ClientSubscriptionRequestObject[['apiName']] <- self$`apiName`
      }
      else {
        ClientSubscriptionRequestObject[['apiName']] <- NULL
      }
      if (!is.null(self$`apiProvider`)) {
        ClientSubscriptionRequestObject[['apiProvider']] <- self$`apiProvider`
      }
      else {
        ClientSubscriptionRequestObject[['apiProvider']] <- NULL
      }
      if (!is.null(self$`apiVersion`)) {
        ClientSubscriptionRequestObject[['apiVersion']] <- self$`apiVersion`
      }
      else {
        ClientSubscriptionRequestObject[['apiVersion']] <- NULL
      }
      if (!is.null(self$`tier`)) {
        ClientSubscriptionRequestObject[['tier']] <- self$`tier`$toJSON()
      }
      else {
        ClientSubscriptionRequestObject[['tier']] <- NULL
      }

      ClientSubscriptionRequestObject
    },
    fromJSON = function(ClientSubscriptionRequestObject) {
      if (is.character(ClientSubscriptionRequestObject)) {
        ClientSubscriptionRequestObject <- jsonlite::fromJSON(ClientSubscriptionRequestJson)
      }

      if ("result" %in% names(ClientSubscriptionRequestObject)) {
        ClientSubscriptionRequestObject <- ClientSubscriptionRequestObject$result
      }

      if (!is.null(ClientSubscriptionRequestObject$`apiName`)) {
        self$`apiName` <- ClientSubscriptionRequestObject$`apiName`
      }
      if (!is.null(ClientSubscriptionRequestObject$`apiProvider`)) {
        self$`apiProvider` <- ClientSubscriptionRequestObject$`apiProvider`
      }
      if (!is.null(ClientSubscriptionRequestObject$`apiVersion`)) {
        self$`apiVersion` <- ClientSubscriptionRequestObject$`apiVersion`
      }
      if (!is.null(ClientSubscriptionRequestObject$`tier`)) {
        tierObject <- ClientSubscriptionTier$new()
        tierObject$fromJSON(jsonlite::toJSON(ClientSubscriptionRequestObject$tier, auto_unbox = TRUE))
        self$`tier` <- tierObject
      }
    },
    toJSONString = function() {
       sprintf(
        '{
           "apiName": %s,
           "apiProvider": %s,
           "apiVersion": %s,
           "tier": %s
        }',
        ifelse( is.null(self$`apiName`),"null",paste0(c('"', self$`apiName`, '"'))),
        ifelse( is.null(self$`apiProvider`),"null",paste0(c('"', self$`apiProvider`, '"'))),
        ifelse( is.null(self$`apiVersion`),"null",paste0(c('"', self$`apiVersion`, '"'))),
        self$`tier`$toJSON()
      )
    },
    fromJSONString = function(ClientSubscriptionRequestJson) {
      ClientSubscriptionRequestObject <- jsonlite::fromJSON(ClientSubscriptionRequestJson)
      self::fromJSON(ClientSubscriptionRequestObject)

    }
  )
)
deardooley/agave-rlang-sdk documentation built on May 17, 2019, 10:12 p.m.