public final class SetCustomField extends SetCustomFieldBase<DiscountCode>
See also DiscountCodeUpdateCommand.
withUpdateableType(client(), type -> { final CustomFieldsDraft customFieldsDraft = CustomFieldsDraftBuilder.ofType(type) .addObject(STRING_FIELD_NAME, "a value") .build(); final String code = randomString(); final DiscountCodeDraft discountCodeDraft = discountCodeDraftBuilder(client(), code).custom(customFieldsDraft).build(); final DiscountCode discountCode = client().executeBlocking(DiscountCodeCreateCommand.of(discountCodeDraft)); assertThat(discountCode.getCustom().getFieldAsString(STRING_FIELD_NAME)) .isEqualTo("a value"); final DiscountCodeUpdateCommand discountCodeUpdateCommand = DiscountCodeUpdateCommand.of(discountCode, SetCustomField.ofObject(STRING_FIELD_NAME, "a new value")); final DiscountCode updatedDiscountCode = client().executeBlocking(discountCodeUpdateCommand); assertThat(updatedDiscountCode.getCustom() .getFieldAsString(STRING_FIELD_NAME)).isEqualTo("a new value"); //clean up client().executeBlocking(DiscountCodeDeleteCommand.of(updatedDiscountCode)); return type; });
See the test code.
Custom
Modifier and Type | Method and Description |
---|---|
static SetCustomField |
ofJson(String name,
com.fasterxml.jackson.databind.JsonNode value) |
static SetCustomField |
ofObject(String name,
Object value) |
static SetCustomField |
ofUnset(String name) |
getName, getValue
getAction
public static SetCustomField ofJson(String name, com.fasterxml.jackson.databind.JsonNode value)
public static SetCustomField ofObject(String name, Object value)
public static SetCustomField ofUnset(String name)