Skip to content

Commit

Permalink
feat: Add GetRelatedProducts endpoint method to shopper catalog endpo…
Browse files Browse the repository at this point in the history
…int class (#31)

feat: Add new GetRelatedProducts endpoint method
  • Loading branch information
GeorgeBotzakis authored Oct 4, 2024
1 parent 09ec27c commit e6c9248
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
25 changes: 25 additions & 0 deletions src/endpoints/catalog.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
7 changes: 7 additions & 0 deletions src/types/catalog.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,13 @@ export interface ShopperCatalogProductsEndpoint
token?: string
additionalHeaders?: ShopperCatalogAdditionalHeaders
}): Promise<ShopperCatalogResourcePage<ProductResponse>>

GetRelatedProducts(options: {
productId: string
customRelationshipSlug: string
token?: string
additionalHeaders?: ShopperCatalogAdditionalHeaders
}): Promise<ShopperCatalogResourcePage<ProductResponse>>
}

export interface NodesShopperCatalogEndpoint
Expand Down

0 comments on commit e6c9248

Please sign in to comment.