forked from cfpb/hmda-platform
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request cfpb#1225 from jmarin/check-digit
Check digit
- Loading branch information
Showing
9 changed files
with
479 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
api-model/src/main/scala/hmda/api/model/public/ULIModel.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package hmda.api.model.public | ||
|
||
object ULIModel { | ||
|
||
case class Loan(loanId: String) | ||
case class ULI(loanId: String, checkDigit: Int, uli: String) { | ||
def toCSV: String = s"$loanId,$checkDigit,$uli" | ||
} | ||
case class LoanCheckDigitResponse(loanIds: Seq[ULI]) | ||
case class ULICheck(uli: String) | ||
case class ULIValidated(isValid: Boolean) | ||
case class ULIBatchValidated(uli: String, isValid: Boolean) { | ||
def toCSV: String = s"$uli,$isValid" | ||
} | ||
case class ULIBatchValidatedResponse(ulis: Seq[ULIBatchValidated]) | ||
} |
16 changes: 16 additions & 0 deletions
16
api-model/src/main/scala/hmda/api/protocol/public/ULIProtocol.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package hmda.api.protocol.public | ||
|
||
import hmda.api.model.public.ULIModel._ | ||
import spray.json.DefaultJsonProtocol | ||
|
||
trait ULIProtocol extends DefaultJsonProtocol { | ||
|
||
implicit val loanFormat = jsonFormat1(Loan.apply) | ||
implicit val uliFormat = jsonFormat3(ULI.apply) | ||
implicit val loanCheckDigitResponse = jsonFormat1(LoanCheckDigitResponse.apply) | ||
implicit val uliCheckFormat = jsonFormat1(ULICheck.apply) | ||
implicit val uliValidatedFormat = jsonFormat1(ULIValidated.apply) | ||
implicit val uliBatchValidatedFormat = jsonFormat2(ULIBatchValidated.apply) | ||
implicit val uliBatchValidatedResponseFormat = jsonFormat1(ULIBatchValidatedResponse.apply) | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package hmda.api.http | ||
|
||
import akka.http.scaladsl.model.{ ContentTypes, HttpEntity, Multipart } | ||
|
||
trait FileUploadUtils { | ||
def multiPartFile(contents: String, fileName: String) = | ||
Multipart.FormData(Multipart.FormData.BodyPart.Strict( | ||
"file", | ||
HttpEntity(ContentTypes.`text/plain(UTF-8)`, contents), | ||
Map("filename" -> fileName) | ||
)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.