Skip to content

Commit

Permalink
type_flush (hack)
Browse files Browse the repository at this point in the history
  • Loading branch information
shtukas committed Oct 26, 2024
1 parent d428cb3 commit 02c538c
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -86,4 +86,11 @@ case class ZuoraAmendmentOrderResponse(
)
object ZuoraAmendmentOrderResponse {
implicit val rw: ReadWriter[ZuoraAmendmentOrderResponse] = macroRW

def type_flush(str: String): String = {
str
.replace(""""$type": "ZuoraAmendmentOrderPayloadOrderActionAdd",""", "")
.replace(""""$type": "ZuoraAmendmentOrderPayloadOrderActionRemove",""", "")
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -212,9 +212,16 @@ object ZuoraLive {
subscription: ZuoraSubscription,
payload: ZuoraAmendmentOrderPayload
): ZIO[Any, ZuoraOrderFailure, Unit] = {

def type_flush(str: String): String = {
str
.replace(""""$type": "ZuoraAmendmentOrderPayloadOrderActionAdd",""", "")
.replace(""""$type": "ZuoraAmendmentOrderPayloadOrderActionRemove",""", "")
}

post[ZuoraAmendmentOrderResponse](
path = s"orders",
body = write(payload)
body = type_flush(write(payload))
).foldZIO(
failure = e =>
ZIO.fail(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1210,9 +1210,9 @@ class SupporterPlus2024MigrationTest extends munit.FunSuite {
)
)
assertEquals(
write(data, indent = 2),
ZuoraAmendmentOrderResponse.type_flush(write(data, indent = 2)),
"""{
| "$type": "ZuoraAmendmentOrderPayloadOrderActionAdd",
|
| "type": "AddProduct",
| "triggerDates": [
| {
Expand Down Expand Up @@ -1268,7 +1268,7 @@ class SupporterPlus2024MigrationTest extends munit.FunSuite {
newContributionAmount = 0
)
assertEquals(
write(data, indent = 2),
ZuoraAmendmentOrderResponse.type_flush(write(data, indent = 2)),
"""{
| "orderDate": "2024-10-24",
| "existingAccountNumber": "A01955911",
Expand All @@ -1277,7 +1277,7 @@ class SupporterPlus2024MigrationTest extends munit.FunSuite {
| "subscriptionNumber": "A-S02019224",
| "orderActions": [
| {
| "$type": "ZuoraAmendmentOrderPayloadOrderActionRemove",
|
| "type": "RemoveProduct",
| "triggerDates": [
| {
Expand All @@ -1298,7 +1298,7 @@ class SupporterPlus2024MigrationTest extends munit.FunSuite {
| }
| },
| {
| "$type": "ZuoraAmendmentOrderPayloadOrderActionAdd",
|
| "type": "AddProduct",
| "triggerDates": [
| {
Expand Down

0 comments on commit 02c538c

Please sign in to comment.