Skip to content

Commit 485e315

Browse files
committed
service: merge Day and CountryDay
1 parent 312c00a commit 485e315

File tree

3 files changed

+13
-42
lines changed

3 files changed

+13
-42
lines changed

src/main/java/com/nonstop/covid19/api/CountryDay.java

Lines changed: 0 additions & 39 deletions
This file was deleted.

src/main/java/com/nonstop/covid19/api/Day.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import java.util.Locale;
55

66
public class Day {
7+
private String country;
78
private Date date;
89
private int confirmed;
910
private int deaths;
@@ -12,10 +13,15 @@ public class Day {
1213
@Override
1314
public String toString() {
1415
return String.format(Locale.getDefault(),
15-
"%s { confirmed: %d, deaths: %d, recovered: %d }",
16+
"%s %s { confirmed: %d, deaths: %d, recovered: %d }",
17+
isGlobal() ? "Global" : getCountry(),
1618
date.toString(), confirmed, deaths, recovered);
1719
}
1820

21+
public String getCountry() {
22+
return country;
23+
}
24+
1925
public Date getDate() {
2026
return date;
2127
}
@@ -31,4 +37,8 @@ public int getDeaths() {
3137
public int getRecovered() {
3238
return recovered;
3339
}
40+
41+
public boolean isGlobal() {
42+
return getCountry() == null;
43+
}
3444
}

src/main/java/com/nonstop/covid19/api/VirusService.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ public interface VirusService {
1717
Call<List<Day>> allDays();
1818

1919
@GET("countries")
20-
Call<List<CountryDay>> allCountries();
20+
Call<List<Day>> allCountries();
2121

2222
@GET("countries")
23-
Call<List<CountryDay>> country(@Query("filter[country]") String countryName);
23+
Call<List<Day>> country(@Query("filter[country]") String countryName);
2424

2525
String BASE_URL = "http://covid-19api.com/api/";
2626

0 commit comments

Comments
 (0)