Sha256: 9f2840edcd5cc5284b1ca029b7bb4aa5a613807bdf8eaab486b02d0664e1b792

Contents?: true

Size: 1.78 KB

Versions: 18

Compression:

Stored size: 1.78 KB

Contents

package org.embulk.input.marketo.delegate;

import com.google.common.collect.FluentIterable;
import org.embulk.base.restclient.ServiceResponseMapper;
import org.embulk.base.restclient.record.ServiceRecord;
import org.embulk.base.restclient.record.ValueLocator;
import org.embulk.input.marketo.MarketoService;
import org.embulk.input.marketo.MarketoServiceImpl;
import org.embulk.input.marketo.MarketoUtils;
import org.embulk.input.marketo.model.MarketoField;
import org.embulk.input.marketo.rest.MarketoRestClient;

import java.util.Iterator;
import java.util.List;

/**
 * Created by tai.khuu on 9/18/17.
 */
public class LeadWithProgramInputPlugin extends MarketoBaseInputPluginDelegate<LeadWithProgramInputPlugin.PluginTask>
{
    public interface PluginTask extends MarketoBaseInputPluginDelegate.PluginTask
    {
    }

    @Override
    protected Iterator<ServiceRecord> getServiceRecords(MarketoService marketoService, PluginTask task)
    {
        List<String> fieldNames = task.getExtractedFields();
        return FluentIterable.from(marketoService.getAllProgramLead(fieldNames)).
                transform(MarketoUtils.TRANSFORM_OBJECT_TO_JACKSON_SERVICE_RECORD_FUNCTION).iterator();
    }

    @Override
    public ServiceResponseMapper<? extends ValueLocator> buildServiceResponseMapper(PluginTask task)
    {
        try (MarketoRestClient marketoRestClient = createMarketoRestClient(task)) {
            MarketoService marketoService = new MarketoServiceImpl(marketoRestClient);
            List<MarketoField> columns = marketoService.describeLeadByProgram();
            task.setExtractedFields(MarketoUtils.getFieldNameFromMarketoFields(columns, MarketoUtils.PROGRAM_ID_COLUMN_NAME));
            return MarketoUtils.buildDynamicResponseMapper(task.getSchemaColumnPrefix(), columns);
        }
    }
}

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
embulk-input-marketo-0.6.9 src/main/java/org/embulk/input/marketo/delegate/LeadWithProgramInputPlugin.java
embulk-input-marketo-0.6.9.alpha src/main/java/org/embulk/input/marketo/delegate/LeadWithProgramInputPlugin.java
embulk-input-marketo-0.6.8 src/main/java/org/embulk/input/marketo/delegate/LeadWithProgramInputPlugin.java
embulk-input-marketo-0.6.8.alpha1 src/main/java/org/embulk/input/marketo/delegate/LeadWithProgramInputPlugin.java
embulk-input-marketo-0.6.7 src/main/java/org/embulk/input/marketo/delegate/LeadWithProgramInputPlugin.java
embulk-input-marketo-0.6.7.test.1 src/main/java/org/embulk/input/marketo/delegate/LeadWithProgramInputPlugin.java
embulk-input-marketo-0.6.6 src/main/java/org/embulk/input/marketo/delegate/LeadWithProgramInputPlugin.java
embulk-input-marketo-0.6.6.alpha.1 src/main/java/org/embulk/input/marketo/delegate/LeadWithProgramInputPlugin.java
embulk-input-marketo-0.6.5 src/main/java/org/embulk/input/marketo/delegate/LeadWithProgramInputPlugin.java
embulk-input-marketo-0.6.4 src/main/java/org/embulk/input/marketo/delegate/LeadWithProgramInputPlugin.java
embulk-input-marketo-0.6.4.alpha.1 src/main/java/org/embulk/input/marketo/delegate/LeadWithProgramInputPlugin.java
embulk-input-marketo-0.6.3 src/main/java/org/embulk/input/marketo/delegate/LeadWithProgramInputPlugin.java
embulk-input-marketo-0.6.2 src/main/java/org/embulk/input/marketo/delegate/LeadWithProgramInputPlugin.java
embulk-input-marketo-0.6.2.alpha.1 src/main/java/org/embulk/input/marketo/delegate/LeadWithProgramInputPlugin.java
embulk-input-marketo-0.6.1 src/main/java/org/embulk/input/marketo/delegate/LeadWithProgramInputPlugin.java
embulk-input-marketo-0.6.1.alpha.1 src/main/java/org/embulk/input/marketo/delegate/LeadWithProgramInputPlugin.java
embulk-input-marketo-0.6.0 src/main/java/org/embulk/input/marketo/delegate/LeadWithProgramInputPlugin.java
embulk-input-marketo-0.6.0.alpha.1 src/main/java/org/embulk/input/marketo/delegate/LeadWithProgramInputPlugin.java