
io.sphere.internal.ShippingMethodServiceImpl Maven / Gradle / Ivy
package io.sphere.internal;
import java.util.Currency;
import java.util.List;
import io.sphere.client.FetchRequest;
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.client.shop.ShippingMethodService;
import io.sphere.client.shop.model.Location;
import io.sphere.client.shop.model.ShippingMethod;
import io.sphere.internal.request.RequestFactory;
import com.google.common.base.Optional;
import org.codehaus.jackson.type.TypeReference;
public class ShippingMethodServiceImpl extends ProjectScopedAPI implements ShippingMethodService {
private final static String expandZonesPath = "zoneRates[*].zone";
public ShippingMethodServiceImpl(RequestFactory requestFactory, ProjectEndpoints endpoints) {
super(requestFactory, endpoints, new TypeReference() {}, new TypeReference>() {});
}
@Override public FetchRequest byId(String id) {
return requestFactory.createFetchRequest(
endpoints.shippingMethods.byId(id),
Optional.absent(),
new TypeReference() {}).expand(expandZonesPath);
}
@Deprecated
@Override public QueryRequest all() {
return query();
}
@Override public QueryRequest query() {
return queryImpl(endpoints.shippingMethods.root()).expand(expandZonesPath);
}
@Override
public FetchRequest> forLocation(Location location, Currency currency) {
return requestFactory.createFetchRequest(
endpoints.shippingMethods.forLocation(location.getCountry(), location.getState(), currency),
Optional.absent(),
new TypeReference>() {}).expand(expandZonesPath);
}
@Override
public FetchRequest> forCart(String cartId) {
return requestFactory.createFetchRequest(
endpoints.shippingMethods.forCart(cartId),
Optional.absent(),
new TypeReference>() {}).expand(expandZonesPath);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy