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

@emarketflows/javascript-sdk

v1.0.6

Published

Javascript SDK client to manage eMarketFlows API and services.

Downloads

466

Readme

eMarket Flows - JavaScript SDK

Table of Contents

Why use this SDK?

This package permits use official eMarketFlows API services in easy steps.

Install

  1. Run this command in your project folder:
    npm i @emarketflows/javascript-sdk
  2. To use this SDK you need an account, you can create one here.
  3. Access your account here and create new client credentials.

Authentication

Authenticate client session with your client identifier and Secret:

/* Import eMarketFlows SDK client */
const client = require('@emarketflows/javascript-sdk');

/** 
* Initialize the eMarketFlows API client
* Is not necessary export it. This SDK set token in cache
* and get this when is neccesary and refresh.
**/
const emfClient = new client({
  AUTH2_CLIENT_ID: YOUR_CLIENT_ID,
  AUTH2_CLIENT_SECRET: YOUR_CLIENT_SECRET,
  AUTH2_CLIENT_SCOPES: YOUR_CLIENT_SCOPES
});

/**
 * Authenticate the client
 * 
 * After install module and autheticate client with your credential, 
 * this package create cache space where sets your temporal client token
 * and refresh it when is necessary.
 * */
emfClient.authenticate();

Consume resources

One of principal uses of eMarketFlows SDK is be a developer interface to code fastly integrations.

/* Import eMarketFlows SDK client */
const { v1: EmfClient } = require('@emarketflows/javascript-sdk');

/* Example 1. Access to push notifications service and list last five notifications. */
const notifications = await EmfClient.notifications.push.list({limit: 5});

/* Example 2. Access to customers service and list last ten customers. */
const customers = await EmfClient.contacts.customers.list({limit: 10});

[CRUD] Methods reference

After install and authenticate your eMarket Flows client:

GET

/* Import eMarketFlows SDK client */
const { v1: EmfClient } = require('@emarketflows/javascript-sdk');

/* Get customer by customer unique identifier */
const customer = await EmfClient.contacts.customers.get(CUSTOMER_ID);

LIST

/* Import eMarketFlows SDK client */
const { v1: EmfClient } = require('@emarketflows/javascript-sdk');

/* List customers with limit */
const customers = await EmfClient.contacts.customers.list({limit: 5});

ADD

/* Import eMarketFlows SDK client */
const { v1: EmfClient } = require('@emarketflows/javascript-sdk');

/* Add customer */
const customer = await EmfClient.contacts.customers.add({
  firstName: "John",
  lastName: "Doe",
  email: "[email protected]"
});

UPDATE

/* Import eMarketFlows SDK client */
const { v1: EmfClient } = require('@emarketflows/javascript-sdk');

/* Update customer */
const customer = await EmfClient.contacts.customers.update({
  id: "CUSTOMER_ID",
  firstName: "Joana",
  lastName: "Doe",
  email: "[email protected]"
});

REMOVE

/* Import eMarketFlows SDK client */
const { v1: EmfClient } = require('@emarketflows/javascript-sdk');

/* Remove customer */
const customer = await EmfClient.contacts.customers.remove(CUSTOMER_ID);

Resources reference

| Service | Resource | DESCRIPTION | LIST | GET | POST | PUT | DELETE | | -------- | ------- | ------- | ------- | ------- | ------- | ------- | ------- | | notifications | push | Push notifications | ✅ | ✅ | ✅ | ✅ | ✅ | | | email | E-mail notifications | ✅ | ✅ | ✅ | ✅ | ✅ | | oauth2 | organizations | Organizations | ✅ | ✅ | ✅ | ✅ | ❌ | | | clients | Account Auth2.0 clients | ✅ | ✅ | ✅ | ✅ | ✅ | | | members | Organization members | ✅ | ✅ | ✅ | ✅ | ✅ | | billing | products | Orgnization products | ✅ | ✅ | ✅ | ✅ | ✅ | | | catalogues | Product catalogues | ✅ | ✅ | ✅ | ✅ | ✅ | | | orders | Organization orders | ✅ | ✅ | ✅ | ✅ | ✅ | | | payments | Order payments | ✅ | ✅ | ✅ | ✅ | ✅ | | | invoices | Invoices | ✅ | ✅ | ✅ | ✅ | ✅ | | | serials | Invoice serials | ✅ | ✅ | ✅ | ✅ | ✅ | | | paymentMethods | Invoice payment methods | ✅ | ✅ | ✅ | ✅ | ✅ | | contacts | customers | Organization customers | ✅ | ✅ | ✅ | ✅ | ✅ | | | groups | Customer groups | ✅ | ✅ | ✅ | ✅ | ✅ | | | providers | Organization providers | ✅ | ✅ | ✅ | ✅ | ✅ | | | addresses | Contact addresses | ✅ | ✅ | ✅ | ✅ | ✅ | | | activities | Contact activities | ✅ | ✅ | ✅ | ✅ | ✅ | | ubications | stores | Organization stores | ✅ | ✅ | ✅ | ✅ | ✅ | | | warehouses | Organization warehouses | ✅ | ✅ | ✅ | ✅ | ✅ | | | corners | Organization corners | ✅ | ✅ | ✅ | ✅ | ✅ | | ecommerce | stores | Organization online stores | ✅ | ✅ | ✅ | ✅ | ✅ |

[Authorization] Check client scopes

Check client permissions importing validate function:

/* Import validation service */
const { validate } = require('@emarketflows/javascript-sdk');

/* Check client scopes with Auth2.0 authorization service */
const isValid = await validate('super:contacts', 'list:providers');

console.log(`Client has super:contacts and list:providers scopes? ${isValid}`);

/**
 * Output if client has scopes: 
 * Client has super:contacts and list:providers scopes? true
 * 
 * Output if client hasn't scopes:
 * Client has super:contacts and list:providers scopes? false
*/

Copyright 2024 @ eMarket Flows. All rights reserved.