Created
November 17, 2019 17:40
-
-
Save gastsail/4fbb2639634eb5f66dcc1b089b290379 to your computer and use it in GitHub Desktop.
script
This file contains hidden or 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
exports.onItemCreation = functions.firestore.document('purchases/{purchaseId}') | |
.onCreate(async(snapshot, context) => { | |
const itemDataSnap = await snapshot.ref.get() | |
return admin.firestore().collection('mail').add({ | |
to: [itemDataSnap.data().email], | |
message: { | |
subject: 'Your reservation is here !', | |
html: 'Hey '+ itemDataSnap.data().name +'. This is your reservation for the event and it costs $' + itemDataSnap.data().dollarqty +', thanks for the purchase.', | |
} | |
}).then(() => console.log('Queued email for delivery!')); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment