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


#' Notification Class
#'
#' 
#'
#' @field event The event you wish to recieve a notification about. Specify * for all events.
#' @field persistent Whether this event should remain active after it triggers the first time.
#' @field url The URI to notify when the import is complete. This can be an email address or URL. If a URL is given, a POST will be made to this address. URL templating is supported. Valid template values are: ${JOB_STATUS}, ${JOB_URL}, ${JOB_ID}, ${JOB_SYSTEM}, ${JOB_NAME}, ${JOB_START_TIME}, ${JOB_END_TIME}, ${JOB_SUBMIT_TIME}, ${JOB_ARCHIVE_PATH}, ${JOB_ARCHIVE_URL}, ${JOB_ERROR}
#'
#' @importFrom R6 R6Class
#' @importFrom jsonlite fromJSON toJSON
#' @export
Notification <- R6::R6Class(
  'Notification',
  public = list(
    `event` = NULL,
    `persistent` = NULL,
    `url` = NULL,
    initialize = function(`event`, `persistent`, `url`){
      if (!missing(`event`)) {
        stopifnot(is.character(`event`), length(`event`) == 1)
        self$`event` <- `event`
      }
      if (!missing(`persistent`)) {
        self$`persistent` <- `persistent`
      }
      if (!missing(`url`)) {
        stopifnot(is.numeric(`url`), length(`url`) == 1)
        self$`url` <- `url`
      }
    },
    asJSON = function() {
      self$toJSON()
    },
    toJSON = function() {
      NotificationObject <- list()
      if (!is.null(self$`event`)) {
        NotificationObject[['event']] <- self$`event`
      }
      else {
        NotificationObject[['event']] <- NULL
      }
      if (!is.null(self$`persistent`)) {
        NotificationObject[['persistent']] <- self$`persistent`
      }
      else {
        NotificationObject[['persistent']] <- NULL
      }
      if (!is.null(self$`url`)) {
        NotificationObject[['url']] <- self$`url`
      }
      else {
        NotificationObject[['url']] <- NULL
      }

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

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

      if (!is.null(NotificationObject$`event`)) {
        self$`event` <- NotificationObject$`event`
      }
      if (!is.null(NotificationObject$`persistent`)) {
        self$`persistent` <- NotificationObject$`persistent`
      }
      if (!is.null(NotificationObject$`url`)) {
        self$`url` <- NotificationObject$`url`
      }
    },
    toJSONString = function() {
       sprintf(
        '{
           "event": %s,
           "persistent": %s,
           "url": %d
        }',
        ifelse( is.null(self$`event`),"null",paste0(c('"', self$`event`, '"'))),
        ifelse( is.null(self$`persistent`),"null",paste0(c('"', self$`persistent`, '"'))),
        ifelse( is.null(self$`url`),"null",paste0(c('"', self$`url`, '"')))
      )
    },
    fromJSONString = function(NotificationJson) {
      NotificationObject <- jsonlite::fromJSON(NotificationJson)
      self::fromJSON(NotificationObject)

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