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

Commit

Permalink
New APIs
Browse files Browse the repository at this point in the history
  • Loading branch information
dr-ep committed Aug 10, 2022
1 parent 25af2e6 commit 0b04b7e
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 29 deletions.
48 changes: 22 additions & 26 deletions src/endpoints/flows.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,38 +122,34 @@ class FlowsEndpoint extends CRUDExtend {
)
}

CreateFlowRelationship(flowSlug, fieldSlug, srcId, targetType, targetId) {
CreateFlowRelationship(endpoint, srcId, flowSlug, targetType, targetId) {
return this.request.send(
`v2/flows/${flowSlug}/entries/${srcId}/relationships/${fieldSlug}`,
`${endpoint}/${srcId}/relationships/${flowSlug}`,
'POST',
{
type: targetType,
id: targetId,
},
type: targetType,
id: targetId
}
)
}

DeleteFlowRelationship(endpoint, srcId, flowSlug) {
return this.request.send(
`${endpoint}/${srcId}/relationships/${flowSlug}`,
'DELETE'
)
}

// 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
// )
// }
UpdateFlowRelationship(endpoint, srcId, flowSlug, targetType, targetId) {
return this.request.send(
`${endpoint}/${srcId}/relationships/${flowSlug}`,
'PUT',
{
type: targetType,
id: targetId
}
)
}
}

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

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

CreateFlowRelationship(flowSlug: string, fieldSlug: string, srcId: string, targetType: string, targetId: string): Promise<void>

// DeleteFlowRelationships(srcType: string, srcId: string, targetType: string): Promise<void>
CreateFlowRelationship(endpoint: string, srcId: string, flowSlug: string, targetType: string, targetId: string)

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

UpdateFlowRelationship(endpoint: string, srcId: string, flowSlug: string, targetType: string, targetId: string)
}

0 comments on commit 0b04b7e

Please sign in to comment.