rdstation-node-client
Version:
Client wrapper for Node.js integration with RDStation.
141 lines (106 loc) • 3.73 kB
Markdown
> Client wrapper for Node.js integration with RDStation.
```sh
$ npm install --save rdstation-node-client
```
**First, initialize the resource**
Currently, there are `Services` , `Conversions` and Leads modules.
```
var rdclient = require('rdstation-node-client');
var services = new rdclient.Services('your_private_token');
var conversions = new rdclient.Conversions('your_token');
var leads = new rdclient.Leads('your_private_token');
```
**Set a deal as won**
```js
var value = 120.00;
var email = 'email@example.com';
services.dealWon(value, email)
.then(function (data) {
console.log('Request done ', data);
})
.catch(function (err) {
console.error(err);
});
```
**Set a deal as lost**
```js
var reason = 'Customer chose competitor product';
var leadId = 9999;
services.dealLost(reason, null, leadId)
.then(function (data) {
console.log('Request done ', data);
})
.catch(function (err) {
console.error(err);
});
```
**Create a new conversion**
```js
var identifier = 'action-name';
conversions.createConversion('action-name', {
email: 'email@example.com',
nome: 'Lead name',
}).then(function (data) {
console.log('Request done ', data);
})
.catch(function (err) {
console.error(err);
});
```
**Change a lead stage to Lead**
```js
var email = 'email@example.com';
var opportunity = false;
leads.changeStatusToLead(email, opportunity).then(function (data) {
console.log('Request done ', data);
})
.catch(function (err) {
console.error(err);
});
```
**Change a lead stage to Lead Qualified**
```js
var email = 'email@example.com';
var opportunity = false;
leads.changeStatusToQualified(email, opportunity).then(function (data) {
console.log('Request done ', data);
})
.catch(function (err) {
console.error(err);
});
```
**Change a lead stage to Client**
```js
var email = 'email@example.com';
var opportunity = false;
leads.changeStatusToClient(email, opportunity).then(function (data) {
console.log('Request done ', data);
})
.catch(function (err) {
console.error(err);
});
```
Currently, this wrapper helps to:
1. Make the request "Close a deal and mark a deal as lost" described in [this article][rd-api-help-deal].
2. Make the request to create a new conversion as described in [this article][rd-api-help-conversion].
3. Make the request to change a lead stage described in [this article][rd-api-help-change].
There are few more possible actions with RD Station API [as described here][rd-api-help-all].
MIT © [Agendor](https://www.agendor.com.br/)
[]: https://npmjs.org/package/rdstation-node-client
[]: https://badge.fury.io/js/rdstation-node-client.svg
[]: https://travis-ci.org/agendor/rdstation-node-client
[]: https://travis-ci.org/agendor/rdstation-node-client.svg?branch=master
[]: https://david-dm.org/agendor/rdstation-node-client.svg?theme=shields.io
[]: https://david-dm.org/agendor/rdstation-node-client
[]: http://ajuda.rdstation.com.br/hc/pt-br/articles/202640385-Marcar-venda-e-lost-via-formul%C3%A1rio-pr%C3%B3prio-ou-sistema-API-
[]: http://ajuda.rdstation.com.br/hc/pt-br/categories/200086659-Integra%C3%A7%C3%B5es
[]: http://ajuda.rdstation.com.br/hc/pt-br/articles/200310589
[]: http://ajuda.rdstation.com.br/hc/pt-br/articles/200310699--Alterar-est%C3%A1gio-do-Lead-no-funil-do-RD-Station-API-