File tree Expand file tree Collapse file tree
commercetools/commercetools-importapi-utils/src/main/java/com/commercetools/sdk Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ package com .commercetools .sdk ;
2+
3+ import com .commercetools .api .models .channel .ChannelReference ;
4+ import com .commercetools .api .models .inventory .InventoryEntry ;
5+ import com .commercetools .importapi .models .common .ChannelKeyReference ;
6+ import com .commercetools .importapi .models .inventories .InventoryImport ;
7+
8+ import static com .commercetools .sdk .CommonImportUtil .getImportApiCustom ;
9+
10+ public class InventoryUtil {
11+ public InventoryImport toInventoryImport (InventoryEntry entry ) {
12+ return InventoryImport .builder ()
13+ .key (entry .getKey ()) // required field
14+ .sku (entry .getSku ()) // required field
15+ .quantityOnStock (entry .getQuantityOnStock ()) // required field
16+ .restockableInDays (entry .getRestockableInDays ())
17+ .expectedDelivery (entry .getExpectedDelivery ())
18+ .reservationExpirationInMinutes (entry .getReservationExpirationInMinutes ())
19+ .supplyChannel (getImportAPISupplyChannel (entry .getSupplyChannel ()))
20+ .custom (getImportApiCustom (entry .getCustom ()))
21+ .build ();
22+ }
23+
24+ private ChannelKeyReference getImportAPISupplyChannel (ChannelReference supplyChannel ) {
25+ if (supplyChannel == null ) {
26+ return null ;
27+ }
28+ return ChannelKeyReference .builder ().key (supplyChannel .getId ()).build ();
29+ }
30+ }
You can’t perform that action at this time.
0 commit comments