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

      AddressTxUtxoObject
    },
    fromJSON = function(AddressTxUtxoJson) {
      AddressTxUtxoObject <- jsonlite::fromJSON(AddressTxUtxoJson)
      if (!is.null(AddressTxUtxoObject$`coinbase`)) {
        self$`coinbase` <- AddressTxUtxoObject$`coinbase`
      }
      if (!is.null(AddressTxUtxoObject$`currency`)) {
        self$`currency` <- AddressTxUtxoObject$`currency`
      }
      if (!is.null(AddressTxUtxoObject$`height`)) {
        self$`height` <- AddressTxUtxoObject$`height`
      }
      if (!is.null(AddressTxUtxoObject$`timestamp`)) {
        self$`timestamp` <- AddressTxUtxoObject$`timestamp`
      }
      if (!is.null(AddressTxUtxoObject$`tx_hash`)) {
        self$`tx_hash` <- AddressTxUtxoObject$`tx_hash`
      }
      if (!is.null(AddressTxUtxoObject$`tx_type`)) {
        self$`tx_type` <- AddressTxUtxoObject$`tx_type`
      }
      if (!is.null(AddressTxUtxoObject$`value`)) {
        valueObject <- Values$new()
        valueObject$fromJSON(jsonlite::toJSON(AddressTxUtxoObject$value, auto_unbox = TRUE, digits = NA))
        self$`value` <- valueObject
      }
      self
    },
    toJSONString = function() {
      jsoncontent <- c(
        if (!is.null(self$`coinbase`)) {
        sprintf(
        '"coinbase":
          "%s"
                ',
        self$`coinbase`
        )},
        if (!is.null(self$`currency`)) {
        sprintf(
        '"currency":
          "%s"
                ',
        self$`currency`
        )},
        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`
        )},
        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(AddressTxUtxoJson) {
      AddressTxUtxoObject <- jsonlite::fromJSON(AddressTxUtxoJson)
      self$`coinbase` <- AddressTxUtxoObject$`coinbase`
      self$`currency` <- AddressTxUtxoObject$`currency`
      self$`height` <- AddressTxUtxoObject$`height`
      self$`timestamp` <- AddressTxUtxoObject$`timestamp`
      self$`tx_hash` <- AddressTxUtxoObject$`tx_hash`
      self$`tx_type` <- AddressTxUtxoObject$`tx_type`
      self$`value` <- Values$new()$fromJSON(jsonlite::toJSON(AddressTxUtxoObject$value, auto_unbox = TRUE, digits = NA))
      self
    }
  )
)
graphsense/rgraphsense documentation built on Sept. 2, 2022, 1:45 p.m.