Migration
This migration guide provides details on the breaking changes introduced in Java SDK v2.x.x and the steps required to adapt your code.
Breaking Changes
1. Fields Typed as Instant
All fields of models specified as date-time in the specs are now typed as java.time.Instant
.
Code Example:
v1.x.x:
Campaign campaign = new Campaign();
campaign.setStartAt("2021-01-23T11:30:58+00:00");
v2.x.x:
Campaign campaign = new Campaign();
campaign.setStartAt(java.time.Instant.parse("2021-01-23T11:30:58+00:00"));
Affected Models and Fields:
- Campaign:
startAt
,endAt
- Customer:
createdAt
,updatedAt
- CustomerMembership:
createdAt
,updatedAt
- EmailKey:
createdAt
,updatedAt
- Order:
confirmedAt
,invoicedAt
,createdAt
,updatedAt
- OrderItem:
createdAt
,updatedAt
- ProductVariantPrice:
validFrom
,validTo
- ProductVariantStock:
changedAt
- PromotionSchedule:
from
,to
- Redirect:
createdAt
,updatedAt
- Shipment:
deliveryDate
- VoucherConstraintsDate:
max
,min
2. Enum Fields Typed as Corresponding Enum Classes
All enum fields of models are now typed using their corresponding Java enum classes, replacing the previous String
type.
Code Example:
v1.x.x:
Attribute attribute = new Attribute();
attribute.setType("simple");
v2.x.x:
Attribute attribute = new Attribute();
attribute.setType(AttributeType.VALUE_SIMPLE);
Affected Models and Fields:
- Attribute:
type
- AttributeGroup:
type
,level
- CustomDataConfigPropertyType:
type
- Customer:
gender
- CustomerAddressRecipient:
gender
,type
- CustomerPassword:
hashingType
- MasterCategoryAttribute:
type
- Order:
status
- OrderFee:
type
- OrderPaymentInstallment:
type
- OrderSubsequentDelivery:
key
- OrderVoucher:
type
- Product:
state
- ProductState:
state
- Promotion:
status
,activationType
,level
- PromotionCondition:
level
- PromotionEffect:
type
- PromotionEffectAutomaticDiscount:
type
- PromotionEffectBuyXGetY:
maxCountType
- PromotionSiblingPromotion:
level
- PromotionUsageLimitPromotionCode:
type
- ShopCountryPriceRounding:
precision
,roundingType
- SubscriptionOrderAddressInstance:
gender
- SubscriptionOrderApplication:
device
- Transaction:
operationStatus
- Voucher:
status
,type
- VoucherConstraintsApplications:
restriction
- VoucherCriterion:
key
,type
Summary
To migrate your code from Java SDK v1.x.x to v2.x.x:
- Update all date-time fields to use
java.time.Instant
. - Replace string-based enum values with their corresponding Java enum constants.