R/tags.R

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

#' @docType class
#' @title Tags
#'
#' @description Tags Class
#'
#' @format An \code{R6Class} generator object
#'
#' @field entity_tags  list( \link{EntityTag} ) 
#'
#' @field next_page  character [optional]
#'
#' @field address_tags  list( \link{AddressTag} ) 
#'
#' @importFrom R6 R6Class
#' @importFrom jsonlite fromJSON toJSON
#' @export
Tags <- R6::R6Class(
  'Tags',
  public = list(
    `entity_tags` = NULL,
    `next_page` = NULL,
    `address_tags` = NULL,
    initialize = function(
        `entity_tags`, `address_tags`, `next_page`=NULL, ...
    ) {
      local.optional.var <- list(...)
      if (!missing(`entity_tags`)) {
        stopifnot(is.vector(`entity_tags`), length(`entity_tags`) != 0)
        sapply(`entity_tags`, function(x) stopifnot(R6::is.R6(x)))
        self$`entity_tags` <- `entity_tags`
      }
      if (!missing(`address_tags`)) {
        stopifnot(is.vector(`address_tags`), length(`address_tags`) != 0)
        sapply(`address_tags`, function(x) stopifnot(R6::is.R6(x)))
        self$`address_tags` <- `address_tags`
      }
      if (!is.null(`next_page`)) {
        stopifnot(is.character(`next_page`), length(`next_page`) == 1)
        self$`next_page` <- `next_page`
      }
    },
    toJSON = function() {
      TagsObject <- list()
      if (!is.null(self$`entity_tags`)) {
        TagsObject[['entity_tags']] <-
          lapply(self$`entity_tags`, function(x) x$toJSON())
      }
      if (!is.null(self$`next_page`)) {
        TagsObject[['next_page']] <-
          self$`next_page`
      }
      if (!is.null(self$`address_tags`)) {
        TagsObject[['address_tags']] <-
          lapply(self$`address_tags`, function(x) x$toJSON())
      }

      TagsObject
    },
    fromJSON = function(TagsJson) {
      TagsObject <- jsonlite::fromJSON(TagsJson)
      if (!is.null(TagsObject$`entity_tags`)) {
        self$`entity_tags` <- ApiClient$new()$deserializeObj(TagsObject$`entity_tags`, "array[EntityTag]", loadNamespace("graphsense"))
      }
      if (!is.null(TagsObject$`next_page`)) {
        self$`next_page` <- TagsObject$`next_page`
      }
      if (!is.null(TagsObject$`address_tags`)) {
        self$`address_tags` <- ApiClient$new()$deserializeObj(TagsObject$`address_tags`, "array[AddressTag]", loadNamespace("graphsense"))
      }
      self
    },
    toJSONString = function() {
      jsoncontent <- c(
        if (!is.null(self$`entity_tags`)) {
        sprintf(
        '"entity_tags":
        [%s]
',
        paste(sapply(self$`entity_tags`, 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`
        )},
        if (!is.null(self$`address_tags`)) {
        sprintf(
        '"address_tags":
        [%s]
',
        paste(sapply(self$`address_tags`, function(x) jsonlite::toJSON(x$toJSON(), auto_unbox=TRUE, digits = NA)), collapse=",")
        )}
      )
      jsoncontent <- paste(jsoncontent, collapse = ",")
      paste('{', jsoncontent, '}', sep = "")
    },
    fromJSONString = function(TagsJson) {
      TagsObject <- jsonlite::fromJSON(TagsJson)
      self$`entity_tags` <- ApiClient$new()$deserializeObj(TagsObject$`entity_tags`, "array[EntityTag]", loadNamespace("graphsense"))
      self$`next_page` <- TagsObject$`next_page`
      self$`address_tags` <- ApiClient$new()$deserializeObj(TagsObject$`address_tags`, "array[AddressTag]", loadNamespace("graphsense"))
      self
    }
  )
)
graphsense/rgraphsense documentation built on Sept. 2, 2022, 1:45 p.m.