Skip to content

Commit 7105def

Browse files
Clean up.
1 parent 850bb01 commit 7105def

File tree

4 files changed

+27
-21
lines changed

4 files changed

+27
-21
lines changed

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@
33
.DS_Store
44
deprecated/
55

6+
*.ignore
7+
*.ignore.*
8+
9+
.Rprofile
10+
611
# sensitive files and tokens
712
*.sensitive.*
813

R/get_account_balances.R

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,11 @@ get_account_balances <- function(currency = NULL, type = NULL) {
7070
# tidy the parsed data
7171
results <- data.table::data.table(parsed$data, check.names = FALSE)
7272

73+
if (nrow(results) == 0) {
74+
message("No assets found.")
75+
return(results)
76+
}
77+
7378
results <- results[, c("type", "id", "currency", "balance", "available", "holds")]
7479

7580
# results[, 4:6] <- lapply(results[, 4:6], as.numeric)

R/helpers.R

Lines changed: 17 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
analyze_response <- function(x) {
44
# stop if not return json
55
if (httr::http_type(x) != "application/json") {
6-
stop("Server not responded correctly")
6+
rlang::abort("Server not responded correctly")
77
}
88

99
# stop if server responding with error
@@ -49,26 +49,26 @@ prep_frequency <- function(x) {
4949
}
5050

5151
lkp <- data.table::fread(
52-
'"freq","formatted"
53-
"1 minute","1min"
54-
"3 minutes","3min"
55-
"5 minutes","5min"
56-
"15 minutes","15min"
57-
"30 minutes","30min"
58-
"1 hour","1hour"
59-
"2 hours","2hour"
60-
"4 hours","4hour"
61-
"6 hours","6hour"
62-
"8 hours","8hour"
63-
"12 hours","12hour"
64-
"1 day","1day"
65-
"1 week","1week"'
52+
'"freq", "formatted"
53+
"1 minute", "1min"
54+
"3 minutes", "3min"
55+
"5 minutes", "5min"
56+
"15 minutes", "15min"
57+
"30 minutes", "30min"
58+
"1 hour", "1hour"
59+
"2 hours", "2hour"
60+
"4 hours", "4hour"
61+
"6 hours", "6hour"
62+
"8 hours", "8hour"
63+
"12 hours", "12hour"
64+
"1 day", "1day"
65+
"1 week", "1week"'
6666
)
6767

6868
x <- lkp[freq == x, ]$formatted
6969

7070
if (length(x) == 0) {
71-
rlang::abort("Unsupported frequency! See function documentation for helps")
71+
rlang::abort("Unsupported frequency! See function documentation for help")
7272
}
7373

7474
return(x)
@@ -130,7 +130,6 @@ prep_datetime_range <- function(from, to, frequency) {
130130
}
131131

132132
prep_query_strings <- function(queries) {
133-
134133
# convert to query strings
135134
if (length(queries) > 0) {
136135
results <- c()
@@ -139,6 +138,7 @@ prep_query_strings <- function(queries) {
139138
result <- paste(i, queries[[i]], sep = "=")
140139
results <- c(results, result)
141140
}
141+
142142
results <- paste0("?", paste0(results, collapse = "&"))
143143
} else {
144144
results <- ""
@@ -183,9 +183,6 @@ get_paths <- function(x, type = "path", append = NULL) {
183183
"deposit-addresses", "/api/v2/deposit-addresses", "api/v2/deposit-addresses"'
184184
)
185185

186-
# convert to data frame
187-
# lkp <- as.data.frame(lkp)
188-
189186
# get specified endpoint
190187
results <- lkp[x == this.x, ][[type]]
191188

R/utils.R

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
#' @export
1717

1818
get_kucoin_time <- function(raw = FALSE) {
19-
2019
# get server response
2120
response <- httr::GET(
2221
url = get_base_url(),

0 commit comments

Comments
 (0)