-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
bf5e9ce
commit ed7b416
Showing
7 changed files
with
169 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# Workflow Reply | ||
|
||
##### Reply Wrapper for [bull-workflow-manager](https://github.com/eoko/bull-workflow-manager) | ||
|
||
### Campaign | ||
|
||
* **Add** ($wf-reply/campaign/add) | ||
|
||
*Add people to one campaign* | ||
|
||
- Workflow data : | ||
- api_key (Reply API Key) | ||
- campaign_id (Id of Reply Campaign) | ||
- Post data : | ||
- email (Email of member) or reply_id (Id of Reply member) | ||
|
||
* **Remove** ($wf-reply/campaign/remove) | ||
|
||
*Remove people from one campaign* | ||
|
||
- Workflow data : | ||
- api_key (Reply API Key) | ||
- campaign_id (Id of Reply Campaign) | ||
- Post data : | ||
- email (Email of member) or reply_id (Id of Reply member) | ||
|
||
* **Remove All** ($wf-reply/campaign/removeAll) | ||
|
||
*Remove people from all campaign* | ||
|
||
- Workflow data : | ||
- api_key (Reply API Key) | ||
- Post data : | ||
- email (Email of member) or reply_id (Id of Reply member) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
const replyService = require('../../services/service'); | ||
|
||
module.exports = async(job) => { | ||
|
||
const { | ||
body, | ||
workflow: { | ||
data: wfData | ||
} | ||
} = job.data; | ||
|
||
if(!wfData || !wfData.api_key) { | ||
throw new Error('Missing data api_key'); | ||
} | ||
|
||
if(!wfData || !wfData.campaign_id) { | ||
throw new Error('Missing data campaign id'); | ||
} | ||
|
||
if(!body) { | ||
throw new Error('Missing body'); | ||
} | ||
|
||
let people = null; | ||
|
||
if (body.reply_id) { | ||
people = await replyService.api(wfData.api_key).send('GET', `/v1/people?id=${body.reply_id}`); | ||
} else if(body.email) { | ||
people = await replyService.api(wfData.api_key).send('GET', `/v1/people?email=${encodeURIComponent(body.email)}`); | ||
} else { | ||
throw new Error('Missing email or reply_id'); | ||
} | ||
|
||
job.progress(50); | ||
|
||
await replyService.api(wfData.api_key).send('POST', `/v1/actions/pushtocampaign`, { | ||
campaignId: parseInt(wfData.campaign_id, 10), | ||
email: people.email, | ||
}); | ||
|
||
job.progress(100); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
const replyService = require('../../services/service'); | ||
|
||
module.exports = async(job) => { | ||
|
||
const { | ||
body, | ||
workflow: { | ||
data: wfData | ||
} | ||
} = job.data; | ||
|
||
if(!wfData || !wfData.api_key) { | ||
throw new Error('Missing data api_key'); | ||
} | ||
|
||
if(!wfData || !wfData.campaign_id) { | ||
throw new Error('Missing data campaign id'); | ||
} | ||
|
||
if(!body) { | ||
throw new Error('Missing body'); | ||
} | ||
|
||
let people = null; | ||
|
||
if (body.reply_id) { | ||
people = await replyService.api(wfData.api_key).send('GET', `/v1/people?id=${body.reply_id}`); | ||
} else if(body.email) { | ||
people = await replyService.api(wfData.api_key).send('GET', `/v1/people?email=${encodeURIComponent(body.email)}`); | ||
} else { | ||
throw new Error('Missing email or reply_id'); | ||
} | ||
|
||
job.progress(50); | ||
|
||
await replyService.api(wfData.api_key).send('POST', `/v1/actions/removepersonfromcampaignbyid`, { | ||
campaignId: parseInt(wfData.campaign_id, 10), | ||
email: people.email, | ||
}); | ||
job.progress(100); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
const replyService = require('../../services/service'); | ||
|
||
module.exports = async(job) => { | ||
|
||
const { | ||
body, | ||
workflow: { | ||
data: wfData | ||
} | ||
} = job.data; | ||
|
||
if(!wfData || !wfData.api_key) { | ||
throw new Error('Missing data api_key'); | ||
} | ||
|
||
if(!body) { | ||
throw new Error('Missing body'); | ||
} | ||
|
||
let people = null; | ||
|
||
if (body.reply_id) { | ||
people = await replyService.api(wfData.api_key).send('GET', `/v1/people?id=${body.reply_id}`); | ||
} else if(body.email) { | ||
people = await replyService.api(wfData.api_key).send('GET', `/v1/people?email=${encodeURIComponent(body.email)}`); | ||
} else { | ||
throw new Error('Missing email or reply_id'); | ||
} | ||
|
||
job.progress(50); | ||
|
||
await replyService.api(wfData.api_key).send('POST', `/v1/actions/removepersonfromallcampaigns`, { | ||
email: people.email, | ||
}); | ||
job.progress(100); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
const replyService = require('../../services/service'); | ||
|
||
module.exports = async(job) => { | ||
|
||
job.progress(100); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters