1+
12package com .commercetools .sdk ;
23
4+ import static com .commercetools .sdk .CommonImportUtil .getImportApiCustom ;
5+ import static java .lang .Integer .parseInt ;
6+
7+ import java .util .List ;
8+
39import com .commercetools .api .models .common .Address ;
4- import com .commercetools .api .models .common .BaseAddress ;
510import com .commercetools .api .models .customer .Customer ;
611import com .commercetools .api .models .customer_group .CustomerGroupReference ;
712import com .commercetools .importapi .models .common .CustomerGroupKeyReference ;
813import com .commercetools .importapi .models .common .StoreKeyReference ;
914import com .commercetools .importapi .models .customers .AuthenticationMode ;
1015import com .commercetools .importapi .models .customers .CustomerAddress ;
1116import com .commercetools .importapi .models .customers .CustomerImport ;
12- import org .jetbrains .annotations .NotNull ;
1317
14- import java .util .List ;
15-
16- import static com .commercetools .sdk .CommonImportUtil .getImportApiCustom ;
17- import static java .lang .Integer .parseInt ;
18+ import org .jetbrains .annotations .NotNull ;
1819
1920public class CustomerUtil {
2021 public CustomerImport toCustomerImport (Customer customer ) {
2122 return CustomerImport .builder ()
22- .key (customer .getKey ()) // required field
23+ .key (customer .getKey ()) // required field
2324 .customerNumber (customer .getCustomerNumber ())
24- .email (customer .getEmail ()) // required field
25+ .email (customer .getEmail ()) // required field
2526 .password (customer .getPassword ())
26- .stores (toImportApiStoreKeyReferences (customer .getStores ())) // required field
27+ .stores (toImportApiStoreKeyReferences (customer .getStores ())) // required field
2728 .firstName (customer .getFirstName ())
2829 .lastName (customer .getLastName ())
2930 .middleName (customer .getMiddleName ())
@@ -34,14 +35,14 @@ public CustomerImport toCustomerImport(Customer customer) {
3435 .companyName (customer .getCompanyName ())
3536 .vatId (customer .getVatId ())
3637 .isEmailVerified (customer .getIsEmailVerified ())
37- .customerGroup (toCustomerGroupKeyReference (customer .getCustomerGroup ())) // required field
38- .addresses (mapToCustomerAddresses (customer .getAddresses ())) // required field
38+ .customerGroup (toCustomerGroupKeyReference (customer .getCustomerGroup ())) // required field
39+ .addresses (mapToCustomerAddresses (customer .getAddresses ())) // required field
3940 .defaultBillingAddress (getAddressesId (customer .getDefaultBillingAddress ()))
4041 .billingAddresses (getAddressesIds (customer .getBillingAddresses ()))
4142 .shippingAddresses (getAddressesIds (customer .getShippingAddresses ()))
4243 .defaultShippingAddress (getAddressesId (customer .findDefaultShippingAddress ().orElse (null )))
4344 .locale (customer .getLocale ())
44- .custom (getImportApiCustom (customer .getCustom ())) // required field
45+ .custom (getImportApiCustom (customer .getCustom ())) // required field
4546 .authenticationMode (toImportApiAuthenticationMode (customer .getAuthenticationMode ()))
4647 .build ();
4748 }
@@ -51,17 +52,16 @@ private AuthenticationMode toImportApiAuthenticationMode(
5152 if (authenticationMode instanceof com .commercetools .api .models .customer .AuthenticationMode .AuthenticationModeEnum ) {
5253 return AuthenticationMode .AuthenticationModeEnum .valueOf (authenticationMode .name ());
5354 }
54- else return null ;
55+ else
56+ return null ;
5557 }
5658
57- private CustomerGroupKeyReference toCustomerGroupKeyReference (
58- @ NotNull CustomerGroupReference customerGroup ) {
59+ private CustomerGroupKeyReference toCustomerGroupKeyReference (@ NotNull CustomerGroupReference customerGroup ) {
5960 return CustomerGroupKeyReference .builder ().key (customerGroup .getId ()).build ();
6061 }
6162
6263 private List <StoreKeyReference > toImportApiStoreKeyReferences (
63- @ NotNull
64- List <com .commercetools .api .models .store .StoreKeyReference > stores ) {
64+ @ NotNull List <com .commercetools .api .models .store .StoreKeyReference > stores ) {
6565 return stores .stream ().map (x -> StoreKeyReference .builder ().key (x .getKey ()).build ()).toList ();
6666 }
6767
@@ -83,7 +83,7 @@ private List<CustomerAddress> mapToCustomerAddresses(List<Address> shippingAddre
8383 private CustomerAddress toCustomerAddress (Address address ) {
8484 return CustomerAddress .builder ()
8585 .key (address .getKey ()) // required field
86- .country (address .getCountry ()) // required field
86+ .country (address .getCountry ()) // required field
8787 .title (address .getTitle ())
8888 .salutation (address .getSalutation ())
8989 .firstName (address .getFirstName ())
@@ -106,7 +106,7 @@ private CustomerAddress toCustomerAddress(Address address) {
106106 .fax (address .getFax ())
107107 .additionalAddressInfo (address .getAdditionalAddressInfo ())
108108 .externalId (address .getExternalId ())
109- .custom (getImportApiCustom (address .getCustom ())) // required field
109+ .custom (getImportApiCustom (address .getCustom ())) // required field
110110 .build ();
111111 }
112112}
0 commit comments