use of org.talend.components.marketo.runtime.client.type.ListOperationParameters in project components by Talend.
the class MarketoRESTClientTestIT method testRemoveFromList.
@Test
public void testRemoveFromList() throws Exception {
MarketoSource source = new MarketoSource();
source.initialize(null, listProperties);
MarketoClientService client = source.getClientService(null);
//
ListOperationParameters parms = new ListOperationParameters();
parms.setApiMode(APIMode.REST.name());
parms.setListId(UNDX_TEST_LIST_SMALL_ID);
parms.setLeadIds(new Integer[] { createdLeads.get(20) });
//
// first subscribe lead
MarketoSyncResult result = client.addToList(parms);
LOG.debug("result = {}.", result);
List<SyncStatus> changes = result.getRecords();
assertTrue(changes.size() > 0);
for (SyncStatus r : changes) {
assertNotNull(r);
assertNotNull(r.getId());
LOG.debug("r = {}.", r);
}
// then remove it
result = client.removeFromList(parms);
LOG.debug("result = {}.", result);
changes = result.getRecords();
assertTrue(changes.size() > 0);
for (SyncStatus r : changes) {
assertNotNull(r);
assertNotNull(r.getId());
assertEquals("removed", r.getStatus());
LOG.debug("r = {}.", r);
}
}
use of org.talend.components.marketo.runtime.client.type.ListOperationParameters in project components by Talend.
the class MarketoBaseTestIT method createDatasets.
public static void createDatasets(int numberOfLeads) throws Exception {
LOG.info("Creating test leads");
TMarketoOutputProperties p = initClient();
if (numberOfLeads < 5) {
numberOfLeads = 5;
}
// create leads for tests
// test attributes
List<Field> fields = new ArrayList<>();
Field field = new Schema.Field("accountType", Schema.create(Schema.Type.STRING), null, (Object) null);
fields.add(field);
field = new Schema.Field("linkedInId", Schema.create(Type.INT), null, (Object) null);
fields.add(field);
field = new Schema.Field("sfdcAccountId", Schema.create(Type.STRING), null, (Object) null);
fields.add(field);
field = new Schema.Field("company", Schema.create(Type.STRING), null, (Object) null);
fields.add(field);
Schema s = MarketoUtils.newSchema(p.schemaInput.schema.getValue(), "leadAttribute", fields);
p.schemaInput.schema.setValue(s);
p.updateOutputSchemas();
//
List<IndexedRecord> leads = new ArrayList<>();
//
for (int i = 0; i < numberOfLeads; i++) {
IndexedRecord record = new GenericData.Record(s);
record.put(0, null);
record.put(1, String.format("%s%02d%s", EMAIL_PREFIX, i, EMAIL_DOMAIN));
record.put(2, String.format("firstName%02d", i));
record.put(3, String.format("lastName%02d", i));
record.put(4, String.format("Account Type %02d", i));
// all the same linkedInId.
record.put(5, COMMON_LINKEDIN_ID);
// all the same SalesforceId.
record.put(6, COMMON_SFDC_ACCOUNT_ID);
// all the same SalesforceId.
record.put(7, "Retail-Dev");
leads.add(record);
}
// /
MarketoSyncResult result = datasetsClient.syncMultipleLeads(p, leads);
LOG.debug("result = {}.", result);
List<SyncStatus> changes = result.getRecords();
assertTrue(changes.size() > 0);
for (SyncStatus r : changes) {
assertNotNull(r);
assertNotNull(r.getId());
createdLeads.add(r.getId());
}
LOG.info("Created {} leads for tests. Now adding 5 leads to {} list.", createdLeads.size(), UNDX_TEST_LIST_SMALL);
// adding 5 members to test list
ListOperationParameters parms = new ListOperationParameters();
parms.setApiMode(REST.name());
parms.setListId(UNDX_TEST_LIST_SMALL_ID);
parms.setLeadIds(new Integer[] { createdLeads.get(0), createdLeads.get(1), createdLeads.get(2), createdLeads.get(3), createdLeads.get(4) });
//
result = datasetsClient.addToList(parms);
LOG.debug("result = {}.", result);
LOG.info("Test Dataset created successfully.");
}
use of org.talend.components.marketo.runtime.client.type.ListOperationParameters in project components by Talend.
the class MarketoSOAPClientTestIT method testIsMemberOfList.
@Test
public void testIsMemberOfList() throws Exception {
MarketoSource source = new MarketoSource();
source.initialize(null, listProperties);
MarketoClientService client = source.getClientService(null);
//
ListOperationParameters parms = new ListOperationParameters();
parms.setApiMode(SOAP.name());
parms.setListKeyValue(UNDX_TEST_LIST_SMALL);
parms.setStrict(true);
parms.setLeadKeyValue(new String[] { createdLeads.get(0).toString(), createdLeads.get(1).toString(), createdLeads.get(2).toString(), "12345" });
//
MarketoSyncResult result = client.isMemberOfList(parms);
LOG.debug("result = {}.", result);
List<SyncStatus> changes = result.getRecords();
assertTrue(changes.size() > 0);
for (SyncStatus r : changes) {
assertNotNull(r);
assertNotNull(r.getId());
assertNotNull(r.getStatus());
LOG.debug("r = {}.", r);
}
}
use of org.talend.components.marketo.runtime.client.type.ListOperationParameters in project components by Talend.
the class MarketoListOperationWriter method open.
@Override
public void open(String uId) throws IOException {
super.open(uId);
properties = (TMarketoListOperationProperties) sink.getProperties();
inputSchema = properties.schemaInput.schema.getValue();
flowSchema = properties.schemaFlow.schema.getValue();
rejectSchema = properties.schemaReject.schema.getValue();
multipleOperations = properties.multipleOperation.getValue();
listOpeParms = new ListOperationParameters();
listOpeParms.setApiMode(api);
operation = properties.listOperation.getValue();
dieOnError = properties.dieOnError.getValue();
//
listOpeParms = new ListOperationParameters();
listOpeParms.setApiMode(api);
listOpeParms.setOperation(operation.name());
listOpeParms.setStrict(dieOnError);
}
use of org.talend.components.marketo.runtime.client.type.ListOperationParameters in project components by Talend.
the class MarketoRESTClientTestIT method testAddToList.
/*
*
*
* ListOperations
*
*/
@Test
public void testAddToList() throws Exception {
MarketoSource source = new MarketoSource();
source.initialize(null, listProperties);
MarketoClientService client = source.getClientService(null);
//
ListOperationParameters parms = new ListOperationParameters();
parms.setApiMode(APIMode.REST.name());
parms.setListId(UNDX_TEST_LIST_SMALL_ID);
parms.setLeadIds(new Integer[] { createdLeads.get(10) });
//
// first make sure to remove lead
MarketoSyncResult result = client.removeFromList(parms);
LOG.debug("result = {}.", result);
List<SyncStatus> changes = result.getRecords();
assertTrue(changes.size() > 0);
for (SyncStatus r : changes) {
assertNotNull(r);
assertNotNull(r.getId());
LOG.debug("r = {}.", r);
}
// then add it
result = client.addToList(parms);
LOG.debug("result = {}.", result);
changes = result.getRecords();
assertTrue(changes.size() > 0);
for (SyncStatus r : changes) {
assertNotNull(r);
assertNotNull(r.getId());
assertEquals("added", r.getStatus());
LOG.debug("r = {}.", r);
}
}
Aggregations