This file contains hidden or 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
| sealed trait Update | |
| case class UpdateRefund(`type` = "updateStatus", additionalData:Option[String], status: Option[String]) extends Update | |
| case class UpdateNewPurchase(`type` = "newPurchase", additionalData:Option[String], amount: Option[Double]) extends Update |
This file contains hidden or 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
| val statusSchema = Schema.oneOf[Status] {alt => | |
| val refundSchema = Schema.record[Refund]{field => | |
| field.const("type", "refund") *> (field("refundId", _.refundId), | |
| field("refundReason", _.refundReason), | |
| field("timestamp", _.timestamp).map(Instant.parse), | |
| field("amount", _.amount)).mapN((refundId:String, refundreason: String, timestamp:Instant, amount:Double) => Refund(refundId = refundId, refundReason = refundreason, timestamp = timestamp, amount = amount)) | |
| } | |
| val paidSchema = Schema.record[Paid]{field => | |
| field.const("type", "paid") *> (field("timestamp", _.timestamp).map(Instant.parse), |
This file contains hidden or 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
| val statusSchema = Schema.oneOf[Status] {alt => | |
| val refundSchema = Schema.record[Refund]{field => | |
| (field("refundId", _.refundId), | |
| field("refundReason", _.refundReason), | |
| field("timestamp", _.timestamp).map(Instant.parse), | |
| field("amount", _.amount)).mapN((refundId:String, refundreason: String, timestamp:Instant, amount:Double) => Refund(refundId = refundId, refundReason = refundreason, timestamp = timestamp, amount = amount)) | |
| } | |
| val paidSchema = Schema.record[Paid]{field => | |
| (field("timestamp", _.timestamp).map(Instant.parse), |
This file contains hidden or 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
| def receivedSchema: Schema[Received] = Schema[String].imapErr{s => | |
| Received.parse(s).toRight(Schema.ReadError(s"$s is not a valid Received value")) | |
| }(_.toString) |
This file contains hidden or 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
| def parse(str: String): Option[Received] = str match { | |
| case "Yes" => Some(Yes) | |
| case "No" => Some(No) | |
| case _ => None | |
| } |
This file contains hidden or 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
| val metadataSchema: Schema[Metadata] = Schema.record[Metadata]{field => | |
| ( | |
| field("isTest", _.isTest), | |
| field("region", _.region)(regionSchema), | |
| field.opt("sourceOfRequest", _.sourceOfRequest) | |
| ).mapN(Metadata.apply) | |
| } |
This file contains hidden or 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
| lazy val regionSchema: Schema[Region] = Schema[String].imap(s => Region.of(s))(region => region.toString) |
This file contains hidden or 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
| val metadataSchema: Schema[Metadata] = Schema.record[Metadata]{field => | |
| ( | |
| field("isTest", _.isTest), | |
| field("region", _.region), | |
| field.opt("sourceOfRequest", _.sourceOfRequest) | |
| ).mapN(Metadata.apply) | |
| } |
This file contains hidden or 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
| case class Invoice(invoiceId: String, orderCode:String, metadata:Metadata, status: Status, isReceived: Received) |
This file contains hidden or 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
| sealed trait Received | |
| case object Yes extends Received | |
| case object No extends Received |