Skip to content

Commit 20bfe06

Browse files
Change API for activateFlowTriggerById (#253)
1 parent e107975 commit 20bfe06

File tree

3 files changed

+9
-22
lines changed

3 files changed

+9
-22
lines changed

backendless.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -612,7 +612,7 @@ declare module Backendless {
612612
* @type: Function
613613
*/
614614

615-
type Execution = 'activateAny' | 'activateAll' | string
615+
type Execution = 'any' | 'all' | string
616616

617617
function activateFlow(flowName: string, initialData?: object): Promise<void>
618618
function activateFlowById(flowId: string, initialData?: object): Promise<void>

src/automations/index.js

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -74,27 +74,14 @@ export default class Automations {
7474
if (execution !== undefined && (typeof execution !== 'string' || !execution)) {
7575
throw new Error(
7676
// eslint-disable-next-line
77-
'The "execution" argument must be a non-empty string and must be one of this values: "activateAny", "activateAll" or Execution ID.'
77+
'The "execution" argument must be a non-empty string and must be one of this values: "any", "all" or Execution ID.'
7878
)
7979
}
8080

81-
const query = {}
82-
83-
switch (execution) {
84-
case 'activateAny':
85-
query.activateAny = true
86-
break
87-
case 'activateAll':
88-
query.activateAll = true
89-
break
90-
default:
91-
query.executionId = execution
92-
}
93-
9481
return this.app.request.post({
9582
url : `${this.app.urls.automationFlow()}/${flowId}/trigger/${triggerId}/activate`,
9683
data : data || {},
97-
query: query,
84+
query: { execution },
9885
})
9986
}
10087
}

test/unit/specs/automations/basic.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ describe('<Automations> Basic', function() {
99
const FLOW_NAME = 'FlowName'
1010
const FLOW_ID = 'FlowID'
1111
const EXECUTION_ID = 'ExecutionID'
12-
const EXECUTION_ANY = 'activateAny'
13-
const EXECUTION_ALL = 'activateAll'
12+
const EXECUTION_ANY = 'any'
13+
const EXECUTION_ALL = 'all'
1414
const TRIGGER_NAME = 'TriggerName'
1515
const TRIGGER_ID = 'TriggerID'
1616

@@ -227,23 +227,23 @@ describe('<Automations> Basic', function() {
227227

228228
expect(req3).to.deep.include({
229229
method: 'POST',
230-
path : `${APP_PATH}/automation/flow/${ FLOW_ID }/trigger/${ TRIGGER_ID }/activate?executionId=ExecutionID`,
230+
path : `${APP_PATH}/automation/flow/${ FLOW_ID }/trigger/${ TRIGGER_ID }/activate?execution=ExecutionID`,
231231
body : {
232232
name: 'Nick',
233233
}
234234
})
235235

236236
expect(req4).to.deep.include({
237237
method: 'POST',
238-
path : `${APP_PATH}/automation/flow/${ FLOW_ID }/trigger/${ TRIGGER_ID }/activate?activateAny=true`,
238+
path : `${APP_PATH}/automation/flow/${ FLOW_ID }/trigger/${ TRIGGER_ID }/activate?execution=any`,
239239
body : {
240240
name: 'Nick',
241241
}
242242
})
243243

244244
expect(req5).to.deep.include({
245245
method: 'POST',
246-
path : `${APP_PATH}/automation/flow/${ FLOW_ID }/trigger/${ TRIGGER_ID }/activate?activateAll=true`,
246+
path : `${APP_PATH}/automation/flow/${ FLOW_ID }/trigger/${ TRIGGER_ID }/activate?execution=all`,
247247
body : {
248248
name: 'Nick',
249249
}
@@ -299,7 +299,7 @@ describe('<Automations> Basic', function() {
299299

300300
it('fails when execution id is invalid', async () => {
301301
// eslint-disable-next-line
302-
const errorMsg = 'The "execution" argument must be a non-empty string and must be one of this values: "activateAny", "activateAll" or Execution ID.'
302+
const errorMsg = 'The "execution" argument must be a non-empty string and must be one of this values: "any", "all" or Execution ID.'
303303

304304
await expect(Backendless.Automations.activateFlowTriggerById(FLOW_ID, TRIGGER_ID, {}, null)).to.eventually.be.rejectedWith(errorMsg)
305305
await expect(Backendless.Automations.activateFlowTriggerById(FLOW_ID, TRIGGER_ID, {}, true)).to.eventually.be.rejectedWith(errorMsg)

0 commit comments

Comments
 (0)