R/rates.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 Rates
#'
#' @description Rates Class
#'
#' @format An \code{R6Class} generator object
#'
#' @field height  integer [optional]
#'
#' @field rates  list( \link{Rate} ) [optional]
#'
#' @importFrom R6 R6Class
#' @importFrom jsonlite fromJSON toJSON
#' @export
Rates <- R6::R6Class(
  'Rates',
  public = list(
    `height` = NULL,
    `rates` = NULL,
    initialize = function(
        `height`=NULL, `rates`=NULL, ...
    ) {
      local.optional.var <- list(...)
      if (!is.null(`height`)) {
        stopifnot(is.numeric(`height`), length(`height`) == 1)
        self$`height` <- `height`
      }
      if (!is.null(`rates`)) {
        stopifnot(is.vector(`rates`), length(`rates`) != 0)
        sapply(`rates`, function(x) stopifnot(R6::is.R6(x)))
        self$`rates` <- `rates`
      }
    },
    toJSON = function() {
      RatesObject <- list()
      if (!is.null(self$`height`)) {
        RatesObject[['height']] <-
          self$`height`
      }
      if (!is.null(self$`rates`)) {
        RatesObject[['rates']] <-
          lapply(self$`rates`, function(x) x$toJSON())
      }

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