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

io.sphere.internal.request.RequestFactory Maven / Gradle / Ivy

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

import com.google.common.base.Optional;
import io.sphere.client.*;
import io.sphere.internal.command.Command;
import io.sphere.client.filters.expressions.FilterExpression;
import io.sphere.client.model.QueryResult;
import io.sphere.client.model.SearchResult;
import io.sphere.client.shop.ApiMode;
import org.codehaus.jackson.type.TypeReference;

import java.util.Locale;

/** Creates instances of requests. Allows for mocking in tests. */
public interface RequestFactory {

    // -----------------
    // Read
    // -----------------

    /** Creates a request that fetches a single object. */
     FetchRequest createFetchRequest(String url, Optional apiMode, TypeReference jsonParserTypeRef);

    /** Creates a request that fetches a single object,
     *  handling given HTTP error status code by returning {@link com.google.common.base.Optional#absent()}. */
     FetchRequest createFetchRequestWithErrorHandling(
            String url, Optional apiMode, int handledErrorStatus, TypeReference jsonParserTypeRef);

    /** Creates a request that fetches a single object, implemented using a query endpoint. */
     FetchRequest createFetchRequestBasedOnQuery(String url, Optional apiMode, TypeReference> jsonParserTypeRef);

    /** Creates a request that queries for multiple objects. */
     QueryRequest createQueryRequest(String url, Optional apiMode, TypeReference> jsonParserTypeRef);

    /** Creates a request that uses search to query for multiple objects. */
     SearchRequest createSearchRequest(
            String url, Optional apiMode, Iterable filters, TypeReference> jsonParserTypeRef, Locale locale);

    // -----------------
    // Write
    // -----------------

    /** Creates a request that issues a command to be executed. */
     CommandRequest createCommandRequest(String url, Command command, TypeReference jsonParserTypeRef);

    // -----------------
    // Delete
    // -----------------

    /** Creates a request that sends a DELETE request. */
     DeleteRequest createDeleteRequest(String url, TypeReference jsonParserTypeRef);
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy