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

Commit 0b04b7e

Browse files
committed
New APIs
1 parent 25af2e6 commit 0b04b7e

File tree

2 files changed

+26
-29
lines changed

2 files changed

+26
-29
lines changed

src/endpoints/flows.js

Lines changed: 22 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -122,38 +122,34 @@ class FlowsEndpoint extends CRUDExtend {
122122
)
123123
}
124124

125-
CreateFlowRelationship(flowSlug, fieldSlug, srcId, targetType, targetId) {
125+
CreateFlowRelationship(endpoint, srcId, flowSlug, targetType, targetId) {
126126
return this.request.send(
127-
`v2/flows/${flowSlug}/entries/${srcId}/relationships/${fieldSlug}`,
127+
`${endpoint}/${srcId}/relationships/${flowSlug}`,
128128
'POST',
129129
{
130-
type: targetType,
131-
id: targetId,
132-
},
130+
type: targetType,
131+
id: targetId
132+
}
133+
)
134+
}
135+
136+
DeleteFlowRelationship(endpoint, srcId, flowSlug) {
137+
return this.request.send(
138+
`${endpoint}/${srcId}/relationships/${flowSlug}`,
139+
'DELETE'
133140
)
134141
}
135142

136-
// DeleteFlowRelationships(srcType, srcId, targetType) {
137-
// const srcEndpoint = getEndpoint(srcType);
138-
// const parsedType = formatUrlResource(targetType)
139-
140-
// return this.request.send(
141-
// `${srcEndpoint}/${srcId}/relationships/${parsedType}`,
142-
// 'DELETE'
143-
// )
144-
// }
145-
146-
// UpdateRelationships(srcType, srcId, targetType, resources = null) {
147-
// const srcEndpoint = getEndpoint(srcType);
148-
// const body = buildRelationshipData(targetType, resources)
149-
// const parsedType = formatUrlResource(targetType)
150-
151-
// return this.request.send(
152-
// `${srcEndpoint}/${srcId}/relationships/${parsedType}`,
153-
// 'PUT',
154-
// body
155-
// )
156-
// }
143+
UpdateFlowRelationship(endpoint, srcId, flowSlug, targetType, targetId) {
144+
return this.request.send(
145+
`${endpoint}/${srcId}/relationships/${flowSlug}`,
146+
'PUT',
147+
{
148+
type: targetType,
149+
id: targetId
150+
}
151+
)
152+
}
157153
}
158154

159155
export default FlowsEndpoint

src/types/flow.d.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,9 +99,10 @@ export interface FlowEndpoint {
9999

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

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

104-
// DeleteFlowRelationships(srcType: string, srcId: string, targetType: string): Promise<void>
103+
CreateFlowRelationship(endpoint: string, srcId: string, flowSlug: string, targetType: string, targetId: string)
105104

106-
// UpdateRelationships(srcType: string, srcId: string, targetType: string, resources?: string | any[]): Promise<void>
105+
DeleteFlowRelationship(endpoint: string, srcId: string, flowSlug: string)
106+
107+
UpdateFlowRelationship(endpoint: string, srcId: string, flowSlug: string, targetType: string, targetId: string)
107108
}

0 commit comments

Comments
 (0)