Map Calendly bookings to Crmble cards
function mapCalendlyBookingsToCrmbleCards(notification) | |
{ | |
var added = new Notification(notification).addedCard("Calendly Bookings"); | |
var booked_email = extractEmailFromCalendlyBooking(added); | |
var target_plugin = null; | |
new IterableCollection(TrelloApi.get("boards/"+this.notif.board().id()+"/plugins?filter=enabled")).each(function(loop) | |
{ | |
if(loop.name == "Crmble") | |
{ | |
target_plugin = loop.id; | |
} | |
}.bind(this)); | |
if(target_plugin) | |
{ | |
added.board().cards().each(function(card) | |
{ | |
if(fetchContactEmailFromCrmbleCard(target_plugin,card) == booked_email) | |
{ | |
card | |
//Set the contact card due to the booking time | |
.setDue(extractDateAndTimeFromCalendlyBooking(added)) | |
//and move to the top of the Meeting Booked list | |
.moveTo("Meeting Booked","top").archive(); | |
} | |
}); | |
} | |
} | |
function fetchContactEmailFromCrmbleCard(target_plugin,card) | |
{ | |
var email = null; | |
new IterableCollection(TrelloApi.get("cards/"+card.id()+"/pluginData")).each(function(plugin) | |
{ | |
if(plugin.idPlugin == target_plugin) | |
{ | |
try | |
{ | |
var contact = JSON.parse(plugin.value).contact; | |
var first = contact.firstName; | |
var last = contact.lastName; | |
var email = contact.email; | |
var phone = contact.phone; | |
} | |
catch(e) | |
{ | |
} | |
} | |
}); | |
return email; | |
} | |
function extractEmailFromCalendlyBooking(card) | |
{ | |
//IMPLEMENT ME! | |
//Need to look at specific format of emails | |
//as they arrive in Trello via BenkoBoard | |
} | |
function extractDateAndTimeFromCalendlyBooking(card) | |
{ | |
//IMPLEMENT ME! | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment