npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

netdeal-node-js-sdk

v1.1.0

Published

Backend Node.js SDK that allows you to integrate your Users with Netdeal Services - http://www.netdeal.com.br

Downloads

4

Readme

Netdeal Node.js SDK

Backend Node.js SDK that allows you to integrate your Users with Netdeal Services. You can use this SDK with Serverless Functions too (AWS Lambda for example). That was the main reason why javascript was chosen to write this SDK.

Installation

npm i netdeal-node-js-sdk

How to use

Configuration

First, you need to import the SDK and configure the app id and secret pass - provided by Netdeal:

const Netdeal = require('netdeal-node-js-sdk');
    
Netdeal.Configuration.appId = 'app-id-value';
Netdeal.Configuration.secretPass = 'secret-pass-value';

This SDK provides an integration cache layer that saves a lot of network requests for you. Learn more about the Cache Layer:

Netdeal.Configuration.enableTheCache(
  Netdeal.Configuration.cache.supportedMethods.REDIS, // Currently only Redis is supported 
  'my-redis-server-endpoint',
  'my-redis-server-endpoint-port',
)

Integrating Entities

This SDK works with Entities Collections, to facilitate the integration of one or many users at the same time. Note that 1000 is the maximum supported amount of entities integrated with one integration call.

Note that you have two ways to populate the user data and that exists two different Entities objects (you can integrate your Users and/or your Leads). Learn more about the Netdeal Integration API:

// Populating the Lead1 data
const Lead1 = new Netdeal.Lead();
Lead1.email = "[email protected]";
Lead1.consumerId = "SOMETHING:asdfasdfasdf";
Lead1.cluster = ["politics", "economy"];
  
// Populating the User1 data
const User1 = new Netdeal.Consumer();
User1.id = 1;
User1.name = "User1";
User1.email = "[email protected]";
User1.cellphone = "+5541987541";
  
// Populating the User2 data
const User2 = new Netdeal.Consumer();
User2.properties = {
  "id": 2,
  "name": "User2",
  "email": "[email protected]",
  "identifier": null,
  "cellphone": "4198741244",
  "birthday": null,
  "photo": null,
  "subscriber": true,
  "created_at": "2018-02-05T14:28:05+00:00",
  "purchases": [
    {
      "id": 1234,
      "consumer_id": 2,
      "created_at": "2017-07-18T13:48:37+00:00"
    },
    {
      "id": 9874,
      "consumer_id": 2,
      "created_at": "2017-07-19T14:42:21+00:00"
    }
  ]
};

Once you have configured your entities (may you can use a loop, or a map function when integrating many users), you can populate the entities collection and call the Netdeal.integrate() method to finalize the integration:

// The entities collections that will be integrated with Netdeal
const collection = Netdeal.createEntitiesCollection();
collection.add(Lead1);
collection.addMany([User1, User2]);
  
// Integrating entities with Netdeal
(async () => {
  const response = await Netdeal.integrate(collection);
  console.log('response');
  console.log(response);
})();

How the Cache Layer works

Once enabled the cache system creates a hash for each of your users integrated with Netdeal. Therefore, if you try to resent an already integrated user that don't have any changes in him attributes the SDK don't will call the Netdeal Integration API, avoiding the integration request.

Once existing a minimal changing in any user attribute the current hash don't will match the cached hash and the Netdeal Integration API will be called and the hash updated for this user.

The SDK caches the Netdeal Access Token to avoid a new request to the Netdeal Authentication API before 30 minutes. In other words, the Access Token has a TTL of 30 minutes.

Community Support

If you need help with this bundle please consider open a question on StackOverflow using the netdeal tag, it is the official support platform for this bundle.

Github Issues are dedicated to bug reports and feature requests.

Contributing

You can contribute to this project cloning this repository and in your clone, you just need to create a new branch using a name related to the new functionality which you'll create.
When you finish your work, you just need to create a pull request which will be revised, merged to master branch (if the code doesn't break the project) and published as a new release.