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

io.sphere.sdk.shippingmethods.queries.GetShippingMethodsByCart Maven / Gradle / Ivy

There is a newer version: 1.0.0-M12
Show newest version
package io.sphere.sdk.shippingmethods.queries;

import com.fasterxml.jackson.core.type.TypeReference;
import io.sphere.sdk.carts.Cart;
import io.sphere.sdk.client.HttpRequestIntent;
import io.sphere.sdk.client.SphereRequest;
import io.sphere.sdk.client.SphereRequestBase;
import io.sphere.sdk.http.HttpResponse;
import io.sphere.sdk.models.Referenceable;
import io.sphere.sdk.shippingmethods.ShippingMethod;

import java.util.List;
import java.util.function.Function;

import static io.sphere.sdk.http.HttpMethod.GET;

//TODO rename class
/**
 * Retrieves all the shipping methods that can ship to the shipping address of the given cart.
 *
 * {@include.example io.sphere.sdk.shippingmethods.queries.GetShippingMethodsByCartTest#execution()}
 */
public class GetShippingMethodsByCart extends SphereRequestBase implements SphereRequest> {
    private final String cartId;

    private GetShippingMethodsByCart(final String cartId) {
        this.cartId = cartId;
    }

    @Override
    public Function> resultMapper() {
        return resultMapperOf(new TypeReference>() {
            @Override
            public String toString() {
                return "TypeReference>";
            }
        });
    }

    @Override
    public HttpRequestIntent httpRequestIntent() {
        return HttpRequestIntent.of(GET, "/shipping-methods?cartId=" + cartId);
    }

    public static GetShippingMethodsByCart of(final Referenceable cart) {
        return of(cart.toReference().getId());
    }

    public static GetShippingMethodsByCart of(final String cartId) {
        return new GetShippingMethodsByCart(cartId);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy