commercetools / commercetools-sdk-java-v2

The e-commerce SDK from commercetools for Java.
https://commercetools.github.io/commercetools-sdk-java-v2/javadoc/index.html
Apache License 2.0
34 stars 15 forks source link

Address types do not seem consistent with API #248

Closed ahmetoz closed 2 years ago

ahmetoz commented 2 years ago

The baseAddress as type does not seem consistent with the API. Please check if I'm wrong or not: https://docs.commercetools.com/api/releases/2021-01-29-custom-fields-for-addresses

I would expect to have 2 types as like documented on the API docs: Address and AddressDraft, also considering mapping between those each other should be easy as both almost same except custom field type.

For instance I can not map/build a valid address type.

CustomerDraftBuilder.of() .addresses(BaseAddressBuilder.of().custom(?)); // not a method

jenschude commented 2 years ago

We had to create this BaseAddress class in order to be able to differentiate between Address and AddressDraft in a backwards compatible way.

The fix here is to not use BaseAddressBuilder but the AddressDraftBuilder. Sorry for the confusion.

ahmetoz commented 2 years ago

Oh yes, I got it now!
I think you could consider this issue as a feedback to add some javadoc for BaseAddress and it's purpose.

jenschude commented 2 years ago

Yeah adding some javadoc to generated classes is somehow, let's say complicated 😃

ahmetoz commented 2 years ago

Hmm, I have a wrong mindset, I was not thinking about those are generated code, valid point 😄 👍🏽

jenschude commented 2 years ago

It says so in the class and as well the folder structure 😉

https://github.com/commercetools/commercetools-sdk-java-v2/blob/5ce6328e1cbf9c21895636f39e75efbc364e46c8/commercetools/commercetools-sdk-java-api/src/main/java-generated/com/commercetools/api/models/common/BaseAddressBuilder.java#L11-L12