Skip to content

Commit

Permalink
feat(client): support union discriminators in deserialization (#328)
Browse files Browse the repository at this point in the history
  • Loading branch information
stainless-app[bot] committed Nov 1, 2024
1 parent 57a5f4f commit 5d39454
Show file tree
Hide file tree
Showing 13 changed files with 57 additions and 10 deletions.
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

0 comments on commit 5d39454

Please sign in to comment.