Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(client): support union discriminators in deserialization #328

Merged
merged 1 commit into from
Oct 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ constructor(

override fun ObjectCodec.deserialize(node: JsonNode): AccountHolderCreateBody {
val json = JsonValue.fromJsonNode(node)

tryDeserialize(node, jacksonTypeRef<Kyb>())?.let {
return AccountHolderCreateBody(kyb = it, _json = json)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ constructor(

override fun ObjectCodec.deserialize(node: JsonNode): AuthRuleV2ApplyBody {
val json = JsonValue.fromJsonNode(node)

tryDeserialize(node, jacksonTypeRef<ApplyAuthRuleRequestAccountTokens>())?.let {
return AuthRuleV2ApplyBody(applyAuthRuleRequestAccountTokens = it, _json = json)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ constructor(

override fun ObjectCodec.deserialize(node: JsonNode): AuthRuleV2CreateBody {
val json = JsonValue.fromJsonNode(node)

tryDeserialize(node, jacksonTypeRef<CreateAuthRuleRequestAccountTokens>())?.let {
return AuthRuleV2CreateBody(
createAuthRuleRequestAccountTokens = it,
Expand Down Expand Up @@ -526,6 +527,7 @@ constructor(

override fun ObjectCodec.deserialize(node: JsonNode): AuthRuleParameters {
val json = JsonValue.fromJsonNode(node)

tryDeserialize(node, jacksonTypeRef<ConditionalBlockParameters>()) {
it.validate()
}
Expand Down Expand Up @@ -1029,6 +1031,7 @@ constructor(

override fun ObjectCodec.deserialize(node: JsonNode): Value {
val json = JsonValue.fromJsonNode(node)

tryDeserialize(node, jacksonTypeRef<String>())?.let {
return Value(string = it, _json = json)
}
Expand Down Expand Up @@ -1361,6 +1364,7 @@ constructor(

override fun ObjectCodec.deserialize(node: JsonNode): AuthRuleParameters {
val json = JsonValue.fromJsonNode(node)

tryDeserialize(node, jacksonTypeRef<ConditionalBlockParameters>()) {
it.validate()
}
Expand Down Expand Up @@ -1864,6 +1868,7 @@ constructor(

override fun ObjectCodec.deserialize(node: JsonNode): Value {
val json = JsonValue.fromJsonNode(node)

tryDeserialize(node, jacksonTypeRef<String>())?.let {
return Value(string = it, _json = json)
}
Expand Down Expand Up @@ -2196,6 +2201,7 @@ constructor(

override fun ObjectCodec.deserialize(node: JsonNode): AuthRuleParameters {
val json = JsonValue.fromJsonNode(node)

tryDeserialize(node, jacksonTypeRef<ConditionalBlockParameters>()) {
it.validate()
}
Expand Down Expand Up @@ -2699,6 +2705,7 @@ constructor(

override fun ObjectCodec.deserialize(node: JsonNode): Value {
val json = JsonValue.fromJsonNode(node)

tryDeserialize(node, jacksonTypeRef<String>())?.let {
return Value(string = it, _json = json)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,7 @@ constructor(

override fun ObjectCodec.deserialize(node: JsonNode): AuthRuleParameters {
val json = JsonValue.fromJsonNode(node)

tryDeserialize(node, jacksonTypeRef<ConditionalBlockParameters>()) { it.validate() }
?.let {
return AuthRuleParameters(conditionalBlockParameters = it, _json = json)
Expand Down Expand Up @@ -849,6 +850,7 @@ constructor(

override fun ObjectCodec.deserialize(node: JsonNode): Value {
val json = JsonValue.fromJsonNode(node)

tryDeserialize(node, jacksonTypeRef<String>())?.let {
return Value(string = it, _json = json)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,23 @@ constructor(

override fun ObjectCodec.deserialize(node: JsonNode): ExternalBankAccountCreateBody {
val json = JsonValue.fromJsonNode(node)
val verificationMethod = json.asObject()?.get("verification_method")?.asString()

when (verificationMethod) {
"EXTERNALLY_VERIFIED" -> {
tryDeserialize(
node,
jacksonTypeRef<ExternallyVerifiedCreateBankAccountApiRequest>()
)
?.let {
return ExternalBankAccountCreateBody(
externallyVerifiedCreateBankAccountApiRequest = it,
_json = json
)
}
}
}

tryDeserialize(node, jacksonTypeRef<BankVerifiedCreateBankAccountApiRequest>())
?.let {
return ExternalBankAccountCreateBody(
Expand All @@ -213,16 +230,6 @@ constructor(
_json = json
)
}
tryDeserialize(
node,
jacksonTypeRef<ExternallyVerifiedCreateBankAccountApiRequest>()
)
?.let {
return ExternalBankAccountCreateBody(
externallyVerifiedCreateBankAccountApiRequest = it,
_json = json
)
}

return ExternalBankAccountCreateBody(_json = json)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,7 @@ private constructor(

override fun ObjectCodec.deserialize(node: JsonNode): AuthRuleParameters {
val json = JsonValue.fromJsonNode(node)

tryDeserialize(node, jacksonTypeRef<ConditionalBlockParameters>()) {
it.validate()
}
Expand Down Expand Up @@ -929,6 +930,7 @@ private constructor(

override fun ObjectCodec.deserialize(node: JsonNode): Value {
val json = JsonValue.fromJsonNode(node)

tryDeserialize(node, jacksonTypeRef<String>())?.let {
return Value(string = it, _json = json)
}
Expand Down Expand Up @@ -1222,6 +1224,7 @@ private constructor(

override fun ObjectCodec.deserialize(node: JsonNode): AuthRuleParameters {
val json = JsonValue.fromJsonNode(node)

tryDeserialize(node, jacksonTypeRef<ConditionalBlockParameters>()) {
it.validate()
}
Expand Down Expand Up @@ -1725,6 +1728,7 @@ private constructor(

override fun ObjectCodec.deserialize(node: JsonNode): Value {
val json = JsonValue.fromJsonNode(node)

tryDeserialize(node, jacksonTypeRef<String>())?.let {
return Value(string = it, _json = json)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,7 @@ private constructor(

override fun ObjectCodec.deserialize(node: JsonNode): AuthRuleParameters {
val json = JsonValue.fromJsonNode(node)

tryDeserialize(node, jacksonTypeRef<ConditionalBlockParameters>()) {
it.validate()
}
Expand Down Expand Up @@ -929,6 +930,7 @@ private constructor(

override fun ObjectCodec.deserialize(node: JsonNode): Value {
val json = JsonValue.fromJsonNode(node)

tryDeserialize(node, jacksonTypeRef<String>())?.let {
return Value(string = it, _json = json)
}
Expand Down Expand Up @@ -1222,6 +1224,7 @@ private constructor(

override fun ObjectCodec.deserialize(node: JsonNode): AuthRuleParameters {
val json = JsonValue.fromJsonNode(node)

tryDeserialize(node, jacksonTypeRef<ConditionalBlockParameters>()) {
it.validate()
}
Expand Down Expand Up @@ -1725,6 +1728,7 @@ private constructor(

override fun ObjectCodec.deserialize(node: JsonNode): Value {
val json = JsonValue.fromJsonNode(node)

tryDeserialize(node, jacksonTypeRef<String>())?.let {
return Value(string = it, _json = json)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,7 @@ private constructor(

override fun ObjectCodec.deserialize(node: JsonNode): AuthRuleParameters {
val json = JsonValue.fromJsonNode(node)

tryDeserialize(node, jacksonTypeRef<ConditionalBlockParameters>()) {
it.validate()
}
Expand Down Expand Up @@ -929,6 +930,7 @@ private constructor(

override fun ObjectCodec.deserialize(node: JsonNode): Value {
val json = JsonValue.fromJsonNode(node)

tryDeserialize(node, jacksonTypeRef<String>())?.let {
return Value(string = it, _json = json)
}
Expand Down Expand Up @@ -1222,6 +1224,7 @@ private constructor(

override fun ObjectCodec.deserialize(node: JsonNode): AuthRuleParameters {
val json = JsonValue.fromJsonNode(node)

tryDeserialize(node, jacksonTypeRef<ConditionalBlockParameters>()) {
it.validate()
}
Expand Down Expand Up @@ -1725,6 +1728,7 @@ private constructor(

override fun ObjectCodec.deserialize(node: JsonNode): Value {
val json = JsonValue.fromJsonNode(node)

tryDeserialize(node, jacksonTypeRef<String>())?.let {
return Value(string = it, _json = json)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,7 @@ private constructor(

override fun ObjectCodec.deserialize(node: JsonNode): AuthRuleParameters {
val json = JsonValue.fromJsonNode(node)

tryDeserialize(node, jacksonTypeRef<ConditionalBlockParameters>()) {
it.validate()
}
Expand Down Expand Up @@ -929,6 +930,7 @@ private constructor(

override fun ObjectCodec.deserialize(node: JsonNode): Value {
val json = JsonValue.fromJsonNode(node)

tryDeserialize(node, jacksonTypeRef<String>())?.let {
return Value(string = it, _json = json)
}
Expand Down Expand Up @@ -1222,6 +1224,7 @@ private constructor(

override fun ObjectCodec.deserialize(node: JsonNode): AuthRuleParameters {
val json = JsonValue.fromJsonNode(node)

tryDeserialize(node, jacksonTypeRef<ConditionalBlockParameters>()) {
it.validate()
}
Expand Down Expand Up @@ -1725,6 +1728,7 @@ private constructor(

override fun ObjectCodec.deserialize(node: JsonNode): Value {
val json = JsonValue.fromJsonNode(node)

tryDeserialize(node, jacksonTypeRef<String>())?.let {
return Value(string = it, _json = json)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,7 @@ private constructor(

override fun ObjectCodec.deserialize(node: JsonNode): AuthRuleParameters {
val json = JsonValue.fromJsonNode(node)

tryDeserialize(node, jacksonTypeRef<ConditionalBlockParameters>()) {
it.validate()
}
Expand Down Expand Up @@ -929,6 +930,7 @@ private constructor(

override fun ObjectCodec.deserialize(node: JsonNode): Value {
val json = JsonValue.fromJsonNode(node)

tryDeserialize(node, jacksonTypeRef<String>())?.let {
return Value(string = it, _json = json)
}
Expand Down Expand Up @@ -1222,6 +1224,7 @@ private constructor(

override fun ObjectCodec.deserialize(node: JsonNode): AuthRuleParameters {
val json = JsonValue.fromJsonNode(node)

tryDeserialize(node, jacksonTypeRef<ConditionalBlockParameters>()) {
it.validate()
}
Expand Down Expand Up @@ -1725,6 +1728,7 @@ private constructor(

override fun ObjectCodec.deserialize(node: JsonNode): Value {
val json = JsonValue.fromJsonNode(node)

tryDeserialize(node, jacksonTypeRef<String>())?.let {
return Value(string = it, _json = json)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,7 @@ private constructor(

override fun ObjectCodec.deserialize(node: JsonNode): AuthRuleParameters {
val json = JsonValue.fromJsonNode(node)

tryDeserialize(node, jacksonTypeRef<ConditionalBlockParameters>()) {
it.validate()
}
Expand Down Expand Up @@ -929,6 +930,7 @@ private constructor(

override fun ObjectCodec.deserialize(node: JsonNode): Value {
val json = JsonValue.fromJsonNode(node)

tryDeserialize(node, jacksonTypeRef<String>())?.let {
return Value(string = it, _json = json)
}
Expand Down Expand Up @@ -1222,6 +1224,7 @@ private constructor(

override fun ObjectCodec.deserialize(node: JsonNode): AuthRuleParameters {
val json = JsonValue.fromJsonNode(node)

tryDeserialize(node, jacksonTypeRef<ConditionalBlockParameters>()) {
it.validate()
}
Expand Down Expand Up @@ -1725,6 +1728,7 @@ private constructor(

override fun ObjectCodec.deserialize(node: JsonNode): Value {
val json = JsonValue.fromJsonNode(node)

tryDeserialize(node, jacksonTypeRef<String>())?.let {
return Value(string = it, _json = json)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,7 @@ private constructor(

override fun ObjectCodec.deserialize(node: JsonNode): AuthRuleParameters {
val json = JsonValue.fromJsonNode(node)

tryDeserialize(node, jacksonTypeRef<ConditionalBlockParameters>()) {
it.validate()
}
Expand Down Expand Up @@ -929,6 +930,7 @@ private constructor(

override fun ObjectCodec.deserialize(node: JsonNode): Value {
val json = JsonValue.fromJsonNode(node)

tryDeserialize(node, jacksonTypeRef<String>())?.let {
return Value(string = it, _json = json)
}
Expand Down Expand Up @@ -1222,6 +1224,7 @@ private constructor(

override fun ObjectCodec.deserialize(node: JsonNode): AuthRuleParameters {
val json = JsonValue.fromJsonNode(node)

tryDeserialize(node, jacksonTypeRef<ConditionalBlockParameters>()) {
it.validate()
}
Expand Down Expand Up @@ -1725,6 +1728,7 @@ private constructor(

override fun ObjectCodec.deserialize(node: JsonNode): Value {
val json = JsonValue.fromJsonNode(node)

tryDeserialize(node, jacksonTypeRef<String>())?.let {
return Value(string = it, _json = json)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,7 @@ private constructor(

override fun ObjectCodec.deserialize(node: JsonNode): Period {
val json = JsonValue.fromJsonNode(node)

tryDeserialize(node, jacksonTypeRef<Double>())?.let {
return Period(double = it, _json = json)
}
Expand Down