R/trade.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 Trade
#'
#' @description Trade Class
#'
#' @format An \code{R6Class} generator object
#'
#' @field id  integer 
#'
#' @field price  character 
#'
#' @field qty  character 
#'
#' @field quoteQty  character 
#'
#' @field time  integer 
#'
#' @field isBuyerMaker  character 
#'
#' @field isBestMatch  character 
#'
#' @importFrom R6 R6Class
#' @importFrom jsonlite fromJSON toJSON
#' @export
Trade <- R6::R6Class(
  'Trade',
  public = list(
    `id` = NULL,
    `price` = NULL,
    `qty` = NULL,
    `quoteQty` = NULL,
    `time` = NULL,
    `isBuyerMaker` = NULL,
    `isBestMatch` = NULL,
    initialize = function(
        `id`, `price`, `qty`, `quoteQty`, `time`, `isBuyerMaker`, `isBestMatch`, ...
    ) {
      local.optional.var <- list(...)
      if (!missing(`id`)) {
        stopifnot(is.numeric(`id`), length(`id`) == 1)
        self$`id` <- `id`
      }
      if (!missing(`price`)) {
        stopifnot(is.character(`price`), length(`price`) == 1)
        self$`price` <- `price`
      }
      if (!missing(`qty`)) {
        stopifnot(is.character(`qty`), length(`qty`) == 1)
        self$`qty` <- `qty`
      }
      if (!missing(`quoteQty`)) {
        stopifnot(is.character(`quoteQty`), length(`quoteQty`) == 1)
        self$`quoteQty` <- `quoteQty`
      }
      if (!missing(`time`)) {
        stopifnot(is.numeric(`time`), length(`time`) == 1)
        self$`time` <- `time`
      }
      if (!missing(`isBuyerMaker`)) {
        stopifnot(is.logical(`isBuyerMaker`), length(`isBuyerMaker`) == 1)
        self$`isBuyerMaker` <- `isBuyerMaker`
      }
      if (!missing(`isBestMatch`)) {
        stopifnot(is.logical(`isBestMatch`), length(`isBestMatch`) == 1)
        self$`isBestMatch` <- `isBestMatch`
      }
    },
    toJSON = function() {
      TradeObject <- list()
      if (!is.null(self$`id`)) {
        TradeObject[['id']] <-
          self$`id`
      }
      if (!is.null(self$`price`)) {
        TradeObject[['price']] <-
          self$`price`
      }
      if (!is.null(self$`qty`)) {
        TradeObject[['qty']] <-
          self$`qty`
      }
      if (!is.null(self$`quoteQty`)) {
        TradeObject[['quoteQty']] <-
          self$`quoteQty`
      }
      if (!is.null(self$`time`)) {
        TradeObject[['time']] <-
          self$`time`
      }
      if (!is.null(self$`isBuyerMaker`)) {
        TradeObject[['isBuyerMaker']] <-
          self$`isBuyerMaker`
      }
      if (!is.null(self$`isBestMatch`)) {
        TradeObject[['isBestMatch']] <-
          self$`isBestMatch`
      }

      TradeObject
    },
    fromJSON = function(TradeJson) {
      TradeObject <- jsonlite::fromJSON(TradeJson)
      if (!is.null(TradeObject$`id`)) {
        self$`id` <- TradeObject$`id`
      }
      if (!is.null(TradeObject$`price`)) {
        self$`price` <- TradeObject$`price`
      }
      if (!is.null(TradeObject$`qty`)) {
        self$`qty` <- TradeObject$`qty`
      }
      if (!is.null(TradeObject$`quoteQty`)) {
        self$`quoteQty` <- TradeObject$`quoteQty`
      }
      if (!is.null(TradeObject$`time`)) {
        self$`time` <- TradeObject$`time`
      }
      if (!is.null(TradeObject$`isBuyerMaker`)) {
        self$`isBuyerMaker` <- TradeObject$`isBuyerMaker`
      }
      if (!is.null(TradeObject$`isBestMatch`)) {
        self$`isBestMatch` <- TradeObject$`isBestMatch`
      }
      self
    },
    toJSONString = function() {
      jsoncontent <- c(
        if (!is.null(self$`id`)) {
        sprintf(
        '"id":
          %d
                ',
        self$`id`
        )},
        if (!is.null(self$`price`)) {
        sprintf(
        '"price":
          "%s"
                ',
        self$`price`
        )},
        if (!is.null(self$`qty`)) {
        sprintf(
        '"qty":
          "%s"
                ',
        self$`qty`
        )},
        if (!is.null(self$`quoteQty`)) {
        sprintf(
        '"quoteQty":
          "%s"
                ',
        self$`quoteQty`
        )},
        if (!is.null(self$`time`)) {
        sprintf(
        '"time":
          %d
                ',
        self$`time`
        )},
        if (!is.null(self$`isBuyerMaker`)) {
        sprintf(
        '"isBuyerMaker":
          %s
                ',
        tolower(self$`isBuyerMaker`)
        )},
        if (!is.null(self$`isBestMatch`)) {
        sprintf(
        '"isBestMatch":
          %s
                ',
        tolower(self$`isBestMatch`)
        )}
      )
      jsoncontent <- paste(jsoncontent, collapse = ",")
      paste('{', jsoncontent, '}', sep = "")
    },
    fromJSONString = function(TradeJson) {
      TradeObject <- jsonlite::fromJSON(TradeJson)
      self$`id` <- TradeObject$`id`
      self$`price` <- TradeObject$`price`
      self$`qty` <- TradeObject$`qty`
      self$`quoteQty` <- TradeObject$`quoteQty`
      self$`time` <- TradeObject$`time`
      self$`isBuyerMaker` <- TradeObject$`isBuyerMaker`
      self$`isBestMatch` <- TradeObject$`isBestMatch`
      self
    }
  )
)
grahamjwhite/binanceRapi documentation built on Nov. 22, 2022, 9:37 p.m.