Compare commits
No commits in common. "1906a24343e3cc22f7a28e1c5b8ee4b6336167d8" and "ee74cf0cc472912844454195608518ccb61cc083" have entirely different histories.
1906a24343
...
ee74cf0cc4
13 changed files with 42 additions and 67 deletions
2
.idea/copyright/Erik_s_Copyright_Notice.xml
generated
2
.idea/copyright/Erik_s_Copyright_Notice.xml
generated
|
@ -1,6 +1,6 @@
|
||||||
<component name="CopyrightManager">
|
<component name="CopyrightManager">
|
||||||
<copyright>
|
<copyright>
|
||||||
<option name="notice" value="&#36;file.fileName Copyright 2021-&#36;today.year Erik C. Thauvin (erik@thauvin.net) Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. Neither the name of this project nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." />
|
<option name="notice" value="&#36;file.fileName Copyright (c) 2021-&#36;today.year, Erik C. Thauvin (erik@thauvin.net) All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. Neither the name of this project nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." />
|
||||||
<option name="myName" value="Erik's Copyright Notice" />
|
<option name="myName" value="Erik's Copyright Notice" />
|
||||||
</copyright>
|
</copyright>
|
||||||
</component>
|
</component>
|
2
.idea/kotlinc.xml
generated
2
.idea/kotlinc.xml
generated
|
@ -1,6 +1,6 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project version="4">
|
<project version="4">
|
||||||
<component name="KotlinJpsPluginSettings">
|
<component name="KotlinJpsPluginSettings">
|
||||||
<option name="version" value="1.8.0" />
|
<option name="version" value="1.7.20" />
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
5
.idea/misc.xml
generated
5
.idea/misc.xml
generated
|
@ -4,8 +4,5 @@
|
||||||
<component name="FrameworkDetectionExcludesConfiguration">
|
<component name="FrameworkDetectionExcludesConfiguration">
|
||||||
<file type="web" url="file://$PROJECT_DIR$" />
|
<file type="web" url="file://$PROJECT_DIR$" />
|
||||||
</component>
|
</component>
|
||||||
<component name="PDMPlugin">
|
<component name="ProjectRootManager" version="2" languageLevel="JDK_11" project-jdk-name="18" project-jdk-type="JavaSDK" />
|
||||||
<option name="skipTestSources" value="false" />
|
|
||||||
</component>
|
|
||||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_11" project-jdk-name="19" project-jdk-type="JavaSDK" />
|
|
||||||
</project>
|
</project>
|
|
@ -1,4 +1,5 @@
|
||||||
Copyright 2021-2023 Erik C. Thauvin (erik@thauvin.net)
|
Copyright (c) 2021-2022, Erik C. Thauvin (erik@thauvin.net)
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without
|
Redistribution and use in source and binary forms, with or without
|
||||||
modification, are permitted provided that the following conditions are met:
|
modification, are permitted provided that the following conditions are met:
|
||||||
|
|
15
README.md
15
README.md
|
@ -1,16 +1,10 @@
|
||||||
[](https://opensource.org/licenses/BSD-3-Clause)
|
[](https://opensource.org/licenses/BSD-3-Clause) [](https://github.com/ethauvin/cryptoprice/releases/latest) [](https://maven-badges.herokuapp.com/maven-central/net.thauvin.erik/cryptoprice) <!-- [](https://oss.sonatype.org/content/repositories/snapshots/net/thauvin/erik/cryptoprice/) -->
|
||||||
[](https://kotlinlang.org/)
|
|
||||||
[](https://oss.sonatype.org/content/repositories/snapshots/net/thauvin/erik/cryptoprice/)
|
|
||||||
[](https://github.com/ethauvin/cryptoprice/releases/latest)
|
|
||||||
[](https://maven-badges.herokuapp.com/maven-central/net.thauvin.erik/cryptoprice)
|
|
||||||
|
|
||||||
[](https://sonarcloud.io/dashboard?id=ethauvin_cryptoprice)
|
[](https://sonarcloud.io/dashboard?id=ethauvin_cryptoprice) [](https://github.com/ethauvin/cryptoprice/actions/workflows/gradle.yml) [](https://circleci.com/gh/ethauvin/cryptoprice/tree/master)
|
||||||
[](https://github.com/ethauvin/cryptoprice/actions/workflows/gradle.yml)
|
|
||||||
[](https://circleci.com/gh/ethauvin/cryptoprice/tree/master)
|
|
||||||
|
|
||||||
# Retrieve cryptocurrencies current (buy, sell or spot) prices
|
# Retrieve cryptocurrencies current (buy, sell or spot) prices
|
||||||
|
|
||||||
A simple implementation of the prices [Coinbase Public API](https://docs.cloud.coinbase.com/sign-in-with-coinbase/docs/api-prices).
|
A simple Kotlin/Java/Android implementation of the prices [Coinbase Public API](https://docs.cloud.coinbase.com/sign-in-with-coinbase/docs/api-prices).
|
||||||
|
|
||||||
## Examples (TL;DR)
|
## Examples (TL;DR)
|
||||||
|
|
||||||
|
@ -38,7 +32,6 @@ To use with [Gradle](https://gradle.org/), include the following dependency in y
|
||||||
```gradle
|
```gradle
|
||||||
repositories {
|
repositories {
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
maven { url = uri("https://oss.sonatype.org/content/repositories/snapshots") } // only needed for SNAPSHOT
|
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
|
@ -92,7 +85,7 @@ val euro = CryptoPrice("BTC", "EUR", 23456.78.toBigDecimal())
|
||||||
println(euro.toCurrency()) // €23,456.78
|
println(euro.toCurrency()) // €23,456.78
|
||||||
|
|
||||||
val krone = CryptoPrice("BTC", "DKK", 123456.78.toBigDecimal())
|
val krone = CryptoPrice("BTC", "DKK", 123456.78.toBigDecimal())
|
||||||
println(krone.toCurrency(Locale.Builder().setLanguage("da").setRegion("DK").build())) // 123.456,78 kr.
|
println(krone.toCurrency(Locale("da", "DK"))) // 123.456,78 kr.
|
||||||
```
|
```
|
||||||
|
|
||||||
##### JSON
|
##### JSON
|
||||||
|
|
|
@ -7,22 +7,22 @@ import org.gradle.api.tasks.testing.logging.TestLogEvent
|
||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
id("application")
|
id("application")
|
||||||
id("com.github.ben-manes.versions") version "0.44.0"
|
id("com.github.ben-manes.versions") version "0.42.0"
|
||||||
id("io.gitlab.arturbosch.detekt") version "1.22.0"
|
id("io.gitlab.arturbosch.detekt") version "1.21.0"
|
||||||
id("java")
|
id("java")
|
||||||
id("maven-publish")
|
id("maven-publish")
|
||||||
id("org.jetbrains.dokka") version "1.7.20"
|
id("org.jetbrains.dokka") version "1.7.10"
|
||||||
id("org.jetbrains.kotlinx.kover") version "0.6.1"
|
id("org.jetbrains.kotlinx.kover") version "0.6.1"
|
||||||
id("org.sonarqube") version "3.5.0.2730"
|
id("org.sonarqube") version "3.4.0.2513"
|
||||||
id("signing")
|
id("signing")
|
||||||
kotlin("jvm") version "1.8.0"
|
kotlin("jvm") version "1.7.20"
|
||||||
}
|
}
|
||||||
|
|
||||||
defaultTasks(ApplicationPlugin.TASK_RUN_NAME)
|
defaultTasks(ApplicationPlugin.TASK_RUN_NAME)
|
||||||
|
|
||||||
description = "Retrieve cryptocurrencies prices"
|
description = "Retrieve cryptocurrencies prices."
|
||||||
group = "net.thauvin.erik"
|
group = "net.thauvin.erik"
|
||||||
version = "1.0.1-SNAPSHOT"
|
version = "1.0.0"
|
||||||
|
|
||||||
val deployDir = "deploy"
|
val deployDir = "deploy"
|
||||||
val gitHub = "ethauvin/$name"
|
val gitHub = "ethauvin/$name"
|
||||||
|
@ -168,8 +168,8 @@ publishing {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
scm {
|
scm {
|
||||||
connection.set("scm:git://github.com/$gitHub.git")
|
connection.set("scm:git:git://github.com/$gitHub.git")
|
||||||
developerConnection.set("scm:git@github.com:$gitHub.git")
|
developerConnection.set("scm:git:git@github.com:$gitHub.git")
|
||||||
url.set(mavenUrl)
|
url.set(mavenUrl)
|
||||||
}
|
}
|
||||||
issueManagement {
|
issueManagement {
|
||||||
|
|
|
@ -2,8 +2,8 @@ import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
|
||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
id("application")
|
id("application")
|
||||||
id("com.github.ben-manes.versions") version "0.44.0"
|
id("com.github.ben-manes.versions") version "0.42.0"
|
||||||
kotlin("jvm") version "1.8.0"
|
kotlin("jvm") version "1.7.20"
|
||||||
}
|
}
|
||||||
|
|
||||||
// ./gradlew run
|
// ./gradlew run
|
||||||
|
@ -20,7 +20,7 @@ repositories {
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation("net.thauvin.erik:cryptoprice:1.1.0-SNAPSHOT")
|
implementation("net.thauvin.erik:cryptoprice:1.0.0")
|
||||||
implementation("org.json:json:20220924")
|
implementation("org.json:json:20220924")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-bin.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
|
|
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
|
@ -1,5 +1,5 @@
|
||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-bin.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
|
|
14
pom.xml
14
pom.xml
|
@ -8,9 +8,9 @@
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<groupId>net.thauvin.erik</groupId>
|
<groupId>net.thauvin.erik</groupId>
|
||||||
<artifactId>cryptoprice</artifactId>
|
<artifactId>cryptoprice</artifactId>
|
||||||
<version>1.0.1-SNAPSHOT</version>
|
<version>1.0.0</version>
|
||||||
<name>cryptoprice</name>
|
<name>cryptoprice</name>
|
||||||
<description>Retrieve cryptocurrencies prices</description>
|
<description>Retrieve cryptocurrencies prices.</description>
|
||||||
<url>https://github.com/ethauvin/cryptoprice</url>
|
<url>https://github.com/ethauvin/cryptoprice</url>
|
||||||
<licenses>
|
<licenses>
|
||||||
<license>
|
<license>
|
||||||
|
@ -27,8 +27,8 @@
|
||||||
</developer>
|
</developer>
|
||||||
</developers>
|
</developers>
|
||||||
<scm>
|
<scm>
|
||||||
<connection>scm:git://github.com/ethauvin/cryptoprice.git</connection>
|
<connection>scm:git:git://github.com/ethauvin/cryptoprice.git</connection>
|
||||||
<developerConnection>scm:git@github.com:ethauvin/cryptoprice.git</developerConnection>
|
<developerConnection>scm:git:git@github.com:ethauvin/cryptoprice.git</developerConnection>
|
||||||
<url>https://github.com/ethauvin/cryptoprice</url>
|
<url>https://github.com/ethauvin/cryptoprice</url>
|
||||||
</scm>
|
</scm>
|
||||||
<issueManagement>
|
<issueManagement>
|
||||||
|
@ -40,7 +40,7 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.jetbrains.kotlin</groupId>
|
<groupId>org.jetbrains.kotlin</groupId>
|
||||||
<artifactId>kotlin-bom</artifactId>
|
<artifactId>kotlin-bom</artifactId>
|
||||||
<version>1.8.0</version>
|
<version>1.7.10</version>
|
||||||
<type>pom</type>
|
<type>pom</type>
|
||||||
<scope>import</scope>
|
<scope>import</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
@ -50,7 +50,7 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.jetbrains.kotlin</groupId>
|
<groupId>org.jetbrains.kotlin</groupId>
|
||||||
<artifactId>kotlin-stdlib-jdk8</artifactId>
|
<artifactId>kotlin-stdlib-jdk8</artifactId>
|
||||||
<version>1.8.0</version>
|
<version>1.7.10</version>
|
||||||
<scope>runtime</scope>
|
<scope>runtime</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
|
@ -62,7 +62,7 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.json</groupId>
|
<groupId>org.json</groupId>
|
||||||
<artifactId>json</artifactId>
|
<artifactId>json</artifactId>
|
||||||
<version>20220924</version>
|
<version>20220320</version>
|
||||||
<scope>runtime</scope>
|
<scope>runtime</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
/*
|
/*
|
||||||
* CryptoException.kt
|
* CryptoException.kt
|
||||||
*
|
*
|
||||||
* Copyright 2021-2023 Erik C. Thauvin (erik@thauvin.net)
|
* Copyright (c) 2021-2022, Erik C. Thauvin (erik@thauvin.net)
|
||||||
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions are met:
|
* modification, are permitted provided that the following conditions are met:
|
||||||
|
@ -36,7 +37,6 @@ package net.thauvin.erik.crypto
|
||||||
*/
|
*/
|
||||||
class CryptoException @JvmOverloads constructor(
|
class CryptoException @JvmOverloads constructor(
|
||||||
var statusCode: Int = NO_STATUS,
|
var statusCode: Int = NO_STATUS,
|
||||||
var id: String,
|
|
||||||
message: String,
|
message: String,
|
||||||
cause: Throwable? = null
|
cause: Throwable? = null
|
||||||
) : Exception(message, cause) {
|
) : Exception(message, cause) {
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
/*
|
/*
|
||||||
* CryptoPrice.kt
|
* CryptoPrice.kt
|
||||||
*
|
*
|
||||||
* Copyright 2021-2023 Erik C. Thauvin (erik@thauvin.net)
|
* Copyright (c) 2021-2022, Erik C. Thauvin (erik@thauvin.net)
|
||||||
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions are met:
|
* modification, are permitted provided that the following conditions are met:
|
||||||
|
@ -72,9 +73,9 @@ open class CryptoPrice(val base: String, val currency: String, val amount: BigDe
|
||||||
return CryptoPrice(getString("base"), getString("currency"), getString("amount").toBigDecimal())
|
return CryptoPrice(getString("base"), getString("currency"), getString("amount").toBigDecimal())
|
||||||
}
|
}
|
||||||
} catch (e: NumberFormatException) {
|
} catch (e: NumberFormatException) {
|
||||||
throw CryptoException(id = "convert_error", message = "Could not convert amount to number.", cause = e)
|
throw CryptoException(message = "Could not convert amount to number.", cause = e)
|
||||||
} catch (e: JSONException) {
|
} catch (e: JSONException) {
|
||||||
throw CryptoException(id = "parse_error", message = "Could not parse price data.", cause = e)
|
throw CryptoException(message = "Could not parse price data.", cause = e)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -100,24 +101,17 @@ open class CryptoPrice(val base: String, val currency: String, val amount: BigDe
|
||||||
|
|
||||||
val request = Request.Builder().url(httpUrl).build()
|
val request = Request.Builder().url(httpUrl).build()
|
||||||
val response = client.newCall(request).execute()
|
val response = client.newCall(request).execute()
|
||||||
val body = response.body?.string() ?: throw CryptoException(
|
val body = response.body?.string() ?: throw CryptoException(response.code, "Empty response.")
|
||||||
response.code,
|
|
||||||
id = "empty_response",
|
|
||||||
message = "Empty response."
|
|
||||||
)
|
|
||||||
try {
|
try {
|
||||||
val json = JSONObject(body)
|
val json = JSONObject(body)
|
||||||
if (response.isSuccessful) {
|
if (response.isSuccessful) {
|
||||||
return body
|
return body
|
||||||
} else {
|
} else {
|
||||||
val data = json.getJSONArray("errors")
|
val data = json.getJSONArray("errors")
|
||||||
throw CryptoException(
|
throw CryptoException(response.code, data.getJSONObject(0).getString("message"))
|
||||||
response.code, data.getJSONObject(0).getString("id"),
|
|
||||||
data.getJSONObject(0).getString("message")
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
} catch (e: JSONException) {
|
} catch (e: JSONException) {
|
||||||
throw CryptoException(response.code, id = "parse_error", "Could not parse data.", e)
|
throw CryptoException(response.code, "Could not parse data.", e)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
/*
|
/*
|
||||||
* CryptoPriceTest.kt
|
* CryptoPriceTest.kt
|
||||||
*
|
*
|
||||||
* Copyright 2021-2023 Erik C. Thauvin (erik@thauvin.net)
|
* Copyright (c) 2021-2022, Erik C. Thauvin (erik@thauvin.net)
|
||||||
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions are met:
|
* modification, are permitted provided that the following conditions are met:
|
||||||
|
@ -133,13 +134,6 @@ class CryptoPriceTest {
|
||||||
block = { spotPrice("FOO") }
|
block = { spotPrice("FOO") }
|
||||||
)
|
)
|
||||||
|
|
||||||
try {
|
|
||||||
spotPrice("BAR")
|
|
||||||
} catch (e: CryptoException) {
|
|
||||||
assertThat(e.id, "spotPrice(bar) error id").isEqualTo("not_found")
|
|
||||||
assertThat(e.message, "spotPrice(bar) error message").isEqualTo("Invalid base currency")
|
|
||||||
}
|
|
||||||
|
|
||||||
assertFailsWith(
|
assertFailsWith(
|
||||||
message = "buyPrice(BTC,BAR)",
|
message = "buyPrice(BTC,BAR)",
|
||||||
exceptionClass = CryptoException::class,
|
exceptionClass = CryptoException::class,
|
||||||
|
@ -189,11 +183,7 @@ class CryptoPriceTest {
|
||||||
assertEquals("A$12,345.60", aud.toCurrency(), "CryptoPrice(LTC,AUD)")
|
assertEquals("A$12,345.60", aud.toCurrency(), "CryptoPrice(LTC,AUD)")
|
||||||
|
|
||||||
val dk = CryptoPrice("BCH", "DKK", d)
|
val dk = CryptoPrice("BCH", "DKK", d)
|
||||||
assertEquals(
|
assertEquals("12.345,60 kr.", dk.toCurrency(Locale("da", "DK")), "CryptoPrice(BCH,DKK)")
|
||||||
"12.345,60 kr.", dk.toCurrency(
|
|
||||||
Locale.Builder().setLanguage("da").setRegion("DK").build()
|
|
||||||
), "CryptoPrice(BCH,DKK)"
|
|
||||||
)
|
|
||||||
|
|
||||||
val jp = CryptoPrice("BTC", "JPY", d)
|
val jp = CryptoPrice("BTC", "JPY", d)
|
||||||
assertEquals("¥12,345.60", jp.toCurrency(Locale.JAPAN), "CryptoPrice(BTC,JPY)")
|
assertEquals("¥12,345.60", jp.toCurrency(Locale.JAPAN), "CryptoPrice(BTC,JPY)")
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue