R/tx_summary.R

# GraphSense API
#
# GraphSense API provides programmatic access to various ledgers' addresses, entities, blocks, transactions and tags for automated and highly efficient forensics tasks.
#
# The version of the OpenAPI document: 1.0.1
# Contact: contact@ikna.io
# Generated by: https://openapi-generator.tech

#' @docType class
#' @title TxSummary
#'
#' @description TxSummary Class
#'
#' @format An \code{R6Class} generator object
#'
#' @field height  integer 
#'
#' @field timestamp  integer 
#'
#' @field tx_hash  character 
#'
#' @importFrom R6 R6Class
#' @importFrom jsonlite fromJSON toJSON
#' @export
TxSummary <- R6::R6Class(
  'TxSummary',
  public = list(
    `height` = NULL,
    `timestamp` = NULL,
    `tx_hash` = NULL,
    initialize = function(
        `height`, `timestamp`, `tx_hash`, ...
    ) {
      local.optional.var <- list(...)
      if (!missing(`height`)) {
        stopifnot(is.numeric(`height`), length(`height`) == 1)
        self$`height` <- `height`
      }
      if (!missing(`timestamp`)) {
        stopifnot(is.numeric(`timestamp`), length(`timestamp`) == 1)
        self$`timestamp` <- `timestamp`
      }
      if (!missing(`tx_hash`)) {
        stopifnot(is.character(`tx_hash`), length(`tx_hash`) == 1)
        self$`tx_hash` <- `tx_hash`
      }
    },
    toJSON = function() {
      TxSummaryObject <- list()
      if (!is.null(self$`height`)) {
        TxSummaryObject[['height']] <-
          self$`height`
      }
      if (!is.null(self$`timestamp`)) {
        TxSummaryObject[['timestamp']] <-
          self$`timestamp`
      }
      if (!is.null(self$`tx_hash`)) {
        TxSummaryObject[['tx_hash']] <-
          self$`tx_hash`
      }

      TxSummaryObject
    },
    fromJSON = function(TxSummaryJson) {
      TxSummaryObject <- jsonlite::fromJSON(TxSummaryJson)
      if (!is.null(TxSummaryObject$`height`)) {
        self$`height` <- TxSummaryObject$`height`
      }
      if (!is.null(TxSummaryObject$`timestamp`)) {
        self$`timestamp` <- TxSummaryObject$`timestamp`
      }
      if (!is.null(TxSummaryObject$`tx_hash`)) {
        self$`tx_hash` <- TxSummaryObject$`tx_hash`
      }
      self
    },
    toJSONString = function() {
      jsoncontent <- c(
        if (!is.null(self$`height`)) {
        sprintf(
        '"height":
          %d
                ',
        self$`height`
        )},
        if (!is.null(self$`timestamp`)) {
        sprintf(
        '"timestamp":
          %d
                ',
        self$`timestamp`
        )},
        if (!is.null(self$`tx_hash`)) {
        sprintf(
        '"tx_hash":
          "%s"
                ',
        self$`tx_hash`
        )}
      )
      jsoncontent <- paste(jsoncontent, collapse = ",")
      paste('{', jsoncontent, '}', sep = "")
    },
    fromJSONString = function(TxSummaryJson) {
      TxSummaryObject <- jsonlite::fromJSON(TxSummaryJson)
      self$`height` <- TxSummaryObject$`height`
      self$`timestamp` <- TxSummaryObject$`timestamp`
      self$`tx_hash` <- TxSummaryObject$`tx_hash`
      self
    }
  )
)
graphsense/rgraphsense documentation built on Sept. 2, 2022, 1:45 p.m.