R/neighbors.R

# GraphSense API
#
# GraphSense API
#
# The version of the OpenAPI document: 0.5.2
# 
# Generated by: https://openapi-generator.tech

#' @docType class
#' @title Neighbors
#'
#' @description Neighbors Class
#'
#' @format An \code{R6Class} generator object
#'
#' @field neighbors  list( \link{Neighbor} ) [optional]
#'
#' @field next_page  character [optional]
#'
#' @importFrom R6 R6Class
#' @importFrom jsonlite fromJSON toJSON
#' @export
Neighbors <- R6::R6Class(
  'Neighbors',
  public = list(
    `neighbors` = NULL,
    `next_page` = NULL,
    initialize = function(
        `neighbors`=NULL, `next_page`=NULL, ...
    ) {
      local.optional.var <- list(...)
      if (!is.null(`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() {
      NeighborsObject <- list()
      if (!is.null(self$`neighbors`)) {
        NeighborsObject[['neighbors']] <-
          lapply(self$`neighbors`, function(x) x$toJSON())
      }
      if (!is.null(self$`next_page`)) {
        NeighborsObject[['next_page']] <-
          self$`next_page`
      }

      NeighborsObject
    },
    fromJSON = function(NeighborsJson) {
      NeighborsObject <- jsonlite::fromJSON(NeighborsJson)
      if (!is.null(NeighborsObject$`neighbors`)) {
        self$`neighbors` <- ApiClient$new()$deserializeObj(NeighborsObject$`neighbors`, "array[Neighbor]", loadNamespace("graphsense"))
      }
      if (!is.null(NeighborsObject$`next_page`)) {
        self$`next_page` <- NeighborsObject$`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(NeighborsJson) {
      NeighborsObject <- jsonlite::fromJSON(NeighborsJson)
      self$`neighbors` <- ApiClient$new()$deserializeObj(NeighborsObject$`neighbors`, "array[Neighbor]", loadNamespace("graphsense"))
      self$`next_page` <- NeighborsObject$`next_page`
      self
    }
  )
)
graphsense/rgraphsense documentation built on Sept. 2, 2022, 1:45 p.m.