Sha256: beced383f6d01b871927a7c36e0315be63a2e9625830631b24c128ddddcc9e8d

Contents?: true

Size: 1.75 KB

Versions: 3

Compression:

Stored size: 1.75 KB

Contents

package org.embulk.input.zendesk.services;

import org.apache.http.client.utils.URIBuilder;
import org.embulk.input.zendesk.ZendeskInputPlugin.PluginTask;
import org.embulk.input.zendesk.models.Target;
import org.embulk.input.zendesk.utils.ZendeskConstants;
import org.embulk.input.zendesk.utils.ZendeskUtils;

public class ZendeskSupportAPIService extends ZendeskNormalServices
{
    public ZendeskSupportAPIService(final PluginTask task)
    {
        super(task);
    }

    public boolean isSupportIncremental()
    {
        return !(task.getTarget().equals(Target.TICKET_FORMS) || task.getTarget().equals(Target.TICKET_FIELDS));
    }

    @Override
    protected String buildURI(final int page, long startTime)
    {
        final URIBuilder uriBuilder = ZendeskUtils.getURIBuilder(task.getLoginUrl()).setPath(buildPath());

        if (isSupportIncremental()) {
            uriBuilder.setParameter(ZendeskConstants.Field.START_TIME, String.valueOf(startTime));
            if (Target.TICKET_METRICS.equals(task.getTarget())) {
                uriBuilder.setParameter("include", "metric_sets");
            }
        }
        else {
            uriBuilder.setParameter("sort_by", "id")
                    .setParameter("per_page", String.valueOf(100))
                    .setParameter("page", String.valueOf(page));
        }

        return uriBuilder.toString();
    }

    private String buildPath()
    {
        return (isSupportIncremental()
                ? ZendeskConstants.Url.API_INCREMENTAL
                : ZendeskConstants.Url.API) +
                "/" +
                (Target.TICKET_METRICS.equals(task.getTarget())
                        ? Target.TICKETS.toString()
                        : task.getTarget().toString())
                + ".json";
    }
}

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
embulk-input-zendesk-0.3.7 src/main/java/org/embulk/input/zendesk/services/ZendeskSupportAPIService.java
embulk-input-zendesk-0.3.6 src/main/java/org/embulk/input/zendesk/services/ZendeskSupportAPIService.java
embulk-input-zendesk-0.3.5 src/main/java/org/embulk/input/zendesk/services/ZendeskSupportAPIService.java