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

      SearchResultByCurrencyObject
    },
    fromJSON = function(SearchResultByCurrencyJson) {
      SearchResultByCurrencyObject <- jsonlite::fromJSON(SearchResultByCurrencyJson)
      if (!is.null(SearchResultByCurrencyObject$`addresses`)) {
        self$`addresses` <- ApiClient$new()$deserializeObj(SearchResultByCurrencyObject$`addresses`, "array[character]", loadNamespace("graphsense"))
      }
      if (!is.null(SearchResultByCurrencyObject$`currency`)) {
        self$`currency` <- SearchResultByCurrencyObject$`currency`
      }
      if (!is.null(SearchResultByCurrencyObject$`txs`)) {
        self$`txs` <- ApiClient$new()$deserializeObj(SearchResultByCurrencyObject$`txs`, "array[character]", loadNamespace("graphsense"))
      }
      self
    },
    toJSONString = function() {
      jsoncontent <- c(
        if (!is.null(self$`addresses`)) {
        sprintf(
        '"addresses":
           [%s]
        ',
        paste(unlist(lapply(self$`addresses`, function(x) paste0('"', x, '"'))), collapse=",")
        )},
        if (!is.null(self$`currency`)) {
        sprintf(
        '"currency":
          "%s"
                ',
        self$`currency`
        )},
        if (!is.null(self$`txs`)) {
        sprintf(
        '"txs":
           [%s]
        ',
        paste(unlist(lapply(self$`txs`, function(x) paste0('"', x, '"'))), collapse=",")
        )}
      )
      jsoncontent <- paste(jsoncontent, collapse = ",")
      paste('{', jsoncontent, '}', sep = "")
    },
    fromJSONString = function(SearchResultByCurrencyJson) {
      SearchResultByCurrencyObject <- jsonlite::fromJSON(SearchResultByCurrencyJson)
      self$`addresses` <- ApiClient$new()$deserializeObj(SearchResultByCurrencyObject$`addresses`, "array[character]", loadNamespace("graphsense"))
      self$`currency` <- SearchResultByCurrencyObject$`currency`
      self$`txs` <- ApiClient$new()$deserializeObj(SearchResultByCurrencyObject$`txs`, "array[character]", loadNamespace("graphsense"))
      self
    }
  )
)
graphsense/rgraphsense documentation built on Sept. 2, 2022, 1:45 p.m.