Skip to content

Commit 77c64a2

Browse files
committed
Merge remote-tracking branch 'origin/DEVX-640-helper-method-from-Coco-product-to-import-API-product' into DEVX-640-helper-method-from-Coco-product-to-import-API-product
2 parents 332df6d + 96592a0 commit 77c64a2

2 files changed

Lines changed: 20 additions & 19 deletions

File tree

.git-blame-ignore-revs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,4 @@ f6aab9d10212756b1d71a0568c706a9df51c322d
3232
eb09ce06943ccb460981afaa6b5ecfd54f8f87e2
3333
4e64347e48610b8128ca737ccdb24634a92bbe34
3434
cd4bb52247f964cdb924e28f32a6cd888d25ccea
35+
49ffd1c6341f8071336509d025c414de63c1a702

commercetools/commercetools-importapi-utils/src/main/java/com/commercetools/sdk/CustomerUtil.java

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,30 @@
1+
12
package 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+
39
import com.commercetools.api.models.common.Address;
4-
import com.commercetools.api.models.common.BaseAddress;
510
import com.commercetools.api.models.customer.Customer;
611
import com.commercetools.api.models.customer_group.CustomerGroupReference;
712
import com.commercetools.importapi.models.common.CustomerGroupKeyReference;
813
import com.commercetools.importapi.models.common.StoreKeyReference;
914
import com.commercetools.importapi.models.customers.AuthenticationMode;
1015
import com.commercetools.importapi.models.customers.CustomerAddress;
1116
import 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

1920
public 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

Comments
 (0)