Skip to content

Commit 2bc6977

Browse files
committed
Switched data type of EPOCH timestamp method parameters from String to long in TheTVDBApi interface.
1 parent 61aec28 commit 2bc6977

File tree

4 files changed

+11
-16
lines changed

4 files changed

+11
-16
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1111
- Included _org.jacoco:jacoco-maven-plugin_ `0.8.5` in order to generate a test coverage report at the end of the build process.
1212

1313
### Changed
14+
- Changed the data types of `TheTVDBApi.queryLastUpdated()` shortcut methods parameters from _String_ to _long_.
1415
- The remote API version used by this connector is now publicly available via the `TheTVDBApi.Version.API_VERSION` constant.
1516
- Specific handling of HTTP-405 responses. Enhance error message with additional information.
1617
- All code now has to have a JUnit test line coverage of at least 80% and no missed class counts.

src/main/java/com/github/m0nk3y2k4/thetvdb/api/TheTVDBApi.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -750,7 +750,7 @@ private Version() {}
750750
* of the returned map represent a <i>TheTVDB.com</i> series ID (key) and when it was updated the last time (value) as Epoch time. This is a shortcut-method for
751751
* {@link #queryLastUpdated(QueryParameters) queryLastUpdated(queryParameters)} with a single "fromTime" query parameter.
752752
*
753-
* @see #queryLastUpdated(String, String) queryLastUpdated(fromTime, toTime)
753+
* @see #queryLastUpdated(long, long) queryLastUpdated(fromTime, toTime)
754754
*
755755
* @param fromTime Epoch time to start your date range
756756
*
@@ -759,7 +759,7 @@ private Version() {}
759759
* @throws APIException If an exception with the remote API occurs, e.g. authentication failure, IO error, resource not found, etc. or
760760
* no records exist for the given timespan.
761761
*/
762-
Map<Long, Long> queryLastUpdated(@Nonnull String fromTime) throws APIException;
762+
Map<Long, Long> queryLastUpdated(long fromTime) throws APIException;
763763

764764
/**
765765
* Returns a map of series that have changed in between the given timeframe, but with a maximum of one week, starting at the provided <em>{@code fromTime}</em>
@@ -768,7 +768,7 @@ private Version() {}
768768
* time (value) as Epoch time. This is a shortcut-method for {@link #queryLastUpdated(QueryParameters) queryLastUpdated(queryParameters)} with a "fromTime"
769769
* and a "toTime" query parameter.
770770
*
771-
* @see #queryLastUpdated(String) queryLastUpdated(fromTime)
771+
* @see #queryLastUpdated(long) queryLastUpdated(fromTime)
772772
*
773773
* @param fromTime Epoch time to start your date range
774774
* @param toTime Epoch time to end your date range. Must not be greater than one week from <em>{@code fromTime}</em>.
@@ -778,7 +778,7 @@ private Version() {}
778778
* @throws APIException If an exception with the remote API occurs, e.g. authentication failure, IO error, resource not found, etc. or
779779
* no records exist for the given timespan.
780780
*/
781-
Map<Long, Long> queryLastUpdated(@Nonnull String fromTime, @Nonnull String toTime) throws APIException;
781+
Map<Long, Long> queryLastUpdated(long fromTime, long toTime) throws APIException;
782782

783783
/**
784784
* Returns a list of valid parameters for querying series which have been updated lately, as plain Strings. These keys are permitted to be used in

src/main/java/com/github/m0nk3y2k4/thetvdb/internal/api/impl/TheTVDBApiImpl.java

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -335,15 +335,13 @@ public Map<Long, Long> queryLastUpdated(QueryParameters queryParameters) throws
335335
}
336336

337337
@Override
338-
public Map<Long, Long> queryLastUpdated(@Nonnull String fromTime) throws APIException {
339-
validateNotEmpty(fromTime);
340-
return queryLastUpdated(query(Map.of(Query.Updates.FROMTIME, fromTime)));
338+
public Map<Long, Long> queryLastUpdated(long fromTime) throws APIException {
339+
return queryLastUpdated(query(Map.of(Query.Updates.FROMTIME, String.valueOf(fromTime))));
341340
}
342341

343342
@Override
344-
public Map<Long, Long> queryLastUpdated(@Nonnull String fromTime, @Nonnull String toTime) throws APIException {
345-
validateNotEmpty(fromTime, toTime);
346-
return queryLastUpdated(query(Map.of(Query.Updates.FROMTIME, fromTime, Query.Updates.TOTIME, toTime)));
343+
public Map<Long, Long> queryLastUpdated(long fromTime, long toTime) throws APIException {
344+
return queryLastUpdated(query(Map.of(Query.Updates.FROMTIME, String.valueOf(fromTime), Query.Updates.TOTIME, String.valueOf(toTime))));
347345
}
348346

349347
@Override

src/test/java/com/github/m0nk3y2k4/thetvdb/internal/api/impl/TheTVDBApiImplTest.java

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -180,10 +180,6 @@ private Stream<Arguments> withInvalidParameters() {
180180
of(route(() -> basicAPI.queryImagesByResolution(3645, " "), "queryImagesByResolution() with empty parameter")),
181181
of(route(() -> basicAPI.queryImagesBySubKey(6311, null), "queryImagesBySubKey() with NULL parameter")),
182182
of(route(() -> basicAPI.queryImagesBySubKey(9447, " "), "queryImagesBySubKey() with empty parameter")),
183-
of(route(() -> basicAPI.queryLastUpdated((String) null), "queryLastUpdated() with NULL from time parameter")),
184-
of(route(() -> basicAPI.queryLastUpdated(" "), "queryLastUpdated() with empty from time parameter")),
185-
of(route(() -> basicAPI.queryLastUpdated(null, null), "queryLastUpdated() with NULL from and to time parameter")),
186-
of(route(() -> basicAPI.queryLastUpdated(" ", ""), "queryLastUpdated() with empty from and to time parameter")),
187183
of(route(() -> basicAPI.getUser(), "getUser() without authentication")),
188184
of(route(() -> basicAPI.getFavorites(), "getFavorites() without authentication")),
189185
of(route(() -> basicAPI.deleteFromFavorites(4874), "deleteFromFavorites() without authentication")),
@@ -245,8 +241,8 @@ private Stream<Arguments> withValidParameters() {
245241
of(route(() -> basicAPI.queryImagesBySubKey(34964, "Key3"), "queryImagesBySubKey()"), IMAGES),
246242
of(route(() -> basicAPI.getAvailableImageQueryParameters(88861), "getAvailableImageQueryParameters()"), IMAGEQUERYPARAMETERS),
247243
of(route(() -> basicAPI.queryLastUpdated(params(FROMTIME, "7")), "queryLastUpdated() with query parameters"), UPDATES),
248-
of(route(() -> basicAPI.queryLastUpdated("54"), "queryLastUpdated() with from time"), UPDATES),
249-
of(route(() -> basicAPI.queryLastUpdated("76", "99"), "queryLastUpdated() with from and to time"), UPDATES),
244+
of(route(() -> basicAPI.queryLastUpdated(54), "queryLastUpdated() with from time"), UPDATES),
245+
of(route(() -> basicAPI.queryLastUpdated(76, 99), "queryLastUpdated() with from and to time"), UPDATES),
250246
of(route(() -> basicAPI.getAvailableLastUpdatedQueryParameters(), "getAvailableLastUpdatedQueryParameters()"), QUERYPARAMETERS),
251247
of(route(() -> userAuthApi.getUser(), "getUser()"), USER),
252248
of(route(() -> userAuthApi.getFavorites(), "getFavorites()"), FAVORITES),

0 commit comments

Comments
 (0)