diff --git a/backendless.d.ts b/backendless.d.ts index a7463b49..d58c7cd1 100644 --- a/backendless.d.ts +++ b/backendless.d.ts @@ -612,7 +612,7 @@ declare module Backendless { * @type: Function */ - type Execution = 'activateAny' | 'activateAll' | string + type Execution = 'any' | 'all' | string function activateFlow(flowName: string, initialData?: object): Promise function activateFlowById(flowId: string, initialData?: object): Promise diff --git a/src/automations/index.js b/src/automations/index.js index 6437dff8..6aecccfb 100644 --- a/src/automations/index.js +++ b/src/automations/index.js @@ -74,27 +74,14 @@ export default class Automations { if (execution !== undefined && (typeof execution !== 'string' || !execution)) { throw new Error( // eslint-disable-next-line - 'The "execution" argument must be a non-empty string and must be one of this values: "activateAny", "activateAll" or Execution ID.' + 'The "execution" argument must be a non-empty string and must be one of this values: "any", "all" or Execution ID.' ) } - const query = {} - - switch (execution) { - case 'activateAny': - query.activateAny = true - break - case 'activateAll': - query.activateAll = true - break - default: - query.executionId = execution - } - return this.app.request.post({ url : `${this.app.urls.automationFlow()}/${flowId}/trigger/${triggerId}/activate`, data : data || {}, - query: query, + query: { execution }, }) } } diff --git a/test/unit/specs/automations/basic.js b/test/unit/specs/automations/basic.js index cb05d039..c160d922 100644 --- a/test/unit/specs/automations/basic.js +++ b/test/unit/specs/automations/basic.js @@ -9,8 +9,8 @@ describe(' Basic', function() { const FLOW_NAME = 'FlowName' const FLOW_ID = 'FlowID' const EXECUTION_ID = 'ExecutionID' - const EXECUTION_ANY = 'activateAny' - const EXECUTION_ALL = 'activateAll' + const EXECUTION_ANY = 'any' + const EXECUTION_ALL = 'all' const TRIGGER_NAME = 'TriggerName' const TRIGGER_ID = 'TriggerID' @@ -227,7 +227,7 @@ describe(' Basic', function() { expect(req3).to.deep.include({ method: 'POST', - path : `${APP_PATH}/automation/flow/${ FLOW_ID }/trigger/${ TRIGGER_ID }/activate?executionId=ExecutionID`, + path : `${APP_PATH}/automation/flow/${ FLOW_ID }/trigger/${ TRIGGER_ID }/activate?execution=ExecutionID`, body : { name: 'Nick', } @@ -235,7 +235,7 @@ describe(' Basic', function() { expect(req4).to.deep.include({ method: 'POST', - path : `${APP_PATH}/automation/flow/${ FLOW_ID }/trigger/${ TRIGGER_ID }/activate?activateAny=true`, + path : `${APP_PATH}/automation/flow/${ FLOW_ID }/trigger/${ TRIGGER_ID }/activate?execution=any`, body : { name: 'Nick', } @@ -243,7 +243,7 @@ describe(' Basic', function() { expect(req5).to.deep.include({ method: 'POST', - path : `${APP_PATH}/automation/flow/${ FLOW_ID }/trigger/${ TRIGGER_ID }/activate?activateAll=true`, + path : `${APP_PATH}/automation/flow/${ FLOW_ID }/trigger/${ TRIGGER_ID }/activate?execution=all`, body : { name: 'Nick', } @@ -299,7 +299,7 @@ describe(' Basic', function() { it('fails when execution id is invalid', async () => { // eslint-disable-next-line - const errorMsg = 'The "execution" argument must be a non-empty string and must be one of this values: "activateAny", "activateAll" or Execution ID.' + const errorMsg = 'The "execution" argument must be a non-empty string and must be one of this values: "any", "all" or Execution ID.' await expect(Backendless.Automations.activateFlowTriggerById(FLOW_ID, TRIGGER_ID, {}, null)).to.eventually.be.rejectedWith(errorMsg) await expect(Backendless.Automations.activateFlowTriggerById(FLOW_ID, TRIGGER_ID, {}, true)).to.eventually.be.rejectedWith(errorMsg)