/** * @deprecated use {@link #getType()} instead * @return id */ @Deprecated @Nullable public String getTypeId() { return Optional.ofNullable(type).map(t -> t.getId()).orElse(null); }
static <T> ResourceIdentifier<T> ofId(final String id, final String typeId) { return ofIdOrKey(id, null, typeId); }
/** * @deprecated use {@link #getType()} instead * @return key of the type to set */ @Deprecated @Nullable public String getTypeKey() { return type.getKey(); }
static <T> ResourceIdentifier<T> ofId(final String id) { return ofId(id, null); }
static <T> ResourceIdentifier<T> ofKey(final String key) { return ofKey(key, null); }
private ChangeParent(final ResourceIdentifier<Category> parent) { super("changeParent"); this.parent = parent.toResourceIdentifier(); }
/** * use {@link #getType()} instead * @return id of the type to set */ @Deprecated @Nullable public String getTypeId() { return type.getTypeId(); }
static GiftLineItemCartDiscountValue ofGiftLineItem(final ResourceIdentifier<Product> product, final Integer variantId, @Nullable final ResourceIdentifier<Channel> supplyChannel, @Nullable final ResourceIdentifier<Channel> distributionChannel) { return GiftLineItemCartDiscountValue.of(product, variantId, supplyChannel, distributionChannel); } }
public static Review createReview(final BlockingSphereClient client, final Reference<Product> productReference) { final ReviewDraft reviewDraft = ReviewDraftBuilder .ofRating(4) .title("review title") .target(productReference) .state(ResourceIdentifier.ofKey("to-approve"))//you know the initial state by key and don't need a ref .build(); final Review review = client.executeBlocking(ReviewCreateCommand.of(reviewDraft)); assertThat(review.getState()).isNotNull(); assertThat(review.getRating()).isEqualTo(4); return review; } }
private ChangeParent(final ResourceIdentifier<Category> parent) { super("changeParent"); this.parent = parent.toResourceIdentifier(); }
static <T> ResourceIdentifier<T> ofKey(final String key, final String typeId) { return ofIdOrKey(null, key, typeId); }
@Test public void copyFromCustomField() { withUpdateableType(client(), type -> { final String value = "foo"; final String id = type.getId(); final CategoryDraftBuilder categoryDraftBuilder = CategoryDraftBuilder.of(en("category-name"), en("category-slug")) .custom(CustomFieldsDraft.ofTypeIdAndObjects(id, singletonMap(STRING_FIELD_NAME, value))); withCategory(client(), categoryDraftBuilder, category -> { //Test builder final CustomFieldsDraft customFieldsDraft = CustomFieldsDraftBuilder.of(category.getCustom()).build(); assertThat(customFieldsDraft.getType().getId()).isEqualTo(id); //Test factory method from draft final CustomFieldsDraft customFieldsDraft2 = CustomFieldsDraft.ofCustomFields(category.getCustom()); assertThat(customFieldsDraft2.getType().getId()).isEqualTo(id); }); return type; }); }
static GiftLineItemCartDiscountValue ofGiftLineItem(final ResourceIdentifier<Product> product, final Integer variantId, @Nullable final ResourceIdentifier<Channel> supplyChannel, @Nullable final ResourceIdentifier<Channel> distributionChannel) { return GiftLineItemCartDiscountValue.of(product, variantId, supplyChannel, distributionChannel); } }
public static Review approveReview(final BlockingSphereClient client, final Review reviewToApprove) { final ResourceIdentifier<State> state = ResourceIdentifier.ofKey("approved");//we know the state by key final ReviewUpdateCommand cmd = ReviewUpdateCommand.of(reviewToApprove, TransitionState.of(state)); final Review approvedReview = client.executeBlocking(cmd); assertThat(reviewToApprove.getState()).isNotEqualTo(approvedReview.getState()); return approvedReview; } }
/** * @deprecated use {@link #getType()} instead * @return key */ @Nullable @Deprecated public String getTypeKey() { return Optional.ofNullable(type).map(t -> t.getKey()).orElse(null); }
protected SetCustomTypeBase(final String action, @Nullable final String typeId, @Nullable final String typeKey, @Nullable final Map<String, JsonNode> fields) { super(action); this.type = ResourceIdentifier.ofIdOrKey(typeId, typeKey); this.fields = fields; }
protected SetCustomTypeBase(final String action, @Nullable final String typeId, @Nullable final String typeKey, @Nullable final Map<String, JsonNode> fields) { super(action); this.type = ResourceIdentifier.ofIdOrKey(typeId, typeKey); this.fields = fields; }
protected SetCustomTypeBase(final String action, @Nullable final String typeId, @Nullable final String typeKey, @Nullable final Map<String, JsonNode> fields) { super(action); this.type = ResourceIdentifier.ofIdOrKey(typeId, typeKey); this.fields = fields; }