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

Commit ad5b53b

Browse files
committed
Currensees 🐘
Signed-off-by: Finbarrs Oketunji <f@finbarrs.eu>
0 parents  commit ad5b53b

30 files changed

+1267
-0
lines changed

.github/workflows/ci.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: Java CI
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- main
7+
push:
8+
branches:
9+
- main
10+
schedule:
11+
- cron: '0 3 * * *'
12+
13+
jobs:
14+
build:
15+
runs-on: ubuntu-latest
16+
name: Java ${{ matrix.java-version }}
17+
strategy:
18+
matrix:
19+
java-version:
20+
- '11'
21+
- '14'
22+
- '15'
23+
- '16'
24+
- '17'
25+
steps:
26+
- uses: actions/checkout@v3
27+
- name: Set up JDK ${{ matrix.java-version }}
28+
uses: actions/setup-java@v3
29+
with:
30+
java-version: ${{ matrix.java-version }}
31+
distribution: 'adopt'
32+
cache: gradle
33+
- name: Compile
34+
run: javac -cp lib/gson-2.10.1.jar:lib/okhttp-3.14.9.jar -d out src/main/java/com/currensees/*.java
35+
- name: Grant execute permission for gradlew
36+
run: chmod +x gradlew
37+
- name: Build with Gradle
38+
run: ./gradlew build

.github/workflows/release.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- v[0-9]+.*
7+
8+
jobs:
9+
create-release:
10+
if: github.repository_owner == 'moatsystems'
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v3
14+
- uses: taiki-e/create-gh-release-action@v1
15+
with:
16+
changelog: CHANGELOG.md
17+
branch: main
18+
env:
19+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.gitignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
.gradle
2+
gradle.properties
3+
build
4+
out
5+
.DS_Store
6+
push.sh
7+
Makefile
8+
src/main/java/com/currensees/CurrenseesUE.java

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# 0.1.0 (April 23, 2023)
2+
3+
* Initial release.

CODEOWNERS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
@0xnu
2+
@moatsystems

CODE_OF_CONDUCT.md

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
# Contributor Covenant Code of Conduct
2+
3+
## Our Pledge
4+
5+
In the interest of fostering an open and welcoming environment, we as
6+
contributors and maintainers pledge to make participation in our project and
7+
our community a harassment-free experience for everyone, regardless of age, body
8+
size, disability, ethnicity, sex characteristics, gender identity and expression,
9+
level of experience, education, socio-economic status, nationality, personal
10+
appearance, race, religion, or sexual identity and orientation.
11+
12+
## Our Standards
13+
14+
Examples of behavior that contributes to creating a positive environment
15+
include:
16+
17+
* Using welcoming and inclusive language
18+
* Being respectful of differing viewpoints and experiences
19+
* Gracefully accepting constructive criticism
20+
* Focusing on what is best for the community
21+
* Showing empathy towards other community members
22+
23+
Examples of unacceptable behavior by participants include:
24+
25+
* The use of sexualized language or imagery and unwelcome sexual attention or
26+
advances
27+
* Trolling, insulting/derogatory comments, and personal or political attacks
28+
* Public or private harassment
29+
* Publishing others' private information, such as a physical or electronic
30+
address, without explicit permission
31+
* Other conduct which could reasonably be considered inappropriate in a
32+
professional setting
33+
34+
## Our Responsibilities
35+
36+
Project maintainers are responsible for clarifying the standards of acceptable
37+
behavior and are expected to take appropriate and fair corrective action in
38+
response to any instances of unacceptable behavior.
39+
40+
Project maintainers have the right and responsibility to remove, edit, or
41+
reject comments, commits, code, wiki edits, issues, and other contributions
42+
that are not aligned to this Code of Conduct, or to ban temporarily or
43+
permanently any contributor for other behaviors that they deem inappropriate,
44+
threatening, offensive, or harmful.
45+
46+
## Scope
47+
48+
This Code of Conduct applies within all project spaces, and it also applies when
49+
an individual is representing the project or its community in public spaces.
50+
Examples of representing a project or community include using an official
51+
project e-mail address, posting via an official social media account, or acting
52+
as an appointed representative at an online or offline event. Representation of
53+
a project may be further defined and clarified by project maintainers.
54+
55+
## Enforcement
56+
57+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
58+
reported by contacting the project team. All complaints will be reviewed and
59+
investigated and will result in a response that is deemed necessary and appropriate
60+
to the circumstances. The project team is obligated to maintain confidentiality with
61+
regard to the reporter of an incident. Further details of specific enforcement
62+
policies may be posted separately.
63+
64+
Project maintainers who do not follow or enforce the Code of Conduct in good
65+
faith may face temporary or permanent repercussions as determined by other
66+
members of the project's leadership.
67+
68+
## Attribution
69+
70+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71+
available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
72+
73+
[homepage]: https://www.contributor-covenant.org
74+
75+
For answers to common questions about this code of conduct, see
76+
https://www.contributor-covenant.org/faq
77+

CONTRIBUTORS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Finbarrs Oketunji <f@finbarrs.eu>

LICENSE

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
BSD 3-Clause License
2+
3+
Copyright (c) 2023, Moat Systems Limited. All Rights Reserved.
4+
5+
Redistribution and use in source and binary forms, with or without
6+
modification, are permitted provided that the following conditions are met:
7+
8+
* Redistributions of source code must retain the above copyright notice, this
9+
list of conditions and the following disclaimer.
10+
11+
* Redistributions in binary form must reproduce the above copyright notice,
12+
this list of conditions and the following disclaimer in the documentation
13+
and/or other materials provided with the distribution.
14+
15+
* Neither the name of the copyright holder nor the names of its
16+
contributors may be used to endorse or promote products derived from
17+
this software without specific prior written permission.
18+
19+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
23+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
25+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
26+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
27+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

README.md

Lines changed: 189 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,189 @@
1+
## Currency API Java Client
2+
3+
[![Build Status](https://github.com/moatsystems/currensees-java/actions/workflows/ci.yml/badge.svg)](https://github.com/moatsystem/currensees-java/actions/workflows/ci.yml)
4+
5+
A Java client for interacting with [Currency API](https://moatsystems.com/currency-api/).
6+
7+
[Moat Systems](https://moatsystems.com) provides customers with accurate and up-to-date currency data for making informed decisions in the global financial market, including Gold, Silver and Special Drawing Rights. Our reliable exchange rate data assist businesses in confidently managing foreign transactions, investments and risks. Accounting, E-commerce, CRM, and ERP software companies will find it helpful to integrate with us instead of developing a custom in-house solution.
8+
9+
### Requirements
10+
11+
This library is tested with Java versions 11, 14, 15, 16 and 17.
12+
13+
### Installation
14+
15+
#### Maven
16+
17+
Add this dependency to your project's POM:
18+
19+
```java
20+
<dependency>
21+
<groupId>com.currensees</groupId>
22+
<artifactId>currensees-java</artifactId>
23+
<version>X.X.X</version>
24+
</dependency>
25+
```
26+
27+
#### Gradle
28+
29+
Add this dependency to your `build.gradle` file:
30+
31+
```
32+
compile 'com.currensees:currensees-java:X.X.X'
33+
```
34+
35+
### Usage Example
36+
37+
This library is a Java client you can use to interact with the [Currency API](https://moatsystems.com/currency-api/).
38+
39+
```java
40+
package myapp;
41+
42+
import com.currensees;
43+
import com.google.gson.Gson;
44+
import com.google.gson.JsonObject;
45+
import java.util.Optional;
46+
47+
public class MyApp {
48+
49+
public static void main(String[] args) {
50+
String username = "your_username";
51+
String password = "your_password";
52+
53+
Optional<String> loginResponse = Auth.loginAndGetUsername(username, password);
54+
55+
if (loginResponse.isPresent()) {
56+
// Convert
57+
Optional<String> conversionResult = Convert.convert(username, "2023_04_19", "GBP", "EUR", "500");
58+
if (conversionResult.isPresent()) {
59+
System.out.println("Conversion result: " + conversionResult.get());
60+
} else {
61+
System.out.println("Conversion failed.");
62+
}
63+
64+
// ConvertAll
65+
Optional<String> conversionAllResult = ConvertAll.convertAll(username, "2023_04_02", "GBP", "120");
66+
if (conversionAllResult.isPresent()) {
67+
System.out.println("Conversion all result: " + conversionAllResult.get());
68+
} else {
69+
System.out.println("Conversion all failed.");
70+
}
71+
72+
// DailyAverage
73+
Optional<String> dailyAverageResult = DailyAverage.getDailyAverage(username, "2023_04_02");
74+
if (dailyAverageResult.isPresent()) {
75+
System.out.println("Daily average result: " + dailyAverageResult.get());
76+
} else {
77+
System.out.println("Fetching daily average failed.");
78+
}
79+
80+
// WeeklyAverage
81+
Optional<String> weeklyAverageResult = WeeklyAverage.getWeeklyAverage(username, "2023_04_03", "2023_04_07");
82+
if (weeklyAverageResult.isPresent()) {
83+
System.out.println("Weekly average result: " + weeklyAverageResult.get());
84+
} else {
85+
System.out.println("Fetching weekly average failed.");
86+
}
87+
88+
// Currencies
89+
Optional<String> currenciesResult = Currencies.getAllCurrencies(username, 19, 4, 2024);
90+
if (currenciesResult.isPresent()) {
91+
System.out.println("All currencies result: " + currenciesResult.get());
92+
} else {
93+
System.out.println("Fetching all currencies failed.");
94+
}
95+
96+
// Currencies - getCurrencyById
97+
Optional<String> currencyByIdResult = Currencies.getCurrencyById(username, "594bffc4-d095-11ed-9e30-acde48001122", 19, 4, 2023);
98+
if (currencyByIdResult.isPresent()) {
99+
System.out.println("Currency by ID result: " + currencyByIdResult.get());
100+
} else {
101+
System.out.println("Fetching currency by ID failed.");
102+
}
103+
104+
// Historical
105+
Optional<String> allHistoricalDataResult = Historical.getAllHistoricalData(username, "2023_04_02", 19, 4, 2023);
106+
if (allHistoricalDataResult.isPresent()) {
107+
System.out.println("All historical data result: " + allHistoricalDataResult.get());
108+
} else {
109+
System.out.println("Fetching all historical data failed.");
110+
}
111+
112+
// Historical - getHistoricalById
113+
Optional<String> historicalDataByIdResult = Historical.getHistoricalDataById(username, "fe1ee1c4-d162-11ed-a2dc-acde48001122", "2023_04_02", 19, 4, 2023);
114+
if (historicalDataByIdResult.isPresent()) {
115+
System.out.println("Historical data by ID result: " + historicalDataByIdResult.get());
116+
} else {
117+
System.out.println("Fetching historical data by ID failed.");
118+
}
119+
120+
// MarginsSpreads - getAllMarginsSpreads
121+
Optional<String> marginsSpreadsAllResult = MarginsSpreads.getAllMarginsSpreads(username, 19, 4, 2023);
122+
if (marginsSpreadsAllResult.isPresent()) {
123+
System.out.println("All Margins Spreads result: " + marginsSpreadsAllResult.get());
124+
} else {
125+
System.out.println("Fetching all Margins Spreads failed.");
126+
}
127+
128+
// MarginsSpreads - getMarginsSpreadsById
129+
Optional<String> marginsSpreadsByIdResult = MarginsSpreads.getMarginsSpreadsById(username, "8e694000-e3c2-11ed-b5bd-acde48001122", 19, 4, 2023);
130+
if (marginsSpreadsByIdResult.isPresent()) {
131+
System.out.println("Margins Spreads by ID result: " + marginsSpreadsByIdResult.get());
132+
} else {
133+
System.out.println("Fetching Margins Spreads by ID failed.");
134+
}
135+
136+
// Performances
137+
Optional<String> performancesResult = Performances.getAllPerformances(username);
138+
if (performancesResult.isPresent()) {
139+
System.out.println("Performances result: " + performancesResult.get());
140+
} else {
141+
System.out.println("Fetching performances failed.");
142+
}
143+
144+
// Performances - getPerformanceById
145+
Optional<String> performanceByIdResult = Performances.getPerformanceById(username, "8edd9b12-e3c2-11ed-b5bd-acde48001122");
146+
if (performanceByIdResult.isPresent()) {
147+
System.out.println("Performance by ID result: " + performanceByIdResult.get());
148+
} else {
149+
System.out.println("Fetching Performance by ID failed.");
150+
}
151+
152+
// Signals
153+
Optional<String> signalsResult = Signals.getAllSignals(username);
154+
if (signalsResult.isPresent()) {
155+
System.out.println("Signals result: " + signalsResult.get());
156+
} else {
157+
System.out.println("Fetching signals failed.");
158+
}
159+
160+
// Signals - getSignalById
161+
Optional<String> signalByIdResult = Signals.getSignalById(username, "8e694050-e3c2-11ed-b5bd-acde48001122");
162+
if (signalByIdResult.isPresent()) {
163+
System.out.println("Signal by ID result: " + signalByIdResult.get());
164+
} else {
165+
System.out.println("Fetching Signal by ID failed.");
166+
}
167+
168+
} else {
169+
System.out.println("Login failed.");
170+
}
171+
}
172+
}
173+
```
174+
175+
### Setting up Currency API Account
176+
177+
Subscribe [here](https://moatsystems.com/currency-api/) for a user account.
178+
179+
### Using the Currency API
180+
181+
You can read the [API documentation](https://docs.currensees.com/) to understand what's possible with the Currency API. If you need further assistance, don't hesitate to [contact us](https://moatsystems.com/contact/).
182+
183+
### License
184+
185+
This project is licensed under the [BSD 3-Clause License](./LICENSE).
186+
187+
### Copyright
188+
189+
(c) 2020 - 2023 [Moat Systems Limited](https://moatsystems.com).

0 commit comments

Comments
 (0)