public static SetBillingAddress of(final Optional<Address> address) { return new SetBillingAddress(address); }
public static SetBillingAddress of(final Address address) { return of(Optional.of(address)); }
public static SetBillingAddress of(final Optional<Address> address) { return new SetBillingAddress(address); }
public static SetBillingAddress of(final Address address) { return of(Optional.of(address)); }
public static SetBillingAddress of(@Nullable final Address address) { return new SetBillingAddress(address); }
private CompletionStage<Cart> setAddressToCart(final Cart cart, final Address shippingAddress, @Nullable final Address billingAddress) { final List<UpdateAction<Cart>> updateActions = new ArrayList<>(); updateActions.add(SetCountry.of(shippingAddress.getCountry())); updateActions.add(SetShippingAddress.of(shippingAddress)); updateActions.add(SetBillingAddress.of(billingAddress)); Optional.ofNullable(shippingAddress.getEmail()) .ifPresent(email -> updateActions.add(SetCustomerEmail.of(email))); final CartUpdateCommand cmd = CartUpdateCommand.of(cart, updateActions); return executeCartUpdateCommandWithHooks(cmd); } }
public static SetBillingAddress of(@Nullable final Address address) { return new SetBillingAddress(address); }
@Test public void setBillingAddress() throws Exception { final Cart cart = createCartWithCountry(client()); assertThat(cart.getBillingAddress()).isNull(); final Address address = AddressBuilder.of(DE).build(); final Cart cartWithAddress = client().executeBlocking(CartUpdateCommand.of(cart, SetBillingAddress.of(address))); assertThat(cartWithAddress.getBillingAddress()).isEqualTo(address); //you can query by billingAddress fields final CartQuery query = CartQuery.of() .withPredicates(m -> m.billingAddress().country().is(DE).and(m.id().is(cart.getId()))); assertThat(client().executeBlocking(query).head()).contains(cartWithAddress); final Cart cartWithoutAddress = client().executeBlocking(CartUpdateCommand.of(cartWithAddress, SetBillingAddress.of(null))); assertThat(cartWithoutAddress.getBillingAddress()).isNull(); }
public static SetBillingAddress of(@Nullable final Address address) { return new SetBillingAddress(address); }