R/snapshot_futures_data.R

# Binance Public Spot API
#
# OpenAPI Specifications for the Binance Public Spot API  API documents:   - [https://github.com/binance/binance-spot-api-docs](https://github.com/binance/binance-spot-api-docs)   - [https://binance-docs.github.io/apidocs/spot/en](https://binance-docs.github.io/apidocs/spot/en)
#
# The version of the OpenAPI document: 1.0
# 
# Generated by: https://openapi-generator.tech

#' @docType class
#' @title SnapshotFuturesData
#'
#' @description SnapshotFuturesData Class
#'
#' @format An \code{R6Class} generator object
#'
#' @field assets  list( \link{SnapshotFuturesDataAssets} ) 
#'
#' @field position  list( \link{SnapshotFuturesDataPosition} ) 
#'
#' @importFrom R6 R6Class
#' @importFrom jsonlite fromJSON toJSON
#' @export
SnapshotFuturesData <- R6::R6Class(
  'SnapshotFuturesData',
  public = list(
    `assets` = NULL,
    `position` = NULL,
    initialize = function(
        `assets`, `position`, ...
    ) {
      local.optional.var <- list(...)
      if (!missing(`assets`)) {
        stopifnot(is.vector(`assets`), length(`assets`) != 0)
        sapply(`assets`, function(x) stopifnot(R6::is.R6(x)))
        self$`assets` <- `assets`
      }
      if (!missing(`position`)) {
        stopifnot(is.vector(`position`), length(`position`) != 0)
        sapply(`position`, function(x) stopifnot(R6::is.R6(x)))
        self$`position` <- `position`
      }
    },
    toJSON = function() {
      SnapshotFuturesDataObject <- list()
      if (!is.null(self$`assets`)) {
        SnapshotFuturesDataObject[['assets']] <-
          lapply(self$`assets`, function(x) x$toJSON())
      }
      if (!is.null(self$`position`)) {
        SnapshotFuturesDataObject[['position']] <-
          lapply(self$`position`, function(x) x$toJSON())
      }

      SnapshotFuturesDataObject
    },
    fromJSON = function(SnapshotFuturesDataJson) {
      SnapshotFuturesDataObject <- jsonlite::fromJSON(SnapshotFuturesDataJson)
      if (!is.null(SnapshotFuturesDataObject$`assets`)) {
        self$`assets` <- ApiClient$new()$deserializeObj(SnapshotFuturesDataObject$`assets`, "array[SnapshotFuturesDataAssets]", loadNamespace("binanceRapi"))
      }
      if (!is.null(SnapshotFuturesDataObject$`position`)) {
        self$`position` <- ApiClient$new()$deserializeObj(SnapshotFuturesDataObject$`position`, "array[SnapshotFuturesDataPosition]", loadNamespace("binanceRapi"))
      }
      self
    },
    toJSONString = function() {
      jsoncontent <- c(
        if (!is.null(self$`assets`)) {
        sprintf(
        '"assets":
        [%s]
',
        paste(sapply(self$`assets`, function(x) jsonlite::toJSON(x$toJSON(), auto_unbox=TRUE, digits = NA)), collapse=",")
        )},
        if (!is.null(self$`position`)) {
        sprintf(
        '"position":
        [%s]
',
        paste(sapply(self$`position`, function(x) jsonlite::toJSON(x$toJSON(), auto_unbox=TRUE, digits = NA)), collapse=",")
        )}
      )
      jsoncontent <- paste(jsoncontent, collapse = ",")
      paste('{', jsoncontent, '}', sep = "")
    },
    fromJSONString = function(SnapshotFuturesDataJson) {
      SnapshotFuturesDataObject <- jsonlite::fromJSON(SnapshotFuturesDataJson)
      self$`assets` <- ApiClient$new()$deserializeObj(SnapshotFuturesDataObject$`assets`, "array[SnapshotFuturesDataAssets]", loadNamespace("binanceRapi"))
      self$`position` <- ApiClient$new()$deserializeObj(SnapshotFuturesDataObject$`position`, "array[SnapshotFuturesDataPosition]", loadNamespace("binanceRapi"))
      self
    }
  )
)
grahamjwhite/binanceRapi documentation built on Nov. 22, 2022, 9:37 p.m.