R/tx_account.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 TxAccount
#'
#' @description TxAccount Class
#'
#' @format An \code{R6Class} generator object
#'
#' @field currency  character 
#'
#' @field from_address  character 
#'
#' @field height  integer 
#'
#' @field timestamp  integer 
#'
#' @field to_address  character 
#'
#' @field tx_hash  character 
#'
#' @field tx_type  character 
#'
#' @field value  \link{Values} 
#'
#' @importFrom R6 R6Class
#' @importFrom jsonlite fromJSON toJSON
#' @export
TxAccount <- R6::R6Class(
  'TxAccount',
  public = list(
    `currency` = NULL,
    `from_address` = NULL,
    `height` = NULL,
    `timestamp` = NULL,
    `to_address` = NULL,
    `tx_hash` = NULL,
    `tx_type` = NULL,
    `value` = NULL,
    initialize = function(
        `currency`, `from_address`, `height`, `timestamp`, `to_address`, `tx_hash`, `tx_type`, `value`, ...
    ) {
      local.optional.var <- list(...)
      if (!missing(`currency`)) {
        stopifnot(is.character(`currency`), length(`currency`) == 1)
        self$`currency` <- `currency`
      }
      if (!missing(`from_address`)) {
        stopifnot(is.character(`from_address`), length(`from_address`) == 1)
        self$`from_address` <- `from_address`
      }
      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(`to_address`)) {
        stopifnot(is.character(`to_address`), length(`to_address`) == 1)
        self$`to_address` <- `to_address`
      }
      if (!missing(`tx_hash`)) {
        stopifnot(is.character(`tx_hash`), length(`tx_hash`) == 1)
        self$`tx_hash` <- `tx_hash`
      }
      if (!missing(`tx_type`)) {
        stopifnot(is.character(`tx_type`), length(`tx_type`) == 1)
        self$`tx_type` <- `tx_type`
      }
      if (!missing(`value`)) {
        stopifnot(R6::is.R6(`value`))
        self$`value` <- `value`
      }
    },
    toJSON = function() {
      TxAccountObject <- list()
      if (!is.null(self$`currency`)) {
        TxAccountObject[['currency']] <-
          self$`currency`
      }
      if (!is.null(self$`from_address`)) {
        TxAccountObject[['from_address']] <-
          self$`from_address`
      }
      if (!is.null(self$`height`)) {
        TxAccountObject[['height']] <-
          self$`height`
      }
      if (!is.null(self$`timestamp`)) {
        TxAccountObject[['timestamp']] <-
          self$`timestamp`
      }
      if (!is.null(self$`to_address`)) {
        TxAccountObject[['to_address']] <-
          self$`to_address`
      }
      if (!is.null(self$`tx_hash`)) {
        TxAccountObject[['tx_hash']] <-
          self$`tx_hash`
      }
      if (!is.null(self$`tx_type`)) {
        TxAccountObject[['tx_type']] <-
          self$`tx_type`
      }
      if (!is.null(self$`value`)) {
        TxAccountObject[['value']] <-
          self$`value`$toJSON()
      }

      TxAccountObject
    },
    fromJSON = function(TxAccountJson) {
      TxAccountObject <- jsonlite::fromJSON(TxAccountJson)
      if (!is.null(TxAccountObject$`currency`)) {
        self$`currency` <- TxAccountObject$`currency`
      }
      if (!is.null(TxAccountObject$`from_address`)) {
        self$`from_address` <- TxAccountObject$`from_address`
      }
      if (!is.null(TxAccountObject$`height`)) {
        self$`height` <- TxAccountObject$`height`
      }
      if (!is.null(TxAccountObject$`timestamp`)) {
        self$`timestamp` <- TxAccountObject$`timestamp`
      }
      if (!is.null(TxAccountObject$`to_address`)) {
        self$`to_address` <- TxAccountObject$`to_address`
      }
      if (!is.null(TxAccountObject$`tx_hash`)) {
        self$`tx_hash` <- TxAccountObject$`tx_hash`
      }
      if (!is.null(TxAccountObject$`tx_type`)) {
        self$`tx_type` <- TxAccountObject$`tx_type`
      }
      if (!is.null(TxAccountObject$`value`)) {
        valueObject <- Values$new()
        valueObject$fromJSON(jsonlite::toJSON(TxAccountObject$value, auto_unbox = TRUE, digits = NA))
        self$`value` <- valueObject
      }
      self
    },
    toJSONString = function() {
      jsoncontent <- c(
        if (!is.null(self$`currency`)) {
        sprintf(
        '"currency":
          "%s"
                ',
        self$`currency`
        )},
        if (!is.null(self$`from_address`)) {
        sprintf(
        '"from_address":
          "%s"
                ',
        self$`from_address`
        )},
        if (!is.null(self$`height`)) {
        sprintf(
        '"height":
          %d
                ',
        self$`height`
        )},
        if (!is.null(self$`timestamp`)) {
        sprintf(
        '"timestamp":
          %d
                ',
        self$`timestamp`
        )},
        if (!is.null(self$`to_address`)) {
        sprintf(
        '"to_address":
          "%s"
                ',
        self$`to_address`
        )},
        if (!is.null(self$`tx_hash`)) {
        sprintf(
        '"tx_hash":
          "%s"
                ',
        self$`tx_hash`
        )},
        if (!is.null(self$`tx_type`)) {
        sprintf(
        '"tx_type":
          "%s"
                ',
        self$`tx_type`
        )},
        if (!is.null(self$`value`)) {
        sprintf(
        '"value":
        %s
        ',
        jsonlite::toJSON(self$`value`$toJSON(), auto_unbox=TRUE, digits = NA)
        )}
      )
      jsoncontent <- paste(jsoncontent, collapse = ",")
      paste('{', jsoncontent, '}', sep = "")
    },
    fromJSONString = function(TxAccountJson) {
      TxAccountObject <- jsonlite::fromJSON(TxAccountJson)
      self$`currency` <- TxAccountObject$`currency`
      self$`from_address` <- TxAccountObject$`from_address`
      self$`height` <- TxAccountObject$`height`
      self$`timestamp` <- TxAccountObject$`timestamp`
      self$`to_address` <- TxAccountObject$`to_address`
      self$`tx_hash` <- TxAccountObject$`tx_hash`
      self$`tx_type` <- TxAccountObject$`tx_type`
      self$`value` <- Values$new()$fromJSON(jsonlite::toJSON(TxAccountObject$value, auto_unbox = TRUE, digits = NA))
      self
    }
  )
)
graphsense/rgraphsense documentation built on Sept. 2, 2022, 1:45 p.m.