Last active
November 15, 2019 03:50
-
-
Save ZainWWF/48485c316a82fb684463e77e6cf7ac07 to your computer and use it in GitHub Desktop.
cloud on Create function "assistance/{assistanceId}"
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
export default functions.region("asia-east2").firestore | |
.document('assistance/{assistanceId}').onCreate(async (snap, context) => { | |
try { | |
const assistanceRef = 'assistance/' + context.params.assistanceId | |
await admin.firestore().doc(assistanceRef) | |
.update({ | |
createdAt: admin.firestore.Timestamp.fromMillis(Date.now()), | |
isResolved: false | |
}) | |
//create a POST request to ZOHO desk | |
//payload for now is { comment, type, userId } | |
return | |
} catch (error) { | |
return "Error: " + error | |
} | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment