R/b_swap_api.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 BSwap operations
#' @description binanceRapi.BSwap
#' @format An \code{R6Class} generator object
#' @field apiClient Handles the client-server communication.
#'
#' @section Methods:
#' \describe{
#' \strong{ SapiV1BswapAddLiquidityPreviewGet } \emph{ Add Liquidity Preview (USER_DATA) }
#' Calculate expected share amount for adding liquidity in single or dual token.  Weight(IP): 150
#'
#' \itemize{
#' \item \emph{ @param } pool.id integer
#' \item \emph{ @param } type Enum < [SINGLE, COMBINATION] >
#' \item \emph{ @param } quote.asset character
#' \item \emph{ @param } quote.qty numeric
#' \item \emph{ @param } recv.window integer
#' \item \emph{ @returnType } \link{OneOfbswapAddLiquidityPreviewCombinationbswapAddLiquidityPreviewSingle} \cr
#'
#'
#' \item status code : 200 | Add Liquidity Preview
#'
#' \item return type : OneOfbswapAddLiquidityPreviewCombinationbswapAddLiquidityPreviewSingle 
#' \item response headers :
#'
#' \tabular{ll}{
#' }
#' \item status code : 400 | Bad Request
#'
#' \item return type : Error 
#' \item response headers :
#'
#' \tabular{ll}{
#' }
#' \item status code : 401 | Unauthorized Request
#'
#' \item return type : Error 
#' \item response headers :
#'
#' \tabular{ll}{
#' }
#' }
#' 
#' \strong{ SapiV1BswapClaimRewardsPost } \emph{ Claim rewards (TRADE) }
#' Claim swap rewards or liquidity rewards   Weight(UID): 1000
#'
#' \itemize{
#' \item \emph{ @param } type integer
#' \item \emph{ @param } recv.window integer
#' \item \emph{ @returnType } \link{InlineResponse200130} \cr
#'
#'
#' \item status code : 200 | Result of claim
#'
#' \item return type : InlineResponse200130 
#' \item response headers :
#'
#' \tabular{ll}{
#' }
#' \item status code : 400 | Bad Request
#'
#' \item return type : Error 
#' \item response headers :
#'
#' \tabular{ll}{
#' }
#' \item status code : 401 | Unauthorized Request
#'
#' \item return type : Error 
#' \item response headers :
#'
#' \tabular{ll}{
#' }
#' }
#'
#' \strong{ SapiV1BswapClaimedHistoryGet } \emph{ Get Claimed History (USER_DATA) }
#' Get history of claimed rewards.   Weight(UID): 1000
#'
#' \itemize{
#' \item \emph{ @param } pool.id integer
#' \item \emph{ @param } asset.rewards character
#' \item \emph{ @param } type integer
#' \item \emph{ @param } start.time integer
#' \item \emph{ @param } end.time integer
#' \item \emph{ @param } limit integer
#' \item \emph{ @param } recv.window integer
#' \item \emph{ @returnType } list( \link{inline_response_200_131} ) \cr
#'
#'
#' \item status code : 200 | Claimed History
#'
#' \item return type : array[InlineResponse200131] 
#' \item response headers :
#'
#' \tabular{ll}{
#' }
#' \item status code : 400 | Bad Request
#'
#' \item return type : Error 
#' \item response headers :
#'
#' \tabular{ll}{
#' }
#' \item status code : 401 | Unauthorized Request
#'
#' \item return type : Error 
#' \item response headers :
#'
#' \tabular{ll}{
#' }
#' }
#'
#' \strong{ SapiV1BswapLiquidityAddPost } \emph{ Add Liquidity (TRADE) }
#' Add liquidity to a pool.  Weight(UID): 1000 (Additional: 3 times one second)
#'
#' \itemize{
#' \item \emph{ @param } pool.id integer
#' \item \emph{ @param } asset character
#' \item \emph{ @param } quantity numeric
#' \item \emph{ @param } type Enum < [Single, Combination] >
#' \item \emph{ @param } recv.window integer
#' \item \emph{ @returnType } \link{InlineResponse200113} \cr
#'
#'
#' \item status code : 200 | Operation Id
#'
#' \item return type : InlineResponse200113
#' \item response headers :
#'
#' \tabular{ll}{
#' }
#' \item status code : 400 | Bad Request
#'
#' \item return type : Error 
#' \item response headers :
#'
#' \tabular{ll}{
#' }
#' \item status code : 401 | Unauthorized Request
#'
#' \item return type : Error 
#' \item response headers :
#'
#' \tabular{ll}{
#' }
#' }
#'
#' \strong{ SapiV1BswapLiquidityGet } \emph{ Liquidity information of a pool (USER_DATA) }
#' Get liquidity information and user share of a pool.  Weight(IP): - &#x60;1&#x60; for one pool; - &#x60;10&#x60; when the poolId parameter is omitted;
#'
#' \itemize{
#' \item \emph{ @param } pool.id integer
#' \item \emph{ @param } recv.window integer
#' \item \emph{ @returnType } list( \link{inline_response_200_122} ) \cr
#'
#'
#' \item status code : 200 | Pool Liquidation information
#'
#' \item return type : array[InlineResponse200122] 
#' \item response headers :
#'
#' \tabular{ll}{
#' }
#' \item status code : 400 | Bad Request
#'
#' \item return type : Error 
#' \item response headers :
#'
#' \tabular{ll}{
#' }
#' \item status code : 401 | Unauthorized Request
#'
#' \item return type : Error 
#' \item response headers :
#'
#' \tabular{ll}{
#' }
#' }
#'
#' \strong{ SapiV1BswapLiquidityOpsGet } \emph{ Liquidity Operation Record (USER_DATA) }
#' Get liquidity operation (add/remove) records.  Weight(UID): 3000
#'
#' \itemize{
#' \item \emph{ @param } operation.id integer
#' \item \emph{ @param } pool.id integer
#' \item \emph{ @param } operation Enum < [ADD, REMOVE] >
#' \item \emph{ @param } start.time integer
#' \item \emph{ @param } end.time integer
#' \item \emph{ @param } limit integer
#' \item \emph{ @param } recv.window integer
#' \item \emph{ @returnType } list( \link{inline_response_200_124} ) \cr
#'
#'
#' \item status code : 200 | Liquidity Operation Record
#'
#' \item return type : array[InlineResponse200124] 
#' \item response headers :
#'
#' \tabular{ll}{
#' }
#' \item status code : 400 | Bad Request
#'
#' \item return type : Error 
#' \item response headers :
#'
#' \tabular{ll}{
#' }
#' \item status code : 401 | Unauthorized Request
#'
#' \item return type : Error 
#' \item response headers :
#'
#' \tabular{ll}{
#' }
#' }
#'
#' \strong{ SapiV1BswapLiquidityRemovePost } \emph{ Remove Liquidity (TRADE) }
#' Remove liquidity from a pool, &#x60;type&#x60; include &#x60;SINGLE&#x60; and &#x60;COMBINATION&#x60;, asset is mandatory for single asset removal  Weight(UID): 1000 (Additional: 3 times one second)
#'
#' \itemize{
#' \item \emph{ @param } pool.id integer
#' \item \emph{ @param } type Enum < [SINGLE, COMBINATION] >
#' \item \emph{ @param } share.amount numeric
#' \item \emph{ @param } asset character
#' \item \emph{ @param } recv.window integer
#' \item \emph{ @returnType } \link{InlineResponse200123} \cr
#'
#'
#' \item status code : 200 | Operation Id
#'
#' \item return type : InlineResponse200123
#' \item response headers :
#'
#' \tabular{ll}{
#' }
#' \item status code : 400 | Bad Request
#'
#' \item return type : Error 
#' \item response headers :
#'
#' \tabular{ll}{
#' }
#' \item status code : 401 | Unauthorized Request
#'
#' \item return type : Error 
#' \item response headers :
#'
#' \tabular{ll}{
#' }
#' }
#'
#' \strong{ SapiV1BswapPoolConfigureGet } \emph{ Pool Configure (USER_DATA) }
#' Weight(IP): 150
#'
#' \itemize{
#' \item \emph{ @param } pool.id integer
#' \item \emph{ @param } recv.window integer
#' \item \emph{ @returnType } list( \link{inline_response_200_128} ) \cr
#'
#'
#' \item status code : 200 | Pool Information
#'
#' \item return type : array[InlineResponse200128] 
#' \item response headers :
#'
#' \tabular{ll}{
#' }
#' \item status code : 400 | Bad Request
#'
#' \item return type : Error 
#' \item response headers :
#'
#' \tabular{ll}{
#' }
#' \item status code : 401 | Unauthorized Request
#'
#' \item return type : Error 
#' \item response headers :
#'
#' \tabular{ll}{
#' }
#' }
#'
#' \strong{ SapiV1BswapPoolsGet } \emph{ List All Swap Pools (MARKET_DATA) }
#' Get metadata about all swap pools.  Weight(IP): 1
#'
#' \itemize{
#' \item \emph{ @returnType } list( \link{inline_response_200_121} ) \cr
#'
#'
#' \item status code : 200 | List of Swap Pools
#'
#' \item return type : array[InlineResponse200121] 
#' \item response headers :
#'
#' \tabular{ll}{
#' }
#' \item status code : 400 | Bad Request
#'
#' \item return type : Error 
#' \item response headers :
#'
#' \tabular{ll}{
#' }
#' }
#'
#' \strong{ SapiV1BswapQuoteGet } \emph{ Request Quote (USER_DATA) }
#' Request a quote for swap quote asset (selling asset) for base asset (buying asset), essentially price/exchange rates.  quoteQty is quantity of quote asset (to sell).  Please be noted the quote is for reference only, the actual price will change as the liquidity changes, it&#39;s recommended to swap immediate after request a quote for slippage prevention.  Weight(UID): 150
#'
#' \itemize{
#' \item \emph{ @param } quote.asset character
#' \item \emph{ @param } base.asset character
#' \item \emph{ @param } quote.qty numeric
#' \item \emph{ @param } recv.window integer
#' \item \emph{ @returnType } \link{InlineResponse200125} \cr
#'
#'
#' \item status code : 200 | Quote Info
#'
#' \item return type : InlineResponse200125 
#' \item response headers :
#'
#' \tabular{ll}{
#' }
#' \item status code : 400 | Bad Request
#'
#' \item return type : Error 
#' \item response headers :
#'
#' \tabular{ll}{
#' }
#' \item status code : 401 | Unauthorized Request
#'
#' \item return type : Error 
#' \item response headers :
#'
#' \tabular{ll}{
#' }
#' }
#'
#' \strong{ SapiV1BswapRemoveLiquidityPreviewGet } \emph{ Remove Liquidity Preview (USER_DATA) }
#' Calculate the expected asset amount of single token redemption or dual token redemption.  Weight(IP): 150
#'
#' \itemize{
#' \item \emph{ @param } pool.id integer
#' \item \emph{ @param } type Enum < [SINGLE, COMBINATION] >
#' \item \emph{ @param } quote.asset character
#' \item \emph{ @param } share.amount numeric
#' \item \emph{ @param } recv.window integer
#' \item \emph{ @returnType } \link{OneOfbswapRmvLiquidityPreviewCombinationbswapRmvLiquidityPreviewSingle} \cr
#'
#'
#' \item status code : 200 | Remove Liquidity Preview
#'
#' \item return type : OneOfbswapRmvLiquidityPreviewCombinationbswapRmvLiquidityPreviewSingle 
#' \item response headers :
#'
#' \tabular{ll}{
#' }
#' \item status code : 400 | Bad Request
#'
#' \item return type : Error 
#' \item response headers :
#'
#' \tabular{ll}{
#' }
#' \item status code : 401 | Unauthorized Request
#'
#' \item return type : Error 
#' \item response headers :
#'
#' \tabular{ll}{
#' }
#' }
#'
#' \strong{ SapiV1BswapSwapGet } \emph{ Swap History (USER_DATA) }
#' Get swap history.  Weight(UID): 3000
#'
#' \itemize{
#' \item \emph{ @param } swap.id integer
#' \item \emph{ @param } start.time integer
#' \item \emph{ @param } end.time integer
#' \item \emph{ @param } status Enum < [0, 1, 2] >
#' \item \emph{ @param } quote.asset character
#' \item \emph{ @param } base.asset character
#' \item \emph{ @param } limit integer
#' \item \emph{ @param } recv.window integer
#' \item \emph{ @returnType } list( \link{inline_response_200_126} ) \cr
#'
#'
#' \item status code : 200 | Swap History
#'
#' \item return type : array[InlineResponse200126] 
#' \item response headers :
#'
#' \tabular{ll}{
#' }
#' \item status code : 400 | Bad Request
#'
#' \item return type : Error 
#' \item response headers :
#'
#' \tabular{ll}{
#' }
#' \item status code : 401 | Unauthorized Request
#'
#' \item return type : Error 
#' \item response headers :
#'
#' \tabular{ll}{
#' }
#' }
#'
#' \strong{ SapiV1BswapSwapPost } \emph{ Swap (TRADE) }
#' Swap &#x60;quoteAsset&#x60; for &#x60;baseAsset&#x60;.  Weight(UID): 1000 (Additional: 3 times one second)
#'
#' \itemize{
#' \item \emph{ @param } quote.asset character
#' \item \emph{ @param } base.asset character
#' \item \emph{ @param } quote.qty numeric
#' \item \emph{ @param } recv.window integer
#' \item \emph{ @returnType } \link{InlineResponse200127} \cr
#'
#'
#' \item status code : 200 | Swap Id
#'
#' \item return type : InlineResponse200127
#' \item response headers :
#'
#' \tabular{ll}{
#' }
#' \item status code : 400 | Bad Request
#'
#' \item return type : Error 
#' \item response headers :
#'
#' \tabular{ll}{
#' }
#' \item status code : 401 | Unauthorized Request
#'
#' \item return type : Error 
#' \item response headers :
#'
#' \tabular{ll}{
#' }
#' }
#'
#' \strong{ SapiV1BswapUnclaimedRewardsGet } \emph{ Get Unclaimed Rewards Record (USER_DATA) }
#' Get unclaimed rewards record.   Weight(UID): 1000
#'
#' \itemize{
#' \item \emph{ @param } type integer
#' \item \emph{ @param } recv.window integer
#' \item \emph{ @returnType } \link{InlineResponse200129} \cr
#'
#'
#' \item status code : 200 | Unclaimed rewards record
#'
#' \item return type : InlineResponse200129  
#' \item response headers :
#'
#' \tabular{ll}{
#' }
#' \item status code : 400 | Bad Request
#'
#' \item return type : Error 
#' \item response headers :
#'
#' \tabular{ll}{
#' }
#' \item status code : 401 | Unauthorized Request
#'
#' \item return type : Error 
#' \item response headers :
#'
#' \tabular{ll}{
#' }
#' }
#'
#' }
#'
#'
#' @examples
#' \dontrun{
#' ####################  SapiV1BswapAddLiquidityPreviewGet  ####################
#'
#' library(binanceRapi)
#' var.pool.id <- 2 # integer | 
#' var.type <- 'SINGLE' # character | * `SINGLE` - for adding a single token * `COMBINATION` - for adding dual tokens
#' var.quote.asset <- 'USDT' # character | 
#' var.quote.qty <- 3.4 # numeric | 
#' var.recv.window <- 5000 # integer | The value cannot be greater than 60000
#'
#' #Add Liquidity Preview (USER_DATA)
#' api.instance <- BSwapApi$new()
#'
#' result <- api.instance$SapiV1BswapAddLiquidityPreviewGet(var.pool.id, var.type, var.quote.asset, var.quote.qty, recv.window=var.recv.window)
#'
#' ####################  SapiV1BswapClaimRewardsPost  ####################
#'
#' library(binanceRapi)
#' var.timestamp <- 56 # integer | UTC timestamp in ms
#' var.signature <- 'signature_example' # character | Signature
#' var.type <- 0 # integer | 0: Swap rewards, 1: Liquidity rewards, default to 0
#' var.recv.window <- 5000 # integer | The value cannot be greater than 60000
#'
#' #Claim rewards (TRADE)
#' api.instance <- BSwapApi$new()
#'
#' result <- api.instance$SapiV1BswapClaimRewardsPost(type=var.type, recv.window=var.recv.window)
#'
#' ####################  SapiV1BswapClaimedHistoryGet  ####################
#'
#' library(binanceRapi)
#' var.timestamp <- 56 # integer | UTC timestamp in ms
#' var.signature <- 'signature_example' # character | Signature
#' var.pool.id <- 56 # integer | 
#' var.asset.rewards <- 'asset.rewards_example' # character | 
#' var.type <- 0 # integer | 0: Swap rewards, 1: Liquidity rewards, default to 0
#' var.start.time <- 56 # integer | UTC timestamp in ms
#' var.end.time <- 56 # integer | UTC timestamp in ms
#' var.limit <- 56 # integer | Default 3, max 100
#' var.recv.window <- 5000 # integer | The value cannot be greater than 60000
#'
#' #Get Claimed History (USER_DATA)
#' api.instance <- BSwapApi$new()
#' 
#' result <- api.instance$SapiV1BswapClaimedHistoryGet(pool.id=var.pool.id, asset.rewards=var.asset.rewards, type=var.type, start.time=var.start.time, end.time=var.end.time, limit=var.limit, recv.window=var.recv.window)
#'
#'
#'
#' ####################  SapiV1BswapLiquidityAddPost  ####################
#'
#' library(binanceRapi)
#' var.pool.id <- 56 # integer | 
#' var.asset <- 'BTC' # character | 
#' var.quantity <- 3.4 # numeric | 
#' var.type <- 'Single' # character | * `Single` - to add a single token * `Combination` - to add dual tokens
#' var.recv.window <- 5000 # integer | The value cannot be greater than 60000
#'
#' #Add Liquidity (TRADE)
#' api.instance <- BSwapApi$new()
#'
#' result <- api.instance$SapiV1BswapLiquidityAddPost(var.pool.id, var.asset, var.quantity, type=var.type, recv.window=var.recv.window)
#'
#'
#' ####################  SapiV1BswapLiquidityGet  ####################
#'
#' library(binanceRapi)
#' var.pool.id <- 56 # integer | 
#' var.recv.window <- 5000 # integer | The value cannot be greater than 60000
#'
#' #Liquidity information of a pool (USER_DATA)
#' api.instance <- BSwapApi$new()
#'
#' result <- api.instance$SapiV1BswapLiquidityGet(pool.id=var.pool.id, recv.window=var.recv.window)
#'
#'
#' ####################  SapiV1BswapLiquidityOpsGet  ####################
#'
#' library(binanceRapi)
#' var.operation.id <- 56 # integer | 
#' var.pool.id <- 56 # integer | 
#' var.operation <- 'operation_example' # character | 
#' var.start.time <- 56 # integer | UTC timestamp in ms
#' var.end.time <- 56 # integer | UTC timestamp in ms
#' var.limit <- 500 # integer | Default 500; max 1000.
#' var.recv.window <- 5000 # integer | The value cannot be greater than 60000
#'
#' #Liquidity Operation Record (USER_DATA)
#' api.instance <- BSwapApi$new()
#'
#' result <- api.instance$SapiV1BswapLiquidityOpsGet(operation.id=var.operation.id, pool.id=var.pool.id, operation=var.operation, start.time=var.start.time, end.time=var.end.time, limit=var.limit, recv.window=var.recv.window)
#'
#'
#' ####################  SapiV1BswapLiquidityRemovePost  ####################
#'
#' library(binanceRapi)
#' var.pool.id <- 56 # integer | 
#' var.type <- 'SINGLE' # character | * `SINGLE` - for single asset removal * `COMBINATION` - for combination of all coins removal
#' var.share.amount <- 3.4 # numeric | 
#' var.asset <- 'BNB' # character | Mandatory for single asset removal
#' var.recv.window <- 5000 # integer | The value cannot be greater than 60000
#'
#' #Remove Liquidity (TRADE)
#' api.instance <- BSwapApi$new()
#'
#' result <- api.instance$SapiV1BswapLiquidityRemovePost(var.pool.id, var.type, var.share.amount, asset=var.asset, recv.window=var.recv.window)
#'
#'
#' ####################  SapiV1BswapPoolConfigureGet  ####################
#'
#' library(binanceRapi)
#' var.pool.id <- 2 # integer | 
#' var.recv.window <- 5000 # integer | The value cannot be greater than 60000
#'
#' #Pool Configure (USER_DATA)
#' api.instance <- BSwapApi$new()
#'
#' result <- api.instance$SapiV1BswapPoolConfigureGet(pool.id=var.pool.id, recv.window=var.recv.window)
#'
#'
#' ####################  SapiV1BswapPoolsGet  ####################
#'
#' library(binanceRapi)
#'
#' #List All Swap Pools (MARKET_DATA)
#' api.instance <- BSwapApi$new()
#'
#' result <- api.instance$SapiV1BswapPoolsGet()
#'
#'
#' ####################  SapiV1BswapQuoteGet  ####################
#'
#' library(binanceRapi)
#' var.quote.asset <- 'USDT' # character | 
#' var.base.asset <- 'BUSD' # character | 
#' var.quote.qty <- 3.4 # numeric | 
#' var.recv.window <- 5000 # integer | The value cannot be greater than 60000
#'
#' #Request Quote (USER_DATA)
#' api.instance <- BSwapApi$new()
#'
#' result <- api.instance$SapiV1BswapQuoteGet(var.quote.asset, var.base.asset, var.quote.qty, recv.window=var.recv.window)
#'
#'
#' ####################  SapiV1BswapRemoveLiquidityPreviewGet  ####################
#'
#' library(binanceRapi)
#' var.pool.id <- 2 # integer | 
#' var.type <- 'SINGLE' # character | * `SINGLE` - remove and obtain a single token * `COMBINATION` - remove and obtain dual token
#' var.quote.asset <- 'USDT' # character | 
#' var.share.amount <- 3.4 # numeric | 
#' var.recv.window <- 5000 # integer | The value cannot be greater than 60000
#'
#' #Remove Liquidity Preview (USER_DATA)
#' api.instance <- BSwapApi$new()
#'
#' result <- api.instance$SapiV1BswapRemoveLiquidityPreviewGet(var.pool.id, var.type, var.quote.asset, var.share.amount, recv.window=var.recv.window)
#'
#'
#' ####################  SapiV1BswapSwapGet  ####################
#'
#' library(binanceRapi)
#' var.swap.id <- 56 # integer | 
#' var.start.time <- 56 # integer | UTC timestamp in ms
#' var.end.time <- 56 # integer | UTC timestamp in ms
#' var.status <- 56 # integer | * `0` - pending for swap * `1` - success * `2` - failed
#' var.quote.asset <- 'USDT' # character | 
#' var.base.asset <- 'BUSD' # character | 
#' var.limit <- 56 # integer | default 3, max 100
#' var.recv.window <- 5000 # integer | The value cannot be greater than 60000
#'
#' #Swap History (USER_DATA)
#' api.instance <- BSwapApi$new()
#'
#' result <- api.instance$SapiV1BswapSwapGet(swap.id=var.swap.id, start.time=var.start.time, end.time=var.end.time, status=var.status, quote.asset=var.quote.asset, base.asset=var.base.asset, limit=var.limit, recv.window=var.recv.window)
#'
#'
#' ####################  SapiV1BswapSwapPost  ####################
#'
#' library(binanceRapi)
#' var.quote.asset <- 'USDT' # character | 
#' var.base.asset <- 'BUSD' # character | 
#' var.quote.qty <- 3.4 # numeric | 
#' var.recv.window <- 5000 # integer | The value cannot be greater than 60000
#'
#' #Swap (TRADE)
#' api.instance <- BSwapApi$new()
#'
#' result <- api.instance$SapiV1BswapSwapPost(var.quote.asset, var.base.asset, var.quote.qty, recv.window=var.recv.window)
#'
#'
#' ####################  SapiV1BswapUnclaimedRewardsGet  ####################
#'
#' library(binanceRapi)
#' var.timestamp <- 56 # integer | UTC timestamp in ms
#' var.signature <- 'signature_example' # character | Signature
#' var.type <- 0 # integer | 0: Swap rewards, 1: Liquidity rewards, default to 0
#' var.recv.window <- 5000 # integer | The value cannot be greater than 60000
#'
#' #Get Unclaimed Rewards Record (USER_DATA)
#' api.instance <- BSwapApi$new()
#'
#' result <- api.instance$SapiV1BswapUnclaimedRewardsGet(type=var.type, recv.window=var.recv.window)
#'
#'
#' }
#' @importFrom R6 R6Class
#' @importFrom base64enc base64encode
#' @export
BSwapApi <- R6::R6Class(
  'BSwapApi',
  public = list(
    apiClient = NULL,
    initialize = function(apiClient){
      if (!missing(apiClient)) {
        self$apiClient <- apiClient
      }
      else {
        self$apiClient <- ApiClient$new()
      }
    },
    SapiV1BswapAddLiquidityPreviewGet = function(pool.id, type, quote.asset, quote.qty, recv.window=NULL, ...){
      apiResponse <- self$SapiV1BswapAddLiquidityPreviewGetWithHttpInfo(pool.id, type, quote.asset, quote.qty, 
                                                                        recv.window, ...)
      resp <- apiResponse$response
      if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
        apiResponse$content
      } else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) {
        apiResponse
      } else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
        apiResponse
      } else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
        apiResponse
      }
    },

    SapiV1BswapAddLiquidityPreviewGetWithHttpInfo = function(pool.id, type, quote.asset, quote.qty, recv.window=NULL, ...){
      args <- list(...)
      queryParams <- list()
      headerParams <- c()

      if (missing(`pool.id`)) {
        stop("Missing required parameter `pool.id`.")
      }

      if (missing(`type`)) {
        stop("Missing required parameter `type`.")
      }

      if (missing(`quote.asset`)) {
        stop("Missing required parameter `quote.asset`.")
      }

      if (missing(`quote.qty`)) {
        stop("Missing required parameter `quote.qty`.")
      }

      queryParams['poolId'] <- pool.id

      queryParams['type'] <- type

      queryParams['quoteAsset'] <- quote.asset

      queryParams['quoteQty'] <- quote.qty

      queryParams['recvWindow'] <- recv.window

      queryParams['timestamp'] <- self$apiClient$Timestamp
      
      queryParams['signature'] <- self$apiClient$credentials$sign(queryParams)

      body <- NULL
      urlPath <- "/sapi/v1/bswap/addLiquidityPreview"
      # API key authentication
      if (nchar(self$apiClient$credentials$key) > 0) {
        headerParams['X-MBX-APIKEY'] <- self$apiClient$credentials$key
      }

      resp <- self$apiClient$CallApi(url = paste0(self$apiClient$basePath, urlPath),
                                 method = "GET",
                                 queryParams = queryParams,
                                 headerParams = headerParams,
                                 body = body,
                                 ...)

      if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
        deserializedRespObj <- tryCatch(
          self$apiClient$deserialize(resp, "OneOfbswapAddLiquidityPreviewCombinationbswapAddLiquidityPreviewSingle", loadNamespace("binanceRapi")),
          error = function(e){
             stop("Failed to deserialize response")
          }
        )
        ApiResponse$new(deserializedRespObj, resp)
      } else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) {
        ApiResponse$new(paste("Server returned " , httr::status_code(resp) , " response status code."), resp)
      } else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
        ApiResponse$new("API client error", resp)
      } else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
        ApiResponse$new("API server error", resp)
      }
    },
    SapiV1BswapClaimRewardsPost = function(type=NULL, recv.window=NULL, ...){
      apiResponse <- self$SapiV1BswapClaimRewardsPostWithHttpInfo(type, recv.window, ...)
      resp <- apiResponse$response
      if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
        apiResponse$content
      } else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) {
        apiResponse
      } else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
        apiResponse
      } else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
        apiResponse
      }
    },
    SapiV1BswapClaimRewardsPostWithHttpInfo = function(type=NULL, recv.window=NULL, ...){
      args <- list(...)
      queryParams <- list()
      headerParams <- c()

      queryParams['type'] <- type
      
      queryParams['recvWindow'] <- recv.window
      
      queryParams['timestamp'] <- self$apiClient$Timestamp
      
      queryParams['signature'] <- self$apiClient$credentials$sign(queryParams)
      
      body <- NULL
      urlPath <- "/sapi/v1/bswap/claimRewards"
      # API key authentication
      if (nchar(self$apiClient$credentials$key) > 0) {
        headerParams['X-MBX-APIKEY'] <- self$apiClient$credentials$key
      }
      
      resp <- self$apiClient$CallApi(url = paste0(self$apiClient$basePath, urlPath),
                                     method = "POST",
                                     queryParams = queryParams,
                                     headerParams = headerParams,
                                     body = body,
                                     ...)
      
      if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
        deserializedRespObj <- tryCatch(
          self$apiClient$deserialize(resp, "InlineResponse200130", loadNamespace("binanceRapi")),
          error = function(e){
            stop("Failed to deserialize response")
          }
        )
        ApiResponse$new(deserializedRespObj, resp)
      } else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) {
        ApiResponse$new(paste("Server returned " , httr::status_code(resp) , " response status code."), resp)
      } else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
        ApiResponse$new("API client error", resp)
      } else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
        ApiResponse$new("API server error", resp)
      }
    },
    SapiV1BswapClaimedHistoryGet = function(pool.id=NULL, asset.rewards=NULL, type=NULL, start.time=NULL, end.time=NULL, limit=NULL, recv.window=NULL, ...){
      apiResponse <- self$SapiV1BswapClaimedHistoryGetWithHttpInfo(pool.id, asset.rewards, type, start.time, end.time, limit, recv.window, ...)
      resp <- apiResponse$response
      if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
        apiResponse$content
      } else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) {
        apiResponse
      } else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
        apiResponse
      } else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
        apiResponse
      }
    },
    
    SapiV1BswapClaimedHistoryGetWithHttpInfo = function(pool.id=NULL, asset.rewards=NULL, type=NULL, start.time=NULL, end.time=NULL, limit=NULL, recv.window=NULL, ...){
      args <- list(...)
      queryParams <- list()
      headerParams <- c()
      
      queryParams['poolId'] <- pool.id
      
      queryParams['assetRewards'] <- asset.rewards
      
      queryParams['type'] <- type
      
      queryParams['startTime'] <- start.time
      
      queryParams['endTime'] <- end.time
      
      queryParams['limit'] <- limit
      
      queryParams['recvWindow'] <- recv.window
      
      queryParams['timestamp'] <- self$apiClient$Timestamp
      
      queryParams['signature'] <- self$apiClient$credentials$sign(queryParams)
      
      body <- NULL
      urlPath <- "/sapi/v1/bswap/claimedHistory"
      # API key authentication
      if (nchar(self$apiClient$credentials$key) > 0) {
        headerParams['X-MBX-APIKEY'] <- self$apiClient$credentials$key
      }
      
      resp <- self$apiClient$CallApi(url = paste0(self$apiClient$basePath, urlPath),
                                     method = "GET",
                                     queryParams = queryParams,
                                     headerParams = headerParams,
                                     body = body,
                                     ...)
      
      if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
        deserializedRespObj <- tryCatch(
          self$apiClient$deserialize(resp, "array[InlineResponse200131]", loadNamespace("binanceRapi")),
          error = function(e){
            stop("Failed to deserialize response")
          }
        )
        ApiResponse$new(deserializedRespObj, resp)
      } else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) {
        ApiResponse$new(paste("Server returned " , httr::status_code(resp) , " response status code."), resp)
      } else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
        ApiResponse$new("API client error", resp)
      } else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
        ApiResponse$new("API server error", resp)
      }
    },
    SapiV1BswapLiquidityAddPost = function(pool.id, asset, quantity, timestamp, signature, type=NULL, recv.window=NULL, ...){
      apiResponse <- self$SapiV1BswapLiquidityAddPostWithHttpInfo(pool.id, asset, quantity, timestamp, signature, type, recv.window, ...)
      resp <- apiResponse$response
      if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
        apiResponse$content
      } else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) {
        apiResponse
      } else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
        apiResponse
      } else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
        apiResponse
      }
    },
    
    SapiV1BswapLiquidityAddPostWithHttpInfo = function(pool.id, asset, quantity, timestamp, signature, type=NULL, recv.window=NULL, ...){
      args <- list(...)
      queryParams <- list()
      headerParams <- c()

      if (missing(`pool.id`)) {
        stop("Missing required parameter `pool.id`.")
      }

      if (missing(`asset`)) {
        stop("Missing required parameter `asset`.")
      }

      if (missing(`quantity`)) {
        stop("Missing required parameter `quantity`.")
      }

      queryParams['poolId'] <- pool.id
      
      queryParams['type'] <- type

      queryParams['asset'] <- asset

      queryParams['quantity'] <- quantity

      queryParams['recvWindow'] <- recv.window

      queryParams['timestamp'] <- self$apiClient$Timestamp
      
      queryParams['signature'] <- self$apiClient$credentials$sign(queryParams)

      body <- NULL
      urlPath <- "/sapi/v1/bswap/liquidityAdd"
      # API key authentication
      if (nchar(self$apiClient$credentials$key) > 0) {
        headerParams['X-MBX-APIKEY'] <- self$apiClient$credentials$key
      }

      resp <- self$apiClient$CallApi(url = paste0(self$apiClient$basePath, urlPath),
                                 method = "POST",
                                 queryParams = queryParams,
                                 headerParams = headerParams,
                                 body = body,
                                 ...)

      if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
        deserializedRespObj <- tryCatch(
          self$apiClient$deserialize(resp, "InlineResponse200123", loadNamespace("binanceRapi")),
          error = function(e){
             stop("Failed to deserialize response")
          }
        )
        ApiResponse$new(deserializedRespObj, resp)
      } else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) {
        ApiResponse$new(paste("Server returned " , httr::status_code(resp) , " response status code."), resp)
      } else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
        ApiResponse$new("API client error", resp)
      } else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
        ApiResponse$new("API server error", resp)
      }
    },
    SapiV1BswapLiquidityGet = function(pool.id=NULL, recv.window=NULL, ...){
      apiResponse <- self$SapiV1BswapLiquidityGetWithHttpInfo(pool.id, recv.window, ...)
      resp <- apiResponse$response
      if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
        apiResponse$content
      } else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) {
        apiResponse
      } else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
        apiResponse
      } else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
        apiResponse
      }
    },

    SapiV1BswapLiquidityGetWithHttpInfo = function(pool.id=NULL, recv.window=NULL, ...){
      args <- list(...)
      queryParams <- list()
      headerParams <- c()

      queryParams['poolId'] <- pool.id

      queryParams['recvWindow'] <- recv.window

      queryParams['timestamp'] <- self$apiClient$Timestamp
      
      queryParams['signature'] <- self$apiClient$credentials$sign(queryParams)

      body <- NULL
      urlPath <- "/sapi/v1/bswap/liquidity"
      # API key authentication
      if (nchar(self$apiClient$credentials$key) > 0) {
        headerParams['X-MBX-APIKEY'] <- self$apiClient$credentials$key
      }

      resp <- self$apiClient$CallApi(url = paste0(self$apiClient$basePath, urlPath),
                                 method = "GET",
                                 queryParams = queryParams,
                                 headerParams = headerParams,
                                 body = body,
                                 ...)

      if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
        deserializedRespObj <- tryCatch(
          self$apiClient$deserialize(resp, "array[InlineResponse200122]", loadNamespace("binanceRapi")),
          error = function(e){
             stop("Failed to deserialize response")
          }
        )
        ApiResponse$new(deserializedRespObj, resp)
      } else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) {
        ApiResponse$new(paste("Server returned " , httr::status_code(resp) , " response status code."), resp)
      } else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
        ApiResponse$new("API client error", resp)
      } else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
        ApiResponse$new("API server error", resp)
      }
    },
    SapiV1BswapLiquidityOpsGet = function(operation.id=NULL, pool.id=NULL, operation=NULL, start.time=NULL, end.time=NULL, limit=NULL, recv.window=NULL, ...){
      apiResponse <- self$SapiV1BswapLiquidityOpsGetWithHttpInfo(operation.id, pool.id, operation, start.time, end.time, limit, recv.window, ...)
      resp <- apiResponse$response
      if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
        apiResponse$content
      } else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) {
        apiResponse
      } else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
        apiResponse
      } else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
        apiResponse
      }
    },

    SapiV1BswapLiquidityOpsGetWithHttpInfo = function(operation.id=NULL, pool.id=NULL, operation=NULL, start.time=NULL, end.time=NULL, limit=NULL, recv.window=NULL, ...){
      args <- list(...)
      queryParams <- list()
      headerParams <- c()

      queryParams['operationId'] <- operation.id

      queryParams['poolId'] <- pool.id

      queryParams['operation'] <- operation

      queryParams['startTime'] <- start.time

      queryParams['endTime'] <- end.time

      queryParams['limit'] <- limit

      queryParams['recvWindow'] <- recv.window

      queryParams['timestamp'] <- self$apiClient$Timestamp
      
      queryParams['signature'] <- self$apiClient$credentials$sign(queryParams)

      body <- NULL
      urlPath <- "/sapi/v1/bswap/liquidityOps"
      # API key authentication
      if (nchar(self$apiClient$credentials$key) > 0) {
        headerParams['X-MBX-APIKEY'] <- self$apiClient$credentials$key
      }

      resp <- self$apiClient$CallApi(url = paste0(self$apiClient$basePath, urlPath),
                                 method = "GET",
                                 queryParams = queryParams,
                                 headerParams = headerParams,
                                 body = body,
                                 ...)

      if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
        deserializedRespObj <- tryCatch(
          self$apiClient$deserialize(resp, "array[InlineResponse200124]", loadNamespace("binanceRapi")),
          error = function(e){
             stop("Failed to deserialize response")
          }
        )
        ApiResponse$new(deserializedRespObj, resp)
      } else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) {
        ApiResponse$new(paste("Server returned " , httr::status_code(resp) , " response status code."), resp)
      } else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
        ApiResponse$new("API client error", resp)
      } else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
        ApiResponse$new("API server error", resp)
      }
    },
    SapiV1BswapLiquidityRemovePost = function(pool.id, type, share.amount, asset=NULL, recv.window=NULL, ...){
      apiResponse <- self$SapiV1BswapLiquidityRemovePostWithHttpInfo(pool.id, type, share.amount, asset, recv.window, ...)
      resp <- apiResponse$response
      if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
        apiResponse$content
      } else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) {
        apiResponse
      } else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
        apiResponse
      } else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
        apiResponse
      }
    },

    SapiV1BswapLiquidityRemovePostWithHttpInfo = function(pool.id, type, share.amount, asset=NULL, recv.window=NULL, ...){
      args <- list(...)
      queryParams <- list()
      headerParams <- c()

      if (missing(`pool.id`)) {
        stop("Missing required parameter `pool.id`.")
      }

      if (missing(`type`)) {
        stop("Missing required parameter `type`.")
      }

      if (missing(`share.amount`)) {
        stop("Missing required parameter `share.amount`.")
      }

      queryParams['poolId'] <- pool.id

      queryParams['type'] <- type

      queryParams['asset'] <- asset

      queryParams['shareAmount'] <- share.amount

      queryParams['recvWindow'] <- recv.window

      queryParams['timestamp'] <- self$apiClient$Timestamp
      
      queryParams['signature'] <- self$apiClient$credentials$sign(queryParams)

      body <- NULL
      urlPath <- "/sapi/v1/bswap/liquidityRemove"
      # API key authentication
      if (nchar(self$apiClient$credentials$key) > 0) {
        headerParams['X-MBX-APIKEY'] <- self$apiClient$credentials$key
      }

      resp <- self$apiClient$CallApi(url = paste0(self$apiClient$basePath, urlPath),
                                 method = "POST",
                                 queryParams = queryParams,
                                 headerParams = headerParams,
                                 body = body,
                                 ...)

      if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
        deserializedRespObj <- tryCatch(
          self$apiClient$deserialize(resp, "InlineResponse200123", loadNamespace("binanceRapi")),
          error = function(e){
             stop("Failed to deserialize response")
          }
        )
        ApiResponse$new(deserializedRespObj, resp)
      } else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) {
        ApiResponse$new(paste("Server returned " , httr::status_code(resp) , " response status code."), resp)
      } else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
        ApiResponse$new("API client error", resp)
      } else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
        ApiResponse$new("API server error", resp)
      }
    },
    SapiV1BswapPoolConfigureGet = function(pool.id=NULL, recv.window=NULL, ...){
      apiResponse <- self$SapiV1BswapPoolConfigureGetWithHttpInfo(pool.id, recv.window, ...)
      resp <- apiResponse$response
      if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
        apiResponse$content
      } else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) {
        apiResponse
      } else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
        apiResponse
      } else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
        apiResponse
      }
    },

    SapiV1BswapPoolConfigureGetWithHttpInfo = function(pool.id=NULL, recv.window=NULL, ...){
      args <- list(...)
      queryParams <- list()
      headerParams <- c()

      queryParams['poolId'] <- pool.id

      queryParams['recvWindow'] <- recv.window

      queryParams['timestamp'] <- self$apiClient$Timestamp
      
      queryParams['signature'] <- self$apiClient$credentials$sign(queryParams)

      body <- NULL
      urlPath <- "/sapi/v1/bswap/poolConfigure"
      # API key authentication
      if (nchar(self$apiClient$credentials$key) > 0) {
        headerParams['X-MBX-APIKEY'] <- self$apiClient$credentials$key
      }

      resp <- self$apiClient$CallApi(url = paste0(self$apiClient$basePath, urlPath),
                                 method = "GET",
                                 queryParams = queryParams,
                                 headerParams = headerParams,
                                 body = body,
                                 ...)

      if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
        deserializedRespObj <- tryCatch(
          self$apiClient$deserialize(resp, "array[InlineResponse200128", loadNamespace("binanceRapi")),
          error = function(e){
             stop("Failed to deserialize response")
          }
        )
        ApiResponse$new(deserializedRespObj, resp)
      } else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) {
        ApiResponse$new(paste("Server returned " , httr::status_code(resp) , " response status code."), resp)
      } else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
        ApiResponse$new("API client error", resp)
      } else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
        ApiResponse$new("API server error", resp)
      }
    },
    SapiV1BswapPoolsGet = function(...){
      apiResponse <- self$SapiV1BswapPoolsGetWithHttpInfo(...)
      resp <- apiResponse$response
      if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
        apiResponse$content
      } else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) {
        apiResponse
      } else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
        apiResponse
      } else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
        apiResponse
      }
    },

    SapiV1BswapPoolsGetWithHttpInfo = function(...){
      args <- list(...)
      queryParams <- list()
      headerParams <- c()

      body <- NULL
      urlPath <- "/sapi/v1/bswap/pools"
      # API key authentication
      if (nchar(self$apiClient$credentials$key) > 0) {
        headerParams['X-MBX-APIKEY'] <- self$apiClient$credentials$key
      }

      resp <- self$apiClient$CallApi(url = paste0(self$apiClient$basePath, urlPath),
                                 method = "GET",
                                 queryParams = queryParams,
                                 headerParams = headerParams,
                                 body = body,
                                 ...)

      if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
        deserializedRespObj <- tryCatch(
          self$apiClient$deserialize(resp, "array[InlineResponse200121]", loadNamespace("binanceRapi")),
          error = function(e){
             stop("Failed to deserialize response")
          }
        )
        ApiResponse$new(deserializedRespObj, resp)
      } else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) {
        ApiResponse$new(paste("Server returned " , httr::status_code(resp) , " response status code."), resp)
      } else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
        ApiResponse$new("API client error", resp)
      } else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
        ApiResponse$new("API server error", resp)
      }
    },
    SapiV1BswapQuoteGet = function(quote.asset, base.asset, quote.qty, recv.window=NULL, ...){
      apiResponse <- self$SapiV1BswapQuoteGetWithHttpInfo(quote.asset, base.asset, quote.qty, recv.window, ...)
      resp <- apiResponse$response
      if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
        apiResponse$content
      } else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) {
        apiResponse
      } else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
        apiResponse
      } else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
        apiResponse
      }
    },

    SapiV1BswapQuoteGetWithHttpInfo = function(quote.asset, base.asset, quote.qty, recv.window=NULL, ...){
      args <- list(...)
      queryParams <- list()
      headerParams <- c()

      if (missing(`quote.asset`)) {
        stop("Missing required parameter `quote.asset`.")
      }

      if (missing(`base.asset`)) {
        stop("Missing required parameter `base.asset`.")
      }

      if (missing(`quote.qty`)) {
        stop("Missing required parameter `quote.qty`.")
      }

      queryParams['quoteAsset'] <- quote.asset

      queryParams['baseAsset'] <- base.asset

      queryParams['quoteQty'] <- quote.qty

      queryParams['recvWindow'] <- recv.window

      queryParams['timestamp'] <- self$apiClient$Timestamp
      
      queryParams['signature'] <- self$apiClient$credentials$sign(queryParams)

      body <- NULL
      urlPath <- "/sapi/v1/bswap/quote"
      # API key authentication
      if (nchar(self$apiClient$credentials$key) > 0) {
        headerParams['X-MBX-APIKEY'] <- self$apiClient$credentials$key
      }

      resp <- self$apiClient$CallApi(url = paste0(self$apiClient$basePath, urlPath),
                                 method = "GET",
                                 queryParams = queryParams,
                                 headerParams = headerParams,
                                 body = body,
                                 ...)

      if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
        deserializedRespObj <- tryCatch(
          self$apiClient$deserialize(resp, "InlineResponse200125", loadNamespace("binanceRapi")),
          error = function(e){
             stop("Failed to deserialize response")
          }
        )
        ApiResponse$new(deserializedRespObj, resp)
      } else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) {
        ApiResponse$new(paste("Server returned " , httr::status_code(resp) , " response status code."), resp)
      } else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
        ApiResponse$new("API client error", resp)
      } else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
        ApiResponse$new("API server error", resp)
      }
    },
    SapiV1BswapRemoveLiquidityPreviewGet = function(pool.id, type, quote.asset, share.amount, recv.window=NULL, ...){
      apiResponse <- self$SapiV1BswapRemoveLiquidityPreviewGetWithHttpInfo(pool.id, type, quote.asset, 
                                                                           share.amount, recv.window, ...)
      resp <- apiResponse$response
      if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
        apiResponse$content
      } else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) {
        apiResponse
      } else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
        apiResponse
      } else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
        apiResponse
      }
    },

    SapiV1BswapRemoveLiquidityPreviewGetWithHttpInfo = function(pool.id, type, quote.asset, share.amount, 
                                                                recv.window=NULL, ...){
      args <- list(...)
      queryParams <- list()
      headerParams <- c()

      if (missing(`pool.id`)) {
        stop("Missing required parameter `pool.id`.")
      }

      if (missing(`type`)) {
        stop("Missing required parameter `type`.")
      }

      if (missing(`quote.asset`)) {
        stop("Missing required parameter `quote.asset`.")
      }

      if (missing(`share.amount`)) {
        stop("Missing required parameter `share.amount`.")
      }

      queryParams['poolId'] <- pool.id

      queryParams['type'] <- type

      queryParams['quoteAsset'] <- quote.asset

      queryParams['shareAmount'] <- share.amount

      queryParams['recvWindow'] <- recv.window

      queryParams['timestamp'] <- self$apiClient$Timestamp
      
      queryParams['signature'] <- self$apiClient$credentials$sign(queryParams)

      body <- NULL
      urlPath <- "/sapi/v1/bswap/removeLiquidityPreview"
      # API key authentication
      if (nchar(self$apiClient$credentials$key) > 0) {
        headerParams['X-MBX-APIKEY'] <- self$apiClient$credentials$key
      }

      resp <- self$apiClient$CallApi(url = paste0(self$apiClient$basePath, urlPath),
                                 method = "GET",
                                 queryParams = queryParams,
                                 headerParams = headerParams,
                                 body = body,
                                 ...)

      if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
        deserializedRespObj <- tryCatch(
          self$apiClient$deserialize(resp, "OneOfbswapRmvLiquidityPreviewCombinationbswapRmvLiquidityPreviewSingle", loadNamespace("binanceRapi")),
          error = function(e){
             stop("Failed to deserialize response")
          }
        )
        ApiResponse$new(deserializedRespObj, resp)
      } else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) {
        ApiResponse$new(paste("Server returned " , httr::status_code(resp) , " response status code."), resp)
      } else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
        ApiResponse$new("API client error", resp)
      } else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
        ApiResponse$new("API server error", resp)
      }
    },
    SapiV1BswapSwapGet = function(swap.id=NULL, start.time=NULL, end.time=NULL, status=NULL, quote.asset=NULL, base.asset=NULL, limit=NULL, recv.window=NULL, ...){
      apiResponse <- self$SapiV1BswapSwapGetWithHttpInfo(swap.id, start.time, end.time, status, quote.asset, base.asset, limit, recv.window, ...)
      resp <- apiResponse$response
      if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
        apiResponse$content
      } else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) {
        apiResponse
      } else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
        apiResponse
      } else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
        apiResponse
      }
    },

    SapiV1BswapSwapGetWithHttpInfo = function(swap.id=NULL, start.time=NULL, end.time=NULL, status=NULL, quote.asset=NULL, base.asset=NULL, limit=NULL, recv.window=NULL, ...){
      args <- list(...)
      queryParams <- list()
      headerParams <- c()

      queryParams['swapId'] <- swap.id

      queryParams['startTime'] <- start.time

      queryParams['endTime'] <- end.time

      queryParams['status'] <- status

      queryParams['quoteAsset'] <- quote.asset

      queryParams['baseAsset'] <- base.asset

      queryParams['limit'] <- limit

      queryParams['recvWindow'] <- recv.window

      queryParams['timestamp'] <- self$apiClient$Timestamp
      
      queryParams['signature'] <- self$apiClient$credentials$sign(queryParams)

      body <- NULL
      urlPath <- "/sapi/v1/bswap/swap"
      # API key authentication
      if (nchar(self$apiClient$credentials$key) > 0) {
        headerParams['X-MBX-APIKEY'] <- self$apiClient$credentials$key
      }

      resp <- self$apiClient$CallApi(url = paste0(self$apiClient$basePath, urlPath),
                                 method = "GET",
                                 queryParams = queryParams,
                                 headerParams = headerParams,
                                 body = body,
                                 ...)

      if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
        deserializedRespObj <- tryCatch(
          self$apiClient$deserialize(resp, "array[InlineResponse200126]", loadNamespace("binanceRapi")),
          error = function(e){
             stop("Failed to deserialize response")
          }
        )
        ApiResponse$new(deserializedRespObj, resp)
      } else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) {
        ApiResponse$new(paste("Server returned " , httr::status_code(resp) , " response status code."), resp)
      } else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
        ApiResponse$new("API client error", resp)
      } else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
        ApiResponse$new("API server error", resp)
      }
    },
    SapiV1BswapSwapPost = function(quote.asset, base.asset, quote.qty, recv.window=NULL, ...){
      apiResponse <- self$SapiV1BswapSwapPostWithHttpInfo(quote.asset, base.asset, quote.qty, recv.window, ...)
      resp <- apiResponse$response
      if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
        apiResponse$content
      } else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) {
        apiResponse
      } else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
        apiResponse
      } else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
        apiResponse
      }
    },

    SapiV1BswapSwapPostWithHttpInfo = function(quote.asset, base.asset, quote.qty, recv.window=NULL, ...){
      args <- list(...)
      queryParams <- list()
      headerParams <- c()

      if (missing(`quote.asset`)) {
        stop("Missing required parameter `quote.asset`.")
      }

      if (missing(`base.asset`)) {
        stop("Missing required parameter `base.asset`.")
      }

      if (missing(`quote.qty`)) {
        stop("Missing required parameter `quote.qty`.")
      }

      queryParams['quoteAsset'] <- quote.asset

      queryParams['baseAsset'] <- base.asset

      queryParams['quoteQty'] <- quote.qty

      queryParams['recvWindow'] <- recv.window

      queryParams['timestamp'] <- self$apiClient$Timestamp
      
      queryParams['signature'] <- self$apiClient$credentials$sign(queryParams)

      body <- NULL
      urlPath <- "/sapi/v1/bswap/swap"
      # API key authentication
      if (nchar(self$apiClient$credentials$key) > 0) {
        headerParams['X-MBX-APIKEY'] <- self$apiClient$credentials$key
      }

      resp <- self$apiClient$CallApi(url = paste0(self$apiClient$basePath, urlPath),
                                 method = "POST",
                                 queryParams = queryParams,
                                 headerParams = headerParams,
                                 body = body,
                                 ...)

      if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
        deserializedRespObj <- tryCatch(
          self$apiClient$deserialize(resp, "InlineResponse200127", loadNamespace("binanceRapi")),
          error = function(e){
             stop("Failed to deserialize response")
          }
        )
        ApiResponse$new(deserializedRespObj, resp)
      } else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) {
        ApiResponse$new(paste("Server returned " , httr::status_code(resp) , " response status code."), resp)
      } else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
        ApiResponse$new("API client error", resp)
      } else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
        ApiResponse$new("API server error", resp)
      }
    },
    SapiV1BswapUnclaimedRewardsGet = function(type=NULL, recv.window=NULL, ...){
      apiResponse <- self$SapiV1BswapUnclaimedRewardsGetWithHttpInfo(type, recv.window, ...)
      resp <- apiResponse$response
      if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
        apiResponse$content
      } else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) {
        apiResponse
      } else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
        apiResponse
      } else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
        apiResponse
      }
    },
    
    SapiV1BswapUnclaimedRewardsGetWithHttpInfo = function(type=NULL, recv.window=NULL, ...){
      args <- list(...)
      queryParams <- list()
      headerParams <- c()
      
      queryParams['type'] <- type
      
      queryParams['recvWindow'] <- recv.window
      
      queryParams['timestamp'] <- self$apiClient$Timestamp
      
      queryParams['signature'] <- self$apiClient$credentials$sign(queryParams)
      
      body <- NULL
      urlPath <- "/sapi/v1/bswap/unclaimedRewards"
      # API key authentication
      if (nchar(self$apiClient$credentials$key) > 0) {
        headerParams['X-MBX-APIKEY'] <- self$apiClient$credentials$key
      }
      
      resp <- self$apiClient$CallApi(url = paste0(self$apiClient$basePath, urlPath),
                                     method = "GET",
                                     queryParams = queryParams,
                                     headerParams = headerParams,
                                     body = body,
                                     ...)
      
      if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
        deserializedRespObj <- tryCatch(
          self$apiClient$deserialize(resp, "InlineResponse200129", loadNamespace("binanceRapi")),
          error = function(e){
            stop("Failed to deserialize response")
          }
        )
        ApiResponse$new(deserializedRespObj, resp)
      } else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) {
        ApiResponse$new(paste("Server returned " , httr::status_code(resp) , " response status code."), resp)
      } else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
        ApiResponse$new("API client error", resp)
      } else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
        ApiResponse$new("API server error", resp)
      }
    }
  )
)
grahamjwhite/binanceRapi documentation built on Nov. 22, 2022, 9:37 p.m.