Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions agilecrm/agilecrm.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down