From 4fd6888c6d16beea99ac4ce8f7434863a7902e38 Mon Sep 17 00:00:00 2001 From: George Botzakis Date: Fri, 4 Oct 2024 18:23:06 +0300 Subject: [PATCH] feat: Added GetRelatedProducts endpoint method to ShopperCatalog.Products --- src/endpoints/catalog.js | 25 +++++++++++++++++++++++++ src/types/catalog.d.ts | 7 +++++++ 2 files changed, 32 insertions(+) diff --git a/src/endpoints/catalog.js b/src/endpoints/catalog.js index 3bbc7ec..d348e42 100644 --- a/src/endpoints/catalog.js +++ b/src/endpoints/catalog.js @@ -315,6 +315,31 @@ class Products extends ShopperCatalogProductsQuery { additionalHeaders ) } + + GetRelatedProducts({ + productId, + customRelationshipSlug, + token = null, + additionalHeaders = null + }) { + const { limit, offset, filter, includes } = this + + return this.request.send( + buildURL(`catalog/${this.endpoint}/${productId}/relationships/${customRelationshipSlug}/products`, { + limit, + offset, + filter, + includes + }), + 'GET', + undefined, + token, + undefined, + false, + undefined, + additionalHeaders + ) + } } class ShopperCatalogEndpoint extends ShopperCatalogQuery { diff --git a/src/types/catalog.d.ts b/src/types/catalog.d.ts index ac5d626..f686459 100644 --- a/src/types/catalog.d.ts +++ b/src/types/catalog.d.ts @@ -167,6 +167,13 @@ export interface ShopperCatalogProductsEndpoint token?: string additionalHeaders?: ShopperCatalogAdditionalHeaders }): Promise> + + GetRelatedProducts(options: { + productId: string + customRelationshipSlug: string + token?: string + additionalHeaders?: ShopperCatalogAdditionalHeaders + }): Promise> } export interface NodesShopperCatalogEndpoint