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


#' PostItRequest Class
#'
#' 
#'
#' @field url The url that will be invoked when the PostIt is redeemed.
#' @field internalUsername The username of the internal user attached to this PostIt.
#' @field method 
#' @field lifetime The maximum lifetime in seconds of this PostIt on this token. Defaults to 2592000 (30 days)
#' @field maxUses The maximum number of invocations remaining on this PostIt. Defaults to no limit
#' @field noauth If true, the provided url will be called without authentication. Default is false
#'
#' @importFrom R6 R6Class
#' @importFrom jsonlite fromJSON toJSON
#' @export
PostItRequest <- R6::R6Class(
  'PostItRequest',
  public = list(
    `url` = NULL,
    `internalUsername` = NULL,
    `method` = NULL,
    `lifetime` = NULL,
    `maxUses` = NULL,
    `noauth` = NULL,
    initialize = function(`url`, `internalUsername`, `method`, `lifetime`, `maxUses`, `noauth`){
      if (!missing(`url`)) {
        stopifnot(is.character(`url`), length(`url`) == 1)
        self$`url` <- `url`
      }
      if (!missing(`internalUsername`)) {
        stopifnot(is.character(`internalUsername`), length(`internalUsername`) == 1)
        self$`internalUsername` <- `internalUsername`
      }
      if (!missing(`method`)) {
        stopifnot(R6::is.R6(`method`))
        self$`method` <- `method`
      }
      if (!missing(`lifetime`)) {
        stopifnot(is.numeric(`lifetime`), length(`lifetime`) == 1)
        self$`lifetime` <- `lifetime`
      }
      if (!missing(`maxUses`)) {
        stopifnot(is.numeric(`maxUses`), length(`maxUses`) == 1)
        self$`maxUses` <- `maxUses`
      }
      if (!missing(`noauth`)) {
        self$`noauth` <- `noauth`
      }
    },
    asJSON = function() {
      self$toJSON()
    },
    toJSON = function() {
      PostItRequestObject <- list()
      if (!is.null(self$`url`)) {
        PostItRequestObject[['url']] <- self$`url`
      }
      else {
        PostItRequestObject[['url']] <- NULL
      }
      if (!is.null(self$`internalUsername`)) {
        PostItRequestObject[['internalUsername']] <- self$`internalUsername`
      }
      else {
        PostItRequestObject[['internalUsername']] <- NULL
      }
      if (!is.null(self$`method`)) {
        PostItRequestObject[['method']] <- self$`method`$toJSON()
      }
      else {
        PostItRequestObject[['method']] <- NULL
      }
      if (!is.null(self$`lifetime`)) {
        PostItRequestObject[['lifetime']] <- self$`lifetime`
      }
      else {
        PostItRequestObject[['lifetime']] <- NULL
      }
      if (!is.null(self$`maxUses`)) {
        PostItRequestObject[['maxUses']] <- self$`maxUses`
      }
      else {
        PostItRequestObject[['maxUses']] <- NULL
      }
      if (!is.null(self$`noauth`)) {
        PostItRequestObject[['noauth']] <- self$`noauth`
      }
      else {
        PostItRequestObject[['noauth']] <- NULL
      }

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

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

      if (!is.null(PostItRequestObject$`url`)) {
        self$`url` <- PostItRequestObject$`url`
      }
      if (!is.null(PostItRequestObject$`internalUsername`)) {
        self$`internalUsername` <- PostItRequestObject$`internalUsername`
      }
      if (!is.null(PostItRequestObject$`method`)) {
        methodObject <- PostItRequestMethod$new()
        methodObject$fromJSON(jsonlite::toJSON(PostItRequestObject$method, auto_unbox = TRUE))
        self$`method` <- methodObject
      }
      if (!is.null(PostItRequestObject$`lifetime`)) {
        self$`lifetime` <- PostItRequestObject$`lifetime`
      }
      if (!is.null(PostItRequestObject$`maxUses`)) {
        self$`maxUses` <- PostItRequestObject$`maxUses`
      }
      if (!is.null(PostItRequestObject$`noauth`)) {
        self$`noauth` <- PostItRequestObject$`noauth`
      }
    },
    toJSONString = function() {
       sprintf(
        '{
           "url": %s,
           "internalUsername": %s,
           "method": %s,
           "lifetime": %d,
           "maxUses": %d,
           "noauth": %s
        }',
        ifelse( is.null(self$`url`),"null",paste0(c('"', self$`url`, '"'))),
        ifelse( is.null(self$`internalUsername`),"null",paste0(c('"', self$`internalUsername`, '"'))),
        self$`method`$toJSON(),
        ifelse( is.null(self$`lifetime`),"null",paste0(c('"', self$`lifetime`, '"'))),
        ifelse( is.null(self$`maxUses`),"null",paste0(c('"', self$`maxUses`, '"'))),
        ifelse( is.null(self$`noauth`),"null",paste0(c('"', self$`noauth`, '"')))
      )
    },
    fromJSONString = function(PostItRequestJson) {
      PostItRequestObject <- jsonlite::fromJSON(PostItRequestJson)
      self::fromJSON(PostItRequestObject)

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