Skip to content

Commit 7a51940

Browse files
Merge pull request #148 from intuit/ipp-17592
add deserialization for CRUD
2 parents 0a3706e + c1a9f0b commit 7a51940

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

ipp-v3-java-devkit/src/main/java/com/intuit/ipp/serialization/IntuitResponseDeserializer.java

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,11 @@ public class IntuitResponseDeserializer extends JsonDeserializer<IntuitResponse>
124124
* variable ATTACHABLE_RESPONSE
125125
*/
126126
private static final String ATTACHABLE_RESPONSE = "AttachableResponse";
127+
128+
/**
129+
* variable ATTACHABLE_RESPONSE
130+
*/
131+
private static final String RECURRING_TXN_RESPONSE = "RecurringTransaction";
127132

128133
/**
129134
* variable objFactory
@@ -236,6 +241,41 @@ public IntuitResponse deserialize(JsonParser jp, DeserializationContext desConte
236241
}
237242
qr.setAttachableResponse(attachableResponses);
238243
}
244+
} else if (key.equals(RECURRING_TXN_RESPONSE)) {
245+
if (JsonResourceTypeLocator.lookupType(key) != null) {
246+
LOG.debug("processing recurring transaction response");
247+
248+
JsonNode rtNode = jn.get(key);
249+
Object recurringTxn = mapper.treeToValue(rtNode, JsonResourceTypeLocator.lookupType(key));
250+
RecurringTransaction rt = new RecurringTransaction();
251+
rt = (RecurringTransaction) recurringTxn;
252+
253+
String entityName = rtNode.fieldNames().next();
254+
LOG.debug("RecurringTransaction : " + entityName);
255+
256+
//read the underlying txn node
257+
JsonNode entityNode = rtNode.get(entityName);
258+
259+
//Force the data to be casted to its type
260+
Object entity = mapper.treeToValue(entityNode, JsonResourceTypeLocator.lookupType(entityName));
261+
262+
//Double check
263+
if (entity instanceof IntuitEntity) {
264+
intuitResponseDeserializerHelper.updateBigDecimalScale((IntuitEntity) entity);
265+
JAXBElement<? extends IntuitEntity> intuitObject = objFactory.createIntuitObject((IntuitEntity) entity);
266+
rt.setIntuitObject(intuitObject);
267+
}
268+
269+
// set the CustomFieldDefinition deserializer
270+
registerModulesForCustomFieldDef(mapper);
271+
272+
Object obj = rt;
273+
if (obj instanceof IntuitEntity) {
274+
intuitResponseDeserializerHelper.updateBigDecimalScale((IntuitEntity) obj);
275+
JAXBElement<? extends IntuitEntity> intuitObject = objFactory.createIntuitObject((IntuitEntity) obj);
276+
qr.setIntuitObject(intuitObject);
277+
}
278+
}
239279
} else {
240280
// It has to be an IntuitEntity
241281
String entity = key;

0 commit comments

Comments
 (0)