|
| 1 | +module DepositLog |
| 2 | + |
| 3 | +export DepositLogQuery, |
| 4 | + DepositLogData, |
| 5 | + deposit_log |
| 6 | + |
| 7 | +using Serde |
| 8 | +using Dates, NanoDates, TimeZones |
| 9 | + |
| 10 | +using CryptoAPIs.Binance |
| 11 | +using CryptoAPIs: Maybe, APIsRequest |
| 12 | + |
| 13 | +@enum DepositStatus begin |
| 14 | + PENDING = 0 |
| 15 | + SUCCESS = 1 |
| 16 | + CREDITED_BUT_CANNOT_WITHDRAW = 6 |
| 17 | + WRONG_DEPOSIT = 7 |
| 18 | + WAITING_USER_CONFIRM = 8 |
| 19 | +end |
| 20 | + |
| 21 | +Base.@kwdef mutable struct DepositLogQuery <: BinancePrivateQuery |
| 22 | + coin::Maybe{String} = nothing |
| 23 | + endTime::Maybe{DateTime} = nothing |
| 24 | + limit::Maybe{Int64} = 1000 |
| 25 | + offset::Maybe{Int64} = nothing |
| 26 | + startTime::Maybe{DateTime} = nothing |
| 27 | + status::Maybe{DepositStatus} = nothing |
| 28 | + txId::Maybe{String} = nothing |
| 29 | + |
| 30 | + recvWindow::Maybe{Int64} = nothing |
| 31 | + timestamp::Maybe{DateTime} = nothing |
| 32 | + signature::Maybe{String} = nothing |
| 33 | +end |
| 34 | + |
| 35 | +function Serde.SerQuery.ser_type(::Type{<:DepositLogQuery}, x::DepositStatus)::Int64 |
| 36 | + return Int64(x) |
| 37 | +end |
| 38 | + |
| 39 | +struct DepositLogData <: BinanceData |
| 40 | + address::String |
| 41 | + addressTag::String |
| 42 | + amount::Float64 |
| 43 | + coin::String |
| 44 | + confirmTimes::String |
| 45 | + id::Int64 |
| 46 | + insertTime::NanoDate |
| 47 | + network::String |
| 48 | + status::DepositStatus |
| 49 | + transferType::Int64 |
| 50 | + txId::Maybe{String} |
| 51 | + unlockConfirm::Int64 |
| 52 | + walletType::Int64 |
| 53 | +end |
| 54 | + |
| 55 | +""" |
| 56 | + deposit_log(client::BinanceClient, query::DepositLogQuery) |
| 57 | + deposit_log(client::BinanceClient; kw...) |
| 58 | +
|
| 59 | +Fetch deposit history. |
| 60 | +
|
| 61 | +[`GET sapi/v1/capital/withdraw/history`](https://binance-docs.github.io/apidocs/spot/en/#deposit-history-supporting-network-user_data) |
| 62 | +
|
| 63 | +## Parameters: |
| 64 | +
|
| 65 | +| Parameter | Type | Required | Description | |
| 66 | +|:-----------|:--------------|:---------|:--------------| |
| 67 | +| coin | String | false | | |
| 68 | +| endTime | DateTime | false | | |
| 69 | +| limit | Int64 | false | Default: 1000 | |
| 70 | +| offset | Int64 | false | | |
| 71 | +| startTime | DateTime | false | | |
| 72 | +| status | DepositStatus | false | | |
| 73 | +| txId | String | false | | |
| 74 | +| recvWindow | Int64 | false | | |
| 75 | +| timestamp | DateTime | false | | |
| 76 | +| signature | String | false | | |
| 77 | +
|
| 78 | +## Code samples: |
| 79 | +
|
| 80 | +```julia |
| 81 | +using Serde |
| 82 | +using CryptoAPIs.Binance |
| 83 | +
|
| 84 | +binance_client = BinanceClient(; |
| 85 | + base_url = "https://api.binance.com", |
| 86 | + public_key = ENV["BINANCE_PUBLIC_KEY"], |
| 87 | + secret_key = ENV["BINANCE_SECRET_KEY"], |
| 88 | +) |
| 89 | +
|
| 90 | +result = Binance.Spot.deposit_log(binance_client) |
| 91 | +
|
| 92 | +to_pretty_json(result.result) |
| 93 | +``` |
| 94 | +
|
| 95 | +## Result: |
| 96 | +
|
| 97 | +```json |
| 98 | +[ |
| 99 | + { |
| 100 | + "id":769800519366885376, |
| 101 | + "amount":0.001, |
| 102 | + "coin":"BNB", |
| 103 | + "network":"BNB", |
| 104 | + "status":0, |
| 105 | + "address":"bnb136ns6lfw4zs5hg4n85vdthaad7hq5m4gtkgf23", |
| 106 | + "addressTag":"101764890", |
| 107 | + "txId":"98A3EA560C6B3336D348B6C83F0F95ECE4F1F5919E94BD006E5BF3BF264FACFC", |
| 108 | + "insertTime":"2022-08-26T05:52:26", |
| 109 | + "transferType":0, |
| 110 | + "confirmTimes":"1/1", |
| 111 | + "unlockConfirm":0, |
| 112 | + "walletType":0 |
| 113 | + }, |
| 114 | + ... |
| 115 | +] |
| 116 | +``` |
| 117 | +""" |
| 118 | +function deposit_log(client::BinanceClient, query::DepositLogQuery) |
| 119 | + return APIsRequest{Vector{DepositLogData}}("GET", "sapi/v1/capital/deposit/hisrec", query)(client) |
| 120 | +end |
| 121 | + |
| 122 | +function deposit_log(client::BinanceClient; kw...) |
| 123 | + return deposit_log(client, DepositLogQuery(; kw...)) |
| 124 | +end |
| 125 | + |
| 126 | +end |
0 commit comments