Skip to content

Commit 1cb2dcb

Browse files
committed
update dependencies
1 parent 7302492 commit 1cb2dcb

4 files changed

Lines changed: 164 additions & 0 deletions

File tree

README.md

Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,123 @@
11
# RCrypto
22
Realtime Crypto (RCrypto) is a build a system that saves real-time BTC & ETH prices in Kenya Shilling.
3+
4+
#### Live API <a href="https://rcrypto.herokuapp.com/"> View Here </a>
5+
6+
#### Live Release
7+
Compiled Build : <a href="https://github.com/Chal13W1zz/RCrypto/releases">Download Here</a>
8+
Run the package using `java -jar RCrypto<version>.jar`
9+
10+
## API Features
11+
12+
1. Users can sync realtime BTC and ETH prices.
13+
2. Users can retrieve BTC and Historical prices from the database.
14+
3. Users can add new BTC and ETH records manually
15+
4. [TO DO] The api has basic authentication.
16+
17+
### Dependencies
18+
19+
1. [junit-jupiter-api] 'org.junit.jupiter:junit-jupiter-api:5.8.1'
20+
2. [junit-jupiter-engine] 'org.junit.jupiter:junit-jupiter-engine:5.8.1'
21+
3. [spark-core] 'com.sparkjava:spark-core:2.9.3'
22+
4. [slf4j-simple] 'org.slf4j:slf4j-simple:1.7.32'
23+
5. [gson] 'com.google.code.gson:gson:2.8.9'
24+
6. [retrofit] 'com.squareup.retrofit2:retrofit:2.9.0'
25+
7. [postgresql] group: 'org.postgresql', name: 'postgresql', version: '42.2.2'
26+
8. [okhttp] 'com.squareup.okhttp3:okhttp:4.9.3'
27+
9. [sql2o] 'group: 'org.sql2o', name: 'sql2o', version: '1.5.4'
28+
10.[converter-gson] 'com.squareup.retrofit2:converter-gson:2.9.0'
29+
30+
31+
32+
33+
## Getting Started
34+
35+
1. git clone https://github.com/Chal13W1zz/RCrypto.git
36+
37+
2. cd RCrypto
38+
39+
3. edit postgresql username and password in App.java
40+
41+
4. run psql < create.sql in the project root to create the database
42+
43+
5. gradle run / mvn run to start up the api locally
44+
45+
46+
## Tests [TO DO]
47+
1. cd RCrypto
48+
2. gradle test
49+
50+
## API Endpoints
51+
52+
53+
| EndPoint | Functionality |
54+
| --------------------------------------- | ------------------------------------:|
55+
| GET /records/sync | sync and realtime prices departments |
56+
| GET /records/view | View historical prices |
57+
| POST /records/add | Manually add new price records |
58+
59+
60+
61+
## Request & Response examples
62+
Request curl `/records/add`
63+
64+
65+
```curl
66+
curl --location --request POST 'https://rcrypto.herokuapp.com/records/add' \
67+
--header 'Content-Type: application/json' \
68+
--data-raw ' {
69+
"bitcoin": {
70+
"usd": 41493
71+
},
72+
"ethereum": {
73+
"usd": 3026.81
74+
}
75+
}'
76+
```
77+
78+
Response (application/json)
79+
```curl
80+
{
81+
"bitcoin": {
82+
"usd": 41493
83+
},
84+
"ethereum": {
85+
"usd": 3026.81
86+
},
87+
"id": 44
88+
}
89+
```
90+
91+
Request curl `/records/sync`
92+
93+
```curl
94+
curl --location --request GET 'https://rcrypto.herokuapp.com/records/sync' \
95+
--header 'Content-Type: application/json'
96+
```
97+
Response (application/json)
98+
99+
```curl
100+
{
101+
"bitcoin": {
102+
"usd": 41493
103+
},
104+
"ethereum": {
105+
"usd": 3026.81
106+
},
107+
"id": 0
108+
}
109+
110+
```
111+
112+
## Limitations
113+
114+
1. The API only responds with JSON
115+
2. TO DO "respond with xml"
116+
117+
## Contribution
118+
119+
1. Fork it! :fork_and_knife:
120+
2. Create your feature branch: `git checkout -b my-new-feature`
121+
3. Commit your changes: `git add -A && git commit -m 'Add some feature'`
122+
4. Push to the branch: `git push origin my-new-feature`
123+
5. Submit a pull request

build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ dependencies {
2121
implementation group: 'org.postgresql', name: 'postgresql', version: '42.2.2'
2222
implementation 'com.sparkjava:spark-core:2.9.3'
2323
implementation 'org.slf4j:slf4j-simple:1.7.35'
24+
implementation 'com.google.code.gson:gson:2.8.9'
2425
}
2526

2627
test {
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package services;
2+
3+
import models.Prices;
4+
import retrofit2.Call;
5+
import retrofit2.http.GET;
6+
import retrofit2.http.Headers;
7+
import retrofit2.http.Query;
8+
9+
public interface PriceApi {
10+
//"https://api.coingecko.com/api/v3/simple/price?ids=bitcoin%2Cethereum&vs_currencies=usd";
11+
String BASE_URL = "https://api.coingecko.com/api/v3/";
12+
@Headers("accept: application/json")
13+
@GET("simple/price")
14+
Call<Prices> getPrices(@Query("ids") String ids, @Query("vs_currencies") String currencies);
15+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package services;
2+
3+
import retrofit2.Retrofit;
4+
import retrofit2.converter.gson.GsonConverterFactory;
5+
6+
public class PriceApiClient {
7+
private static PriceApiClient instance = null;
8+
private PriceApi priceApi;
9+
10+
private PriceApiClient() {
11+
Retrofit retrofit = new Retrofit.Builder().baseUrl(PriceApi.BASE_URL)
12+
.addConverterFactory(GsonConverterFactory.create())
13+
.build();
14+
priceApi = retrofit.create(PriceApi.class);
15+
}
16+
17+
public static synchronized PriceApiClient getInstance() {
18+
if (instance == null) {
19+
instance = new PriceApiClient();
20+
}
21+
return instance;
22+
}
23+
24+
public PriceApi getPriceApi() {
25+
return priceApi;
26+
}
27+
}

0 commit comments

Comments
 (0)