Skip to content

Instantly share code, notes, and snippets.

@typerory
Created April 3, 2018 21:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save typerory/9a271b3daa15a1e73011215c38b9f2be to your computer and use it in GitHub Desktop.
Save typerory/9a271b3daa15a1e73011215c38b9f2be to your computer and use it in GitHub Desktop.
Pull from Zoho Inventory products to Firestore
exports.updateItems = functions.database.ref('/update').onUpdate(event => {
return superagent
.get(zohoItemsRef + 'items?' + zohoToken + zohoOrg)
.query({
authtoken: zohoToken,
organization_id: zohoOrg
})
.set('cache-control', 'no-cache')
.then(res => {
res.body.items.forEach(function(item) {
if (item.status === 'active') {
var itemData = {
name: item.name,
description: item.description,
price: item.rate,
category: item.cf_product_category,
src: item.cf_src,
manufacturer: item.cf_iotymanufacturer,
model: item.cf_iotymodel,
createdTime: item.created_time,
lastModifiedTime: item.last_modified_time
}
if (item.cf_quick_pick) {
itemData.quickMenu = item.cf_quick_pick
}
if (item.cf_size) {
itemData.size = item.cf_size
}
itemRef.doc(item.item_id).set(itemData)
}
})
return
})
.catch(e => {
console.log(e)
return
})
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment