commercetools-jvm-sdk icon indicating copy to clipboard operation
commercetools-jvm-sdk copied to clipboard

LineItem from ShoppingList and Cart should have stereotype

Open schleichardt opened this issue 7 years ago • 5 comments

http://commercetools.github.io/commercetools-jvm-sdk/apidocs/io/sphere/sdk/carts/LineItem.html and http://commercetools.github.io/commercetools-jvm-sdk/apidocs/io/sphere/sdk/shoppinglists/LineItem.html do not share a common interface so I need to code similar stuff twice. Think also about including to another common interface CustomLineItems from Cart.

Common fields of the LineItem classes are:

  • custom
  • id
  • name
  • productId
  • productSlug
  • productType
  • quantity
  • variant

Why would this be useful? For example for typed templates to reuse the same template to show an item in the wishlist and in the cart.

schleichardt avatar Dec 22 '17 10:12 schleichardt

cc @lauraluiz

schleichardt avatar Dec 22 '17 10:12 schleichardt

Yep i have noticed too, i agree this need some refactoring. if possible to make a PR there that would be great. Otherwise we'll just include it later in the sdk. WDYT @schleichardt ?

acbeni avatar Dec 22 '17 13:12 acbeni

It is not that urgent so I would wait.

schleichardt avatar Jan 02 '18 15:01 schleichardt

In order to refactor we need to use LineItemLike wich is already there but contains members that aren't in shopping lists LineItem, so the refactoring is break changing which unfortunately means it should be postponed to 2.0.

acbeni avatar Jan 16 '18 13:01 acbeni

Actually we have 4 classes that can benefit from this: custom line items, regular cart line items, regular shopping list line items and text line items. All of them have different levels of "similarity" among them. For example:

  • all 4 of them might share a common interface (haven't checked)
  • regular cart and regular shopping list line items share the "product" part.
  • regular cart and custom line item share the current LineItemLike interface and it should stay like that (except for the name).
  • regular shopping list and text line item might share a common interface (haven't checked).

Just something to take into account for 2.0 :)

lauraluiz avatar Jan 16 '18 13:01 lauraluiz