-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #497 from hopetambala/PLATFORM-583_2
PLATFORM-583: New signup process on puente-manage
- Loading branch information
Showing
9 changed files
with
30,392 additions
and
7,479 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 |
---|---|---|
@@ -1,4 +1,6 @@ | ||
PARSE_ENV=dev | ||
PARSE_APP_ID="myAppId" | ||
PARSE_JAVASCRIPT_KEY=_PLACEHOLDER_ | ||
PARSE_SERVER_URL="http://localhost:1337/parse" | ||
PARSE_SERVER_URL="http://localhost:1337/parse" | ||
PUENTE_SMS_EMAIL_API_URL=http://puentes-messaging-microservice.com | ||
PUENTE_MANAGE_URL=https://sample-puente-manage.app/" |
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 |
---|---|---|
|
@@ -22,6 +22,9 @@ describe('role testing', () => { | |
password: 'dracarys', | ||
email: '[email protected]', | ||
organization: 'got', | ||
restParams: { | ||
runMessaging: false, | ||
}, | ||
}; | ||
return cloudFunctions.signup(credentials).then((result) => { | ||
const jsonString = JSON.stringify(result); | ||
|
@@ -59,6 +62,10 @@ describe('role testing', () => { | |
email: '[email protected]', | ||
organization: 'got', | ||
phonenumber: 1234567890, | ||
restParams: { | ||
runMessaging: false, | ||
path: 'email', | ||
}, | ||
}; | ||
return cloudFunctions.signup(credentials).then((result) => { | ||
const jsonString = JSON.stringify(result); | ||
|
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 |
---|---|---|
|
@@ -70,6 +70,10 @@ describe('role testing', () => { | |
password: 'leia', | ||
email: '[email protected]', | ||
organization: 'star-wars', | ||
restParams: { | ||
runMessaging: false, | ||
path: 'email', | ||
}, | ||
}; | ||
return cloudFunctions.signup(credentials).then((result) => { | ||
const jsonString = JSON.stringify(result); | ||
|
@@ -94,6 +98,10 @@ describe('role testing', () => { | |
email: '[email protected]', | ||
organization: 'star-wars', | ||
phonenumber: '1234567373', | ||
restParams: { | ||
runMessaging: false, | ||
path: 'email', | ||
}, | ||
}; | ||
return cloudFunctions.signup(credentials).then((result) => { | ||
const jsonString = JSON.stringify(result); | ||
|
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 |
---|---|---|
|
@@ -171,6 +171,5 @@ const Batch = { | |
}); | ||
}, | ||
}; | ||
// export default batch; | ||
|
||
module.exports = Batch; |
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,80 @@ | ||
const axios = require('axios').default; | ||
|
||
const { PUENTE_SMS_EMAIL_API_URL: url } = process.env; | ||
|
||
|
||
/** | ||
* Too tightly coupled with just signup and password reset | ||
*/ | ||
|
||
async function sendEmail(apiURL, restParamsData, parseObject) { | ||
const { emailSubject, type } = restParamsData; | ||
const { email: emailAddress, objectId, firstname } = parseObject; | ||
|
||
const payload = { | ||
emailSubject, | ||
objectId, | ||
userFullName: firstname, | ||
emailsToSendTo: [ | ||
emailAddress, | ||
], | ||
type, // signup, passwordReset,default | ||
}; | ||
|
||
return axios.post(`${apiURL}/email`, payload); | ||
} | ||
|
||
async function sendText(apiURL, restParamsData, parseObject) { | ||
const { textTo: phoneNumber, type } = restParamsData; | ||
const { objectId, firstname } = parseObject; | ||
|
||
let textBody = ''; | ||
|
||
if (type === 'signup') textBody = `Hello ${firstname}! Verify your Puente account at\nhttps://puente-manage.vercel.app/account/verify?objectId=${objectId}`; | ||
if (type === 'passwordReset') textBody = `Hello ${firstname}! Reset your Puente password at\nhttps://puente-manage.vercel.app/account/reset?objectId=${objectId}`; | ||
|
||
const payload = { | ||
textTo: phoneNumber, | ||
textBody, | ||
}; | ||
|
||
return axios.post(`${apiURL}/text`, payload); | ||
} | ||
|
||
|
||
const Messaging = { | ||
/** | ||
* Performs a query based on the parameter defined in a column | ||
* | ||
* @example | ||
* sendMessage( | ||
* 'text', | ||
* { | ||
* "textTo": "1234567", | ||
* "textBody": "Text" | ||
* } | ||
* ) | ||
* | ||
* @param {string} path which endpoint to hit | ||
* @param {string} restParamData Data consisting of which | ||
* @returns Results of Query | ||
*/ | ||
sendMessage: async function sendMessage(restParams, parseObject) { | ||
const { | ||
runMessaging, | ||
path, | ||
data, | ||
} = restParams; | ||
|
||
if (!runMessaging) return null; | ||
|
||
try { | ||
const response = path === 'email' ? await sendEmail(url, data, parseObject) : await sendText(url, data, parseObject); | ||
return response; | ||
} catch (e) { | ||
return e; | ||
} | ||
}, | ||
}; | ||
|
||
module.exports = Messaging; |
Oops, something went wrong.