Compare commits
2 commits
7fb928fbc6
...
257cec56b4
Author | SHA1 | Date | |
---|---|---|---|
257cec56b4 | |||
7a658c20e0 |
16 changed files with 43 additions and 43 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -64,7 +64,6 @@ dist/
|
|||
ehthumbs.db
|
||||
fabric.properties
|
||||
gen/
|
||||
gradle.properties
|
||||
hs_err_pid*
|
||||
kobaltBuild
|
||||
kobaltw*-test
|
||||
|
|
2
.idea/kotlinc.xml
generated
2
.idea/kotlinc.xml
generated
|
@ -1,6 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="KotlinJpsPluginSettings">
|
||||
<option name="version" value="1.8.10" />
|
||||
<option name="version" value="1.9.10" />
|
||||
</component>
|
||||
</project>
|
1
.idea/misc.xml
generated
1
.idea/misc.xml
generated
|
@ -1,4 +1,3 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
||||
<component name="FrameworkDetectionExcludesConfiguration">
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
[](https://opensource.org/licenses/BSD-3-Clause)
|
||||
[](https://kotlinlang.org/)
|
||||
[](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://central.sonatype.com/artifact/net.thauvin.erik/cryptoprice)
|
||||
|
||||
[](https://sonarcloud.io/dashboard?id=ethauvin_cryptoprice)
|
||||
[](https://github.com/ethauvin/cryptoprice/actions/workflows/gradle.yml)
|
||||
|
|
|
@ -7,15 +7,15 @@ import org.gradle.api.tasks.testing.logging.TestLogEvent
|
|||
|
||||
plugins {
|
||||
id("application")
|
||||
id("com.github.ben-manes.versions") version "0.47.0"
|
||||
id("io.gitlab.arturbosch.detekt") version "1.23.0"
|
||||
id("com.github.ben-manes.versions") version "0.48.0"
|
||||
id("io.gitlab.arturbosch.detekt") version "1.23.1"
|
||||
id("java")
|
||||
id("maven-publish")
|
||||
id("org.jetbrains.dokka") version "1.8.20"
|
||||
id("org.jetbrains.kotlinx.kover") version "0.7.2"
|
||||
id("org.sonarqube") version "4.2.1.3168"
|
||||
id("org.jetbrains.dokka") version "1.9.0"
|
||||
id("org.jetbrains.kotlinx.kover") version "0.7.3"
|
||||
id("org.sonarqube") version "4.3.1.3277"
|
||||
id("signing")
|
||||
kotlin("jvm") version "1.8.22"
|
||||
kotlin("jvm") version "1.9.10"
|
||||
}
|
||||
|
||||
defaultTasks(ApplicationPlugin.TASK_RUN_NAME)
|
||||
|
@ -49,7 +49,7 @@ dependencies {
|
|||
implementation("org.json:json:20230618")
|
||||
|
||||
testImplementation(kotlin("test"))
|
||||
testImplementation("com.willowtreeapps.assertk:assertk-jvm:0.26.1")
|
||||
testImplementation("com.willowtreeapps.assertk:assertk-jvm:0.27.0")
|
||||
}
|
||||
|
||||
application {
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
<SmellBaseline>
|
||||
<ManuallySuppressedIssues/>
|
||||
<CurrentIssues>
|
||||
<ID>NestedBlockDepth:CryptoPrice.kt$CryptoPrice.Companion$@JvmStatic @JvmOverloads @Throws(CryptoException::class, IOException::class) fun apiCall(paths: List<String>, params: Map<String, String> = emptyMap()): String</ID>
|
||||
<ID>ThrowsCount:CryptoPrice.kt$CryptoPrice.Companion$@JvmStatic @JvmOverloads @Throws(CryptoException::class, IOException::class) fun apiCall(paths: List<String>, params: Map<String, String> = emptyMap()): String</ID>
|
||||
</CurrentIssues>
|
||||
</SmellBaseline>
|
||||
|
|
|
@ -2,8 +2,8 @@ import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
|
|||
|
||||
plugins {
|
||||
id("application")
|
||||
id("com.github.ben-manes.versions") version "0.47.0"
|
||||
kotlin("jvm") version "1.8.10"
|
||||
id("com.github.ben-manes.versions") version "0.48.0"
|
||||
kotlin("jvm") version "1.9.10"
|
||||
}
|
||||
|
||||
// ./gradlew run
|
||||
|
@ -21,7 +21,7 @@ repositories {
|
|||
|
||||
dependencies {
|
||||
implementation("net.thauvin.erik:cryptoprice:1.0.1-SNAPSHOT")
|
||||
implementation("org.json:json:20230227")
|
||||
implementation("org.json:json:20230618")
|
||||
}
|
||||
|
||||
java {
|
||||
|
|
BIN
examples/gradle/wrapper/gradle-wrapper.jar
vendored
BIN
examples/gradle/wrapper/gradle-wrapper.jar
vendored
Binary file not shown.
|
@ -1,6 +1,7 @@
|
|||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-bin.zip
|
||||
networkTimeout=10000
|
||||
validateDistributionUrl=true
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
|
|
8
examples/gradlew
vendored
8
examples/gradlew
vendored
|
@ -83,7 +83,8 @@ done
|
|||
# This is normally unused
|
||||
# shellcheck disable=SC2034
|
||||
APP_BASE_NAME=${0##*/}
|
||||
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
|
||||
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
|
||||
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit
|
||||
|
||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||
MAX_FD=maximum
|
||||
|
@ -130,11 +131,14 @@ location of your Java installation."
|
|||
fi
|
||||
else
|
||||
JAVACMD=java
|
||||
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
if ! command -v java >/dev/null 2>&1
|
||||
then
|
||||
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
fi
|
||||
|
||||
# Increase the maximum file descriptors if we can.
|
||||
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
|
||||
|
|
0
gradle.properties
Normal file
0
gradle.properties
Normal file
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
Binary file not shown.
3
gradle/wrapper/gradle-wrapper.properties
vendored
3
gradle/wrapper/gradle-wrapper.properties
vendored
|
@ -1,6 +1,7 @@
|
|||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-bin.zip
|
||||
networkTimeout=10000
|
||||
validateDistributionUrl=true
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
|
|
8
gradlew
vendored
8
gradlew
vendored
|
@ -83,7 +83,8 @@ done
|
|||
# This is normally unused
|
||||
# shellcheck disable=SC2034
|
||||
APP_BASE_NAME=${0##*/}
|
||||
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
|
||||
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
|
||||
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit
|
||||
|
||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||
MAX_FD=maximum
|
||||
|
@ -130,11 +131,14 @@ location of your Java installation."
|
|||
fi
|
||||
else
|
||||
JAVACMD=java
|
||||
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
if ! command -v java >/dev/null 2>&1
|
||||
then
|
||||
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
fi
|
||||
|
||||
# Increase the maximum file descriptors if we can.
|
||||
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
|
||||
|
|
|
@ -110,11 +110,16 @@ open class CryptoPrice(val base: String, val currency: String, val amount: BigDe
|
|||
if (response.isSuccessful) {
|
||||
return body
|
||||
} else {
|
||||
if (json.has("errors")) {
|
||||
val data = json.getJSONArray("errors")
|
||||
throw CryptoException(
|
||||
response.code, data.getJSONObject(0).getString("id"),
|
||||
data.getJSONObject(0).getString("message")
|
||||
)
|
||||
} else {
|
||||
throw CryptoException(response.code, json.getString("error"),
|
||||
json.getString("message"))
|
||||
}
|
||||
}
|
||||
} catch (e: JSONException) {
|
||||
throw CryptoException(response.code, id = "parse_error", "Could not parse data.", e)
|
||||
|
|
|
@ -33,10 +33,8 @@ package net.thauvin.erik.crypto
|
|||
|
||||
import assertk.all
|
||||
import assertk.assertThat
|
||||
import assertk.assertions.contains
|
||||
import assertk.assertions.isEqualTo
|
||||
import assertk.assertions.isGreaterThan
|
||||
import assertk.assertions.isNotNull
|
||||
import assertk.assertions.prop
|
||||
import net.thauvin.erik.crypto.CryptoPrice.Companion.apiCall
|
||||
import net.thauvin.erik.crypto.CryptoPrice.Companion.buyPrice
|
||||
|
@ -126,20 +124,7 @@ class CryptoPriceTest {
|
|||
|
||||
@Test
|
||||
@Throws(CryptoException::class)
|
||||
fun testPrices() {
|
||||
assertFailsWith(
|
||||
message = "spotPrice(FOO)",
|
||||
exceptionClass = CryptoException::class,
|
||||
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")
|
||||
}
|
||||
|
||||
fun testNotFound() {
|
||||
assertFailsWith(
|
||||
message = "buyPrice(BTC,BAR)",
|
||||
exceptionClass = CryptoException::class,
|
||||
|
@ -151,7 +136,8 @@ class CryptoPriceTest {
|
|||
} catch (e: CryptoException) {
|
||||
assertThat(e, "sellPrice(FOOBAR)").all {
|
||||
prop(CryptoException::statusCode).isEqualTo(404)
|
||||
prop(CryptoException::message).isNotNull().contains("invalid", true)
|
||||
prop(CryptoException::message).isEqualTo("not found")
|
||||
prop(CryptoException::id).isEqualTo("not found")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue