Skip to content

Commit 16720ba

Browse files
committed
Rename check digit URL, add documentation
1 parent b6b3d66 commit 16720ba

File tree

3 files changed

+148
-5
lines changed

3 files changed

+148
-5
lines changed

Documents/public-api.md

Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,149 @@ This documenatation describes de public HMDA Platform HTTP API
8484
For a definition of these fields, please consult the [HMDA Filing Instructions Guide](http://www.consumerfinance.gov/data-research/hmda/static/for-filers/2017/2017-HMDA-FIG.pdf).
8585
Please note that the Modified LAR does not include the fields `Loan Application Number`, `Date Application Received` or `Date of Action` described in HMDA Filing Instructions Guide.
8686

87+
## Check Digit
8788

89+
### Check digit generation
90+
91+
* `/uli/checkDigit`
92+
93+
* `POST` - Calculates check digit and full ULI from a loan id.
94+
95+
Example payload, in `JSON` format:
96+
97+
```json
98+
{
99+
"loanId": "10Bx939c5543TqA1144M999143X"
100+
}
101+
```
102+
103+
Example response:
104+
105+
```json
106+
{
107+
"loanId": "10Cx939c5543TqA1144M999143X",
108+
"checkDigit": 10,
109+
"uli": "10Cx939c5543TqA1144M999143X10"
110+
}
111+
```
112+
113+
A file with a list of Loan Ids can also be uploaded to this endpoint for batch check digit generation.
114+
115+
Example file contents:
116+
117+
```
118+
10Cx939c5543TqA1144M999143X
119+
10Bx939c5543TqA1144M999143X
120+
```
121+
122+
Example response in `JSON` format:
123+
124+
```json
125+
{
126+
"loanIds": [
127+
{
128+
"loanId": "10Bx939c5543TqA1144M999143X",
129+
"checkDigit": 38,
130+
"uli": "10Bx939c5543TqA1144M999143X38"
131+
},
132+
{
133+
"loanId": "10Cx939c5543TqA1144M999143X",
134+
"checkDigit": 10,
135+
"uli": "10Cx939c5543TqA1144M999143X10"
136+
}
137+
]
138+
}
139+
```
140+
141+
* `/uli/checkDigit/csv`
142+
143+
* `POST` - calculates check digits for loan ids submitted as a file
144+
145+
Example file contents:
146+
147+
```
148+
10Cx939c5543TqA1144M999143X
149+
10Bx939c5543TqA1144M999143X
150+
```
151+
152+
Example response in `CSV` format:
153+
154+
```csv
155+
10Bx939c5543TqA1144M999143X,38,10Bx939c5543TqA1144M999143X38
156+
10Cx939c5543TqA1144M999143X,10,10Cx939c5543TqA1144M999143X10
157+
```
158+
159+
### ULI Validation
160+
161+
* `/uli/validate`
162+
163+
* `POST` - Validates a ULI (correct check digit)
164+
165+
Example payload, in `JSON` format:
166+
167+
```json
168+
{
169+
"uli": "10Bx939c5543TqA1144M999143X38"
170+
}
171+
```
172+
173+
Example response:
174+
175+
```json
176+
{
177+
"isValid": true
178+
}
179+
```
180+
181+
A file with a list of ULIs can also be uploaded to this endpoint for batch ULI validation.
182+
183+
Example file contents:
184+
185+
```
186+
10Cx939c5543TqA1144M999143X10
187+
10Bx939c5543TqA1144M999143X38
188+
10Bx939c5543TqA1144M999133X38
189+
```
190+
191+
Example response in `JSON` format:
192+
193+
```json
194+
{
195+
"ulis": [
196+
{
197+
"uli": "10Cx939c5543TqA1144M999143X10",
198+
"isValid": true
199+
},
200+
{
201+
"uli": "10Bx939c5543TqA1144M999143X38",
202+
"isValid": true
203+
},
204+
{
205+
"uli": "10Bx939c5543TqA1144M999133X38",
206+
"isValid": false
207+
}
208+
]
209+
}
210+
```
211+
212+
* `/uli/validate/csv`
213+
214+
* `POST` - Batch validation of ULIs
215+
216+
Example file contents:
217+
218+
```
219+
10Cx939c5543TqA1144M999143X10
220+
10Bx939c5543TqA1144M999143X38
221+
10Bx939c5543TqA1144M999133X38
222+
```
223+
224+
Example response in `CSV` format:
225+
226+
```csv
227+
10Cx939c5543TqA1144M999143X10,true
228+
10Bx939c5543TqA1144M999143X38,true
229+
10Bx939c5543TqA1144M999133X38,false
230+
```
88231

89232

api/src/main/scala/hmda/api/http/public/PublicHttpApi.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ trait PublicHttpApi extends PublicLarHttpApi with HmdaCustomDirectives with ApiE
3535
modifiedLar(instId)
3636
} ~
3737
pathPrefix("uli") {
38-
path("check-digit") {
38+
path("checkDigit") {
3939
timedPost { _ =>
4040
entity(as[Loan]) { loan =>
4141
val loanId = loan.loanId
@@ -59,7 +59,7 @@ trait PublicHttpApi extends PublicLarHttpApi with HmdaCustomDirectives with ApiE
5959
}
6060
}
6161
} ~
62-
path("check-digit" / "csv") {
62+
path("checkDigit" / "csv") {
6363
timedPost { _ =>
6464
fileUpload("file") {
6565
case (_, byteSource) =>

api/src/test/scala/hmda/api/http/public/PublicHttpApiSpec.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,12 @@ class PublicHttpApiSpec extends WordSpec with MustMatchers with BeforeAndAfterAl
5656
val uliCheck = ULICheck(uli)
5757

5858
"return check digit and ULI from loan id" in {
59-
Post("/uli/check-digit", loan) ~> publicHttpRoutes ~> check {
59+
Post("/uli/checkDigit", loan) ~> publicHttpRoutes ~> check {
6060
responseAs[ULI] mustBe ULI(loanId, checkDigit, uli)
6161
}
6262
}
6363
"return check digit and ULI from file of loan ids" in {
64-
Post("/uli/check-digit", loanFile) ~> publicHttpRoutes ~> check {
64+
Post("/uli/checkDigit", loanFile) ~> publicHttpRoutes ~> check {
6565
status mustBe StatusCodes.OK
6666
responseAs[LoanCheckDigitResponse].loanIds mustBe Seq(
6767
ULI("10Bx939c5543TqA1144M999143X", 38, "10Bx939c5543TqA1144M999143X38"),
@@ -70,7 +70,7 @@ class PublicHttpApiSpec extends WordSpec with MustMatchers with BeforeAndAfterAl
7070
}
7171
}
7272
"return csv with check digit and ULI from file of loan ids" in {
73-
Post("/uli/check-digit/csv", loanFile) ~> publicHttpRoutes ~> check {
73+
Post("/uli/checkDigit/csv", loanFile) ~> publicHttpRoutes ~> check {
7474
status mustBe StatusCodes.OK
7575
val csv = responseAs[String]
7676
csv must include("10Bx939c5543TqA1144M999143X,38,10Bx939c5543TqA1144M999143X38")

0 commit comments

Comments
 (0)