Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit c5edbe8

Browse files
update remove stat extra fields
1 parent 95082ff commit c5edbe8

File tree

4 files changed

+12
-53
lines changed

4 files changed

+12
-53
lines changed

‎etherscan-sample/src/main/java/jfyg/etherscan/helloetherescan/SampleActivity.kt‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,10 @@ class SampleActivity : AppCompatActivity() {
3232
fab.setOnClickListener {
3333

3434
//stat test
35-
stat.getLastPriceInBtc()
35+
stat.getEtherStatistics()
3636
.observeOn(AndroidSchedulers.mainThread())
3737
.subscribeBy(
38-
onSuccess = { Log.d(TAG, "The current price of Ether in Btc: $it") },
38+
onSuccess = { Log.d(TAG, "The current price of Ether in Btc: ${it.ethUsd}") },
3939
onError = { Log.d(TAG, "error receiving stat") })
4040

4141

‎etherscanapi/src/main/java/jfyg/data/stat/Stats.kt‎

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package jfyg.data.stat
22

33
import io.reactivex.Single
4+
import jfyg.data.StatPrice
45
import jfyg.network.queries.ApiQuery
56
import jfyg.utils.ETH_PRICE
67
import jfyg.utils.ETH_SUPPLY
@@ -28,24 +29,9 @@ class Stats : StatsContract {
2829
override fun getTotalSupplyInWei(): Single<Double> = supplyQuery.map { it.result?.toDouble()?.div(wei) }
2930

3031
/**
31-
* Get ETHER LastPrice Price in btc
32+
* Get Ether Statistics
3233
*/
33-
override fun getLastPriceInUsd(): Single<Float> = priceQuery.map { it.result?.ethUsd?.toFloat() }
34-
35-
/**
36-
* Return timestamp
37-
*/
38-
override fun getEthTimestamp(): Single<Long> = priceQuery.map { it.result?.ethUsdTimestamp?.toLong() }
39-
40-
/**
41-
* Get ETHER LastPrice Price in usd
42-
*/
43-
override fun getLastPriceInBtc(): Single<Float> = priceQuery.map { it.result?.ethBtcTimestamp?.toFloat() }
44-
45-
/**
46-
* Return timestamp
47-
*/
48-
override fun getBtcTimestamp(): Single<Long> = priceQuery.map { it.result?.ethBtcTimestamp?.toLong() }
34+
override fun getEtherStatistics(): Single<StatPrice> = priceQuery.map { it.result }
4935

5036
/**
5137
* Return network status

‎etherscanapi/src/main/java/jfyg/data/stat/StatsContract.kt‎

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package jfyg.data.stat
22

33
import io.reactivex.Single
4+
import jfyg.data.StatPrice
45

56
/**
67
* https://etherscan.io/apis#stats
@@ -18,24 +19,9 @@ internal interface StatsContract {
1819
fun getTotalSupplyInWei(): Single<Double>
1920

2021
/**
21-
* Get ETHER LastPrice Price in btc
22+
* Get ETHER statistics
2223
*/
23-
fun getLastPriceInBtc(): Single<Float>
24-
25-
/**
26-
* Return timestamp
27-
*/
28-
fun getBtcTimestamp(): Single<Long>
29-
30-
/**
31-
* Get ETHER LastPrice Price in usd
32-
*/
33-
fun getLastPriceInUsd(): Single<Float>
34-
35-
/**
36-
* Return timestamp
37-
*/
38-
fun getEthTimestamp(): Single<Long>
24+
fun getEtherStatistics(): Single<StatPrice>
3925

4026
/**
4127
* Return network status

‎etherscanapi/src/test/java/jfyg/data/stat/StatsTest.kt‎

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -61,33 +61,20 @@ internal class StatsTest {
6161
}
6262

6363
@Test
64-
fun getLastPriceInUsd() {
64+
fun getEtherStatistics() {
6565
val response = gson.fromJson(inputPrice, StatPriceResponse::class.java)
6666
assertEquals("377.67", response.result?.ethUsd)
67-
}
68-
69-
@Test
70-
fun getEthTimestamp() {
71-
val response = gson.fromJson(inputPrice, StatPriceResponse::class.java)
72-
assertEquals("1523064526", response.result?.ethUsdTimestamp)
73-
}
74-
75-
@Test
76-
fun getLastPriceInBtc() {
77-
val response = gson.fromJson(inputPrice, StatPriceResponse::class.java)
7867
assertEquals("0.0557", response.result?.ethBtc)
79-
}
80-
81-
@Test
82-
fun getBtcTimestamp() {
83-
val response = gson.fromJson(inputPrice, StatPriceResponse::class.java)
68+
assertEquals("1523064526", response.result?.ethUsdTimestamp)
8469
assertEquals("1523064523", response.result?.ethBtcTimestamp)
70+
8571
}
8672

8773
@Test
8874
fun networkStatusIsDown() {
8975
val response = gson.fromJson(inputBadResponse, BaseResponse::class.java)
9076
assertEquals("0", response.status)
77+
9178
}
9279

9380
@Test

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /