Skip to content

Conversation

@jensmeichler
Copy link
Contributor

Adds the possibility to manage (CRUD) the sort options through the java client.

I used the docs regarding the sort option management to create the operations and tested it to be working. Also created an integration test to hopefully prove that it's working as intended.

Copy link
Contributor

@Mudaafi Mudaafi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is looking good. I had some implementation suggestions, but looking at the timeline, I might just push those changes up directly

private String sortBy;

@SerializedName("sort_order")
private String sortOrder;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since sort_order can only be one of two values "ascending" | "descending", would it be better to type it as an enum?

* @return returns the sort options response
* @throws ConstructorException if the request is invalid
*/
public SortOptionsResponse retrieveSortOptions(String section, String sortBy)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rather than having this overload, we would probably prefer having an overload that takes in a RetrieveSortOptionsRequest so that we cover all the different request parameters.

* @return returns the deleted sort options as JSON string
* @throws ConstructorException if the request is invalid
*/
public String deleteSortOptions(String sortBy, String sortOrder, String section)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This method only deletes one sort option. We can keep this method for ease of use and rename it as deleteSortOption, but we should have another method that takes in an array of sortOptions to allow for the deletion of multiple options at once

Copy link

@evanyan13 evanyan13 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!
Left some lint-related comments for consideration please

}

/**
* Retrieves all sort options with default section "Products"
Copy link

@evanyan13 evanyan13 Dec 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the comment here is meant to be:
Retrieves all sort options with provided sortBy value

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice catch!

public void sortOptionDeserialization() throws Exception {
String json =
"{"
+ "\"display_name\": \"Preis\","

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this meant to be "Price"?
Or is this left as a weird value by intention?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's German. I'll change it to be Price

+ "\"total_count\": 2,"
+ "\"sort_options\": ["
+ " {"
+ " \"display_name\": \"Preis\","

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar question here

Copy link
Contributor

@Mudaafi Mudaafi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR is missing the ability to batch-create sort options. Will add it in a future PR. Tests pass locally.

@Mudaafi Mudaafi merged commit 490f9af into Constructor-io:master Dec 5, 2025
4 of 5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants