File tree Expand file tree Collapse file tree 3 files changed +10
-2
lines changed
main/scala/hmda/api/http/public
test/scala/hmda/api/http/public Expand file tree Collapse file tree 3 files changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -152,6 +152,7 @@ Example file contents:
152152Example response in ` CSV ` format:
153153
154154``` csv
155+ loanId,checkDigit,uli
15515610Bx939c5543TqA1144M999143X,38,10Bx939c5543TqA1144M999143X38
15615710Cx939c5543TqA1144M999143X,10,10Cx939c5543TqA1144M999143X10
157158```
@@ -224,6 +225,7 @@ Example file contents:
224225Example response in ` CSV ` format:
225226
226227``` csv
228+ uli,isValid
22722910Cx939c5543TqA1144M999143X10,true
22823010Bx939c5543TqA1144M999143X38,true
22923110Bx939c5543TqA1144M999133X38,false
Original file line number Diff line number Diff line change @@ -63,12 +63,14 @@ trait PublicHttpApi extends PublicLarHttpApi with HmdaCustomDirectives with ApiE
6363 timedPost { _ =>
6464 fileUpload(" file" ) {
6565 case (_, byteSource) =>
66+ val headerSource = Source .fromIterator(() => List (" loanId,checkDigit,uli\n " ).toIterator)
6667 val checkDigit = processLoanIdFile(byteSource)
6768 .map(l => l.toCSV)
6869 .map(l => l + " \n " )
6970 .map(s => ByteString (s))
7071
71- complete(HttpEntity .Chunked .fromData(`text/csv`.toContentType(HttpCharsets .`UTF-8`), checkDigit))
72+ val csv = headerSource.map(s => ByteString (s)).concat(checkDigit)
73+ complete(HttpEntity .Chunked .fromData(`text/csv`.toContentType(HttpCharsets .`UTF-8`), csv))
7274
7375 case _ =>
7476 complete(ToResponseMarshallable (StatusCodes .BadRequest ))
@@ -103,12 +105,14 @@ trait PublicHttpApi extends PublicLarHttpApi with HmdaCustomDirectives with ApiE
103105 timedPost { _ =>
104106 fileUpload(" file" ) {
105107 case (_, byteSource) =>
108+ val headerSource = Source .fromIterator(() => List (" uli,isValid\n " ).toIterator)
106109 val validated = processUliFile(byteSource)
107110 .map(u => u.toCSV)
108111 .map(l => l + " \n " )
109112 .map(s => ByteString (s))
110113
111- complete(HttpEntity .Chunked .fromData(`text/csv`.toContentType(HttpCharsets .`UTF-8`), validated))
114+ val csv = headerSource.map(s => ByteString (s)).concat(validated)
115+ complete(HttpEntity .Chunked .fromData(`text/csv`.toContentType(HttpCharsets .`UTF-8`), csv))
112116
113117 case _ =>
114118 complete(ToResponseMarshallable (StatusCodes .BadRequest ))
Original file line number Diff line number Diff line change @@ -73,6 +73,7 @@ class PublicHttpApiSpec extends WordSpec with MustMatchers with BeforeAndAfterAl
7373 Post (" /uli/checkDigit/csv" , loanFile) ~> publicHttpRoutes ~> check {
7474 status mustBe StatusCodes .OK
7575 val csv = responseAs[String ]
76+ csv must include(" loanId,checkDigit,uli" )
7677 csv must include(" 10Bx939c5543TqA1144M999143X,38,10Bx939c5543TqA1144M999143X38" )
7778 csv must include(" 10Cx939c5543TqA1144M999143X,10,10Cx939c5543TqA1144M999143X10" )
7879 }
@@ -86,6 +87,7 @@ class PublicHttpApiSpec extends WordSpec with MustMatchers with BeforeAndAfterAl
8687 Post (" /uli/validate/csv" , uliFile) ~> publicHttpRoutes ~> check {
8788 status mustBe StatusCodes .OK
8889 val csv = responseAs[String ]
90+ csv must include(" uli,isValid" )
8991 csv must include(" 10Cx939c5543TqA1144M999143X10,true" )
9092 csv must include(" 10Bx939c5543TqA1144M999143X38,true" )
9193 csv must include(" 10Bx939c5543TqA1144M999133X38,false" )
You can’t perform that action at this time.
0 commit comments