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

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