Skip to content
This repository has been archived by the owner on Jul 24, 2024. It is now read-only.

Commit

Permalink
feat: catalog product children (#726)
Browse files Browse the repository at this point in the history
  • Loading branch information
rostyk-kanafotskyy authored Sep 14, 2022
1 parent 4b001fd commit 6449f79
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 0 deletions.
24 changes: 24 additions & 0 deletions src/endpoints/catalog.js
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,30 @@ class Products extends ShopperCatalogProductsQuery {
additionalHeaders
)
}

GetProductChildren({
productId,
token = null,
additionalHeaders = null
}) {
const { limit, offset, filter, includes } = this

return this.request.send(
buildURL(`catalog/${this.endpoint}/${productId}/relationships/children`, {
limit,
offset,
filter,
includes
}),
'GET',
undefined,
token,
undefined,
false,
undefined,
additionalHeaders
)
}
}

class ShopperCatalogEndpoint extends ShopperCatalogQuery {
Expand Down
16 changes: 16 additions & 0 deletions src/endpoints/catalogs.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,22 @@ class Products extends CRUDExtend {
token
)
}

GetCatalogProductChildren({
catalogId,
releaseId,
productId,
token = null
}) {
return this.request.send(
`catalogs/${catalogId}/releases/${releaseId}/${
this.endpoint
}/${productId}/relationships/children`,
'GET',
undefined,
token
)
}
}

class Releases extends CRUDExtend {
Expand Down
6 changes: 6 additions & 0 deletions src/types/catalog.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,12 @@ export interface ShopperCatalogProductsEndpoint
token?: string
additionalHeaders?: ShopperCatalogAdditionalHeaders
}): Promise<ShopperCatalogResourcePage<ProductResponse>>

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

export interface NodesShopperCatalogEndpoint
Expand Down
7 changes: 7 additions & 0 deletions src/types/catalogs-products.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,4 +157,11 @@ export interface CatalogsProductsEndpoint {
releaseId: string
token?: string
}): Promise<ResourcePage<PcmProduct>>

GetCatalogProductChildren(options: {
catalogId: string
releaseId: string
productId: string
token?: string
}): Promise<ResourcePage<PcmProduct>>
}

0 comments on commit 6449f79

Please sign in to comment.