agilecrm / nodejs

82 stars 81 forks source link

lacks a method to update lead score #15

Closed nikunjve closed 5 years ago

nikunjve commented 6 years ago

Please add a method to update lead score. Other methods don't work for it.

priyankinfinnov commented 6 years ago

+1 Needed.

agilecrm commented 5 years ago

This will be taken up

rammohan-agile commented 5 years ago

Hi @nikunjve , @priyankinfinnov Thanks for using AGILE CRM , Please use below function to update Lead score This will solve your problem

// update lead score

ContactAPI.prototype.update_lead = function update_lead(contact, success, failure) { var options = this.getOptions(); options.path = '/dev/api/contacts/edit/lead-score'; options.method = 'PUT'; options.headers['Content-Type'] = 'application/json';

var put = https.request(options, function(resp) {
    resp.setEncoding('utf8');
    var body = "";
    resp.on('data', function(data) {
        body += data;
    });
    resp.on('end', function() {
        if (success) {
            try {
                console.log("Status Code = " + resp.statusCode);
                var statusCode = resp.statusCode;
                if (statusCode != 200){
                    console.log("Error message = " + body);
                }
                try {
                    var contacts = JSON.parse(body);
                    success(contacts);
                } catch (e) {
                        return body;
                }
            } catch (ex) {
                failure(ex);
            }
        }
    });
    resp.on('error', function(e) {
        if (failure) {
            failure(e);
        }
    });
});
try {
    var data = JSON.stringify(contact);
    put.write(data);
    put.end();
} catch (ex) {
    failure(ex);
}

}; Hope This will Help You , In case you need more information regarding Agile CRM REST API please check below main reference :

https://github.com/agilecrm/rest-api

Thanks, Agile crm support team.

priyankinfinnov commented 5 years ago

Really appreciate your fast action. Just in 1.5 years! Thanks Again.