sambarnes90 / node-mautic Goto Github PK
View Code? Open in Web Editor NEWNode.js wrapper for the Mautic API
License: GNU General Public License v3.0
Node.js wrapper for the Mautic API
License: GNU General Public License v3.0
Hi sambarnes90,
I am trying to use your wrapper for the Mautic API which works well so far. I am now having problems doing any POST request. I am trying to create a DynamicContent asset with the API but it does not work. It seems that I am creating the bodyParameters wrong.
I've created a stack overflow question for this (https://stackoverflow.com/questions/51320765/mautic-api-cannot-create-dynamiccontent) because I am quite sure, this is my mistake not understanding it.
It would help a lot if you could put an example for creating data (dynamic content, contacts, ...) in this repo.
Thanks!
Hey @sambarnes90
I've just finished a bit more up-to-date and more complete Node.js package for Mautic: https://github.com/vdavid/node-mautic
I've started from your code base (I did a bunch of replaces to reformat the API call functions) so I'd like to thank you for your work! Sorry for not forking the repo, I didn't originally intend to publish my package, I've created it for my company, but then I thought, why not, it might be helpful for others too.
If you think my package might help people, please consider recommending it in your README.md so that they have an easier time finding (and perhaps contributing to) it.
Thanks :)
David
Just posting these examples of other operations for contacts (search, create, update) here for others (and my future) reference ๐
var print_result = function (result) {
// Pretty print the JSON result
console.log(JSON.stringify(result, null, " "));
};
var test_get = function(config){
var contactId = 35944;
mautic.contacts.getContact(config,contactId,print_result);
}
var test_list = function(config){
// These search parameters seem not well documented... maybe dig more:
// https://github.com/mautic/mautic/issues?q=is%3Aissue+search+parameter
var email = "[email protected]";
mautic.contacts.listContacts(config,{ "search":"email:"+email },print_result);
// e.g. /api/contacts?search=firstname:Jeff
mautic.contacts.listContacts(config,{ "search":"firstname:Jeff" },print_result);
}
var test_create = function(config){
new_contact = {
'firstname':'Asdf',
'lastname':'Wxyz',
'email':'[email protected]',
'ipAddress':'127.0.0.1',
"some_custom_field":"foo"
};
mautic.contacts.createContact(config,new_contact,print_result);
};
var test_update = function(config)
{
var contactId = 35944;
mautic.contacts.editContact(config,"PATCH",{ email:"[email protected]" },contactId,print_result)
};
var test_update_by_email = function(config)
{
var email = "[email protected]";
mautic.contacts.listContacts(config,{ "search":"email:"+email },function(result) {
if (result && result.total=="1" && result.contacts) {
var contactId = Object.keys(result.contacts)[0];
mautic.contacts.editContact(config,"PATCH",{
"my_custom_string_field": "foo",
"my_custom_date_field": new Date("Jan 2, 2013").toISOString()
},contactId,print_result)
} else {
console.log('Lookup failed by email: '+email);
}
});
};
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.