Giter VIP home page Giter VIP logo

node-mautic's Introduction

!!! Project No Longer Maintined !!!


Node.js Wrapper for Mautic API

Mautic Logo

Alpha version of a basic wrapper to use the Mautic API in Node.js.

Usage

  • npm install mautic-api-node
  • Require the module with var mautic = require('mautic-api-node')
  • Update the mautic.config object with relevant details as per below:
    mautic.config.base_url = "https://example.mautic.com";
    mautic.config.redirect_uri = "https://www.mautic.com";
    mautic.config.public_key = "EXAMPLE_PUBLIC_KEY";
    mautic.config.secret_key = "EXAMPLE_SECRET_KEY";
    mautic.config.state = "RANDOM_STATE";
    mautic.config.api_endpoint = "https://example.mautic.com/api";
  • Use mautic.auth.checkAuth(callback) to check auth and process the data with callback.
  • You must run this from the command line first, perhaps using example.js - as this will create the token file needed to authenticate with the Mautic API.
  • Callback will either receive a single parameter from these options:
    • An asset object containing the JSON response from the API.
    • An error string containing a relevant error message.
    • An error object from the request itself.

Examples

  • Please reference example.js for an example.

Support

Reference

node-mautic's People

Contributors

sambarnes90 avatar

Stargazers

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

Watchers

 avatar  avatar

node-mautic's Issues

Example for Post Request

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!

More samples - example.js only has a simple get contact by id

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);
    }
  });
};

Another package that might interest you

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

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.