R/rate.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 Rate
#'
#' @description Rate Class
#'
#' @format An \code{R6Class} generator object
#'
#' @field code  character 
#'
#' @field value  numeric 
#'
#' @importFrom R6 R6Class
#' @importFrom jsonlite fromJSON toJSON
#' @export
Rate <- R6::R6Class(
  'Rate',
  public = list(
    `code` = NULL,
    `value` = NULL,
    initialize = function(
        `code`, `value`, ...
    ) {
      local.optional.var <- list(...)
      if (!missing(`code`)) {
        stopifnot(is.character(`code`), length(`code`) == 1)
        self$`code` <- `code`
      }
      if (!missing(`value`)) {
        stopifnot(is.numeric(`value`), length(`value`) == 1)
        self$`value` <- `value`
      }
    },
    toJSON = function() {
      RateObject <- list()
      if (!is.null(self$`code`)) {
        RateObject[['code']] <-
          self$`code`
      }
      if (!is.null(self$`value`)) {
        RateObject[['value']] <-
          self$`value`
      }

      RateObject
    },
    fromJSON = function(RateJson) {
      RateObject <- jsonlite::fromJSON(RateJson)
      if (!is.null(RateObject$`code`)) {
        self$`code` <- RateObject$`code`
      }
      if (!is.null(RateObject$`value`)) {
        self$`value` <- RateObject$`value`
      }
      self
    },
    toJSONString = function() {
      jsoncontent <- c(
        if (!is.null(self$`code`)) {
        sprintf(
        '"code":
          "%s"
                ',
        self$`code`
        )},
        if (!is.null(self$`value`)) {
        sprintf(
        '"value":
          %d
                ',
        self$`value`
        )}
      )
      jsoncontent <- paste(jsoncontent, collapse = ",")
      paste('{', jsoncontent, '}', sep = "")
    },
    fromJSONString = function(RateJson) {
      RateObject <- jsonlite::fromJSON(RateJson)
      self$`code` <- RateObject$`code`
      self$`value` <- RateObject$`value`
      self
    }
  )
)
graphsense/rgraphsense documentation built on Sept. 2, 2022, 1:45 p.m.