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

      ErrorObject
    },
    fromJSON = function(ErrorJson) {
      ErrorObject <- jsonlite::fromJSON(ErrorJson)
      if (!is.null(ErrorObject$`code`)) {
        self$`code` <- ErrorObject$`code`
      }
      if (!is.null(ErrorObject$`msg`)) {
        self$`msg` <- ErrorObject$`msg`
      }
      self
    },
    toJSONString = function() {
      jsoncontent <- c(
        if (!is.null(self$`code`)) {
        sprintf(
        '"code":
          %d
                ',
        self$`code`
        )},
        if (!is.null(self$`msg`)) {
        sprintf(
        '"msg":
          "%s"
                ',
        self$`msg`
        )}
      )
      jsoncontent <- paste(jsoncontent, collapse = ",")
      paste('{', jsoncontent, '}', sep = "")
    },
    fromJSONString = function(ErrorJson) {
      ErrorObject <- jsonlite::fromJSON(ErrorJson)
      self$`code` <- ErrorObject$`code`
      self$`msg` <- ErrorObject$`msg`
      self
    }
  )
)
grahamjwhite/binanceRapi documentation built on Nov. 22, 2022, 9:37 p.m.