File tree Expand file tree Collapse file tree
lithic-java-core/src/main/kotlin/com/lithic/api Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -11,6 +11,7 @@ import com.fasterxml.jackson.databind.JsonMappingException
1111import com.fasterxml.jackson.databind.JsonNode
1212import com.fasterxml.jackson.databind.deser.ContextualDeserializer
1313import com.fasterxml.jackson.databind.deser.std.StdDeserializer
14+ import com.lithic.api.errors.LithicInvalidDataException
1415import kotlin.reflect.KClass
1516
1617abstract class BaseDeserializer <T : Any >(type : KClass <T >) :
@@ -29,6 +30,13 @@ abstract class BaseDeserializer<T : Any>(type: KClass<T>) :
2930
3031 protected abstract fun ObjectCodec.deserialize (node : JsonNode ): T
3132
33+ protected fun <T > ObjectCodec.deserialize (node : JsonNode , type : TypeReference <T >): T =
34+ try {
35+ readValue(treeAsTokens(node), type)
36+ } catch (e: Exception ) {
37+ throw LithicInvalidDataException (" Error deserializing" , e)
38+ }
39+
3240 protected fun <T > ObjectCodec.tryDeserialize (
3341 node : JsonNode ,
3442 type : TypeReference <T >,
Original file line number Diff line number Diff line change @@ -416,18 +416,14 @@ private constructor(
416416 json.asObject().getOrNull()?.get(" verification_method" )?.asString()?.getOrNull()
417417
418418 if (verificationMethod == " EXTERNALLY_VERIFIED" ) {
419- tryDeserialize(
420- node,
421- jacksonTypeRef<ExternallyVerifiedCreateBankAccountApiRequest >(),
422- ) {
423- it.validate()
424- }
425- ?.let {
426- return Body (
427- externallyVerifiedCreateBankAccountApiRequest = it,
428- _json = json,
429- )
430- }
419+ return Body (
420+ externallyVerifiedCreateBankAccountApiRequest =
421+ deserialize(
422+ node,
423+ jacksonTypeRef<ExternallyVerifiedCreateBankAccountApiRequest >(),
424+ ),
425+ _json = json,
426+ )
431427 }
432428
433429 tryDeserialize(node, jacksonTypeRef<BankVerifiedCreateBankAccountApiRequest >()) {
You can’t perform that action at this time.
0 commit comments