001 002package com.commercetools.api.models.cart; 003 004import java.util.Arrays; 005import java.util.Optional; 006 007import com.fasterxml.jackson.annotation.JsonCreator; 008import com.fasterxml.jackson.annotation.JsonValue; 009 010import io.vrap.rmf.base.client.JsonEnum; 011import io.vrap.rmf.base.client.utils.Generated; 012 013/** 014 * <p>Indicates how Line Items in a Cart are tracked.</p> 015 */ 016@Generated(value = "io.vrap.rmf.codegen.rendering.CoreCodeGenerator", comments = "https://github.com/commercetools/rmf-codegen") 017public interface InventoryMode extends JsonEnum { 018 019 /** 020 <p>Adding and ordering items from a Cart are independent of the Inventory with no inventory checks or modifications.</p> 021 <p>This is the default mode.</p> 022 023 */ 024 InventoryMode NONE = InventoryModeEnum.NONE; 025 /** 026 <p>Orders are tracked on the Inventory, and ordering a <a href="ctp:api:type:LineItem">LineItem</a> deducts the available quantity on the respective <a href="ctp:api:type:InventoryEntry">InventoryEntry</a>.</p> 027 <p>An <a href="/../api/projects/orders#create-order">Order can be created</a> even if the Line Item quantity is zero or negative, but if no matching Inventory Entry exists for the Line Item, an <a href="ctp:api:type:OutOfStockError">OutOfStock</a> error is returned.</p> 028 029 */ 030 InventoryMode TRACK_ONLY = InventoryModeEnum.TRACK_ONLY; 031 /** 032 <p>Line Items in a Cart are only reserved for the duration of the ordering transaction. 033 If a Line Item is not available when <a href="/../api/projects/orders#create-order">creating an Order</a>, an <a href="ctp:api:type:OutOfStockError">OutOfStock</a> error is returned. 034 This is because the <a href="ctp:api:type:InventoryEntry">InventoryEntry</a> <code>availableQuantity</code> is insufficient (but is still updated) for the ordered Line Item quantity.</p> 035 <p>However, an Order can be created if the <a href="ctp:api:type:InventoryEntry">InventoryEntry</a> <code>restockableInDays</code> is set (including <code>0</code>).</p> 036 037 */ 038 InventoryMode RESERVE_ON_ORDER = InventoryModeEnum.RESERVE_ON_ORDER; 039 040 /** 041 * possible values of InventoryMode 042 */ 043 enum InventoryModeEnum implements InventoryMode { 044 /** 045 * None 046 */ 047 NONE("None"), 048 049 /** 050 * TrackOnly 051 */ 052 TRACK_ONLY("TrackOnly"), 053 054 /** 055 * ReserveOnOrder 056 */ 057 RESERVE_ON_ORDER("ReserveOnOrder"); 058 private final String jsonName; 059 060 private InventoryModeEnum(final String jsonName) { 061 this.jsonName = jsonName; 062 } 063 064 public String getJsonName() { 065 return jsonName; 066 } 067 068 public String toString() { 069 return jsonName; 070 } 071 } 072 073 /** 074 * the JSON value 075 * @return json value 076 */ 077 @JsonValue 078 String getJsonName(); 079 080 /** 081 * the enum value 082 * @return name 083 */ 084 String name(); 085 086 /** 087 * convert value to string 088 * @return string representation 089 */ 090 String toString(); 091 092 /** 093 * factory method for a enum value of InventoryMode 094 * if no enum has been found an anonymous instance will be created 095 * @param value the enum value to be wrapped 096 * @return enum instance 097 */ 098 @JsonCreator 099 public static InventoryMode findEnum(String value) { 100 return findEnumViaJsonName(value).orElse(new InventoryMode() { 101 @Override 102 public String getJsonName() { 103 return value; 104 } 105 106 @Override 107 public String name() { 108 return value.toUpperCase(); 109 } 110 111 public String toString() { 112 return value; 113 } 114 }); 115 } 116 117 /** 118 * method to find enum using the JSON value 119 * @param jsonName the json value to be wrapped 120 * @return optional of enum instance 121 */ 122 public static Optional<InventoryMode> findEnumViaJsonName(String jsonName) { 123 return Arrays.stream(values()).filter(t -> t.getJsonName().equals(jsonName)).findFirst(); 124 } 125 126 /** 127 * possible enum values 128 * @return array of possible enum values 129 */ 130 public static InventoryMode[] values() { 131 return InventoryModeEnum.values(); 132 } 133 134 public static com.commercetools.api.models.cart.InventoryMode defaultValue() { 135 return com.commercetools.api.models.cart.InventoryMode.NONE; 136 } 137 138}