use of com.marketo.mktows.ParamsSyncMultipleLeads in project components by Talend.
the class MarketoSOAPClient method syncMultipleLeads.
@Override
public MarketoSyncResult syncMultipleLeads(TMarketoOutputProperties parameters, List<IndexedRecord> leads) {
MarketoSyncResult mkto = new MarketoSyncResult();
try {
ParamsSyncMultipleLeads request = new ParamsSyncMultipleLeads();
ArrayOfLeadRecord leadRecords = new ArrayOfLeadRecord();
for (IndexedRecord r : leads) {
leadRecords.getLeadRecords().add(convertToLeadRecord(r, parameters.mappingInput.getNameMappingsForMarketo()));
}
JAXBElement<Boolean> dedup = objectFactory.createParamsSyncMultipleLeadsDedupEnabled(parameters.deDupeEnabled.getValue());
request.setDedupEnabled(dedup);
request.setLeadRecordList(leadRecords);
SuccessSyncMultipleLeads result = getPort().syncMultipleLeads(request, header);
//
if (LOG.isDebugEnabled()) {
try {
JAXBContext context = JAXBContext.newInstance(SuccessSyncLead.class);
Marshaller m = context.createMarshaller();
m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
m.marshal(result, System.out);
} catch (JAXBException e) {
LOG.error(e.getMessage());
}
}
//
List<SyncStatus> records = new ArrayList<>();
for (com.marketo.mktows.SyncStatus status : result.getResult().getSyncStatusList().getSyncStatuses()) {
SyncStatus s = new SyncStatus(status.getLeadId(), status.getStatus().value());
s.setErrorMessage(status.getError().getValue());
records.add(s);
}
mkto.setSuccess(result.getResult().getSyncStatusList() != null);
mkto.setRecords(records);
} catch (Exception e) {
LOG.error(e.toString());
mkto.setSuccess(false);
mkto.setErrors(Collections.singletonList(new MarketoError(SOAP, e.getMessage())));
}
return mkto;
}
Aggregations