All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.sphere.internal.ProjectScopedAPI Maven / Gradle / Ivy

There is a newer version: 0.72.1
Show newest version
package io.sphere.internal;

import com.google.common.base.Optional;
import io.sphere.client.CommandRequest;
import io.sphere.client.ProjectEndpoints;
import io.sphere.client.QueryRequest;
import io.sphere.client.model.QueryResult;
import io.sphere.client.shop.ApiMode;
import io.sphere.internal.command.Command;
import io.sphere.internal.request.RequestFactory;
import org.codehaus.jackson.type.TypeReference;

/** Base class for Sphere HTTP APIs scoped to a project. */
abstract class ProjectScopedAPI {
    protected ProjectEndpoints endpoints;
    protected RequestFactory requestFactory;
    protected TypeReference typeReference;
    protected TypeReference> queryResultTypeReference;

    protected ProjectScopedAPI(RequestFactory requestFactory, ProjectEndpoints endpoints, TypeReference typeReference, TypeReference> queryResultTypeReference) {
        this.requestFactory = requestFactory;
        this.endpoints = endpoints;
        this.typeReference = typeReference;
        this.queryResultTypeReference = queryResultTypeReference;
    }

    protected CommandRequest createCommandRequest(String url, Command command) {
        return requestFactory.createCommandRequest(url, command, typeReference);
    }

    protected QueryRequest queryImpl(String url) {
        return requestFactory.createQueryRequest(url, Optional.absent(), queryResultTypeReference);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy