-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
99 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
...l/src/main/kotlin/com/njkim/reactivecrypto/coineal/http/raw/CoinealRawAccountOperation.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package com.njkim.reactivecrypto.coineal.http.raw | ||
|
||
import com.njkim.reactivecrypto.coineal.model.CoinealApiResponse | ||
import com.njkim.reactivecrypto.coineal.model.CoinealBalance | ||
import com.njkim.reactivecrypto.coineal.model.CoinealBalanceWrapper | ||
import com.njkim.reactivecrypto.core.common.util.toEpochMilli | ||
import com.njkim.reactivecrypto.core.common.util.toMultiValueMap | ||
import org.springframework.web.reactive.function.client.WebClient | ||
import org.springframework.web.reactive.function.client.bodyToMono | ||
import reactor.core.publisher.Flux | ||
import java.time.ZonedDateTime | ||
|
||
/** | ||
Created by jay on 02/07/2019 | ||
**/ | ||
class CoinealRawAccountOperation( | ||
private val webClient: WebClient, | ||
private val accessKey: String, | ||
private val secretKey: String | ||
) { | ||
fun balance(): Flux<CoinealBalance> { | ||
var params = mapOf( | ||
"api_key" to accessKey, | ||
"time" to ZonedDateTime.now().toEpochMilli() | ||
) | ||
params = sign(params, secretKey) | ||
return webClient.get() | ||
.uri { | ||
it.path("/open/api/user/account") | ||
.queryParams(params.toMultiValueMap()) | ||
.build() | ||
} | ||
.retrieve() | ||
.bodyToMono<CoinealApiResponse<CoinealBalanceWrapper>>() | ||
.flatMapIterable { | ||
it.data.coinList | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
...e-crypto-coineal/src/main/kotlin/com/njkim/reactivecrypto/coineal/model/CoinealBalance.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package com.njkim.reactivecrypto.coineal.model | ||
|
||
/** | ||
Created by jay on 02/07/2019 | ||
**/ | ||
import com.fasterxml.jackson.annotation.JsonProperty | ||
import com.njkim.reactivecrypto.core.common.model.currency.Currency | ||
import java.math.BigDecimal | ||
|
||
class CoinealBalance( | ||
@get:JsonProperty("coin") | ||
val currency: Currency, | ||
|
||
@get:JsonProperty("normal") | ||
val normal: BigDecimal, | ||
|
||
@get:JsonProperty("locked") | ||
val locked: BigDecimal, | ||
|
||
@get:JsonProperty("btcValuatin") | ||
val btcValuatIn: BigDecimal | ||
) |
19 changes: 19 additions & 0 deletions
19
...o-coineal/src/main/kotlin/com/njkim/reactivecrypto/coineal/model/CoinealBalanceWrapper.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package com.njkim.reactivecrypto.coineal.model | ||
|
||
import com.fasterxml.jackson.annotation.JsonProperty | ||
import java.math.BigDecimal | ||
|
||
/** | ||
Created by jay on 02/07/2019 | ||
**/ | ||
data class CoinealBalanceWrapper( | ||
@JsonProperty("total_asset") | ||
val totalAsset: BigDecimal, | ||
@JsonProperty("coin_list") | ||
private val nullableCoinList: List<CoinealBalance>? | ||
) { | ||
val coinList: List<CoinealBalance> | ||
get() { | ||
return nullableCoinList ?: emptyList() | ||
} | ||
} |