use of org.talend.components.marketo.tmarketoinput.TMarketoInputProperties in project components by Talend.
the class MarketoSourceOrSink method getSchemaNames.
@Override
public List<NamedThing> getSchemaNames(RuntimeContainer container) throws IOException {
List<NamedThing> customObjects = new ArrayList<>();
MarketoClientServiceExtended client = (MarketoClientServiceExtended) getClientService(null);
TMarketoInputProperties ip = new TMarketoInputProperties("COSchemas");
ip.init();
ip.connection = properties.getConnectionProperties();
ip.inputOperation.setValue(InputOperation.CustomObject);
ip.customObjectAction.setValue(CustomObjectAction.list);
ip.customObjectNames.setValue("");
ip.schemaInput.schema.setValue(MarketoConstants.getCustomObjectDescribeSchema());
MarketoRecordResult r = client.listCustomObjects(ip);
for (IndexedRecord co : r.getRecords()) {
// name cannot be null
String name = co.get(0).toString();
Object displayName = co.get(1);
if (displayName == null) {
displayName = name;
}
customObjects.add(new SimpleNamedThing(name, displayName.toString()));
}
//
return customObjects;
}
use of org.talend.components.marketo.tmarketoinput.TMarketoInputProperties in project components by Talend.
the class MarketoSourceOrSink method getEndpointSchema.
@Override
public Schema getEndpointSchema(RuntimeContainer container, String schemaName) throws IOException {
MarketoRESTClient client = (MarketoRESTClient) getClientService(null);
TMarketoInputProperties ip = new TMarketoInputProperties("retrieveSchema");
Schema describeSchema = MarketoConstants.getCustomObjectDescribeSchema();
ip.connection = properties.getConnectionProperties();
ip.inputOperation.setValue(InputOperation.CustomObject);
ip.customObjectAction.setValue(CustomObjectAction.describe);
ip.customObjectName.setValue(schemaName);
ip.schemaInput.schema.setValue(describeSchema);
MarketoRecordResult r = client.describeCustomObject(ip);
if (!r.isSuccess()) {
return null;
}
List<IndexedRecord> records = r.getRecords();
if (records == null || records.isEmpty()) {
return null;
}
IndexedRecord record = records.get(0);
return FieldDescription.getSchemaFromJson(schemaName, record.get(describeSchema.getField("fields").pos()).toString(), record.get(describeSchema.getField("dedupeFields").pos()).toString());
}
use of org.talend.components.marketo.tmarketoinput.TMarketoInputProperties in project components by Talend.
the class MarketoInputReaderTestIT method testLeadActivityWithSpecificActivitiesREST.
@Test
public void testLeadActivityWithSpecificActivitiesREST() throws Exception {
TMarketoInputProperties props = getRESTProperties();
props.inputOperation.setValue(getLeadActivity);
String since = new SimpleDateFormat(DATETIME_PATTERN_PARAM).format(new Date(new Date().getTime() - 10000000));
props.sinceDateTime.setValue(since);
props.batchSize.setValue(300);
props.afterInputOperation();
props.beforeMappingInput();
props.setIncludeTypes.setValue(true);
props.includeTypes.type.setValue(Arrays.asList("DeleteLead", "AddToList"));
reader = getReader(props);
assertTrue(reader.start());
IndexedRecord r = reader.getCurrent();
assertNotNull(r);
assertTrue(r.getSchema().getFields().size() > 6);
while (reader.advance()) {
r = reader.getCurrent();
assertNotNull(r);
assertThat(Integer.parseInt(r.get(3).toString()), anyOf(is(24), is(37)));
}
assertTrue(((int) reader.getReturnValues().get(RETURN_NB_CALL)) >= 1);
}
use of org.talend.components.marketo.tmarketoinput.TMarketoInputProperties in project components by Talend.
the class MarketoInputReaderTestIT method testTDI38956.
@Test
public void testTDI38956() throws Exception {
TMarketoInputProperties props = getRESTProperties();
props.inputOperation.setValue(getLead);
props.leadKeyTypeREST.setValue(email);
props.afterInputOperation();
String email = EMAIL_LEAD_TEST;
props.leadKeyValue.setValue(email);
MarketoSource source = new MarketoSource();
source.initialize(null, props);
MarketoClientService client = source.getClientService(null);
MarketoRecordResult result = client.getLead(props, null);
LOG.debug("{}", result);
List<IndexedRecord> records = result.getRecords();
assertNotEquals(emptyList(), records);
IndexedRecord record = records.get(0);
assertNotNull(record);
// createdAt shouldn't be null
assertNotNull(record.get(4));
// updatedAt shouldn't be null
assertNotNull(record.get(5));
}
use of org.talend.components.marketo.tmarketoinput.TMarketoInputProperties in project components by Talend.
the class MarketoInputReaderTestIT method getSOAPProperties.
public TMarketoInputProperties getSOAPProperties() {
TMarketoInputProperties props = new TMarketoInputProperties("test");
props.connection.setupProperties();
props.connection.endpoint.setValue(ENDPOINT_SOAP);
props.connection.clientAccessId.setValue(USERID_SOAP);
props.connection.secretKey.setValue(SECRETKEY_SOAP);
props.connection.setupLayout();
props.mappingInput.setupProperties();
props.setupProperties();
props.connection.apiMode.setValue(SOAP);
props.schemaInput.setupProperties();
props.schemaInput.setupLayout();
props.includeTypes.setupProperties();
props.includeTypes.type.setValue(new ArrayList<String>());
props.excludeTypes.setupProperties();
props.excludeTypes.type.setValue(new ArrayList<String>());
props.setupLayout();
return props;
}
Aggregations