Search in sources :

Example 1 with ArrayOfLeadRecord

use of com.marketo.mktows.ArrayOfLeadRecord in project components by Talend.

the class MarketoSOAPClientTest method getMultipleLeadResult.

public SuccessGetMultipleLeads getMultipleLeadResult() {
    SuccessGetMultipleLeads result = new SuccessGetMultipleLeads();
    ResultGetMultipleLeads res = new ResultGetMultipleLeads();
    res.setReturnCount(1);
    res.setRemainingCount(0);
    ArrayOfLeadRecord leadrecords = new ArrayOfLeadRecord();
    LeadRecord r = new LeadRecord();
    r.setId(objectFactory.createLeadRecordId(12345));
    r.setEmail(objectFactory.createLeadRecordEmail("t@t.com"));
    r.setForeignSysPersonId(objectFactory.createLeadRecordForeignSysPersonId(""));
    r.setForeignSysType(objectFactory.createLeadRecordForeignSysType(null));
    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;
}
Also used : ArrayOfLeadRecord(com.marketo.mktows.ArrayOfLeadRecord) ArrayOfLeadRecord(com.marketo.mktows.ArrayOfLeadRecord) LeadRecord(com.marketo.mktows.LeadRecord) QName(javax.xml.namespace.QName) SuccessGetMultipleLeads(com.marketo.mktows.SuccessGetMultipleLeads) JAXBElement(javax.xml.bind.JAXBElement) ResultGetMultipleLeads(com.marketo.mktows.ResultGetMultipleLeads)

Example 2 with ArrayOfLeadRecord

use of com.marketo.mktows.ArrayOfLeadRecord 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;
}
Also used : Marshaller(javax.xml.bind.Marshaller) IndexedRecord(org.apache.avro.generic.IndexedRecord) JAXBException(javax.xml.bind.JAXBException) SyncStatus(org.talend.components.marketo.runtime.client.rest.type.SyncStatus) ArrayList(java.util.ArrayList) JAXBContext(javax.xml.bind.JAXBContext) ParamsSyncMultipleLeads(com.marketo.mktows.ParamsSyncMultipleLeads) DatatypeConfigurationException(javax.xml.datatype.DatatypeConfigurationException) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException) InvalidKeyException(java.security.InvalidKeyException) WebServiceException(javax.xml.ws.WebServiceException) MarketoException(org.talend.components.marketo.runtime.client.type.MarketoException) ParseException(java.text.ParseException) JAXBException(javax.xml.bind.JAXBException) ComponentException(org.talend.components.api.exception.ComponentException) MalformedURLException(java.net.MalformedURLException) MarketoSyncResult(org.talend.components.marketo.runtime.client.type.MarketoSyncResult) MarketoError(org.talend.components.marketo.runtime.client.type.MarketoError) ArrayOfLeadRecord(com.marketo.mktows.ArrayOfLeadRecord) SuccessSyncMultipleLeads(com.marketo.mktows.SuccessSyncMultipleLeads)

Example 3 with ArrayOfLeadRecord

use of com.marketo.mktows.ArrayOfLeadRecord 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;
}
Also used : ArrayOfLeadRecord(com.marketo.mktows.ArrayOfLeadRecord) ArrayOfAttribute(com.marketo.mktows.ArrayOfAttribute) ArrayOfLeadRecord(com.marketo.mktows.ArrayOfLeadRecord) LeadRecord(com.marketo.mktows.LeadRecord) ArrayOfAttribute(com.marketo.mktows.ArrayOfAttribute) Attribute(com.marketo.mktows.Attribute) QName(javax.xml.namespace.QName) SuccessGetLead(com.marketo.mktows.SuccessGetLead) ResultGetLead(com.marketo.mktows.ResultGetLead) JAXBElement(javax.xml.bind.JAXBElement)

Aggregations

ArrayOfLeadRecord (com.marketo.mktows.ArrayOfLeadRecord)3 LeadRecord (com.marketo.mktows.LeadRecord)2 JAXBElement (javax.xml.bind.JAXBElement)2 QName (javax.xml.namespace.QName)2 ArrayOfAttribute (com.marketo.mktows.ArrayOfAttribute)1 Attribute (com.marketo.mktows.Attribute)1 ParamsSyncMultipleLeads (com.marketo.mktows.ParamsSyncMultipleLeads)1 ResultGetLead (com.marketo.mktows.ResultGetLead)1 ResultGetMultipleLeads (com.marketo.mktows.ResultGetMultipleLeads)1 SuccessGetLead (com.marketo.mktows.SuccessGetLead)1 SuccessGetMultipleLeads (com.marketo.mktows.SuccessGetMultipleLeads)1 SuccessSyncMultipleLeads (com.marketo.mktows.SuccessSyncMultipleLeads)1 MalformedURLException (java.net.MalformedURLException)1 InvalidKeyException (java.security.InvalidKeyException)1 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)1 ParseException (java.text.ParseException)1 ArrayList (java.util.ArrayList)1 JAXBContext (javax.xml.bind.JAXBContext)1 JAXBException (javax.xml.bind.JAXBException)1 Marshaller (javax.xml.bind.Marshaller)1