Skip to content

Instantly share code, notes, and snippets.

@ZainWWF
Last active November 15, 2019 03:50
Show Gist options
  • Save ZainWWF/48485c316a82fb684463e77e6cf7ac07 to your computer and use it in GitHub Desktop.
Save ZainWWF/48485c316a82fb684463e77e6cf7ac07 to your computer and use it in GitHub Desktop.
cloud on Create function "assistance/{assistanceId}"
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