Permalink
Browse files

Add default date params to law tree update api

Add two overload methods to the law tree updates api to allow for
use of default date range parameters.  The "from" date will default to
1970-01-01 and the "to" parameter will default to the current date time.
  • Loading branch information...
McSquirrel committed Aug 30, 2017
1 parent ce39793 commit aabda96735c43f61c6650bb3f2f0c424c4cdeb63
Showing with 35 additions and 2 deletions.
  1. +6 −1 docs/api/laws.rst
  2. +29 −1 src/main/java/gov/nysenate/openleg/controller/api/law/LawUpdatesCtrl.java
View
@@ -397,9 +397,14 @@ To see updates to the content of law documents, see `Get law document updates`_.
List of laws with tree updates during the given date/time range
::
/api/3/laws/tree/updates
/api/3/laws/tree/updates/{fromDateTime}
/api/3/laws/tree/updates/{fromDateTime}/{toDateTime}
.. note:: The fromDateTime and toDateTime should be formatted as the ISO Date Time format. For example December 10, 2014, 1:30:02 PM should be inputted as 2014-12-10T13:30:02. The fromDateTime and toDateTime range is exclusive.
The fromDateTime and toDateTime should be formatted as the ISO Date Time format.
For example December 10, 2014, 1:30:02 PM should be inputted as 2014-12-10T13:30:02.
The fromDateTime and toDateTime range is exclusive.
If excluded, fromDateTime defaults to Jan 1 1970 and toDateTime defaults to the current datetime
**Optional Params**
@@ -40,7 +40,7 @@
@Autowired private LawUpdatesDao lawUpdatesDao;
/**
* Law Updates API (for all laws)
* Law Document Updates API (for all laws)
* ------------------------------
*
* Usages:
@@ -70,6 +70,34 @@ public BaseResponse getAllUpdates(@PathVariable String from, @PathVariable Strin
return getAllUpdates(parseISODateTime(from, "from"), parseISODateTime(to, "to"), request);
}
/**
* Law Tree Updates API
* ------------------------------
*
* Usages:
* (GET) /api/3/laws/tree/updates
* (GET) /api/3/laws/tree/updates/{from date-time}
* (GET) /api/3/laws/tree/updates/{from date-time}/{to date-time}
*
* date parameters default to 1970-01-01 and now respectively
*
* Request Params: type (string) - Update type (processed, published) Default: published
* limit, offset (int) - Paginate
* order (string) - Order by update date
*
* Expected Response: List of UpdateTokenView<LawVersionId>
*/
@RequestMapping(value = "/tree/updates")
public BaseResponse getLawTreeUpdates(WebRequest request) {
return getLawTreeUpdates(null, null, request);
}
@RequestMapping(value = "/tree/updates/{from:.*\\.?.*}")
public BaseResponse getLawTreeUpdates(@PathVariable String from,
WebRequest request) {
return getLawTreeUpdates(from, null, request);
}
@RequestMapping(value = "/tree/updates/{from:.*\\.?.*}/{to:.*\\.?.*}")
public BaseResponse getLawTreeUpdates(@PathVariable String from,
@PathVariable String to,

0 comments on commit aabda96

Please sign in to comment.