Skip to content
This repository was archived by the owner on May 20, 2025. It is now read-only.

Commit 62474b2

Browse files
committed
v0.1.1
Signed-off-by: Finbarrs Oketunji <f@finbarrs.eu>
1 parent ad5b53b commit 62474b2

File tree

7 files changed

+50
-1
lines changed

7 files changed

+50
-1
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# 0.1.1 (May 02, 2023)
2+
3+
* Monthly average added.
4+
15
# 0.1.0 (April 23, 2023)
26

37
* Initial release.

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,14 @@ public class MyApp {
8585
System.out.println("Fetching weekly average failed.");
8686
}
8787

88+
// MonthlyAverage
89+
Optional<String> monthlyAverageResult = MonthlyAverage.getMonthlyAverage(username, 2023, 04);
90+
if (monthlyAverageResult.isPresent()) {
91+
System.out.println("Monthly average result: " + monthlyAverageResult.get());
92+
} else {
93+
System.out.println("Fetching monthly average failed.");
94+
}
95+
8896
// Currencies
8997
Optional<String> currenciesResult = Currencies.getAllCurrencies(username, 19, 4, 2024);
9098
if (currenciesResult.isPresent()) {

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ dependencies {
1818
}
1919

2020
group = 'com.currensees'
21-
version = '0.1.0'
21+
version = '0.1.1'
2222
description = 'currensees-java'
2323
sourceCompatibility = '1.11'
2424
targetCompatibility = '1.11'
303 KB
Binary file not shown.
9.08 KB
Binary file not shown.

releases/currensees-java-0.1.1.jar

21.9 KB
Binary file not shown.
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
package com.currensees;
2+
3+
import java.net.URI;
4+
import java.net.http.HttpClient;
5+
import java.net.http.HttpRequest;
6+
import java.net.http.HttpResponse;
7+
import java.util.Optional;
8+
9+
public class MonthlyAverage {
10+
11+
public static Optional<String> getMonthlyAverage(String username, String year, String month) {
12+
try {
13+
HttpClient client = HttpClient.newHttpClient();
14+
15+
HttpRequest request = HttpRequest.newBuilder()
16+
.uri(URI.create("https://currensees.com/v1/monthly_average/" + year + "/" + month))
17+
.header("Content-Type", "application/json")
18+
.header("Accept", "application/json")
19+
.header("Cookie", "user_type=member; username=" + username)
20+
.GET()
21+
.build();
22+
23+
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
24+
25+
if (response.statusCode() == 200) {
26+
return Optional.of(response.body());
27+
} else {
28+
System.out.println("Fetching monthly average failed with status code: " + response.statusCode());
29+
System.out.println("Response body: " + response.body());
30+
return Optional.empty();
31+
}
32+
} catch (Exception e) {
33+
e.printStackTrace();
34+
return Optional.empty();
35+
}
36+
}
37+
}

0 commit comments

Comments
 (0)