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


#' HistoryEvent Class
#'
#' A generic history event representing a change on a resource or one of its associations.
#'
#' @field created The date of the event.
#' @field description A brief description of the event details.
#' @field status The status of the file/folder after this event.
#' @field progress 
#'
#' @importFrom R6 R6Class
#' @importFrom jsonlite fromJSON toJSON
#' @export
HistoryEvent <- R6::R6Class(
  'HistoryEvent',
  public = list(
    `created` = NULL,
    `description` = NULL,
    `status` = NULL,
    `progress` = NULL,
    initialize = function(`created`, `description`, `status`, `progress`){
      if (!missing(`created`)) {
        stopifnot(is.character(`created`), length(`created`) == 1)
        self$`created` <- `created`
      }
      if (!missing(`description`)) {
        stopifnot(is.character(`description`), length(`description`) == 1)
        self$`description` <- `description`
      }
      if (!missing(`status`)) {
        stopifnot(is.character(`status`), length(`status`) == 1)
        self$`status` <- `status`
      }
      if (!missing(`progress`)) {
        stopifnot(R6::is.R6(`progress`))
        self$`progress` <- `progress`
      }
    },
    asJSON = function() {
      self$toJSON()
    },
    toJSON = function() {
      HistoryEventObject <- list()
      if (!is.null(self$`created`)) {
        HistoryEventObject[['created']] <- self$`created`
      }
      else {
        HistoryEventObject[['created']] <- NULL
      }
      if (!is.null(self$`description`)) {
        HistoryEventObject[['description']] <- self$`description`
      }
      else {
        HistoryEventObject[['description']] <- NULL
      }
      if (!is.null(self$`status`)) {
        HistoryEventObject[['status']] <- self$`status`
      }
      else {
        HistoryEventObject[['status']] <- NULL
      }
      if (!is.null(self$`progress`)) {
        HistoryEventObject[['progress']] <- self$`progress`$toJSON()
      }
      else {
        HistoryEventObject[['progress']] <- NULL
      }

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

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

      if (!is.null(HistoryEventObject$`created`)) {
        self$`created` <- HistoryEventObject$`created`
      }
      if (!is.null(HistoryEventObject$`description`)) {
        self$`description` <- HistoryEventObject$`description`
      }
      if (!is.null(HistoryEventObject$`status`)) {
        self$`status` <- HistoryEventObject$`status`
      }
      if (!is.null(HistoryEventObject$`progress`)) {
        progressObject <- TransferTaskProgressSummary$new()
        progressObject$fromJSON(jsonlite::toJSON(HistoryEventObject$progress, auto_unbox = TRUE))
        self$`progress` <- progressObject
      }
    },
    toJSONString = function() {
       sprintf(
        '{
           "created": %s,
           "description": %s,
           "status": %s,
           "progress": %s
        }',
        ifelse( is.null(self$`created`),"null",paste0(c('"', self$`created`, '"'))),
        ifelse( is.null(self$`description`),"null",paste0(c('"', self$`description`, '"'))),
        ifelse( is.null(self$`status`),"null",paste0(c('"', self$`status`, '"'))),
        self$`progress`$toJSON()
      )
    },
    fromJSONString = function(HistoryEventJson) {
      HistoryEventObject <- jsonlite::fromJSON(HistoryEventJson)
      self::fromJSON(HistoryEventObject)

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