R/inline_response2001.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 InlineResponse2001
#'
#' @description InlineResponse2001 Class
#'
#' @format An \code{R6Class} generator object
#'
#' @field timezone  character 
#'
#' @field serverTime  integer 
#'
#' @field rateLimits  list( \link{InlineResponse2001RateLimits} ) 
#'
#' @field exchangeFilters  list( object ) 
#'
#' @field symbols  list( \link{InlineResponse2001Symbols} ) 
#'
#' @importFrom R6 R6Class
#' @importFrom jsonlite fromJSON toJSON
#' @export
InlineResponse2001 <- R6::R6Class(
  'InlineResponse2001',
  public = list(
    `timezone` = NULL,
    `serverTime` = NULL,
    `rateLimits` = NULL,
    `exchangeFilters` = NULL,
    `symbols` = NULL,
    initialize = function(
        `timezone`, `serverTime`, `rateLimits`, `exchangeFilters`, `symbols`, ...
    ) {
      local.optional.var <- list(...)
      if (!missing(`timezone`)) {
        stopifnot(is.character(`timezone`), length(`timezone`) == 1)
        self$`timezone` <- `timezone`
      }
      if (!missing(`serverTime`)) {
        stopifnot(is.numeric(`serverTime`), length(`serverTime`) == 1)
        self$`serverTime` <- `serverTime`
      }
      if (!missing(`rateLimits`)) {
        stopifnot(is.vector(`rateLimits`), length(`rateLimits`) != 0)
        sapply(`rateLimits`, function(x) stopifnot(R6::is.R6(x)))
        self$`rateLimits` <- `rateLimits`
      }
      if (!missing(`exchangeFilters`)) {
        stopifnot(is.vector(`exchangeFilters`), length(`exchangeFilters`) != 0)
        sapply(`exchangeFilters`, function(x) stopifnot(is.character(x)))
        self$`exchangeFilters` <- `exchangeFilters`
      }
      if (!missing(`symbols`)) {
        stopifnot(is.vector(`symbols`), length(`symbols`) != 0)
        sapply(`symbols`, function(x) stopifnot(R6::is.R6(x)))
        self$`symbols` <- `symbols`
      }
    },
    toJSON = function() {
      InlineResponse2001Object <- list()
      if (!is.null(self$`timezone`)) {
        InlineResponse2001Object[['timezone']] <-
          self$`timezone`
      }
      if (!is.null(self$`serverTime`)) {
        InlineResponse2001Object[['serverTime']] <-
          self$`serverTime`
      }
      if (!is.null(self$`rateLimits`)) {
        InlineResponse2001Object[['rateLimits']] <-
          lapply(self$`rateLimits`, function(x) x$toJSON())
      }
      if (!is.null(self$`exchangeFilters`)) {
        InlineResponse2001Object[['exchangeFilters']] <-
          self$`exchangeFilters`
      }
      if (!is.null(self$`symbols`)) {
        InlineResponse2001Object[['symbols']] <-
          lapply(self$`symbols`, function(x) x$toJSON())
      }

      InlineResponse2001Object
    },
    fromJSON = function(InlineResponse2001Json) {
      InlineResponse2001Object <- jsonlite::fromJSON(InlineResponse2001Json)
      if (!is.null(InlineResponse2001Object$`timezone`)) {
        self$`timezone` <- InlineResponse2001Object$`timezone`
      }
      if (!is.null(InlineResponse2001Object$`serverTime`)) {
        self$`serverTime` <- InlineResponse2001Object$`serverTime`
      }
      if (!is.null(InlineResponse2001Object$`rateLimits`)) {
        self$`rateLimits` <- ApiClient$new()$deserializeObj(InlineResponse2001Object$`rateLimits`, "array[InlineResponse2001RateLimits]", loadNamespace("binanceRapi"))
      }
      if (!is.null(InlineResponse2001Object$`exchangeFilters`)) {
        self$`exchangeFilters` <- ApiClient$new()$deserializeObj(InlineResponse2001Object$`exchangeFilters`, "array[object]", loadNamespace("binanceRapi"))
      }
      if (!is.null(InlineResponse2001Object$`symbols`)) {
        self$`symbols` <- ApiClient$new()$deserializeObj(InlineResponse2001Object$`symbols`, "array[InlineResponse2001Symbols]", loadNamespace("binanceRapi"))
      }
      self
    },
    toJSONString = function() {
      jsoncontent <- c(
        if (!is.null(self$`timezone`)) {
        sprintf(
        '"timezone":
          "%s"
                ',
        self$`timezone`
        )},
        if (!is.null(self$`serverTime`)) {
        sprintf(
        '"serverTime":
          %d
                ',
        self$`serverTime`
        )},
        if (!is.null(self$`rateLimits`)) {
        sprintf(
        '"rateLimits":
        [%s]
',
        paste(sapply(self$`rateLimits`, function(x) jsonlite::toJSON(x$toJSON(), auto_unbox=TRUE, digits = NA)), collapse=",")
        )},
        if (!is.null(self$`exchangeFilters`)) {
        sprintf(
        '"exchangeFilters":
           [%s]
        ',
        paste(unlist(lapply(self$`exchangeFilters`, function(x) paste0('"', x, '"'))), collapse=",")
        )},
        if (!is.null(self$`symbols`)) {
        sprintf(
        '"symbols":
        [%s]
',
        paste(sapply(self$`symbols`, function(x) jsonlite::toJSON(x$toJSON(), auto_unbox=TRUE, digits = NA)), collapse=",")
        )}
      )
      jsoncontent <- paste(jsoncontent, collapse = ",")
      paste('{', jsoncontent, '}', sep = "")
    },
    fromJSONString = function(InlineResponse2001Json) {
      InlineResponse2001Object <- jsonlite::fromJSON(InlineResponse2001Json)
      self$`timezone` <- InlineResponse2001Object$`timezone`
      self$`serverTime` <- InlineResponse2001Object$`serverTime`
      self$`rateLimits` <- ApiClient$new()$deserializeObj(InlineResponse2001Object$`rateLimits`, "array[InlineResponse2001RateLimits]", loadNamespace("binanceRapi"))
      self$`exchangeFilters` <- ApiClient$new()$deserializeObj(InlineResponse2001Object$`exchangeFilters`, "array[object]", loadNamespace("binanceRapi"))
      self$`symbols` <- ApiClient$new()$deserializeObj(InlineResponse2001Object$`symbols`, "array[InlineResponse2001Symbols]", loadNamespace("binanceRapi"))
      self
    }
  )
)
grahamjwhite/binanceRapi documentation built on Nov. 22, 2022, 9:37 p.m.