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

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