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:
152
152
Example response in ` CSV ` format:
153
153
154
154
``` csv
155
+ loanId,checkDigit,uli
155
156
10Bx939c5543TqA1144M999143X,38,10Bx939c5543TqA1144M999143X38
156
157
10Cx939c5543TqA1144M999143X,10,10Cx939c5543TqA1144M999143X10
157
158
```
@@ -224,6 +225,7 @@ Example file contents:
224
225
Example response in ` CSV ` format:
225
226
226
227
``` csv
228
+ uli,isValid
227
229
10Cx939c5543TqA1144M999143X10,true
228
230
10Bx939c5543TqA1144M999143X38,true
229
231
10Bx939c5543TqA1144M999133X38,false
Original file line number Diff line number Diff line change @@ -63,12 +63,14 @@ trait PublicHttpApi extends PublicLarHttpApi with HmdaCustomDirectives with ApiE
63
63
timedPost { _ =>
64
64
fileUpload(" file" ) {
65
65
case (_, byteSource) =>
66
+ val headerSource = Source .fromIterator(() => List (" loanId,checkDigit,uli\n " ).toIterator)
66
67
val checkDigit = processLoanIdFile(byteSource)
67
68
.map(l => l.toCSV)
68
69
.map(l => l + " \n " )
69
70
.map(s => ByteString (s))
70
71
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))
72
74
73
75
case _ =>
74
76
complete(ToResponseMarshallable (StatusCodes .BadRequest ))
@@ -103,12 +105,14 @@ trait PublicHttpApi extends PublicLarHttpApi with HmdaCustomDirectives with ApiE
103
105
timedPost { _ =>
104
106
fileUpload(" file" ) {
105
107
case (_, byteSource) =>
108
+ val headerSource = Source .fromIterator(() => List (" uli,isValid\n " ).toIterator)
106
109
val validated = processUliFile(byteSource)
107
110
.map(u => u.toCSV)
108
111
.map(l => l + " \n " )
109
112
.map(s => ByteString (s))
110
113
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))
112
116
113
117
case _ =>
114
118
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
73
73
Post (" /uli/checkDigit/csv" , loanFile) ~> publicHttpRoutes ~> check {
74
74
status mustBe StatusCodes .OK
75
75
val csv = responseAs[String ]
76
+ csv must include(" loanId,checkDigit,uli" )
76
77
csv must include(" 10Bx939c5543TqA1144M999143X,38,10Bx939c5543TqA1144M999143X38" )
77
78
csv must include(" 10Cx939c5543TqA1144M999143X,10,10Cx939c5543TqA1144M999143X10" )
78
79
}
@@ -86,6 +87,7 @@ class PublicHttpApiSpec extends WordSpec with MustMatchers with BeforeAndAfterAl
86
87
Post (" /uli/validate/csv" , uliFile) ~> publicHttpRoutes ~> check {
87
88
status mustBe StatusCodes .OK
88
89
val csv = responseAs[String ]
90
+ csv must include(" uli,isValid" )
89
91
csv must include(" 10Cx939c5543TqA1144M999143X10,true" )
90
92
csv must include(" 10Bx939c5543TqA1144M999143X38,true" )
91
93
csv must include(" 10Bx939c5543TqA1144M999133X38,false" )
You can’t perform that action at this time.
0 commit comments