com.cloudconvert.resource.sync.JobsResource Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of cloudconvert-java Show documentation
Show all versions of cloudconvert-java Show documentation
CloudConvert is an online file converter API - more than 200 different audio, video, document, ebook, archive, image, spreadsheet and presentation formats supported.
package com.cloudconvert.resource.sync;
import com.cloudconvert.client.mapper.ObjectMapperProvider;
import com.cloudconvert.client.setttings.SettingsProvider;
import com.cloudconvert.dto.request.TaskRequest;
import com.cloudconvert.dto.response.JobResponse;
import com.cloudconvert.dto.response.Pageable;
import com.cloudconvert.dto.result.Result;
import com.cloudconvert.executor.RequestExecutor;
import com.cloudconvert.resource.AbstractJobsResource;
import com.cloudconvert.resource.params.Filter;
import com.cloudconvert.resource.params.Include;
import com.cloudconvert.resource.params.Pagination;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import lombok.extern.slf4j.Slf4j;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.io.IOException;
import java.net.URISyntaxException;
import java.util.List;
import java.util.Map;
@Slf4j
public class JobsResource extends AbstractJobsResource<
Result, Result>, Result> {
private final RequestExecutor requestExecutor;
public JobsResource(
final SettingsProvider settingsProvider,
final ObjectMapperProvider objectMapperProvider, final RequestExecutor requestExecutor
) {
super(settingsProvider, objectMapperProvider);
this.requestExecutor = requestExecutor;
}
@Override
public Result create(
@NotNull final Map tasks
) throws IOException, URISyntaxException {
return create(tasks, "");
}
@Override
public Result create(
@NotNull final Map tasks, @NotNull final String tag
) throws IOException, URISyntaxException {
return requestExecutor.execute(getCreateHttpUriRequest(tasks, tag), JOB_RESPONSE_TYPE_REFERENCE);
}
@Override
public Result show(
@NotNull final String jobId
) throws IOException, URISyntaxException {
return requestExecutor.execute(getShowHttpUriRequest(jobId), JOB_RESPONSE_TYPE_REFERENCE);
}
@Override
public Result wait(
@NotNull final String jobId
) throws IOException, URISyntaxException {
return requestExecutor.execute(getWaitHttpUriRequest(jobId), JOB_RESPONSE_TYPE_REFERENCE);
}
@Override
public Result> list() throws IOException, URISyntaxException {
return list(ImmutableMap.of());
}
@Override
public Result> list(
@NotNull final Map filters
) throws IOException, URISyntaxException {
return list(filters, ImmutableList.of());
}
@Override
public Result> list(
@NotNull final Map filters, @NotNull final List includes
) throws IOException, URISyntaxException {
return list(filters, includes, null);
}
@Override
public Result> list(
@NotNull final Map filters, @NotNull final List includes, @Nullable final Pagination pagination
) throws IOException, URISyntaxException {
return requestExecutor.execute(getListHttpUriRequest(filters, includes, pagination), JOB_RESPONSE_PAGEABLE_TYPE_REFERENCE);
}
@Override
public Result delete(
@NotNull final String jobId
) throws IOException, URISyntaxException {
return requestExecutor.execute(getDeleteHttpUriRequest(jobId), VOID_TYPE_REFERENCE);
}
@Override
public void close() throws IOException {
requestExecutor.close();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy