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

      LinksObject
    },
    fromJSON = function(LinksJson) {
      LinksObject <- jsonlite::fromJSON(LinksJson)
      if (!is.null(LinksObject$`links`)) {
        self$`links` <- ApiClient$new()$deserializeObj(LinksObject$`links`, "array[Link]", loadNamespace("graphsense"))
      }
      if (!is.null(LinksObject$`next_page`)) {
        self$`next_page` <- LinksObject$`next_page`
      }
      self
    },
    toJSONString = function() {
      jsoncontent <- c(
        if (!is.null(self$`links`)) {
        sprintf(
        '"links":
        [%s]
',
        paste(sapply(self$`links`, 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(LinksJson) {
      LinksObject <- jsonlite::fromJSON(LinksJson)
      self$`links` <- ApiClient$new()$deserializeObj(LinksObject$`links`, "array[Link]", loadNamespace("graphsense"))
      self$`next_page` <- LinksObject$`next_page`
      self
    }
  )
)
graphsense/rgraphsense documentation built on Sept. 2, 2022, 1:45 p.m.