public final class SetCustomType extends SetCustomTypeBase<DiscountCode>
See also DiscountCodeUpdateCommand.
final String code = randomString(); final DiscountCodeDraft discountCodeDraft = discountCodeDraftBuilder(client(), code).build(); withUpdateableType(client(), type -> { withUpdateableDiscountCode(client(), discountCodeDraft, discountCode -> { final HashMap<String, Object> fields = new HashMap<>(); fields.put(STRING_FIELD_NAME, "hello"); final DiscountCodeUpdateCommand discountCodeUpdateCommand = DiscountCodeUpdateCommand.of(discountCode, SetCustomType.ofTypeIdAndObjects(type.getId(), fields)); final DiscountCode updatedDiscountCode = client().executeBlocking(discountCodeUpdateCommand); assertThat(updatedDiscountCode.getCustom().getType()).isEqualTo(type.toReference()); assertThat(updatedDiscountCode.getCustom().getFieldAsString(STRING_FIELD_NAME)).isEqualTo("hello"); final DiscountCode updatedDiscountCode1 = client().executeBlocking(DiscountCodeUpdateCommand.of(updatedDiscountCode, SetCustomType.ofRemoveType())); assertThat(updatedDiscountCode1.getCustom()).isNull(); return updatedDiscountCode1; }); return type; });
See the test code.
Modifier and Type | Method and Description |
---|---|
static SetCustomType |
ofRemoveType() |
static SetCustomType |
ofTypeIdAndJson(String typeId,
Map<String,com.fasterxml.jackson.databind.JsonNode> fields) |
static SetCustomType |
ofTypeIdAndObjects(String typeId,
Map<String,Object> fields) |
static SetCustomType |
ofTypeKeyAndJson(String typeKey,
Map<String,com.fasterxml.jackson.databind.JsonNode> fields) |
static SetCustomType |
ofTypeKeyAndObjects(String typeKey,
Map<String,Object> fields) |
getFields, getType, mapObjectToJsonMap
getAction
public static SetCustomType ofTypeKeyAndObjects(String typeKey, Map<String,Object> fields)
public static SetCustomType ofTypeIdAndObjects(String typeId, Map<String,Object> fields)
public static SetCustomType ofTypeIdAndJson(String typeId, Map<String,com.fasterxml.jackson.databind.JsonNode> fields)
public static SetCustomType ofTypeKeyAndJson(String typeKey, Map<String,com.fasterxml.jackson.databind.JsonNode> fields)
public static SetCustomType ofRemoveType()