# 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 GiftCard operations
#' @description binanceRapi.GiftCard
#' @format An \code{R6Class} generator object
#' @field apiClient Handles the client-server communication.
#'
#' @section Methods:
#' \describe{
#' \strong{ SapiV1GiftcardCreateCodePost } \emph{ Create a Binance Code (USER_DATA) }
#' This API is for creating a Binance Code. To get started with, please make sure: - You have a Binance account - You have passed kyc - You have a sufficient balance in your Binance funding wallet - You need Enable Withdrawals for the API Key which requests this endpoint. Daily creation volume: 2 BTC / 24H Daily creation times: 200 Codes / 24H Weight(IP): 1
#'
#' \itemize{
#' \item \emph{ @param } token character
#' \item \emph{ @param } amount numeric
#' \item \emph{ @param } timestamp integer
#' \item \emph{ @param } signature character
#' \item \emph{ @param } recv.window integer
#' \item \emph{ @returnType } \link{InlineResponse200141} \cr
#'
#'
#' \item status code : 200 | Code creation
#'
#' \item return type : InlineResponse200141
#' \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{ SapiV1GiftcardCryptographyRsaPublicKeyGet } \emph{ Fetch RSA Public Key (USER_DATA) }
#' This API is for fetching the RSA Public Key. This RSA Public key will be used to encrypt the card code. Please note that the RSA Public key fetched is valid only for the current day. Weight(IP): 1
#'
#' \itemize{
#' \item \emph{ @param } timestamp integer
#' \item \emph{ @param } signature character
#' \item \emph{ @param } recv.window integer
#' \item \emph{ @returnType } \link{InlineResponse200144} \cr
#'
#'
#' \item status code : 200 | RSA Public Key.
#'
#' \item return type : InlineResponse200144
#' \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{ SapiV1GiftcardRedeemCodePost } \emph{ Redeem a Binance Code (USER_DATA) }
#' This API is for redeeming the Binance Code. Once redeemed, the coins will be deposited in your funding wallet. Please note that if you enter the wrong code 5 times within 24 hours, you will no longer be able to redeem any Binance Code that day. Weight(IP): 1
#'
#' \itemize{
#' \item \emph{ @param } code character
#' \item \emph{ @param } timestamp integer
#' \item \emph{ @param } signature character
#' \item \emph{ @param } external.uid character
#' \item \emph{ @param } recv.window integer
#' \item \emph{ @returnType } \link{InlineResponse200142} \cr
#'
#'
#' \item status code : 200 | Redeemed Information
#'
#' \item return type : InlineResponse200142
#' \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{ SapiV1GiftcardVerifyGet } \emph{ Verify a Binance Code (USER_DATA) }
#' This API is for verifying whether the Binance Code is valid or not by entering Binance Code or reference number. Please note that if you enter the wrong binance code 5 times within an hour, you will no longer be able to verify any binance code for that hour. Weight(IP): 1
#'
#' \itemize{
#' \item \emph{ @param } reference.no character
#' \item \emph{ @param } timestamp integer
#' \item \emph{ @param } signature character
#' \item \emph{ @param } recv.window integer
#' \item \emph{ @returnType } \link{InlineResponse200143} \cr
#'
#'
#' \item status code : 200 | Code Verification
#'
#' \item return type : InlineResponse200143
#' \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{
#' #################### SapiV1GiftcardCreateCodePost ####################
#'
#' library(binanceRapi)
#' var.token <- 'token_example' # character | The coin type contained in the Binance Code
#' var.amount <- 3.4 # numeric | The amount of the coin
#' var.timestamp <- 56 # integer | UTC timestamp in ms
#' var.signature <- 'signature_example' # character | Signature
#' var.recv.window <- 5000 # integer | The value cannot be greater than 60000
#'
#' #Create a Binance Code (USER_DATA)
#' api.instance <- GiftCardApi$new()
#'
#' #Configure API key authorization: ApiKeyAuth
#' api.instance$apiClient$apiKeys['X-MBX-APIKEY'] <- 'TODO_YOUR_API_KEY';
#'
#' result <- api.instance$SapiV1GiftcardCreateCodePost(var.token, var.amount, var.timestamp, var.signature, recv.window=var.recv.window)
#'
#'
#' #################### SapiV1GiftcardCryptographyRsaPublicKeyGet ####################
#'
#' library(binanceRapi)
#' var.timestamp <- 56 # integer | UTC timestamp in ms
#' var.signature <- 'signature_example' # character | Signature
#' var.recv.window <- 5000 # integer | The value cannot be greater than 60000
#'
#' #Fetch RSA Public Key (USER_DATA)
#' api.instance <- GiftCardApi$new()
#'
#' #Configure API key authorization: ApiKeyAuth
#' api.instance$apiClient$apiKeys['X-MBX-APIKEY'] <- 'TODO_YOUR_API_KEY';
#'
#' result <- api.instance$SapiV1GiftcardCryptographyRsaPublicKeyGet(var.timestamp, var.signature, recv.window=var.recv.window)
#'
#'
#' #################### SapiV1GiftcardRedeemCodePost ####################
#'
#' library(binanceRapi)
#' var.code <- 'code_example' # character | Binance Code
#' var.timestamp <- 56 # integer | UTC timestamp in ms
#' var.signature <- 'signature_example' # character | Signature
#' var.external.uid <- 'external.uid_example' # character | Each external unique ID represents a unique user on the partner platform. The function helps you to identify the redemption behavior of different users, such as redemption frequency and amount. It also helps risk and limit control of a single account, such as daily limit on redemption volume, frequency, and incorrect number of entries. This will also prevent a single user account reach the partner's daily redemption limits. We strongly recommend you to use this feature and transfer us the User ID of your users if you have different users redeeming Binance codes on your platform. To protect user data privacy, you may choose to transfer the user id in any desired format (max. 400 characters).
#' var.recv.window <- 5000 # integer | The value cannot be greater than 60000
#'
#' #Redeem a Binance Code (USER_DATA)
#' api.instance <- GiftCardApi$new()
#'
#' #Configure API key authorization: ApiKeyAuth
#' api.instance$apiClient$apiKeys['X-MBX-APIKEY'] <- 'TODO_YOUR_API_KEY';
#'
#' result <- api.instance$SapiV1GiftcardRedeemCodePost(var.code, var.timestamp, var.signature, external.uid=var.external.uid, recv.window=var.recv.window)
#'
#'
#' #################### SapiV1GiftcardVerifyGet ####################
#'
#' library(binanceRapi)
#' var.reference.no <- 'reference.no_example' # character | reference number
#' var.timestamp <- 56 # integer | UTC timestamp in ms
#' var.signature <- 'signature_example' # character | Signature
#' var.recv.window <- 5000 # integer | The value cannot be greater than 60000
#'
#' #Verify a Binance Code (USER_DATA)
#' api.instance <- GiftCardApi$new()
#'
#' #Configure API key authorization: ApiKeyAuth
#' api.instance$apiClient$apiKeys['X-MBX-APIKEY'] <- 'TODO_YOUR_API_KEY';
#'
#' result <- api.instance$SapiV1GiftcardVerifyGet(var.reference.no, var.timestamp, var.signature, recv.window=var.recv.window)
#'
#'
#' }
#' @importFrom R6 R6Class
#' @importFrom base64enc base64encode
#' @export
GiftCardApi <- R6::R6Class(
'GiftCardApi',
public = list(
apiClient = NULL,
initialize = function(apiClient){
if (!missing(apiClient)) {
self$apiClient <- apiClient
}
else {
self$apiClient <- ApiClient$new()
}
},
SapiV1GiftcardCreateCodePost = function(token, amount, timestamp, signature, recv.window=NULL, ...){
apiResponse <- self$SapiV1GiftcardCreateCodePostWithHttpInfo(token, amount, timestamp, signature, 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
}
},
SapiV1GiftcardCreateCodePostWithHttpInfo = function(token, amount, timestamp, signature, recv.window=NULL, ...){
args <- list(...)
queryParams <- list()
headerParams <- c()
if (missing(`token`)) {
stop("Missing required parameter `token`.")
}
if (missing(`amount`)) {
stop("Missing required parameter `amount`.")
}
if (missing(`timestamp`)) {
stop("Missing required parameter `timestamp`.")
}
if (missing(`signature`)) {
stop("Missing required parameter `signature`.")
}
queryParams['token'] <- token
queryParams['amount'] <- amount
queryParams['recvWindow'] <- recv.window
queryParams['timestamp'] <- timestamp
queryParams['signature'] <- signature
body <- NULL
urlPath <- "/sapi/v1/giftcard/createCode"
# API key authentication
if ("X-MBX-APIKEY" %in% names(self$apiClient$apiKeys) && nchar(self$apiClient$apiKeys["X-MBX-APIKEY"]) > 0) {
headerParams['X-MBX-APIKEY'] <- paste(unlist(self$apiClient$apiKeys["X-MBX-APIKEY"]), collapse='')
}
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, "InlineResponse200141", 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)
}
},
SapiV1GiftcardCryptographyRsaPublicKeyGet = function(timestamp, signature, recv.window=NULL, ...){
apiResponse <- self$SapiV1GiftcardCryptographyRsaPublicKeyGetWithHttpInfo(timestamp, signature, 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
}
},
SapiV1GiftcardCryptographyRsaPublicKeyGetWithHttpInfo = function(timestamp, signature, recv.window=NULL, ...){
args <- list(...)
queryParams <- list()
headerParams <- c()
if (missing(`timestamp`)) {
stop("Missing required parameter `timestamp`.")
}
if (missing(`signature`)) {
stop("Missing required parameter `signature`.")
}
queryParams['recvWindow'] <- recv.window
queryParams['timestamp'] <- timestamp
queryParams['signature'] <- signature
body <- NULL
urlPath <- "/sapi/v1/giftcard/cryptography/rsa-public-key"
# API key authentication
if ("X-MBX-APIKEY" %in% names(self$apiClient$apiKeys) && nchar(self$apiClient$apiKeys["X-MBX-APIKEY"]) > 0) {
headerParams['X-MBX-APIKEY'] <- paste(unlist(self$apiClient$apiKeys["X-MBX-APIKEY"]), collapse='')
}
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, "InlineResponse200144", 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)
}
},
SapiV1GiftcardRedeemCodePost = function(code, timestamp, signature, external.uid=NULL, recv.window=NULL, ...){
apiResponse <- self$SapiV1GiftcardRedeemCodePostWithHttpInfo(code, timestamp, signature, external.uid, 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
}
},
SapiV1GiftcardRedeemCodePostWithHttpInfo = function(code, timestamp, signature, external.uid=NULL, recv.window=NULL, ...){
args <- list(...)
queryParams <- list()
headerParams <- c()
if (missing(`code`)) {
stop("Missing required parameter `code`.")
}
if (missing(`timestamp`)) {
stop("Missing required parameter `timestamp`.")
}
if (missing(`signature`)) {
stop("Missing required parameter `signature`.")
}
queryParams['code'] <- code
queryParams['externalUid'] <- external.uid
queryParams['recvWindow'] <- recv.window
queryParams['timestamp'] <- timestamp
queryParams['signature'] <- signature
body <- NULL
urlPath <- "/sapi/v1/giftcard/redeemCode"
# API key authentication
if ("X-MBX-APIKEY" %in% names(self$apiClient$apiKeys) && nchar(self$apiClient$apiKeys["X-MBX-APIKEY"]) > 0) {
headerParams['X-MBX-APIKEY'] <- paste(unlist(self$apiClient$apiKeys["X-MBX-APIKEY"]), collapse='')
}
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, "InlineResponse200142", 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)
}
},
SapiV1GiftcardVerifyGet = function(reference.no, timestamp, signature, recv.window=NULL, ...){
apiResponse <- self$SapiV1GiftcardVerifyGetWithHttpInfo(reference.no, timestamp, signature, 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
}
},
SapiV1GiftcardVerifyGetWithHttpInfo = function(reference.no, timestamp, signature, recv.window=NULL, ...){
args <- list(...)
queryParams <- list()
headerParams <- c()
if (missing(`reference.no`)) {
stop("Missing required parameter `reference.no`.")
}
if (missing(`timestamp`)) {
stop("Missing required parameter `timestamp`.")
}
if (missing(`signature`)) {
stop("Missing required parameter `signature`.")
}
queryParams['referenceNo'] <- reference.no
queryParams['recvWindow'] <- recv.window
queryParams['timestamp'] <- timestamp
queryParams['signature'] <- signature
body <- NULL
urlPath <- "/sapi/v1/giftcard/verify"
# API key authentication
if ("X-MBX-APIKEY" %in% names(self$apiClient$apiKeys) && nchar(self$apiClient$apiKeys["X-MBX-APIKEY"]) > 0) {
headerParams['X-MBX-APIKEY'] <- paste(unlist(self$apiClient$apiKeys["X-MBX-APIKEY"]), collapse='')
}
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, "InlineResponse200143", 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)
}
}
)
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.