diff --git a/R/impl_account_sub_account.R b/R/impl_account_sub_account.R index ccdcec5c..93e96f95 100644 --- a/R/impl_account_sub_account.R +++ b/R/impl_account_sub_account.R @@ -58,17 +58,10 @@ box::use( #' @param remarks Character string (optional); remarks or notes about the sub-account (1–24 characters if provided). #' #' @return Promise resolving to a `data.table` containing sub-account details, including: -#' - `userId` (character): Unique identifier of the master account. -#' - `uid` (integer): Unique identifier for the sub-account. +#' - `uid` (numeric): Unique identifier for the sub-account. #' - `subName` (character): Name of the sub-account. -#' - `status` (integer): Current status of the sub-account. -#' - `type` (integer): Type of sub-account. +#' - `remarks` (character): Remarks or notes associated with the sub-account. #' - `access` (character): Permission type granted to the sub-account. -#' - `createdAt` (integer): Timestamp of creation in milliseconds. -#' - `remarks` (character): Any provided remarks or notes. -#' - `tradeTypes` (list): Array of available trade types for the sub-account. -#' - `openedTradeTypes` (list): Array of currently open trade types. -#' - `hostedStatus` (character or NULL): Hosted status of the sub-account. #' #' ## Details #' @@ -92,6 +85,10 @@ box::use( #' ### Response Schema #' - `code` (string): Status code, where `"200000"` indicates success. #' - `data` (object): Contains pagination metadata and an `items` array with the sub-account details. +#' - `uid` (integer): Unique identifier for the sub-account. +#' - `subName` (string): Name of the sub-account. +#' - `remarks` (string): Remarks or notes associated with the sub-account. +#' - `access` (string): Permission type granted to the sub-account. #' #' **Example JSON Response**: #' ```json @@ -169,9 +166,8 @@ add_subaccount_impl <- coro::async(function( access = c("Spot", "Futures", "Margin"), remarks = NULL ) { - access <- rlang::arg_match(access) + access <- rlang::arg_match0(access, values = c("Spot", "Futures", "Margin")) tryCatch({ - endpoint <- "/api/v2/sub/user/created" method <- "POST" body_list <- list( @@ -186,9 +182,9 @@ add_subaccount_impl <- coro::async(function( headers <- await(build_headers(method, endpoint, body, keys)) url <- paste0(base_url, endpoint) response <- httr::POST(url, headers, body = body, encode = "raw", httr::timeout(3)) - saveRDS(response, "./api-responses/impl_account_sub_account/response-add_subaccount_impl.ignore.Rds") + # saveRDS(response, "../../api-responses/impl_account_sub_account/response-add_subaccount_impl.ignore.Rds") parsed_response <- process_kucoin_response(response, url) - saveRDS(parsed_response, "./api-responses/impl_account_sub_account/parsed_response-add_subaccount_impl.Rds") + # saveRDS(parsed_response, "../../api-responses/impl_account_sub_account/parsed_response-add_subaccount_impl.Rds") return(data.table::as.data.table(parsed_response$data)) }, error = function(e) { rlang::abort(paste("Error in add_subaccount_impl:", conditionMessage(e))) diff --git a/scripts/tests-manual/run-single_test.R b/scripts/tests-manual/run-single_test.R index 3b6613d4..92458a41 100644 --- a/scripts/tests-manual/run-single_test.R +++ b/scripts/tests-manual/run-single_test.R @@ -16,6 +16,12 @@ box::use( get_deposit_addresses_v3_impl, get_deposit_history_impl ], + ../../R/impl_account_sub_account[ + add_subaccount_impl, + get_subaccount_list_summary_impl, + get_subaccount_detail_balance_impl, + get_subaccount_spot_v2_impl + ], ../../R/utils[get_api_keys, get_base_url], ../../R/utils_time_convert_kucoin[time_convert_from_kucoin, time_convert_to_kucoin], coro[async, await], @@ -28,19 +34,16 @@ main_async <- async(function() { keys <- get_api_keys() base_url <- get_base_url() - # Example 1: Using lubridate datetime objects directly - cat("\n--- Example 1: Using datetime objects ---\n") - history1 <- await(get_deposit_history_impl( + # 1. Add a subaccount + subaccount <- await(add_subaccount_impl( keys = keys, base_url = base_url, - currency = "BTC", - status = "SUCCESS", - startAt = lubridate::now() - lubridate::years(3), - endAt = lubridate::now(), - page_size = 50 + password = "some69superComplexS3cr3tP@ssw0rd", + subName = "rtradebot6971469", + access = "Spot", + remarks = "Some super genius remark" )) - cat("\nDeposit History for BTC (using datetime objects):\n") - print(history1) + print(subaccount) }) # Run the main async function