R/ClientRequest.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


#' ClientRequest Class
#'
#' 
#'
#' @field name The name of the client.
#' @field description Description of the client. This will be shown to users when authentication via OAuth web flows
#' @field tier 
#' @field callbackUrl Callback URL for OAuth authentication grant.
#'
#' @importFrom R6 R6Class
#' @importFrom jsonlite fromJSON toJSON
#' @export
ClientRequest <- R6::R6Class(
  'ClientRequest',
  public = list(
    `name` = NULL,
    `description` = NULL,
    `tier` = NULL,
    `callbackUrl` = NULL,
    initialize = function(`name`, `description`, `tier`, `callbackUrl`){
      if (!missing(`name`)) {
        stopifnot(is.character(`name`), length(`name`) == 1)
        self$`name` <- `name`
      }
      if (!missing(`description`)) {
        stopifnot(is.character(`description`), length(`description`) == 1)
        self$`description` <- `description`
      }
      if (!missing(`tier`)) {
        stopifnot(R6::is.R6(`tier`))
        self$`tier` <- `tier`
      }
      if (!missing(`callbackUrl`)) {
        stopifnot(is.character(`callbackUrl`), length(`callbackUrl`) == 1)
        self$`callbackUrl` <- `callbackUrl`
      }
    },
    asJSON = function() {
      self$toJSON()
    },
    toJSON = function() {
      ClientRequestObject <- list()
      if (!is.null(self$`name`)) {
        ClientRequestObject[['name']] <- self$`name`
      }
      else {
        ClientRequestObject[['name']] <- NULL
      }
      if (!is.null(self$`description`)) {
        ClientRequestObject[['description']] <- self$`description`
      }
      else {
        ClientRequestObject[['description']] <- NULL
      }
      if (!is.null(self$`tier`)) {
        ClientRequestObject[['tier']] <- self$`tier`$toJSON()
      }
      else {
        ClientRequestObject[['tier']] <- NULL
      }
      if (!is.null(self$`callbackUrl`)) {
        ClientRequestObject[['callbackUrl']] <- self$`callbackUrl`
      }
      else {
        ClientRequestObject[['callbackUrl']] <- NULL
      }

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

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

      if (!is.null(ClientRequestObject$`name`)) {
        self$`name` <- ClientRequestObject$`name`
      }
      if (!is.null(ClientRequestObject$`description`)) {
        self$`description` <- ClientRequestObject$`description`
      }
      if (!is.null(ClientRequestObject$`tier`)) {
        tierObject <- ClientSubscriptionTier$new()
        tierObject$fromJSON(jsonlite::toJSON(ClientRequestObject$tier, auto_unbox = TRUE))
        self$`tier` <- tierObject
      }
      if (!is.null(ClientRequestObject$`callbackUrl`)) {
        self$`callbackUrl` <- ClientRequestObject$`callbackUrl`
      }
    },
    toJSONString = function() {
       sprintf(
        '{
           "name": %s,
           "description": %s,
           "tier": %s,
           "callbackUrl": %s
        }',
        ifelse( is.null(self$`name`),"null",paste0(c('"', self$`name`, '"'))),
        ifelse( is.null(self$`description`),"null",paste0(c('"', self$`description`, '"'))),
        self$`tier`$toJSON(),
        ifelse( is.null(self$`callbackUrl`),"null",paste0(c('"', self$`callbackUrl`, '"')))
      )
    },
    fromJSONString = function(ClientRequestJson) {
      ClientRequestObject <- jsonlite::fromJSON(ClientRequestJson)
      self::fromJSON(ClientRequestObject)

    }
  )
)
agaveplatform/r-sdk documentation built on May 13, 2019, 8:20 a.m.