Giter Site home page Giter Site logo

nodejs's Introduction

Agile CRM Node JS API

Agile CRM is a new breed CRM software with sales and marketing automation.

Table of contents

NPM Install

Requirements

API's details

1 Contact

2. Deal

3. Note

4. Task

5. Dynamic Filter

NPM Agile CRM Installation

  $ npm install agile_crm

Requirements

  1. Two files required agilecrm.js and test.js OR

  2. Setting Domain Name and API Key

Finding Domain name and API Key

In the above image, API Key is present at the "API & Analytics" tab at https://mycompany.agilecrm.com/#analytics-code.

    Domain Name : mycompany
    API Key     : myagilecrmapikey

So you have to update your

    var AgileCRMManager = require("./agilecrm.js");
    var obj = new AgileCRMManager("DOMAIN", "KEY", "EMAIL");
    var success = function (data) {
    console.log(data);
   	console.log("hello");
    };
    var error = function (data) {
    console.log(data);
      };

API's details

###1. Contact

1.1 To get a contact by email

  var AgileCRMManager = require("./agilecrm.js");
  var obj = new AgileCRMManager("DOMAIN", "KEY", "EMAIL");
  var success = function (data) {
    console.log(data);
	};
  var error = function (data) {
    console.log(data);
	};
	
obj.contactAPI.getContactByEmail('[email protected]', success, error);

1.2 To get a contact by contact ID

  var AgileCRMManager = require("./agilecrm.js");
  var obj = new AgileCRMManager("DOMAIN", "KEY", "EMAIL");
  var success = function (data) {
    console.log(data);
	};
  var error = function (data) {
    console.log(data);
	};
	
obj.contactAPI.getContactById('5736096881180672', success, error);

1.3 To create a contact

Acceptable request Representation:

{
    "star_value": "4",
    "lead_score": "92",
    "tags": [
        "Lead",
        "Likely Buyer"
    ],
    "properties": [
        {
            "type": "SYSTEM",
            "name": "first_name",
            "value": "Los "
        },
        {
            "type": "SYSTEM",
            "name": "last_name",
            "value": "Bruikheilmer"
        },
        {
            "type": "SYSTEM",
            "name": "company",
            "value": "steady.inc"
        },
        {
            "type": "SYSTEM",
            "name": "title",
            "value": "VP Sales"
        },
        {
            "type": "SYSTEM",
            "name": "email",
            "subtype": "work",
            "value": "[email protected]  "
        },
        {
            "type": "SYSTEM",
            "name": "address",
            "value": "{\"address\":\"225 George Street\",\"city\":\"NSW\",\"state\":\"Sydney\",\"zip\":\"2000\",\"country\":\"Australia\"}"
        },
        {
            "type": "CUSTOM",
            "name": "My Custom Field",
            "value": "Custom value"
        }
    ]
}
  var AgileCRMManager = require("./agilecrm.js");
  var obj = new AgileCRMManager("DOMAIN", "KEY", "EMAIL");
  var success = function (data) {
    console.log(data);
	};
  var error = function (data) {
    console.log(data);
	};
	
  var contact = {
    "lead_score": "92",
    "tags": [
        "Lead",
        "Likely Buyer"
    ],
    "properties": [
        {
            "type": "SYSTEM",
            "name": "first_name",
            "value": "Los "
        },
        {
            "type": "SYSTEM",
            "name": "email",
            "subtype": "work",
            "value": "[email protected]"
        },
        {
            "type": "SYSTEM",
            "name": "address",
            "value": "{\"address\":\"225 George Street\",\"city\":\"NSW\",\"state\":\"Sydney\",\"zip\":\"2000\",\"country\":\"Australia\"}"
        }
    ]
  };

obj.contactAPI.add(contact, success, error);

1.4 To update a contact

  var AgileCRMManager = require("./agilecrm.js");
  var obj = new AgileCRMManager("DOMAIN", "KEY", "EMAIL");
  var success = function (data) {
    console.log(data);
	};
  var error = function (data) {
    console.log(data);
	};
  var update_contact = {
    "id": "5698936018829312",
    "properties": [
        {
            "type": "SYSTEM",
            "name": "first_name",
            "value": "Losalitest"
        },
        {
            "type": "SYSTEM",
            "name": "last_name",
            "value": "Lee"
        }
    ]
};
obj.contactAPI.update(update_contact, success, error);

1.5 To delete a contact

  var AgileCRMManager = require("./agilecrm.js");
  var obj = new AgileCRMManager("DOMAIN", "KEY", "EMAIL");
  var success = function (data) {
    console.log(data);
	};
  var error = function (data) {
    console.log(data);
	};
	
  obj.contactAPI.deleteContact('5633009881448448', success, error);

1.6 To update tags to a contact

  var AgileCRMManager = require("./agilecrm.js");
  var obj = new AgileCRMManager("DOMAIN", "KEY", "EMAIL");
  var success = function (data) {
    console.log(data);
	};
  var error = function (data) {
    console.log(data);
	};
	
  var update_tags = {
    "id": "5671839405703168",
    "tags": [
        "test1",
        "test2"
    ]
};


obj.contactAPI.updateTagsById(update_tags, success, error);

1.7 To delete tags to a contact

  var AgileCRMManager = require("./agilecrm.js");
  var obj = new AgileCRMManager("DOMAIN", "KEY", "EMAIL");
  var success = function (data) {
    console.log(data);
	};
  var error = function (data) {
    console.log(data);
	};
	
  var delete_tags = {
    "id": "5671839405703168",
    "tags": [
        "test1"
    ]
};


obj.contactAPI.deleteTagsById(delete_tags, success, error);

1.8 Change owner of a contact

  var AgileCRMManager = require("./agilecrm.js");
  var obj = new AgileCRMManager("DOMAIN", "KEY", "EMAIL");
  var success = function (data) {
    console.log(data);
	};
  var error = function (data) {
    console.log(data);
	};
	
 obj.contactAPI.changeContactOwner('[email protected]','5650547373768704',success, error); 

###2. Deal

2.1 To get a deal by deal ID

  var AgileCRMManager = require("./agilecrm.js");
  var obj = new AgileCRMManager("DOMAIN", "KEY", "EMAIL");
  var success = function (data) {
    console.log(data);
	};
  var error = function (data) {
    console.log(data);
	};
	
obj.contactAPI.getDealById('5650703586426880', success, error);

2.2 To get deals by contact id

  var AgileCRMManager = require("./agilecrm.js");
  var obj = new AgileCRMManager("DOMAIN", "KEY", "EMAIL");
  var success = function (data) {
    console.log(data);
	};
  var error = function (data) {
    console.log(data);
	};
	
obj.contactAPI.getDealByContactId("5675392618725376", success, error);

2.3 To create a deal

Acceptable request Representation:

{
    "name": "Deal-Tomato",
    "expected_value": "500",
    "probability": "75",
    "close_date": 1455042600,
    "milestone": "Proposal",
    "contact_ids": [
        "5758948741218304"
    ],
    "custom_data": [
        {
            "name": "Group Size",
            "value": "10"
        }
    ]
}
  var AgileCRMManager = require("./agilecrm.js");
  var obj = new AgileCRMManager("DOMAIN", "KEY", "EMAIL");
  var success = function (data) {
    console.log(data);
	};
  var error = function (data) {
    console.log(data);
	};
	
  var deal = {
    "name": "Deal-Tomato",
    "expected_value": "500",
    "probability": "75",
    "close_date": 1455042600,
    "milestone": "Proposal",
    "contact_ids": [
        "5758948741218304"
    ],
    "custom_data": [
        {
            "name": "Group Size",
            "value": "10"
        }
    ]
};

obj.contactAPI.createDeal(deal, success, error);

2.4 To update a deal

  var AgileCRMManager = require("./agilecrm.js");
  var obj = new AgileCRMManager("DOMAIN", "KEY", "EMAIL");
  var success = function (data) {
    console.log(data);
	};
  var error = function (data) {
    console.log(data);
	};
	
  var update_deal = {
    "id": "5122047336251392",
    "expected_value": "1000",
    "contact_ids": [
        "5675392618725376",
        "5744178885558278"
    ],
    "custom_data": [
        {
            "name": "dealTester",
            "value": "hello hello2"
        }
    ]
};


obj.contactAPI.updateDeal(update_deal, success, error);

2.5 To delete a deal

  var AgileCRMManager = require("./agilecrm.js");
  var obj = new AgileCRMManager("DOMAIN", "KEY", "EMAIL");
  var success = function (data) {
    console.log(data);
	};
  var error = function (data) {
    console.log(data);
	};
	
  obj.contactAPI.deleteDealById('5650703586426880', success, error);

2.6 Get deal source

  var AgileCRMManager = require("./agilecrm.js");
  var obj = new AgileCRMManager("DOMAIN", "KEY", "EMAIL");
  var success = function (data) {
    console.log(data);
	};
  var error = function (data) {
    console.log(data);
	};
	
  obj.contactAPI.getDealSource(success, error);

###3. Note

3.1 Create a note to a contact

  var AgileCRMManager = require("./agilecrm.js");
  var obj = new AgileCRMManager("DOMAIN", "KEY", "EMAIL");
  var success = function (data) {
    console.log(data);
	};
  var error = function (data) {
    console.log(data);
	};
	
  var note = {
    "subject": " Note subject",
    "description": "Note description",
    "contact_ids": [
        "5688267051630592",
        "5721389839417344"
    ]
  };

  obj.contactAPI.createNote(note, success, error);

3.2 Update a note to a contact

  var AgileCRMManager = require("./agilecrm.js");
  var obj = new AgileCRMManager("DOMAIN", "KEY", "EMAIL");
  var success = function (data) {
    console.log(data);
	};
  var error = function (data) {
    console.log(data);
	};
	
  var update_note = {
    "id": "5754615706419200",
    "subject": "Test",
    "description": "Sample test updated1",
    "contact_ids": [
        "5630286201094144"
    ]
  };

  obj.contactAPI.updateNote(update_note, success, error);

3.3 Get note by contact ID

  var AgileCRMManager = require("./agilecrm.js");
  var obj = new AgileCRMManager("DOMAIN", "KEY", "EMAIL");
  var success = function (data) {
    console.log(data);
	};
  var error = function (data) {
    console.log(data);
	};
	
  obj.contactAPI.getNoteByContactId("5630286201094144", success, error);

3.4 Delete a note by contact ID and note ID

  • Delete a note from a contact
  • first parameter ID is contact and second one is note ID
  var AgileCRMManager = require("./agilecrm.js");
  var obj = new AgileCRMManager("DOMAIN", "KEY", "EMAIL");
  var success = function (data) {
    console.log(data);
	};
  var error = function (data) {
    console.log(data);
	};
	
  obj.contactAPI.deleteNoteById("5630286201094144","5754615706419200", success, error);

###4. Task

4.1 Create a task to a contact

  • Task type accepeted value : CALL, EMAIL, FOLLOW_UP, MEETING, MILESTONE, SEND, TWEET, OTHER
  • Task priority_type accepeted value : HIGH, NORMAL, LOW
  • Task due accepeted value : epoch time in miliseconds
  var AgileCRMManager = require("./agilecrm.js");
  var obj = new AgileCRMManager("DOMAIN", "KEY", "EMAIL");
  var success = function (data) {
    console.log(data);
	};
  var error = function (data) {
    console.log(data);
	};
	
  var task = {
    "subject": "test",
    "contacts": [
        "5630286201094144"
    ],
    "type": "EMAIL",
    "priority_type": "HIGH",
    "due": 11545245654
  };


  obj.contactAPI.createTask(task, success, error);

4.2 Create a task to a contact by email ID

  • Task type accepeted value : CALL, EMAIL, FOLLOW_UP, MEETING, MILESTONE, SEND, TWEET, OTHER
  • Task priority_type accepeted value : HIGH, NORMAL, LOW
  • Task due accepeted value : epoch time in miliseconds
  var AgileCRMManager = require("./agilecrm.js");
  var obj = new AgileCRMManager("DOMAIN", "KEY", "EMAIL");
  var success = function (data) {
    console.log(data);
	};
	
  var error = function (data) {
    console.log(data);
	};
	
  var task_email = {
    "subject": "test email task",
    "type": "EMAIL",
    "priority_type": "HIGH",
    "due": 11545245654
  };


  obj.contactAPI.createTaskByEmail("[email protected]",task_email, success, error);

4.3 Update a task to a contact

  • Task type accepeted value : CALL, EMAIL, FOLLOW_UP, MEETING, MILESTONE, SEND, TWEET, OTHER
  • Task priority_type accepeted value : HIGH, NORMAL, LOW
  • Task due accepeted value : epoch time in miliseconds
  var AgileCRMManager = require("./agilecrm.js");
  var obj = new AgileCRMManager("DOMAIN", "KEY", "EMAIL");
  var success = function (data) {
    console.log(data);
	};
	
  var error = function (data) {
    console.log(data);
	};
	
  var update_task = {
    "id": "5637588316585984",
    "subject": "test updated",
    "contacts": [
        "5630286201094144"
    ],
    "type": "EMAIL",
    "priority_type": "HIGH",
    "due": 11545245654
  };


  obj.contactAPI.updateTask(update_task, success, error);

4.4 Get a task by task ID

  var AgileCRMManager = require("./agilecrm.js");
  var obj = new AgileCRMManager("DOMAIN", "KEY", "EMAIL");
  var success = function (data) {
    console.log(data);
	};
	
  var error = function (data) {
    console.log(data);
	};
	
  obj.contactAPI.getTaskById('5766696644116480', success, error);

4.5 Delete a task by task ID

  var AgileCRMManager = require("./agilecrm.js");
  var obj = new AgileCRMManager("DOMAIN", "KEY", "EMAIL");
  var success = function (data) {
    console.log(data);
	};
	
  var error = function (data) {
    console.log(data);
	};
	
  obj.contactAPI.deleteTaskById('5766696644116480', success, error);

###5. Dynamic filter

5.1 Get contacts by property

  var AgileCRMManager = require("./agilecrm.js");
  var obj = new AgileCRMManager("DOMAIN", "KEY", "EMAIL");
  var success = function (data) {
    console.log(data);
	};
  var error = function (data) {
    console.log(data);
	};
	
  obj.contactAPI.getContactsByPropertyFilter('Country','United State',success, error);

5.2 Get contacts or companies by tag

  var AgileCRMManager = require("./agilecrm.js");
  var obj = new AgileCRMManager("DOMAIN", "KEY", "EMAIL");
  var success = function (data) {
    console.log(data);
	};
  var error = function (data) {
    console.log(data);
	};
	
  obj.contactAPI.getContactsByTagFilter('tester tag',success, error);

5.3 Get companies by property

  var AgileCRMManager = require("./agilecrm.js");
  var obj = new AgileCRMManager("DOMAIN", "KEY", "EMAIL");
  var success = function (data) {
    console.log(data);
	};
  var error = function (data) {
    console.log(data);
	};
	
  obj.contactAPI.getCompaniesByPropertyFilter('Custom Field Name','xyz120202',success, error);

nodejs's People

Contributors

graut avatar ranjanagilecrm avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

nodejs's Issues

make this library promise based?

Do you plan to make this library promise based anytime soon?

Things have changed a lot in nodejs world lately... callbacks are a thing of the past, promises are the present and now latest node versions support async/await out of the box (still promises but with a nice syntax)

Also, the way you handle callback is kind of "old school JS" (success and error callbacks instead of error first callbacks) so this lib cannot even be promisified the standard way

NO License Information

Can you please Update the README with your License Information? Without License Information your software can not be used in most companies.

HTTP400 on function getDealByContactId

if i call the function getDealByContactId, the function respond with following error:

Status Code = 400
SyntaxError: Unexpected token < in JSON at position 0
    at Object.parse (native)
    at IncomingMessage.<anonymous> (/Users/Tilman/Documents/Programme/NodeJS/async_test/node_modules/agile_crm/agilecrm.js:477:48)
    at emitNone (events.js:91:20)
    at IncomingMessage.emit (events.js:185:7)
    at endReadableNT (_stream_readable.js:926:12)
    at _combinedTickCallback (internal/process/next_tick.js:74:11)
    at process._tickCallback (internal/process/next_tick.js:98:9)

Status code 400 and following body (got it with debuging features) idicate, the API is calling the wrong api endpoint.

<html><head>
<meta http-equiv="content-type" content="text/html;charset=utf-8">
<title>400 Unable to extract parameter from http request: javax.ws.rs.PathParam("contact-id") value is '5137069722566656deals' for public com.agilecrm.contact.Contact com.agilecrm.core.api.contacts.ContactsAPI.getContact(java.lang.Long) throws com.agilecrm.user.access.exception.AccessDeniedException</title>
</head>
<body text=#000000 bgcolor=#ffffff>
<h1>Error: Unable to extract parameter from http request: javax.ws.rs.PathParam("contact-id") value is '5137069722566656deals' for public com.agilecrm.contact.Contact com.agilecrm.core.api.contacts.ContactsAPI.getContact(java.lang.Long) throws com.agilecrm.user.access.exception.AccessDeniedException</h1>
</body></html>

"deleteContact" returning error

Delete contact is returning an error, saying contact is not defined. This seems to be an issue with the library but it may be my implementation.'
agileAPI.contactAPI.deleteContact("5724499700416512", success, error);
agileAPI being the obj referenced in the docs. I can get data from agile and upload data but cannot delete any entries by id.

Status Code Spam

Hi,
Since the update of the 24th of October, my server logs are getting totally messed up because of the 'Status Code = XXX'. Could it be possible to be able to activate or not those log with a property on AgileCRM initialization ? And it would be nice to add some info to those console.log, it doesn't give any information on which request / function / process has been done.

Thanks

Missing error handling code

I'm having a lot of difficulty with connect ETIMEDOUT and agilecrm server but that's not the issue here. I was experiencing some of them while using the contact update method. Digging into your code, I found that some error handling code is missing for a lot of methods
.add()
.update()
.deleteContact()
(and 20 more)
Please consider adding this piece of code like you did for .getContactById()

/*https request*/
.on("error", function(e){
        if (failure) {
            failure(e);
        }
    });

Thx

page_size parameter

I am creating an app in freshdeveloper to comunicate it with Agile CRM, is already done but I have a limit to show the notes to only 10 results. I noted that if I modify agilecrm.js and add notes?page_size=1000 in the options.path inside ContactAPI.prototype.getNoteByContactId it shows every note. But when the app is compiled it install the original agilecrm.js

It is posible to set page_size outside agilecrm.js?

getContactByEmail throws exception if no contact found

If no contact is found the response body is an empty string. The code attempts to parse this as JSON and throws an exception. This implies that the code has failed but an empty response is a valid response as there may well be no contact in the database with a specific email address.

Proposal is to check the body and if the body is an empty string return undefined.

Problem on duplicate contact

In ContactAPI.prototype.add function when I try to create a new contact,

It returns "Sorry, duplicate contact found with the same email address." with a success response. Then it tries to parse it
var contacts = JSON.parse(body);

gets an exception and it says "Unexpected token S" and cant see real error.

Fork with fixes

Hi All,

I've created a fork https://github.com/pnmcosta/agile_crm with some things addresses:

  • Proper error handling
  • Clean up and tidy

You can replace the npm package with the fork, if you

npm install pnmcosta/agile_crm

Or change your package dependency to:

  "dependencies": {
    "agile_crm": "github:pnmcosta/agile_crm"
  }

To AgileCRM, feel free to use my changes on your package.

Cheers,
P.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.