Search in sources :

Example 1 with ArrayOfAttribute

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

the class MarketoSOAPClientTest method getLeadActivityResult.

public SuccessGetLeadActivity getLeadActivityResult() throws Exception {
    SuccessGetLeadActivity result = new SuccessGetLeadActivity();
    LeadActivityList res = new LeadActivityList();
    res.setReturnCount(1);
    res.setRemainingCount(0);
    StreamPosition sp = new StreamPosition();
    sp.setOffset(objectFactory.createStreamPositionOffset(""));
    res.setNewStartPosition(sp);
    ArrayOfActivityRecord arecords = new ArrayOfActivityRecord();
    // 
    ActivityRecord ar = new ActivityRecord();
    ar.setId(objectFactory.createActivityRecordId(123456L));
    ar.setMarketoGUID("ABC-123-DEF");
    ar.setMktgAssetName("mktgAssetName");
    ar.setActivityDateTime(factory.newXMLGregorianCalendar(gcDateTest));
    ar.setActivityType("activityType");
    ar.setCampaign(objectFactory.createActivityRecordCampaign("campaign"));
    ar.setForeignSysId(objectFactory.createActivityRecordForeignSysId("foreignSysId"));
    ar.setForeignSysOrgId(objectFactory.createActivityRecordForeignSysOrgId("foreignSysOrgId"));
    ar.setMktPersonId("mktPersonId");
    ar.setPersonName(objectFactory.createActivityRecordPersonName("personName"));
    ar.setOrgName(objectFactory.createActivityRecordOrgName("orgName"));
    ArrayOfAttribute aoa = objectFactory.createArrayOfAttribute();
    Attribute attr = new Attribute();
    attr.setAttrName("attrName");
    attr.setAttrValue("attrValue");
    aoa.getAttributes().add(attr);
    ar.setActivityAttributes(objectFactory.createActivityRecordActivityAttributes(aoa));
    // 
    arecords.getActivityRecords().add(ar);
    res.setActivityRecordList(objectFactory.createLeadActivityListActivityRecordList(arecords));
    result.setLeadActivityList(res);
    return result;
}
Also used : ArrayOfActivityRecord(com.marketo.mktows.ArrayOfActivityRecord) ArrayOfAttribute(com.marketo.mktows.ArrayOfAttribute) ArrayOfAttribute(com.marketo.mktows.ArrayOfAttribute) Attribute(com.marketo.mktows.Attribute) SuccessGetLeadActivity(com.marketo.mktows.SuccessGetLeadActivity) StreamPosition(com.marketo.mktows.StreamPosition) ArrayOfActivityRecord(com.marketo.mktows.ArrayOfActivityRecord) ActivityRecord(com.marketo.mktows.ActivityRecord) LeadActivityList(com.marketo.mktows.LeadActivityList)

Example 2 with ArrayOfAttribute

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

the class MarketoSOAPClient method convertToLeadRecord.

/*
     * 
     * SyncLeads operations
     * 
     */
public LeadRecord convertToLeadRecord(IndexedRecord record, Map<String, String> mappings) throws MarketoException {
    // first, check if a mandatory field is in the schema
    Boolean ok = Boolean.FALSE;
    for (Entry<String, String> e : mappings.entrySet()) {
        ok |= (e.getKey().equals(FIELD_ID) || e.getKey().equals(FIELD_EMAIL) || e.getKey().equals(FIELD_FOREIGN_SYS_PERSON_ID) || e.getValue().equals(FIELD_ID) || e.getValue().equals(FIELD_EMAIL) || e.getValue().equals(FIELD_FOREIGN_SYS_PERSON_ID)) && record.get(record.getSchema().getField(e.getKey()).pos()) != null;
    }
    if (!ok) {
        MarketoException err = new MarketoException("SOAP", "syncLead error: Missing mandatory field for operation.");
        LOG.error(err.toString());
        throw err;
    }
    // 
    LeadRecord lead = new LeadRecord();
    ArrayOfAttribute aoa = new ArrayOfAttribute();
    for (Field f : record.getSchema().getFields()) {
        // find matching marketo column name
        String col = mappings.get(f.name());
        if (col.equals(FIELD_ID)) {
            final Integer id = (Integer) record.get(f.pos());
            if (id != null) {
                lead.setId(objectFactory.createLeadRecordId(id));
            }
        } else if (col.equals(FIELD_EMAIL)) {
            final String email = (String) record.get(f.pos());
            if (email != null) {
                lead.setEmail(objectFactory.createLeadRecordEmail(email));
            }
        } else if (col.equals(FIELD_FOREIGN_SYS_PERSON_ID)) {
            final String fspid = (String) record.get(f.pos());
            if (fspid != null) {
                lead.setForeignSysPersonId(objectFactory.createLeadRecordForeignSysPersonId(fspid));
            }
        } else if (col.equals(FIELD_FOREIGN_SYS_TYPE)) {
            final String fst = (String) record.get(f.pos());
            if (fst != null) {
                lead.setForeignSysType(objectFactory.createLeadRecordForeignSysType(ForeignSysType.valueOf(fst)));
            }
        } else {
            // skip status & error fields
            if (FIELD_STATUS.equals(col) || FIELD_ERROR_MSG.equals(col)) {
                continue;
            }
            Attribute attr = new Attribute();
            Object value = record.get(f.pos());
            attr.setAttrName(col);
            if (MarketoClientUtils.isDateTypeField(f) && value != null) {
                attr.setAttrValue(MarketoClientUtils.formatLongToDateString(Long.valueOf(String.valueOf(value))));
            } else {
                attr.setAttrValue(String.valueOf(value));
            }
            aoa.getAttributes().add(attr);
        }
    }
    QName qname = new QName("http://www.marketo.com/mktows/", "leadAttributeList");
    JAXBElement<ArrayOfAttribute> attrList = new JAXBElement(qname, ArrayOfAttribute.class, aoa);
    lead.setLeadAttributeList(attrList);
    return lead;
}
Also used : ArrayOfAttribute(com.marketo.mktows.ArrayOfAttribute) ArrayOfAttribute(com.marketo.mktows.ArrayOfAttribute) Attribute(com.marketo.mktows.Attribute) QName(javax.xml.namespace.QName) MarketoException(org.talend.components.marketo.runtime.client.type.MarketoException) ArrayOfString(com.marketo.mktows.ArrayOfString) JAXBElement(javax.xml.bind.JAXBElement) Field(org.apache.avro.Schema.Field) ArrayOfLeadRecord(com.marketo.mktows.ArrayOfLeadRecord) LeadRecord(com.marketo.mktows.LeadRecord)

Example 3 with ArrayOfAttribute

use of com.marketo.mktows.ArrayOfAttribute 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)

Example 4 with ArrayOfAttribute

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

the class MarketoSOAPClientTest method getLeadChangeResult.

public SuccessGetLeadChanges getLeadChangeResult() {
    SuccessGetLeadChanges result = new SuccessGetLeadChanges();
    ResultGetLeadChanges res = new ResultGetLeadChanges();
    res.setReturnCount(1);
    res.setRemainingCount(0);
    StreamPosition sp = new StreamPosition();
    sp.setOffset(objectFactory.createStreamPositionOffset(""));
    res.setNewStartPosition(sp);
    // 
    ArrayOfLeadChangeRecord lcr = new ArrayOfLeadChangeRecord();
    LeadChangeRecord lc = new LeadChangeRecord();
    lc.setId(objectFactory.createLeadChangeRecordId(123456L));
    lc.setMarketoGUID("ABC-123-DEF");
    lc.setMktgAssetName(objectFactory.createLeadChangeRecordMktgAssetName("mktgAssetName"));
    lc.setActivityDateTime(factory.newXMLGregorianCalendar(gcDateTest));
    lc.setActivityType("activityType");
    lc.setCampaign("campaign");
    lc.setMktPersonId("mktPersonId");
    ArrayOfAttribute aoa = objectFactory.createArrayOfAttribute();
    Attribute attr = new Attribute();
    attr.setAttrName("attrName");
    attr.setAttrValue("attrValue");
    aoa.getAttributes().add(attr);
    lc.setActivityAttributes(objectFactory.createActivityRecordActivityAttributes(aoa));
    lcr.getLeadChangeRecords().add(lc);
    // 
    res.setLeadChangeRecordList(objectFactory.createResultGetLeadChangesLeadChangeRecordList(lcr));
    result.setResult(res);
    return result;
}
Also used : ArrayOfAttribute(com.marketo.mktows.ArrayOfAttribute) ArrayOfAttribute(com.marketo.mktows.ArrayOfAttribute) Attribute(com.marketo.mktows.Attribute) SuccessGetLeadChanges(com.marketo.mktows.SuccessGetLeadChanges) ResultGetLeadChanges(com.marketo.mktows.ResultGetLeadChanges) StreamPosition(com.marketo.mktows.StreamPosition) ArrayOfLeadChangeRecord(com.marketo.mktows.ArrayOfLeadChangeRecord) ArrayOfLeadChangeRecord(com.marketo.mktows.ArrayOfLeadChangeRecord) LeadChangeRecord(com.marketo.mktows.LeadChangeRecord)

Aggregations

ArrayOfAttribute (com.marketo.mktows.ArrayOfAttribute)4 Attribute (com.marketo.mktows.Attribute)4 ArrayOfLeadRecord (com.marketo.mktows.ArrayOfLeadRecord)2 LeadRecord (com.marketo.mktows.LeadRecord)2 StreamPosition (com.marketo.mktows.StreamPosition)2 JAXBElement (javax.xml.bind.JAXBElement)2 QName (javax.xml.namespace.QName)2 ActivityRecord (com.marketo.mktows.ActivityRecord)1 ArrayOfActivityRecord (com.marketo.mktows.ArrayOfActivityRecord)1 ArrayOfLeadChangeRecord (com.marketo.mktows.ArrayOfLeadChangeRecord)1 ArrayOfString (com.marketo.mktows.ArrayOfString)1 LeadActivityList (com.marketo.mktows.LeadActivityList)1 LeadChangeRecord (com.marketo.mktows.LeadChangeRecord)1 ResultGetLead (com.marketo.mktows.ResultGetLead)1 ResultGetLeadChanges (com.marketo.mktows.ResultGetLeadChanges)1 SuccessGetLead (com.marketo.mktows.SuccessGetLead)1 SuccessGetLeadActivity (com.marketo.mktows.SuccessGetLeadActivity)1 SuccessGetLeadChanges (com.marketo.mktows.SuccessGetLeadChanges)1 Field (org.apache.avro.Schema.Field)1 MarketoException (org.talend.components.marketo.runtime.client.type.MarketoException)1