R/sapi_v1_bswap_liquidity_share.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 SapiV1BswapLiquidityShare
#'
#' @description SapiV1BswapLiquidityShare Class
#'
#' @format An \code{R6Class} generator object
#'
#' @field shareAmount  numeric 
#'
#' @field sharePercentage  numeric 
#'
#' @field asset  \link{SapiV1BswapLiquidityShareAsset} 
#'
#' @importFrom R6 R6Class
#' @importFrom jsonlite fromJSON toJSON
#' @export
SapiV1BswapLiquidityShare <- R6::R6Class(
  'SapiV1BswapLiquidityShare',
  public = list(
    `shareAmount` = NULL,
    `sharePercentage` = NULL,
    `asset` = NULL,
    initialize = function(
        `shareAmount`, `sharePercentage`, `asset`, ...
    ) {
      local.optional.var <- list(...)
      if (!missing(`shareAmount`)) {
        stopifnot(is.numeric(`shareAmount`), length(`shareAmount`) == 1)
        self$`shareAmount` <- `shareAmount`
      }
      if (!missing(`sharePercentage`)) {
        stopifnot(is.numeric(`sharePercentage`), length(`sharePercentage`) == 1)
        self$`sharePercentage` <- `sharePercentage`
      }
      if (!missing(`asset`)) {
        stopifnot(R6::is.R6(`asset`))
        self$`asset` <- `asset`
      }
    },
    toJSON = function() {
      SapiV1BswapLiquidityShareObject <- list()
      if (!is.null(self$`shareAmount`)) {
        SapiV1BswapLiquidityShareObject[['shareAmount']] <-
          self$`shareAmount`
      }
      if (!is.null(self$`sharePercentage`)) {
        SapiV1BswapLiquidityShareObject[['sharePercentage']] <-
          self$`sharePercentage`
      }
      if (!is.null(self$`asset`)) {
        SapiV1BswapLiquidityShareObject[['asset']] <-
          self$`asset`$toJSON()
      }

      SapiV1BswapLiquidityShareObject
    },
    fromJSON = function(SapiV1BswapLiquidityShareJson) {
      SapiV1BswapLiquidityShareObject <- jsonlite::fromJSON(SapiV1BswapLiquidityShareJson)
      if (!is.null(SapiV1BswapLiquidityShareObject$`shareAmount`)) {
        self$`shareAmount` <- SapiV1BswapLiquidityShareObject$`shareAmount`
      }
      if (!is.null(SapiV1BswapLiquidityShareObject$`sharePercentage`)) {
        self$`sharePercentage` <- SapiV1BswapLiquidityShareObject$`sharePercentage`
      }
      if (!is.null(SapiV1BswapLiquidityShareObject$`asset`)) {
        assetObject <- SapiV1BswapLiquidityShareAsset$new()
        assetObject$fromJSON(jsonlite::toJSON(SapiV1BswapLiquidityShareObject$asset, auto_unbox = TRUE, digits = NA))
        self$`asset` <- assetObject
      }
      self
    },
    toJSONString = function() {
      jsoncontent <- c(
        if (!is.null(self$`shareAmount`)) {
        sprintf(
        '"shareAmount":
          %d
                ',
        self$`shareAmount`
        )},
        if (!is.null(self$`sharePercentage`)) {
        sprintf(
        '"sharePercentage":
          %d
                ',
        self$`sharePercentage`
        )},
        if (!is.null(self$`asset`)) {
        sprintf(
        '"asset":
        %s
        ',
        jsonlite::toJSON(self$`asset`$toJSON(), auto_unbox=TRUE, digits = NA)
        )}
      )
      jsoncontent <- paste(jsoncontent, collapse = ",")
      paste('{', jsoncontent, '}', sep = "")
    },
    fromJSONString = function(SapiV1BswapLiquidityShareJson) {
      SapiV1BswapLiquidityShareObject <- jsonlite::fromJSON(SapiV1BswapLiquidityShareJson)
      self$`shareAmount` <- SapiV1BswapLiquidityShareObject$`shareAmount`
      self$`sharePercentage` <- SapiV1BswapLiquidityShareObject$`sharePercentage`
      self$`asset` <- SapiV1BswapLiquidityShareAsset$new()$fromJSON(jsonlite::toJSON(SapiV1BswapLiquidityShareObject$asset, auto_unbox = TRUE, digits = NA))
      self
    }
  )
)
grahamjwhite/binanceRapi documentation built on Nov. 22, 2022, 9:37 p.m.