diff --git a/.idea/cryptoprice.iml b/.idea/cryptoprice.iml
new file mode 100644
index 0000000..d6ebd48
--- /dev/null
+++ b/.idea/cryptoprice.iml
@@ -0,0 +1,9 @@
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml
new file mode 100644
index 0000000..f243f08
--- /dev/null
+++ b/.idea/inspectionProfiles/Project_Default.xml
@@ -0,0 +1,36 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/modules.xml b/.idea/modules.xml
new file mode 100644
index 0000000..e18fafb
--- /dev/null
+++ b/.idea/modules.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/examples/build.gradle.kts b/examples/build.gradle.kts
index 5e36972..b653e56 100644
--- a/examples/build.gradle.kts
+++ b/examples/build.gradle.kts
@@ -6,6 +6,8 @@ plugins {
// ./gradlew run
// ./gradlew runJava
+// ./gradlew run --args="btc"
+// ./gradlew runJava --args="eth eur"
defaultTasks(ApplicationPlugin.TASK_RUN_NAME)
@@ -26,7 +28,7 @@ application {
tasks {
register("runJava") {
group = "application"
- main = "com.example.CryptoPriceSample"
+ mainClass.set("com.example.CryptoPriceSample")
classpath = sourceSets.main.get().runtimeClasspath
}
}
diff --git a/examples/gradle/wrapper/gradle-wrapper.jar b/examples/gradle/wrapper/gradle-wrapper.jar
index e708b1c..7454180 100644
Binary files a/examples/gradle/wrapper/gradle-wrapper.jar and b/examples/gradle/wrapper/gradle-wrapper.jar differ
diff --git a/examples/gradle/wrapper/gradle-wrapper.properties b/examples/gradle/wrapper/gradle-wrapper.properties
index 0f80bbf..69a9715 100644
--- a/examples/gradle/wrapper/gradle-wrapper.properties
+++ b/examples/gradle/wrapper/gradle-wrapper.properties
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-bin.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-7.1-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
diff --git a/examples/gradlew b/examples/gradlew
index 4f906e0..744e882 100755
--- a/examples/gradlew
+++ b/examples/gradlew
@@ -72,7 +72,7 @@ case "`uname`" in
Darwin* )
darwin=true
;;
- MINGW* )
+ MSYS* | MINGW* )
msys=true
;;
NONSTOP* )
diff --git a/examples/src/main/java/com/example/CryptoPriceSample.java b/examples/src/main/java/com/example/CryptoPriceSample.java
index 2855b6e..049257a 100644
--- a/examples/src/main/java/com/example/CryptoPriceSample.java
+++ b/examples/src/main/java/com/example/CryptoPriceSample.java
@@ -10,34 +10,39 @@ import java.util.List;
public class CryptoPriceSample {
public static void main(String[] args) {
try {
- // Get current Bitcoin spot price.
- final CryptoPrice price = CryptoPrice.spotPrice("BTC");
- System.out.println("The current Bitcoin price is " + price.toCurrency());
+ if (args.length > 0) {
+ final CryptoPrice price;
+ if (args.length == 2) {
+ price = CryptoPrice.spotPrice(args[0], args[1]);
+ } else {
+ price = CryptoPrice.spotPrice(args[0]);
+ }
+ System.out.println("The current " + price.getBase() + " price is " + price.getAmount() + " in "
+ + price.getCurrency());
+ } else {
+ // Get current Bitcoin spot price.
+ final CryptoPrice price = CryptoPrice.spotPrice("BTC");
+ System.out.println("The current Bitcoin price is " + price.toCurrency());
- System.out.println();
+ System.out.println();
- // Get current Ethereum spot price in Pound sterling.
- final CryptoPrice gbpPrice = CryptoPrice.spotPrice("ETH", "GBP");
- System.out.println("The current Ethereum price is " + gbpPrice.toCurrency());
+ // Get current Ethereum spot price in Pound sterling.
+ final CryptoPrice gbpPrice = CryptoPrice.spotPrice("ETH", "GBP");
+ System.out.println("The current Ethereum price is " + gbpPrice.toCurrency());
- // Get current Litecoin spot price in Euros.
- final CryptoPrice euroPrice = CryptoPrice.spotPrice("LTC", "EUR");
- System.out.println("The current Litecoin price is " + euroPrice.toCurrency());
+ // Get current Litecoin spot price in Euros.
+ final CryptoPrice euroPrice = CryptoPrice.spotPrice("LTC", "EUR");
+ System.out.println("The current Litecoin price is " + euroPrice.toCurrency());
- System.out.println();
-
- // Get current Bitcoin buy price using API.
- // See: https://developers.coinbase.com/api/v2#get-buy-price
- final CryptoPrice buyPrice =
- CryptoPrice.toPrice(
- CryptoPrice.apiCall(
- List.of("prices", "BTC-USD", "buy"),
- Collections.emptyMap()
- )
- );
- System.out.println("The current " + buyPrice.getBase() + " buy price is " + buyPrice.getAmount()
- + " in " + buyPrice.getCurrency());
+ System.out.println();
+ // Get current Bitcoin buy price using API.
+ // See: https://developers.coinbase.com/api/v2#get-buy-price
+ final CryptoPrice buyPrice = CryptoPrice
+ .toPrice(CryptoPrice.apiCall(List.of("prices", "BTC-USD", "buy"), Collections.emptyMap()));
+ System.out.println("The current " + buyPrice.getBase() + " buy price is " + buyPrice.getAmount()
+ + " in " + buyPrice.getCurrency());
+ }
} catch (CryptoException e) {
System.err.println("HTTP Status Code: " + e.getStatusCode());
System.err.println(e.getMessage());
diff --git a/examples/src/main/kotlin/com/example/CryptoPriceExample.kt b/examples/src/main/kotlin/com/example/CryptoPriceExample.kt
index 6130ea5..51f4348 100644
--- a/examples/src/main/kotlin/com/example/CryptoPriceExample.kt
+++ b/examples/src/main/kotlin/com/example/CryptoPriceExample.kt
@@ -7,32 +7,37 @@ import net.thauvin.erik.crypto.CryptoPrice.Companion.toPrice
import java.io.IOException
-fun main(@Suppress("UNUSED_PARAMETER") args: Array) {
+fun main(args: Array) {
try {
- // Get current Bitcoin spot price.
- val price = spotPrice("BTC")
- println("The current Bitcoin price is ${price.toCurrency()}")
+ if (args.isNotEmpty()) {
+ val price = if (args.size == 2) spotPrice(args[0], args[1]) else spotPrice(args[0])
+ println("The current ${price.base} price is ${price.amount} in ${price.currency}")
+ } else {
+ // Get current Bitcoin spot price.
+ val price = spotPrice("BTC")
+ println("The current Bitcoin price is ${price.toCurrency()}")
- println()
-
- // Get current Ethereum spot price in Pound sterling.
- val gbpPrice = spotPrice("ETH", "GBP")
- println("The current Ehtereum price is ${gbpPrice.toCurrency()}")
+ println()
- // Get current Litecoin spot price in Euro.
- val euroPrice = spotPrice("LTC", "EUR")
- println("The current Litecoin price is ${euroPrice.toCurrency()}")
+ // Get current Ethereum spot price in Pound sterling.
+ val gbpPrice = spotPrice("ETH", "GBP")
+ println("The current Ehtereum price is ${gbpPrice.toCurrency()}")
- println()
-
- // Get current Bitcoin buy price using API.
- // See: https://developers.coinbase.com/api/v2#get-buy-price
- val buyPrice = apiCall(listOf("prices", "BTC-USD", "buy"), emptyMap()).toPrice()
- println("The current ${buyPrice.base} buy price is ${buyPrice.amount} in ${buyPrice.currency}")
+ // Get current Litecoin spot price in Euro.
+ val euroPrice = spotPrice("LTC", "EUR")
+ println("The current Litecoin price is ${euroPrice.toCurrency()}")
+
+ println()
+
+ // Get current Bitcoin buy price using API.
+ // See: https://developers.coinbase.com/api/v2#get-buy-price
+ val buyPrice = apiCall(listOf("prices", "BTC-USD", "buy"), emptyMap()).toPrice()
+ println("The current ${buyPrice.base} buy price is ${buyPrice.amount} in ${buyPrice.currency}")
+ }
} catch (e: CryptoException) {
System.err.println("HTTP Status Code: ${e.statusCode}")
System.err.println(e.message)
} catch (e: IOException) {
- System.err.println(e.message)
+ System.err.println(e.message)
}
}