Skip to content
This repository was archived by the owner on Feb 10, 2025. It is now read-only.

Commit 63ca15e

Browse files
authored
Merge pull request #2216 from commercetools/authenticationmode-customer
Authenticationmode customer
2 parents c3b342d + c0d1c1b commit 63ca15e

File tree

9 files changed

+97
-15
lines changed

9 files changed

+97
-15
lines changed

commercetools-internal-docs/src/main/java/io/sphere/sdk/meta/ReleaseNotes.java

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
import io.sphere.sdk.customers.commands.CustomerSignInCommand;
4040
import io.sphere.sdk.customers.commands.CustomerVerifyEmailCommand;
4141
import io.sphere.sdk.customers.commands.updateactions.AddShippingAddressId;
42+
import io.sphere.sdk.customers.commands.updateactions.SetAuthenticationMode;
4243
import io.sphere.sdk.customers.commands.updateactions.SetSalutation;
4344
import io.sphere.sdk.customers.errors.CustomerInvalidCurrentPassword;
4445
import io.sphere.sdk.customers.expansion.CustomerSignInResultExpansionModel;
@@ -156,18 +157,20 @@
156157
</ul>
157158
-->
158159
-->
159-
<h3 class=released-version id="v2_8_0">2.8.0 (04.04.2022)</h3>
160+
<h3 class=released-version id="v2_7_0">2.7.0 (04.04.2022)</h3>
160161
<ul>
161-
<li class=new-in-release>Support new Order message: {@link OrderPaymentAddedMessage}</li>
162+
<li class=new-in-release>Support Authentication Mode for Customer {@link Customer#getAuthenticationMode()} and related update action {@link SetAuthenticationMode}</li>
163+
</ul>
164+
<h3 class=released-version id="v2_7_0">2.7.0 (04.04.2022)</h3>
165+
<ul>
166+
<li class=new-in-release>Support Authentication Mode for Customer {@link Customer#getAuthenticationMode()} and related update action {@link SetAuthenticationMode}</li>
167+
<li class=new-in-release>Support new Order message {@link OrderPaymentAddedMessage}</li>
162168
<li class=new-in-release>Support of the new properties {@link ApiClient#getAccessTokenValiditySeconds()} and {@link ApiClient#getRefreshTokenValiditySeconds()} as for ApiClient as for ApiClientDraft</li>
163169
<li class=new-in-release>Support of the HTTP Method HEAD and applied it for Products {@link ProductsHead}, {@link ProductByIdHead} and {@link ProductByKeyHead}</li>
164170
<li class=new-in-release>Support new custom field in {@link Delivery#getCustom()} and created update action for Order and OrderEdit {@link SetDeliveryCustomType}, {@link SetDeliveryCustomField}, {@link io.sphere.sdk.orderedits.commands.stagedactions.SetDeliveryCustomType} and {@link io.sphere.sdk.orderedits.commands.stagedactions.SetDeliveryCustomField}</li>
165171
<li class=new-in-release>Support product selection as a new feature {@link ProductSelection}</li>
166172
<li class=new-in-release>Support product projection in Store {@link ProductProjectionInStoreByIdGet}, {@link ProductProjectionInStoreQuery} and {@link ProductProjectionByKeyGet}</li>
167173
</ul>
168-
<h3 class=released-version id="v2_7_0">2.7.0 (24.02.2022)</h3>
169-
<ul>
170-
</ul>
171174
<h3 class=released-version id="v2_6_0">2.6.0 (07.02.2022)</h3>
172175
<ul>
173176
</ul>
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package io.sphere.sdk.customers;
2+
3+
import com.fasterxml.jackson.annotation.JsonValue;
4+
import io.sphere.sdk.models.SphereEnumeration;
5+
6+
/**
7+
* AuthenticationMode.
8+
*
9+
* For the import and the export of values see also {@link SphereEnumeration}.
10+
*/
11+
public enum AuthenticationMode {
12+
PASSWORD("Password"),
13+
EXTERNAL_AUTH("ExternalAuth");
14+
15+
private final String jsonValue;
16+
17+
private AuthenticationMode(final String json) {
18+
this.jsonValue = json;
19+
}
20+
21+
@JsonValue
22+
public String jsonValue() {
23+
return this.jsonValue;
24+
}
25+
}

commercetools-models/src/main/java/io/sphere/sdk/customers/Customer.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -378,6 +378,10 @@ default CustomerName getName() {
378378
@IgnoreInQueryModel
379379
LocalDate getDateOfBirth();
380380

381+
@Nullable
382+
@IgnoreInQueryModel
383+
AuthenticationMode getAuthenticationMode();
384+
381385
@Override
382386
default Reference<Customer> toReference() {
383387
return Reference.of(referenceTypeId(), getId(), this);

commercetools-models/src/main/java/io/sphere/sdk/customers/CustomerDraft.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import com.fasterxml.jackson.annotation.JsonProperty;
44
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
55
import io.sphere.sdk.annotations.FactoryMethod;
6+
import io.sphere.sdk.annotations.IgnoreInQueryModel;
67
import io.sphere.sdk.annotations.ResourceDraftValue;
78
import io.sphere.sdk.carts.Cart;
89
import io.sphere.sdk.customergroups.CustomerGroup;
@@ -114,4 +115,7 @@ default CustomerName getName() {
114115

115116
@Nullable
116117
List<ResourceIdentifier<Store>> getStores();
118+
119+
@Nullable
120+
AuthenticationMode getAuthenticationMode();
117121
}

commercetools-models/src/main/java/io/sphere/sdk/customers/CustomerDraftBuilder.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414

1515
public final class CustomerDraftBuilder extends CustomerDraftBuilderBase<CustomerDraftBuilder> {
1616

17-
CustomerDraftBuilder(@Nullable final List<Address> addresses, @Nullable final ResourceIdentifier<Cart> anonymousCart, @Nullable final String anonymousCartId, @Nullable final String anonymousId, @Nullable final List<Integer> billingAddresses, @Nullable final String companyName, @Nullable final CustomFieldsDraft custom, @Nullable final ResourceIdentifier<CustomerGroup> customerGroup, @Nullable final String customerNumber, @Nullable final LocalDate dateOfBirth, @Nullable final Integer defaultBillingAddress, @Nullable final Integer defaultShippingAddress, final String email, final Boolean emailVerified, @Nullable final String externalId, @Nullable final String firstName, @Nullable final String key, @Nullable final String lastName, @Nullable final Locale locale, @Nullable final String middleName, final String password, @Nullable final String salutation, @Nullable final List<Integer> shippingAddresses, final @Nullable List<ResourceIdentifier<Store>> stores, @Nullable final String title, @Nullable final String vatId) {
18-
super(addresses, anonymousCart, anonymousCartId, anonymousId, billingAddresses, companyName, custom, customerGroup, customerNumber, dateOfBirth, defaultBillingAddress, defaultShippingAddress, email, emailVerified, externalId, firstName, key, lastName, locale, middleName, password,salutation, shippingAddresses, stores, title, vatId);
17+
CustomerDraftBuilder(@Nullable final List<Address> addresses, @Nullable final ResourceIdentifier<Cart> anonymousCart, @Nullable final String anonymousCartId, @Nullable final String anonymousId, @Nullable final AuthenticationMode authenticationMode, @Nullable final List<Integer> billingAddresses, @Nullable final String companyName, @Nullable final CustomFieldsDraft custom, @Nullable final ResourceIdentifier<CustomerGroup> customerGroup, @Nullable final String customerNumber, @Nullable final LocalDate dateOfBirth, @Nullable final Integer defaultBillingAddress, @Nullable final Integer defaultShippingAddress, final String email, final Boolean emailVerified, @Nullable final String externalId, @Nullable final String firstName, @Nullable final String key, @Nullable final String lastName, @Nullable final Locale locale, @Nullable final String middleName, final String password, @Nullable final String salutation, @Nullable final List<Integer> shippingAddresses, final @Nullable List<ResourceIdentifier<Store>> stores, @Nullable final String title, @Nullable final String vatId) {
18+
super(addresses, anonymousCart, anonymousCartId, anonymousId, authenticationMode, billingAddresses, companyName, custom, customerGroup, customerNumber, dateOfBirth, defaultBillingAddress, defaultShippingAddress, email, emailVerified, externalId, firstName, key, lastName, locale, middleName, password,salutation, shippingAddresses, stores, title, vatId);
1919
}
2020

2121
public static CustomerDraftBuilder of(final CustomerName customerName, final String email, final String password) {

commercetools-models/src/main/java/io/sphere/sdk/customers/CustomerDraftDsl.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818

1919
public final class CustomerDraftDsl extends CustomerDraftDslBase<CustomerDraftDsl> {
2020

21-
CustomerDraftDsl(@Nullable final List<Address> addresses, @Nullable final ResourceIdentifier<Cart> anonymousCart, @Nullable final String anonymousCartId, @Nullable final String anonymousId, @Nullable final List<Integer> billingAddresses, @Nullable final String companyName, @Nullable final CustomFieldsDraft custom, @Nullable final ResourceIdentifier<CustomerGroup> customerGroup, @Nullable final String customerNumber, @Nullable final LocalDate dateOfBirth, @Nullable final Integer defaultBillingAddress, @Nullable final Integer defaultShippingAddress, final String email, @JsonProperty("isEmailVerified") final Boolean emailVerified, @Nullable final String externalId, @Nullable final String firstName, @Nullable final String key, @Nullable final String lastName, @Nullable final Locale locale, @Nullable final String middleName, final String password, @Nullable final String salutation , @Nullable final List<Integer> shippingAddresses, @Nullable final List<ResourceIdentifier<Store>> stores, @Nullable final String title, @Nullable final String vatId) {
22-
super(addresses, anonymousCart, anonymousCartId, anonymousId, billingAddresses, companyName, custom, customerGroup, customerNumber, dateOfBirth, defaultBillingAddress, defaultShippingAddress, email, emailVerified, externalId, firstName, key, lastName, locale, middleName, password, salutation, shippingAddresses, stores, title, vatId);
21+
CustomerDraftDsl(@Nullable final List<Address> addresses, @Nullable final ResourceIdentifier<Cart> anonymousCart, @Nullable final String anonymousCartId, @Nullable final String anonymousId, @Nullable final AuthenticationMode authenticationMode, @Nullable final List<Integer> billingAddresses, @Nullable final String companyName, @Nullable final CustomFieldsDraft custom, @Nullable final ResourceIdentifier<CustomerGroup> customerGroup, @Nullable final String customerNumber, @Nullable final LocalDate dateOfBirth, @Nullable final Integer defaultBillingAddress, @Nullable final Integer defaultShippingAddress, final String email, @JsonProperty("isEmailVerified") final Boolean emailVerified, @Nullable final String externalId, @Nullable final String firstName, @Nullable final String key, @Nullable final String lastName, @Nullable final Locale locale, @Nullable final String middleName, final String password, @Nullable final String salutation , @Nullable final List<Integer> shippingAddresses, @Nullable final List<ResourceIdentifier<Store>> stores, @Nullable final String title, @Nullable final String vatId) {
22+
super(addresses, anonymousCart, anonymousCartId, anonymousId, authenticationMode, billingAddresses, companyName, custom, customerGroup, customerNumber, dateOfBirth, defaultBillingAddress, defaultShippingAddress, email, emailVerified, externalId, firstName, key, lastName, locale, middleName, password, salutation, shippingAddresses, stores, title, vatId);
2323

2424
if (!isValidAddressIndex(addresses, defaultBillingAddress) || !isValidAddressIndex(addresses, defaultShippingAddress)) {
2525
throw new IllegalArgumentException("The defaultBillingAddress and defaultShippingAddress cannot contain an index which is not in the address list");
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
package io.sphere.sdk.customers.commands.updateactions;
2+
3+
import io.sphere.sdk.commands.UpdateActionImpl;
4+
import io.sphere.sdk.customers.AuthenticationMode;
5+
import io.sphere.sdk.customers.Customer;
6+
7+
import javax.annotation.Nullable;
8+
9+
/**
10+
* Sets authentication mode for the customer.
11+
*
12+
* {@doc.gen intro}
13+
*
14+
* {@include.example io.sphere.sdk.customers.commands.CustomerUpdateCommandIntegrationTest#setAuthenticationMode()}
15+
*/
16+
public final class SetAuthenticationMode extends UpdateActionImpl<Customer> {
17+
private final AuthenticationMode authMode;
18+
@Nullable
19+
private final String password;
20+
21+
private SetAuthenticationMode(final AuthenticationMode authMode, @Nullable final String password) {
22+
super("setAuthenticationMode");
23+
this.authMode = authMode;
24+
this.password = password;
25+
}
26+
27+
public static SetAuthenticationMode of(final AuthenticationMode authMode, @Nullable final String password) {
28+
return new SetAuthenticationMode(authMode, password);
29+
}
30+
31+
public AuthenticationMode getAuthMode() {
32+
return authMode;
33+
}
34+
35+
@Nullable
36+
public String getPassword() {
37+
return password;
38+
}
39+
}

commercetools-models/src/test/java/io/sphere/sdk/customers/commands/CustomerUpdateCommandIntegrationTest.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -364,6 +364,18 @@ public void setVatId() throws Exception {
364364
});
365365
}
366366

367+
@Test
368+
public void setAuthenticationMode() throws Exception {
369+
withUpdateableCustomer(client(), customer -> {
370+
CustomerUpdateCommand update = CustomerUpdateCommand.of(customer, SetAuthenticationMode.of(AuthenticationMode.EXTERNAL_AUTH, null));
371+
final Customer updatedCustomer = client().executeBlocking(update);
372+
373+
assertThat(updatedCustomer.getAuthenticationMode()).isEqualTo(AuthenticationMode.EXTERNAL_AUTH);
374+
375+
return updatedCustomer;
376+
});
377+
}
378+
367379
@Test
368380
public void setDateOfBirth() throws Exception {
369381
withCustomer(client(), customer -> {

commercetools-models/src/test/java/io/sphere/sdk/productselections/commands/ProductSelectionCreateCommandIntegrationTest.java

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,13 @@
11
package io.sphere.sdk.productselections.commands;
22

3-
import io.sphere.sdk.json.SphereJsonUtils;
43
import io.sphere.sdk.models.LocalizedString;
54
import io.sphere.sdk.productselections.ProductSelection;
65
import io.sphere.sdk.productselections.ProductSelectionDraft;
76
import io.sphere.sdk.productselections.ProductSelectionType;
8-
import io.sphere.sdk.productselections.queries.ProductSelectionQuery;
97
import io.sphere.sdk.test.IntegrationTest;
10-
import io.sphere.sdk.types.commands.TypeDeleteCommand;
11-
import io.sphere.sdk.types.queries.TypeQuery;
12-
import org.junit.BeforeClass;
8+
139
import org.junit.Test;
1410

15-
import java.io.IOException;
1611

1712
import static io.sphere.sdk.test.SphereTestUtils.en;
1813
import static org.assertj.core.api.Assertions.assertThat;

0 commit comments

Comments
 (0)