From 4c29951763598de237a04bf802f4445bf4d942ca Mon Sep 17 00:00:00 2001 From: Nadir Hamid Date: Mon, 17 Jun 2019 10:46:12 -0600 Subject: [PATCH 1/2] add phone number lookup for contact add phone number lookup by contact --- agilecrm/agilecrm.js | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/agilecrm/agilecrm.js b/agilecrm/agilecrm.js index f8b3fde..0cfff75 100644 --- a/agilecrm/agilecrm.js +++ b/agilecrm/agilecrm.js @@ -17,7 +17,7 @@ AgileCRMManager.prototype.key = null; AgileCRMManager.prototype.email = null; AgileCRMManager.prototype.contactAPI = null; - +sea function ContactAPI(domain, key, email) { this.domain = domain; this.key = key; @@ -144,6 +144,39 @@ ContactAPI.prototype.getContactByEmail = function getContactByEmail(email, succe }); }; +ContactAPI.prototype.getContactByPhoneNumber = function getContactByPhoneNumber(number, success, failure) { + var options = this.getOptions(); + options.path = '/dev/api/contacts/search/phonenumber/' + number; + + https.get(options, function (resp) { + var body = ""; + resp.on('data', function(data) { + body += data; + }); + resp.on('end', function() { + if (success) { + try { + console.log("Status Code = " + resp.statusCode); + console.log("reply is ", body); + var contacts = JSON.parse(body); + success(contacts, resp.statusCode); + } catch (ex) { + success([], resp.statusCode); + } + } + }); + resp.on('error', function(e) { + if (failure) { + failure(e); + } + }); + }).on("error", function(e) { + if (failure) { + failure(e); + } + }); +}; + ContactAPI.prototype.add = function add(contact, success, failure) { var options = this.getOptions(); options.path = '/dev/api/contacts'; From 49d1fe12de151a93396dd6adb125258ddd3389e1 Mon Sep 17 00:00:00 2001 From: Nadir Hamid Date: Mon, 17 Jun 2019 10:48:04 -0600 Subject: [PATCH 2/2] remove characters from editing remove characters from editing --- agilecrm/agilecrm.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/agilecrm/agilecrm.js b/agilecrm/agilecrm.js index 0cfff75..97cb81e 100644 --- a/agilecrm/agilecrm.js +++ b/agilecrm/agilecrm.js @@ -17,7 +17,7 @@ AgileCRMManager.prototype.key = null; AgileCRMManager.prototype.email = null; AgileCRMManager.prototype.contactAPI = null; -sea + function ContactAPI(domain, key, email) { this.domain = domain; this.key = key;