@@ -469,13 +469,21 @@ public boolean deleteVariations(
469469 * @param section the section of the autocomplete that you're modifying the item for.
470470 * @param force whether or not the system should process the request even if it will invalidate
471471 * a large number of existing variations.
472+ * @param onMissing Either "FAIL", "IGNORE", "CREATE", indicating how the system will handle
473+ * updating items that don't exist. "FAIL" fails the ingestion if there are items that don't
474+ * exist. "IGNORE" ignores items that don't exist. "CREATE" creates items that don't exist.
475+ * Defaults to "FAIL".
472476 * @param notificationEmail An email address where you'd like to receive an email notification
473477 * in case the task fails.
474478 * @return true if successfully modified
475479 * @throws ConstructorException if the request is invalid.
476480 */
477481 public boolean updateItems (
478- ConstructorItem [] items , String section , Boolean force , String notificationEmail )
482+ ConstructorItem [] items ,
483+ String section ,
484+ Boolean force ,
485+ String notificationEmail ,
486+ CatalogRequest .OnMissing onMissing )
479487 throws ConstructorException {
480488 try {
481489 HttpUrl url = this .makeUrl (Arrays .asList ("v2" , "items" ));
@@ -492,6 +500,10 @@ public boolean updateItems(
492500 .build ();
493501 }
494502
503+ if (onMissing != null && onMissing != CatalogRequest .OnMissing .FAIL ) {
504+ url = url .newBuilder ().addQueryParameter ("on_missing" , onMissing .name ()).build ();
505+ }
506+
495507 Map <String , Object > data = new HashMap <String , Object >();
496508 List <Object > itemsAsJSON = new ArrayList <Object >();
497509 for (ConstructorItem item : items ) {
@@ -511,18 +523,36 @@ public boolean updateItems(
511523 }
512524 }
513525
526+ /**
527+ * Updates items from your index.
528+ *
529+ * @param items the items that you're updating
530+ * @param section the section of the autocomplete that you're modifying the item for.
531+ * @param force whether or not the system should process the request even if it will invalidate
532+ * a large number of existing variations.
533+ * @param notificationEmail An email address where you'd like to receive an email notification
534+ * in case the task fails.
535+ * @return true if successfully modified
536+ * @throws ConstructorException if the request is invalid.
537+ */
538+ public boolean updateItems (
539+ ConstructorItem [] items , String section , Boolean force , String notificationEmail )
540+ throws ConstructorException {
541+ return updateItems (items , section , force , notificationEmail , null );
542+ }
543+
514544 public boolean updateItems (ConstructorItem [] items ) throws ConstructorException {
515- return updateItems (items , "Products" , false , null );
545+ return updateItems (items , "Products" , false , null , null );
516546 }
517547
518548 public boolean updateItems (ConstructorItem [] items , String section )
519549 throws ConstructorException {
520- return updateItems (items , section , false , null );
550+ return updateItems (items , section , false , null , null );
521551 }
522552
523553 public boolean updateItems (ConstructorItem [] items , String section , Boolean force )
524554 throws ConstructorException {
525- return updateItems (items , section , force , null );
555+ return updateItems (items , section , force , null , null );
526556 }
527557
528558 /**
@@ -534,14 +564,19 @@ public boolean updateItems(ConstructorItem[] items, String section, Boolean forc
534564 * a large number of existing variations.
535565 * @param notificationEmail An email address where you'd like to receive an email notification
536566 * in case the task fails.
567+ * @param onMissing Either "FAIL", "IGNORE", "CREATE", indicating how the system will handle
568+ * updating variations that don't exist. "FAIL" fails the ingestion if there are items that
569+ * don't exist. "IGNORE" ignores variations that don't exist. "CREATE" creates items that
570+ * don't exist. Defaults to "FAIL".
537571 * @return true if successfully modified
538572 * @throws ConstructorException if the request is invalid.
539573 */
540574 public boolean updateVariations (
541575 ConstructorVariation [] variations ,
542576 String section ,
543577 Boolean force ,
544- String notificationEmail )
578+ String notificationEmail ,
579+ CatalogRequest .OnMissing onMissing )
545580 throws ConstructorException {
546581 try {
547582 HttpUrl url = this .makeUrl (Arrays .asList ("v2" , "variations" ));
@@ -557,6 +592,9 @@ public boolean updateVariations(
557592 .addQueryParameter ("notification_email" , notificationEmail )
558593 .build ();
559594 }
595+ if (onMissing != null && onMissing != CatalogRequest .OnMissing .FAIL ) {
596+ url = url .newBuilder ().addQueryParameter ("on_missing" , onMissing .name ()).build ();
597+ }
560598
561599 Map <String , Object > data = new HashMap <String , Object >();
562600 List <Object > variationsAsJSON = new ArrayList <Object >();
@@ -577,19 +615,44 @@ public boolean updateVariations(
577615 }
578616 }
579617
618+ /**
619+ * Update variations from your index.
620+ *
621+ * @param variations the variations that you're updating.
622+ * @param section the section of the autocomplete that you're modifying the item for.
623+ * @param force whether or not the system should process the request even if it will invalidate
624+ * a large number of existing variations.
625+ * @param notificationEmail An email address where you'd like to receive an email notification
626+ * in case the task fails.
627+ * @return true if successfully modified
628+ * @throws ConstructorException if the request is invalid.
629+ */
630+ public boolean updateVariations (
631+ ConstructorVariation [] variations ,
632+ String section ,
633+ Boolean force ,
634+ String notificationEmail )
635+ throws ConstructorException {
636+ try {
637+ return updateVariations (variations , section , force , notificationEmail , null );
638+ } catch (Exception exception ) {
639+ throw new ConstructorException (exception );
640+ }
641+ }
642+
580643 public boolean updateVariations (ConstructorVariation [] variations ) throws ConstructorException {
581- return updateVariations (variations , "Products" , false , null );
644+ return updateVariations (variations , "Products" , false , null , null );
582645 }
583646
584647 public boolean updateVariations (ConstructorVariation [] variations , String section )
585648 throws ConstructorException {
586- return updateVariations (variations , section , false , null );
649+ return updateVariations (variations , section , false , null , null );
587650 }
588651
589652 public boolean updateVariations (
590653 ConstructorVariation [] variations , String section , Boolean force )
591654 throws ConstructorException {
592- return updateVariations (variations , section , force , null );
655+ return updateVariations (variations , section , force , null , null );
593656 }
594657
595658 /**
@@ -2251,6 +2314,9 @@ public String patchCatalog(CatalogRequest req) throws ConstructorException {
22512314 if (force != null ) {
22522315 urlBuilder .addQueryParameter ("force" , Boolean .toString (force ));
22532316 }
2317+ if (req .getOnMissing () != CatalogRequest .OnMissing .FAIL ) {
2318+ urlBuilder .addQueryParameter ("on_missing" , req .getOnMissing ().name ());
2319+ }
22542320
22552321 urlBuilder .addQueryParameter ("patch_delta" , Boolean .toString (true ));
22562322
0 commit comments