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

Commit

Permalink
Updated CreateFlowRelationship API
Browse files Browse the repository at this point in the history
  • Loading branch information
dr-ep committed Aug 10, 2022
1 parent 58e4ccc commit 25af2e6
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 31 deletions.
55 changes: 27 additions & 28 deletions src/endpoints/flows.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,39 +122,38 @@ class FlowsEndpoint extends CRUDExtend {
)
}

CreateFlowRelationship(srcType, srcId, targetType, resources) {
const srcEndpoint = getEndpoint(srcType);
const body = buildRelationshipData(targetType, resources)
const parsedType = formatUrlResource(targetType)

CreateFlowRelationship(flowSlug, fieldSlug, srcId, targetType, targetId) {
return this.request.send(
`${srcEndpoint}/${srcId}/relationships/${parsedType}`,
`v2/flows/${flowSlug}/entries/${srcId}/relationships/${fieldSlug}`,
'POST',
body
)
}

DeleteFlowRelationships(srcType, srcId, targetType) {
const srcEndpoint = getEndpoint(srcType);
const parsedType = formatUrlResource(targetType)

return this.request.send(
`${srcEndpoint}/${srcId}/relationships/${parsedType}`,
'DELETE'
{
type: targetType,
id: targetId,
},
)
}

UpdateRelationships(srcType, srcId, targetType, resources = null) {
const srcEndpoint = getEndpoint(srcType);
const body = buildRelationshipData(targetType, resources)
const parsedType = formatUrlResource(targetType)

return this.request.send(
`${srcEndpoint}/${srcId}/relationships/${parsedType}`,
'PUT',
body
)
}
// DeleteFlowRelationships(srcType, srcId, targetType) {
// const srcEndpoint = getEndpoint(srcType);
// const parsedType = formatUrlResource(targetType)

// return this.request.send(
// `${srcEndpoint}/${srcId}/relationships/${parsedType}`,
// 'DELETE'
// )
// }

// UpdateRelationships(srcType, srcId, targetType, resources = null) {
// const srcEndpoint = getEndpoint(srcType);
// const body = buildRelationshipData(targetType, resources)
// const parsedType = formatUrlResource(targetType)

// return this.request.send(
// `${srcEndpoint}/${srcId}/relationships/${parsedType}`,
// 'PUT',
// body
// )
// }
}

export default FlowsEndpoint
6 changes: 3 additions & 3 deletions src/types/flow.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,9 @@ export interface FlowEndpoint {

GetFlowTypeAttributes(flowType: string, token?: string): Promise<Attributes>

CreateFlowRelationship(srcType: string, srcId: string, targetType: string, resources?: string | any[]): Promise<void>
CreateFlowRelationship(flowSlug: string, fieldSlug: string, srcId: string, targetType: string, targetId: string): Promise<void>

DeleteFlowRelationships(srcType: string, srcId: string, targetType: string): Promise<void>
// DeleteFlowRelationships(srcType: string, srcId: string, targetType: string): Promise<void>

UpdateRelationships(srcType: string, srcId: string, targetType: string, resources?: string | any[]): Promise<void>
// UpdateRelationships(srcType: string, srcId: string, targetType: string, resources?: string | any[]): Promise<void>
}

0 comments on commit 25af2e6

Please sign in to comment.