R/stats.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 Stats
#'
#' @description Stats Class
#'
#' @format An \code{R6Class} generator object
#'
#' @field currencies  list( \link{CurrencyStats} ) 
#'
#' @field request_timestamp  character 
#'
#' @field version  character 
#'
#' @importFrom R6 R6Class
#' @importFrom jsonlite fromJSON toJSON
#' @export
Stats <- R6::R6Class(
  'Stats',
  public = list(
    `currencies` = NULL,
    `request_timestamp` = NULL,
    `version` = NULL,
    initialize = function(
        `currencies`, `request_timestamp`, `version`, ...
    ) {
      local.optional.var <- list(...)
      if (!missing(`currencies`)) {
        stopifnot(is.vector(`currencies`), length(`currencies`) != 0)
        sapply(`currencies`, function(x) stopifnot(R6::is.R6(x)))
        self$`currencies` <- `currencies`
      }
      if (!missing(`request_timestamp`)) {
        stopifnot(is.character(`request_timestamp`), length(`request_timestamp`) == 1)
        self$`request_timestamp` <- `request_timestamp`
      }
      if (!missing(`version`)) {
        stopifnot(is.character(`version`), length(`version`) == 1)
        self$`version` <- `version`
      }
    },
    toJSON = function() {
      StatsObject <- list()
      if (!is.null(self$`currencies`)) {
        StatsObject[['currencies']] <-
          lapply(self$`currencies`, function(x) x$toJSON())
      }
      if (!is.null(self$`request_timestamp`)) {
        StatsObject[['request_timestamp']] <-
          self$`request_timestamp`
      }
      if (!is.null(self$`version`)) {
        StatsObject[['version']] <-
          self$`version`
      }

      StatsObject
    },
    fromJSON = function(StatsJson) {
      StatsObject <- jsonlite::fromJSON(StatsJson)
      if (!is.null(StatsObject$`currencies`)) {
        self$`currencies` <- ApiClient$new()$deserializeObj(StatsObject$`currencies`, "array[CurrencyStats]", loadNamespace("graphsense"))
      }
      if (!is.null(StatsObject$`request_timestamp`)) {
        self$`request_timestamp` <- StatsObject$`request_timestamp`
      }
      if (!is.null(StatsObject$`version`)) {
        self$`version` <- StatsObject$`version`
      }
      self
    },
    toJSONString = function() {
      jsoncontent <- c(
        if (!is.null(self$`currencies`)) {
        sprintf(
        '"currencies":
        [%s]
',
        paste(sapply(self$`currencies`, function(x) jsonlite::toJSON(x$toJSON(), auto_unbox=TRUE, digits = NA)), collapse=",")
        )},
        if (!is.null(self$`request_timestamp`)) {
        sprintf(
        '"request_timestamp":
          "%s"
                ',
        self$`request_timestamp`
        )},
        if (!is.null(self$`version`)) {
        sprintf(
        '"version":
          "%s"
                ',
        self$`version`
        )}
      )
      jsoncontent <- paste(jsoncontent, collapse = ",")
      paste('{', jsoncontent, '}', sep = "")
    },
    fromJSONString = function(StatsJson) {
      StatsObject <- jsonlite::fromJSON(StatsJson)
      self$`currencies` <- ApiClient$new()$deserializeObj(StatsObject$`currencies`, "array[CurrencyStats]", loadNamespace("graphsense"))
      self$`request_timestamp` <- StatsObject$`request_timestamp`
      self$`version` <- StatsObject$`version`
      self
    }
  )
)
graphsense/rgraphsense documentation built on Sept. 2, 2022, 1:45 p.m.