diff --git a/src/endpoints/flows.js b/src/endpoints/flows.js index 2b6310e6fc..78eb402e32 100644 --- a/src/endpoints/flows.js +++ b/src/endpoints/flows.js @@ -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 diff --git a/src/types/flow.d.ts b/src/types/flow.d.ts index 9aad5c257b..f80f4168f9 100644 --- a/src/types/flow.d.ts +++ b/src/types/flow.d.ts @@ -99,9 +99,10 @@ export interface FlowEndpoint { GetFlowTypeAttributes(flowType: string, token?: string): Promise - CreateFlowRelationship(flowSlug: string, fieldSlug: string, srcId: string, targetType: string, targetId: string): Promise - // DeleteFlowRelationships(srcType: string, srcId: string, targetType: string): Promise + CreateFlowRelationship(endpoint: string, srcId: string, flowSlug: string, targetType: string, targetId: string) - // UpdateRelationships(srcType: string, srcId: string, targetType: string, resources?: string | any[]): Promise + DeleteFlowRelationship(endpoint: string, srcId: string, flowSlug: string) + + UpdateFlowRelationship(endpoint: string, srcId: string, flowSlug: string, targetType: string, targetId: string) }