R/nft_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 NFT operations
#' @description binanceRapi.NFT
#' @format An \code{R6Class} generator object
#' @field apiClient Handles the client-server communication.
#'
#' @section Methods:
#' \describe{
#' \strong{ SapiV1NftHistoryDepositGet } \emph{ Get NFT Deposit History(USER_DATA) }
#' - The max interval between startTime and endTime is 90 days. - If startTime and endTime are not sent, the recent 7 days' data will be returned.  Weight(UID): 3000
#'
#' \itemize{
#' \item \emph{ @param } start.time integer
#' \item \emph{ @param } end.time integer
#' \item \emph{ @param } limit integer
#' \item \emph{ @param } page integer
#' \item \emph{ @param } recv.window integer
#' \item \emph{ @returnType } \link{InlineResponse200138} \cr
#'
#'
#' \item status code : 200 | NFT Deposit History
#'
#' \item return type : InlineResponse200138 
#' \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{ SapiV1NftHistoryTransactionsGet } \emph{ Get NFT Transaction History (USER_DATA) }
#' - The max interval between startTime and endTime is 90 days. - If startTime and endTime are not sent, the recent 7 days' data will be returned.  Weight(UID): 3000
#'
#' \itemize{
#' \item \emph{ @param } order.type integer
#' \item \emph{ @param } start.time integer
#' \item \emph{ @param } end.time integer
#' \item \emph{ @param } limit integer
#' \item \emph{ @param } page integer
#' \item \emph{ @param } recv.window integer
#' \item \emph{ @returnType } \link{InlineResponse200137} \cr
#'
#'
#' \item status code : 200 | NFT Transaction History
#'
#' \item return type : InlineResponse200137 
#' \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{ SapiV1NftHistoryWithdrawGet } \emph{ Get NFT Withdraw History (USER_DATA) }
#' - The max interval between startTime and endTime is 90 days. - If startTime and endTime are not sent, the recent 7 days' data will be returned.  Weight(UID): 3000
#'
#' \itemize{
#' \item \emph{ @param } start.time integer
#' \item \emph{ @param } end.time integer
#' \item \emph{ @param } limit integer
#' \item \emph{ @param } page integer
#' \item \emph{ @param } recv.window integer
#' \item \emph{ @returnType } \link{InlineResponse200139} \cr
#'
#'
#' \item status code : 200 | NFT Withdraw History
#'
#' \item return type : InlineResponse200139 
#' \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{ SapiV1NftUserGetAssetGet } \emph{ Get NFT Asset (USER_DATA) }
#' Weight(UID): 3000
#'
#' \itemize{
#' \item \emph{ @param } limit integer
#' \item \emph{ @param } page integer
#' \item \emph{ @param } recv.window integer
#' \item \emph{ @returnType } \link{InlineResponse200140} \cr
#'
#'
#' \item status code : 200 | Asset Information
#'
#' \item return type : InlineResponse200140 
#' \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{
#' ####################  SapiV1NftHistoryDepositGet  ####################
#'
#' library(binanceRapi)
#' var.start.time <- 56 # integer | UTC timestamp in ms
#' var.end.time <- 56 # integer | UTC timestamp in ms
#' var.limit <- 50 # integer | Default 50, Max 50
#' var.page <- 1 # integer | Default 1
#' var.recv.window <- 5000 # integer | The value cannot be greater than 60000
#'
#' #Get NFT Deposit History(USER_DATA)
#' api.instance <- NFTApi$new()
#'
#' result <- api.instance$SapiV1NftHistoryDepositGet(start.time=var.start.time, end.time=var.end.time, limit=var.limit, page=var.page, recv.window=var.recv.window)
#'
#'
#' ####################  SapiV1NftHistoryTransactionsGet  ####################
#'
#' library(binanceRapi)
#' var.order.type <- 1 # integer | 0: purchase order, 1: sell order, 2: royalty income, 3: primary market order, 4: mint fee
#' var.start.time <- 56 # integer | UTC timestamp in ms
#' var.end.time <- 56 # integer | UTC timestamp in ms
#' var.limit <- 50 # integer | Default 50, Max 50
#' var.page <- 1 # integer | Default 1
#' var.recv.window <- 5000 # integer | The value cannot be greater than 60000
#'
#' #Get NFT Transaction History (USER_DATA)
#' api.instance <- NFTApi$new()
#'
#' result <- api.instance$SapiV1NftHistoryTransactionsGet(var.order.type, start.time=var.start.time, end.time=var.end.time, limit=var.limit, page=var.page, recv.window=var.recv.window)
#'
#'
#' ####################  SapiV1NftHistoryWithdrawGet  ####################
#'
#' library(binanceRapi)
#' var.start.time <- 56 # integer | UTC timestamp in ms
#' var.end.time <- 56 # integer | UTC timestamp in ms
#' var.limit <- 50 # integer | Default 50, Max 50
#' var.page <- 1 # integer | Default 1
#' var.recv.window <- 5000 # integer | The value cannot be greater than 60000
#'
#' #Get NFT Withdraw History (USER_DATA)
#' api.instance <- NFTApi$new()
#'
#' result <- api.instance$SapiV1NftHistoryWithdrawGet(start.time=var.start.time, end.time=var.end.time, limit=var.limit, page=var.page, recv.window=var.recv.window)
#'
#'
#' ####################  SapiV1NftUserGetAssetGet  ####################
#'
#' library(binanceRapi)
#' var.limit <- 50 # integer | Default 50, Max 50
#' var.page <- 1 # integer | Default 1
#' var.recv.window <- 5000 # integer | The value cannot be greater than 60000
#'
#' #Get NFT Asset (USER_DATA)
#' api.instance <- NFTApi$new()
#'
#' result <- api.instance$SapiV1NftUserGetAssetGet(limit=var.limit, page=var.page, recv.window=var.recv.window)
#'
#'
#' }
#' @importFrom R6 R6Class
#' @importFrom base64enc base64encode
#' @export
NFTApi <- R6::R6Class(
  'NFTApi',
  public = list(
    apiClient = NULL,
    initialize = function(apiClient){
      if (!missing(apiClient)) {
        self$apiClient <- apiClient
      }
      else {
        self$apiClient <- ApiClient$new()
      }
    },
    SapiV1NftHistoryDepositGet = function(start.time=NULL, end.time=NULL, limit=NULL, page=NULL, recv.window=NULL, ...){
      apiResponse <- self$SapiV1NftHistoryDepositGetWithHttpInfo(start.time, end.time, limit, page, 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
      }
    },

    SapiV1NftHistoryDepositGetWithHttpInfo = function(start.time=NULL, end.time=NULL, limit=NULL, page=NULL, recv.window=NULL, ...){
      args <- list(...)
      queryParams <- list()
      headerParams <- c()

      queryParams['startTime'] <- start.time

      queryParams['endTime'] <- end.time

      queryParams['limit'] <- limit

      queryParams['page'] <- page

      queryParams['recvWindow'] <- recv.window

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

      body <- NULL
      urlPath <- "/sapi/v1/nft/history/deposit"
      # 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, "InlineResponse200138", 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)
      }
    },
    SapiV1NftHistoryTransactionsGet = function(order.type, start.time=NULL, end.time=NULL, limit=NULL, page=NULL, recv.window=NULL, ...){
      apiResponse <- self$SapiV1NftHistoryTransactionsGetWithHttpInfo(order.type, start.time, end.time, limit, page, 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
      }
    },

    SapiV1NftHistoryTransactionsGetWithHttpInfo = function(order.type, start.time=NULL, end.time=NULL, limit=NULL, page=NULL, recv.window=NULL, ...){
      args <- list(...)
      queryParams <- list()
      headerParams <- c()

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

      queryParams['orderType'] <- order.type

      queryParams['startTime'] <- start.time

      queryParams['endTime'] <- end.time

      queryParams['limit'] <- limit

      queryParams['page'] <- page

      queryParams['recvWindow'] <- recv.window

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

      body <- NULL
      urlPath <- "/sapi/v1/nft/history/transactions"
      # 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, "InlineResponse200137", 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)
      }
    },
    SapiV1NftHistoryWithdrawGet = function(start.time=NULL, end.time=NULL, limit=NULL, page=NULL, recv.window=NULL, ...){
      apiResponse <- self$SapiV1NftHistoryWithdrawGetWithHttpInfo(start.time, end.time, limit, page, 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
      }
    },

    SapiV1NftHistoryWithdrawGetWithHttpInfo = function(start.time=NULL, end.time=NULL, limit=NULL, page=NULL, recv.window=NULL, ...){
      args <- list(...)
      queryParams <- list()
      headerParams <- c()

      queryParams['startTime'] <- start.time

      queryParams['endTime'] <- end.time

      queryParams['limit'] <- limit

      queryParams['page'] <- page

      queryParams['recvWindow'] <- recv.window

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

      body <- NULL
      urlPath <- "/sapi/v1/nft/history/withdraw"
      # 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, "InlineResponse200139", 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)
      }
    },
    SapiV1NftUserGetAssetGet = function(limit=NULL, page=NULL, recv.window=NULL, ...){
      apiResponse <- self$SapiV1NftUserGetAssetGetWithHttpInfo(limit, page, 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
      }
    },

    SapiV1NftUserGetAssetGetWithHttpInfo = function(limit=NULL, page=NULL, recv.window=NULL, ...){
      args <- list(...)
      queryParams <- list()
      headerParams <- c()

      queryParams['limit'] <- limit

      queryParams['page'] <- page

      queryParams['recvWindow'] <- recv.window

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

      body <- NULL
      urlPath <- "/sapi/v1/nft/user/getAsset"
      # 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, "InlineResponse200140", 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.