src/main/java/org/embulk/input/zendesk/services/ZendeskNormalServices.java in embulk-input-zendesk-all-0.3.9 vs src/main/java/org/embulk/input/zendesk/services/ZendeskNormalServices.java in embulk-input-zendesk-all-0.4.0

- old
+ new

@@ -57,23 +57,29 @@ } } return taskReport; } - public JsonNode getDataFromPath(String path, final int page, final boolean isPreview, final long startTime) { + return getDataFromPath(path, page,isPreview, startTime); + } + + public JsonNode getDataFromPath(String path, final int page, final boolean isPreview, final long startTime, final long endTime) + { if (path.isEmpty()) { - path = buildURI(page, startTime); + path = buildURI(page, startTime, endTime); } final String response = getZendeskRestClient().doGet(path, task, isPreview); return ZendeskUtils.parseJsonObject(response); } protected abstract String buildURI(int page, long startTime); + protected abstract String buildURI(int page, long startTime, long endTime); + @VisibleForTesting protected ZendeskRestClient getZendeskRestClient() { if (zendeskRestClient == null) { zendeskRestClient = new ZendeskRestClient(); @@ -285,20 +291,27 @@ } private void importDataForNonIncremental(final ZendeskInputPlugin.PluginTask task, final int taskIndex, RecordImporter recordImporter, final boolean getStartDate) { long startTime = 0; + long endTime = 0; if (Target.SATISFACTION_RATINGS.equals(task.getTarget())){ if (getStartDate && task.getStartTime().isPresent()) { startTime = ZendeskDateUtils.getStartTime(task.getStartTime().get()); } logger.info("Start time = {}", startTime); + if (task.getEndTime().isPresent()) { + endTime = ZendeskDateUtils.isoToEpochSecond(task.getEndTime().get()); + } + + logger.info("End time = {}", endTime); + int i = 1; final Set<String> knownIds = ConcurrentHashMap.newKeySet(); while (true) { - final JsonNode result = getDataFromPath("", taskIndex +i, false, startTime); + final JsonNode result = getDataFromPath("", taskIndex +i, false, startTime, endTime); final Iterator<JsonNode> iterator = ZendeskUtils.getListRecords(result, task.getTarget().getJsonName()); while (iterator.hasNext()) { final JsonNode recordJsonNode = iterator.next(); if (task.getDedup()) {