use of com.marketo.mktows.SuccessGetLead in project components by Talend.
the class MarketoSOAPClient method getLead.
@Override
public MarketoRecordResult getLead(TMarketoInputProperties parameters, String offset) {
LOG.debug("MarketoSOAPClient.getLead with selector:{} key:{} value:{}.", parameters.leadSelectorSOAP.getValue(), parameters.leadKeyTypeSOAP.getValue(), parameters.leadKeyValue.getValue());
String leadKeyType = parameters.leadKeyTypeSOAP.getValue().toString();
String leadKeyValue = parameters.leadKeyValue.getValue();
Schema schema = parameters.schemaInput.schema.getValue();
Map<String, String> mappings = parameters.mappingInput.getNameMappingsForMarketo();
// Create Request
ParamsGetLead request = new ParamsGetLead();
LeadKey key = new LeadKey();
key.setKeyType(valueOf(leadKeyType));
key.setKeyValue(leadKeyValue);
request.setLeadKey(key);
//
SuccessGetLead result = null;
MarketoRecordResult mkto = new MarketoRecordResult();
try {
result = getPort().getLead(request, header);
} catch (Exception e) {
LOG.error("Lead not found : {}.", e.getMessage());
mkto.setSuccess(false);
mkto.setRecordCount(0);
mkto.setRemainCount(0);
mkto.setErrors(Collections.singletonList(new MarketoError(SOAP, e.getMessage())));
return mkto;
}
if (result == null || result.getResult().getCount() == 0) {
LOG.debug(MESSAGE_REQUEST_RETURNED_0_MATCHING_LEADS);
mkto.setErrors(Collections.singletonList(new MarketoError(SOAP, MESSAGE_NO_LEADS_FOUND)));
mkto.setSuccess(true);
} else {
int counted = result.getResult().getCount();
List<IndexedRecord> results = convertLeadRecords(result.getResult().getLeadRecordList().getValue().getLeadRecords(), schema, mappings);
mkto.setRecordCount(counted);
mkto.setRemainCount(0);
mkto.setSuccess(true);
mkto.setRecords(results);
}
return mkto;
}
use of com.marketo.mktows.SuccessGetLead in project components by Talend.
the class MarketoSOAPClientTest method getGetLeadResult.
public SuccessGetLead getGetLeadResult() {
SuccessGetLead result = new SuccessGetLead();
ResultGetLead res = new ResultGetLead();
res.setCount(1);
ArrayOfLeadRecord leadrecords = new ArrayOfLeadRecord();
LeadRecord r = new LeadRecord();
r.setId(objectFactory.createLeadRecordId(12345));
r.setEmail(objectFactory.createLeadRecordEmail("email@email.com"));
r.setForeignSysPersonId(objectFactory.createLeadRecordForeignSysPersonId("foreignSysPersonId"));
r.setForeignSysType(objectFactory.createLeadRecordForeignSysType(ForeignSysType.SFDC));
ArrayOfAttribute aoa = objectFactory.createArrayOfAttribute();
Attribute attr = new Attribute();
attr.setAttrName("attrName");
attr.setAttrValue("attrValue");
aoa.getAttributes().add(attr);
r.setLeadAttributeList(objectFactory.createActivityRecordActivityAttributes(aoa));
leadrecords.getLeadRecords().add(r);
QName qname = new QName("http://www.marketo.com/mktows/", "leadAttributeList");
JAXBElement<ArrayOfLeadRecord> attrList = new JAXBElement(qname, LeadRecord.class, leadrecords);
res.setLeadRecordList(attrList);
result.setResult(res);
return result;
}
Aggregations