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

      LinkUtxoObject
    },
    fromJSON = function(LinkUtxoJson) {
      LinkUtxoObject <- jsonlite::fromJSON(LinkUtxoJson)
      if (!is.null(LinkUtxoObject$`currency`)) {
        self$`currency` <- LinkUtxoObject$`currency`
      }
      if (!is.null(LinkUtxoObject$`height`)) {
        self$`height` <- LinkUtxoObject$`height`
      }
      if (!is.null(LinkUtxoObject$`input_value`)) {
        input_valueObject <- Values$new()
        input_valueObject$fromJSON(jsonlite::toJSON(LinkUtxoObject$input_value, auto_unbox = TRUE, digits = NA))
        self$`input_value` <- input_valueObject
      }
      if (!is.null(LinkUtxoObject$`output_value`)) {
        output_valueObject <- Values$new()
        output_valueObject$fromJSON(jsonlite::toJSON(LinkUtxoObject$output_value, auto_unbox = TRUE, digits = NA))
        self$`output_value` <- output_valueObject
      }
      if (!is.null(LinkUtxoObject$`timestamp`)) {
        self$`timestamp` <- LinkUtxoObject$`timestamp`
      }
      if (!is.null(LinkUtxoObject$`tx_hash`)) {
        self$`tx_hash` <- LinkUtxoObject$`tx_hash`
      }
      if (!is.null(LinkUtxoObject$`tx_type`)) {
        self$`tx_type` <- LinkUtxoObject$`tx_type`
      }
      self
    },
    toJSONString = function() {
      jsoncontent <- c(
        if (!is.null(self$`currency`)) {
        sprintf(
        '"currency":
          "%s"
                ',
        self$`currency`
        )},
        if (!is.null(self$`height`)) {
        sprintf(
        '"height":
          %d
                ',
        self$`height`
        )},
        if (!is.null(self$`input_value`)) {
        sprintf(
        '"input_value":
        %s
        ',
        jsonlite::toJSON(self$`input_value`$toJSON(), auto_unbox=TRUE, digits = NA)
        )},
        if (!is.null(self$`output_value`)) {
        sprintf(
        '"output_value":
        %s
        ',
        jsonlite::toJSON(self$`output_value`$toJSON(), auto_unbox=TRUE, digits = NA)
        )},
        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`
        )}
      )
      jsoncontent <- paste(jsoncontent, collapse = ",")
      paste('{', jsoncontent, '}', sep = "")
    },
    fromJSONString = function(LinkUtxoJson) {
      LinkUtxoObject <- jsonlite::fromJSON(LinkUtxoJson)
      self$`currency` <- LinkUtxoObject$`currency`
      self$`height` <- LinkUtxoObject$`height`
      self$`input_value` <- Values$new()$fromJSON(jsonlite::toJSON(LinkUtxoObject$input_value, auto_unbox = TRUE, digits = NA))
      self$`output_value` <- Values$new()$fromJSON(jsonlite::toJSON(LinkUtxoObject$output_value, auto_unbox = TRUE, digits = NA))
      self$`timestamp` <- LinkUtxoObject$`timestamp`
      self$`tx_hash` <- LinkUtxoObject$`tx_hash`
      self$`tx_type` <- LinkUtxoObject$`tx_type`
      self
    }
  )
)
graphsense/rgraphsense documentation built on Sept. 2, 2022, 1:45 p.m.