@@ -2954,4 +2954,106 @@ public String deleteFacetConfiguration(FacetConfigurationRequest facetConfigurat
29542954 facetConfigurationRequest .geFacetConfiguration ().getName (),
29552955 facetConfigurationRequest .getSection ());
29562956 }
2957+
2958+ /**
2959+ * Creates a facet option configuration
2960+ *
2961+ * @param request The facet option configuration request containing the configuration to create
2962+ * @return returns the created facet option configuration
2963+ * @throws ConstructorException if the request is invalid
2964+ */
2965+ public String createFacetOptionConfiguration (
2966+ FacetOptionConfigurationRequest facetOptionConfigurationRequest )
2967+ throws ConstructorException {
2968+ try {
2969+ HttpUrl url =
2970+ this .makeUrl (
2971+ Arrays .asList (
2972+ "v1" ,
2973+ "facets" ,
2974+ facetOptionConfigurationRequest .getFacetName (),
2975+ "options" ));
2976+ url =
2977+ url .newBuilder ()
2978+ .addQueryParameter (
2979+ "section" , facetOptionConfigurationRequest .getSection ())
2980+ .build ();
2981+
2982+ String params =
2983+ new Gson ()
2984+ .toJson (facetOptionConfigurationRequest .getFacetOptionConfiguration ());
2985+ RequestBody body =
2986+ RequestBody .create (params , MediaType .parse ("application/json; charset=utf-8" ));
2987+ Request request = this .makeAuthorizedRequestBuilder ().url (url ).post (body ).build ();
2988+
2989+ Response response = client .newCall (request ).execute ();
2990+
2991+ return getResponseBody (response );
2992+ } catch (Exception exception ) {
2993+ throw new ConstructorException (exception );
2994+ }
2995+ }
2996+
2997+ /**
2998+ * Deletes a facet option configuration
2999+ *
3000+ * @param facetName the name of the facet
3001+ * @param facetOptionValue the value of the facet option to delete
3002+ * @param section the section of the facet
3003+ * @return returns the deleted facet option configuration
3004+ * @throws ConstructorException if the request is invalid
3005+ */
3006+ public String deleteFacetOptionConfiguration (
3007+ String facetName , String facetOptionValue , String section ) throws ConstructorException {
3008+ if (facetName == null || facetName .trim ().isEmpty ()) {
3009+ throw new IllegalArgumentException ("facetName is required" );
3010+ }
3011+ if (facetOptionValue == null || facetOptionValue .trim ().isEmpty ()) {
3012+ throw new IllegalArgumentException ("facetOptionValue is required" );
3013+ }
3014+
3015+ try {
3016+ HttpUrl url =
3017+ this .makeUrl (
3018+ Arrays .asList ("v1" , "facets" , facetName , "options" , facetOptionValue ));
3019+ url = url .newBuilder ().addQueryParameter ("section" , section ).build ();
3020+
3021+ Request request = this .makeAuthorizedRequestBuilder ().url (url ).delete ().build ();
3022+
3023+ Response response = client .newCall (request ).execute ();
3024+
3025+ return getResponseBody (response );
3026+ } catch (Exception exception ) {
3027+ throw new ConstructorException (exception );
3028+ }
3029+ }
3030+
3031+ /**
3032+ * Deletes a facet option configuration with default section "Products"
3033+ *
3034+ * @param facetName the name of the facet
3035+ * @param facetOptionValue the value of the facet option to delete
3036+ * @return returns the deleted facet option configuration
3037+ * @throws ConstructorException if the request is invalid
3038+ */
3039+ public String deleteFacetOptionConfiguration (String facetName , String facetOptionValue )
3040+ throws ConstructorException {
3041+ return deleteFacetOptionConfiguration (facetName , facetOptionValue , "Products" );
3042+ }
3043+
3044+ /**
3045+ * Deletes a facet option configuration
3046+ *
3047+ * @param request The facet option configuration request containing the configuration to delete
3048+ * @return returns the deleted facet option configuration
3049+ * @throws ConstructorException if the request is invalid
3050+ */
3051+ public String deleteFacetOptionConfiguration (
3052+ FacetOptionConfigurationRequest facetOptionConfigurationRequest )
3053+ throws ConstructorException {
3054+ return deleteFacetOptionConfiguration (
3055+ facetOptionConfigurationRequest .getFacetName (),
3056+ facetOptionConfigurationRequest .getFacetOptionConfiguration ().getValue (),
3057+ facetOptionConfigurationRequest .getSection ());
3058+ }
29573059}
0 commit comments