Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: product template relationship (#522)
* feat: PCMTempalte type and endpoint * add extentions to PCMproduct type
- Loading branch information
1 parent
111d192
commit bd1918f
Showing
5 changed files
with
91 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import RequestFactory from '../factories/request' | ||
import { buildRelationshipData } from '../utils/helpers' | ||
|
||
class PCMTemplateRelationshipEndpoint { | ||
constructor(endpoint) { | ||
const config = { ...endpoint } // Need to clone config so it is only updated in PCM | ||
this.request = new RequestFactory(config) | ||
config.version = 'pcm' | ||
this.endpoint = 'relationships/templates' | ||
} | ||
|
||
All(productId) { | ||
return this.request.send(`products/${productId}/${this.endpoint}`, 'GET') | ||
} | ||
|
||
Create(productId, resources) { | ||
const body = buildRelationshipData('template', resources) | ||
return this.request.send( | ||
`products/${productId}/${this.endpoint}`, | ||
'POST', | ||
body | ||
) | ||
} | ||
|
||
Delete(productId, resources) { | ||
const body = buildRelationshipData('template', resources) | ||
return this.request.send( | ||
`products/${productId}/${this.endpoint}`, | ||
'DELETE', | ||
body | ||
) | ||
} | ||
} | ||
|
||
export default PCMTemplateRelationshipEndpoint |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/** | ||
* Products templates relationship | ||
*/ | ||
import { Identifiable, ResourceList } from './core' | ||
|
||
export interface PcmTemplateRelationship extends Identifiable { | ||
meta: { | ||
created_at: string | ||
tags?: string[] | ||
} | ||
type: string | ||
} | ||
|
||
export type ProductTemplateRelationshipResource = string | { id: string; meta: { tags: string[] } } | ||
|
||
export interface PcmTemplateRelationshipEndpoint { | ||
endpoint: 'relationships/templates' | ||
|
||
/** | ||
* Get all product template relationships | ||
* Description: | ||
* @param productId | ||
* @constructor | ||
*/ | ||
All(productId: string): Promise<ResourceList<PcmTemplateRelationship>> | ||
|
||
/** | ||
* Create a product template relationship | ||
* Description: | ||
* @param productId | ||
* @param resources | ||
* @constructor | ||
*/ | ||
Create( | ||
productId: string, | ||
resources?: string | ProductTemplateRelationshipResource[] | ||
): Promise<void> | ||
|
||
/** | ||
* Delete a product template relationship | ||
* Description: | ||
* @param productId | ||
* @param resources | ||
* @constructor | ||
*/ | ||
Delete( | ||
productId: string, | ||
resources?: string | string[] | ||
): Promise<void> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters