R/search_result_level6.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 SearchResultLevel6
#'
#' @description SearchResultLevel6 Class
#'
#' @format An \code{R6Class} generator object
#'
#' @field matching_addresses  list( \link{Address} ) 
#'
#' @field neighbor  \link{NeighborEntity} 
#'
#' @field paths  list( \link{SearchResultLeaf} ) 
#'
#' @importFrom R6 R6Class
#' @importFrom jsonlite fromJSON toJSON
#' @export
SearchResultLevel6 <- R6::R6Class(
  'SearchResultLevel6',
  public = list(
    `matching_addresses` = NULL,
    `neighbor` = NULL,
    `paths` = NULL,
    initialize = function(
        `matching_addresses`, `neighbor`, `paths`, ...
    ) {
      local.optional.var <- list(...)
      if (!missing(`matching_addresses`)) {
        stopifnot(is.vector(`matching_addresses`), length(`matching_addresses`) != 0)
        sapply(`matching_addresses`, function(x) stopifnot(R6::is.R6(x)))
        self$`matching_addresses` <- `matching_addresses`
      }
      if (!missing(`neighbor`)) {
        stopifnot(R6::is.R6(`neighbor`))
        self$`neighbor` <- `neighbor`
      }
      if (!missing(`paths`)) {
        stopifnot(is.vector(`paths`), length(`paths`) != 0)
        sapply(`paths`, function(x) stopifnot(R6::is.R6(x)))
        self$`paths` <- `paths`
      }
    },
    toJSON = function() {
      SearchResultLevel6Object <- list()
      if (!is.null(self$`matching_addresses`)) {
        SearchResultLevel6Object[['matching_addresses']] <-
          lapply(self$`matching_addresses`, function(x) x$toJSON())
      }
      if (!is.null(self$`neighbor`)) {
        SearchResultLevel6Object[['neighbor']] <-
          self$`neighbor`$toJSON()
      }
      if (!is.null(self$`paths`)) {
        SearchResultLevel6Object[['paths']] <-
          lapply(self$`paths`, function(x) x$toJSON())
      }

      SearchResultLevel6Object
    },
    fromJSON = function(SearchResultLevel6Json) {
      SearchResultLevel6Object <- jsonlite::fromJSON(SearchResultLevel6Json)
      if (!is.null(SearchResultLevel6Object$`matching_addresses`)) {
        self$`matching_addresses` <- ApiClient$new()$deserializeObj(SearchResultLevel6Object$`matching_addresses`, "array[Address]", loadNamespace("graphsense"))
      }
      if (!is.null(SearchResultLevel6Object$`neighbor`)) {
        neighborObject <- NeighborEntity$new()
        neighborObject$fromJSON(jsonlite::toJSON(SearchResultLevel6Object$neighbor, auto_unbox = TRUE, digits = NA))
        self$`neighbor` <- neighborObject
      }
      if (!is.null(SearchResultLevel6Object$`paths`)) {
        self$`paths` <- ApiClient$new()$deserializeObj(SearchResultLevel6Object$`paths`, "array[SearchResultLeaf]", loadNamespace("graphsense"))
      }
      self
    },
    toJSONString = function() {
      jsoncontent <- c(
        if (!is.null(self$`matching_addresses`)) {
        sprintf(
        '"matching_addresses":
        [%s]
',
        paste(sapply(self$`matching_addresses`, function(x) jsonlite::toJSON(x$toJSON(), auto_unbox=TRUE, digits = NA)), collapse=",")
        )},
        if (!is.null(self$`neighbor`)) {
        sprintf(
        '"neighbor":
        %s
        ',
        jsonlite::toJSON(self$`neighbor`$toJSON(), auto_unbox=TRUE, digits = NA)
        )},
        if (!is.null(self$`paths`)) {
        sprintf(
        '"paths":
        [%s]
',
        paste(sapply(self$`paths`, function(x) jsonlite::toJSON(x$toJSON(), auto_unbox=TRUE, digits = NA)), collapse=",")
        )}
      )
      jsoncontent <- paste(jsoncontent, collapse = ",")
      paste('{', jsoncontent, '}', sep = "")
    },
    fromJSONString = function(SearchResultLevel6Json) {
      SearchResultLevel6Object <- jsonlite::fromJSON(SearchResultLevel6Json)
      self$`matching_addresses` <- ApiClient$new()$deserializeObj(SearchResultLevel6Object$`matching_addresses`, "array[Address]", loadNamespace("graphsense"))
      self$`neighbor` <- NeighborEntity$new()$fromJSON(jsonlite::toJSON(SearchResultLevel6Object$neighbor, auto_unbox = TRUE, digits = NA))
      self$`paths` <- ApiClient$new()$deserializeObj(SearchResultLevel6Object$`paths`, "array[SearchResultLeaf]", loadNamespace("graphsense"))
      self
    }
  )
)
graphsense/rgraphsense documentation built on Sept. 2, 2022, 1:45 p.m.