public class CartDiscountServiceImpl extends java.lang.Object implements CartDiscountService
Modifier and Type | Field and Description |
---|---|
protected com.github.benmanes.caffeine.cache.Cache<java.lang.String,java.lang.String> |
keyToIdCache |
protected static int |
MAXIMUM_ALLOWED_UPDATE_ACTIONS |
Constructor and Description |
---|
CartDiscountServiceImpl(CartDiscountSyncOptions syncOptions) |
Modifier and Type | Method and Description |
---|---|
java.util.concurrent.CompletionStage<java.util.Optional<io.sphere.sdk.cartdiscounts.CartDiscount>> |
createCartDiscount(io.sphere.sdk.cartdiscounts.CartDiscountDraft cartDiscountDraft)
Given a resource draft of type
CartDiscountDraft , this method attempts to create a
resource CartDiscount based on it in the CTP project defined by the sync options. |
java.util.concurrent.CompletionStage<java.util.Optional<io.sphere.sdk.cartdiscounts.CartDiscount>> |
fetchCartDiscount(java.lang.String key)
Given a cart discount key, this method fetches a cart discount that matches this given key in
the CTP project defined in a potentially injected
SphereClient . |
java.util.concurrent.CompletionStage<java.util.Set<io.sphere.sdk.cartdiscounts.CartDiscount>> |
fetchMatchingCartDiscountsByKeys(java.util.Set<java.lang.String> keys)
Given a
Set of CartDiscount keys, this method fetches a set of all the CartDiscounts,
matching this given set of keys in the CTP project, defined in an injected SphereClient . |
java.util.concurrent.CompletionStage<io.sphere.sdk.cartdiscounts.CartDiscount> |
updateCartDiscount(io.sphere.sdk.cartdiscounts.CartDiscount cartDiscount,
java.util.List<io.sphere.sdk.commands.UpdateAction<io.sphere.sdk.cartdiscounts.CartDiscount>> updateActions)
Given a
CartDiscount and a List <UpdateAction <CartDiscount >>, this method issues an update request with these update actions on this
CartDiscount in the CTP project defined in a potentially injected SphereClient . |
protected final com.github.benmanes.caffeine.cache.Cache<java.lang.String,java.lang.String> keyToIdCache
protected static final int MAXIMUM_ALLOWED_UPDATE_ACTIONS
public CartDiscountServiceImpl(@Nonnull CartDiscountSyncOptions syncOptions)
@Nonnull public java.util.concurrent.CompletionStage<java.util.Set<io.sphere.sdk.cartdiscounts.CartDiscount>> fetchMatchingCartDiscountsByKeys(@Nonnull java.util.Set<java.lang.String> keys)
CartDiscountService
Set
of CartDiscount keys, this method fetches a set of all the CartDiscounts,
matching this given set of keys in the CTP project, defined in an injected SphereClient
. A mapping of the key to the id of the fetched CartDiscount is persisted in an
in-memory map.fetchMatchingCartDiscountsByKeys
in interface CartDiscountService
keys
- set of CartDiscounts keys to fetch matching CartDiscount by.CompletionStage
<Set
> in which the result of its completion
contains a Set
of all matching CartDiscounts.@Nonnull public java.util.concurrent.CompletionStage<java.util.Optional<io.sphere.sdk.cartdiscounts.CartDiscount>> fetchCartDiscount(@Nullable java.lang.String key)
CartDiscountService
SphereClient
. If there is no matching
cart discount an empty Optional
will be returned in the returned future. A mapping of
the key to the id of the fetched cart discount is persisted in an in-memory map.fetchCartDiscount
in interface CartDiscountService
key
- the key of the product to fetch.CompletionStage
<Optional
> in which the result of it's completion
contains an Optional
that contains the matching CartDiscount
if exists,
otherwise empty.@Nonnull public java.util.concurrent.CompletionStage<java.util.Optional<io.sphere.sdk.cartdiscounts.CartDiscount>> createCartDiscount(@Nonnull io.sphere.sdk.cartdiscounts.CartDiscountDraft cartDiscountDraft)
CartDiscountService
CartDiscountDraft
, this method attempts to create a
resource CartDiscount
based on it in the CTP project defined by the sync options.
A completion stage containing an empty Optional
and the error callback will be
triggered in those cases:
On the other hand, if the CartDiscount gets created successfully on CTP, then the created
CartDiscount's id and key are cached. The method returns a CompletionStage
in which the
result of it's completion contains an instance Optional
of the created `CartDiscount`.
createCartDiscount
in interface CartDiscountService
cartDiscountDraft
- the resource draft to create a resource based off of.CompletionStage
containing an optional with the created CartDiscount
if successful otherwise an empty optional.@Nonnull public java.util.concurrent.CompletionStage<io.sphere.sdk.cartdiscounts.CartDiscount> updateCartDiscount(@Nonnull io.sphere.sdk.cartdiscounts.CartDiscount cartDiscount, @Nonnull java.util.List<io.sphere.sdk.commands.UpdateAction<io.sphere.sdk.cartdiscounts.CartDiscount>> updateActions)
CartDiscountService
CartDiscount
and a List
<UpdateAction
<CartDiscount
>>, this method issues an update request with these update actions on this
CartDiscount
in the CTP project defined in a potentially injected SphereClient
.
This method returns CompletionStage
<CartDiscount
> in which the result of
its completion contains an instance of the CartDiscount
which was updated in the CTP
project.updateCartDiscount
in interface CartDiscountService
cartDiscount
- the CartDiscount
to update.updateActions
- the update actions to update the CartDiscount
with.CompletionStage
<CartDiscount
> containing as a result of its
completion an instance of the CartDiscount
which was updated in the CTP project or
a SphereException
.