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

everest-tms-api

v1.4.13

Published

Package that allows you to easily interact with the Everest TMS.

Downloads

271

Readme

Welcome to everest-tms-api

This is a powerful Node.js package that allows you to easily interact with the TMS Everest. This package has been created by COGEPART GROUP and available for open-source development. You are authorized to fork and participate to the package evolution.

🚀 Get started

Installation

$ npm install everest-tms-api
// or
$ yarn add everest-tms-api

Code

import { EverestApi } from 'everest-tms-api';

const api = new EverestApi({
  endpoint: process.env.API_ENDPOINT_URL,
  client_id: process.env.API_CLIENT_ID,
  client_secret: process.env.API_CLIENT_SECRET,
});

api.authenticate().then(async () => {
  const result = await api.getInfos();
  console.log(result);
});

👾 Usage

This all package is based on the Everest API documentation. | Type | Enabled | | ---------------- | :-----: | | General routes | ✅ | | Missions routes | ✅ | | Clients routes | ✅ | | Agents routes | ✅ | | Invoices routes | ✅ | | Contacts routes | ✅ | | Models | ✅ | | Webhooks | ✅ |


Configuration

When you invoke the EverestApi class, who have to give some parameters from your Everest API:

  • endpoint: "https://[company].everst.io/api" (type: string. You can find it from your everest dashboard on uri /admin/api)
  • client_id: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" (type: string. You can find it from your everest dashboard on uri /admin/api)
  • client_secret: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" (type: string. You can find it from your everest dashboard on uri /admin/api)
  • timeout: 10000 (type: number. timeout is in milliseconds, 10000 is 10s)

Module

Import the class EverestApi from the package and run it with your configuration.

import { EverestApi } from 'everest-tms-api';

const api = new EverestApi({
  endpoint: process.env.API_ENDPOINT_URL,
  client_id: process.env.API_CLIENT_ID,
  client_secret: process.env.API_CLIENT_SECRET,
});

Now, you have to authenticate yourself with this line:

const api = new EverestApi({...});
await api.authenticate();

Then, you can call the route you want from the api class module initialized and authenticated.

Example

For example, if we want to create a new agent, we need to do that (from an async function (Promise)):

const api = new EverestApi({...});
await api.authenticate();
await api.createAgent({
    email: `[email protected]`,
    first_name: 'Léon',
    last_name: 'LEFEBVRE',
    password: "#abcdefg&123456789!",
    password_repeat: "#abcdefg&123456789!",
    address_line1: '1 Example road, London, UK',
})

Webhooks

For Hooks, types has been created based on the Everest API documentation, you can import them from the library like this:

import { IEverestHook } from 'everest-tms-api';

const result = '{from webhook [agent_deleted]}' as IEverestHook;

switch (result.event) {
  case HookEnum.agent_deleted:
    console.log(result.agent_id);
    break;
  case HookEnum.agent_created:
    console.log(result.available);
    break;
  default:
    console.log('Webhook not recognized');
}

⚠️ WARNING: BE CAREFUL ENUMS FROM STATUS / TYPES!. Some values like status or types are not based on enums defined in the queries/mutations typed in this library due to default API REST from Everest. You can use the index enum if you want to avoid that (like the example below).

import { IEverestHook } from 'everest-tms-api';

const result = '{from webhook [invoice_created]}';
const type = result.type; // In this example, type is equal to 1 (INVOICE)
return Object.values(EverestInvoiceTypeEnum)[
  result.type
] as EverestInvoiceTypeEnum;

🚦 Tests

First, run the yarn command from the root of this project, and add a .env file:

NODE_ENV="dev"
API_ENDPOINT_URL="https://[company].everst.io/api"
API_CLIENT_ID="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
API_CLIENT_SECRET="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"

⚠️ WARNING: MAKE SURE YOU ARE IN PREPROD / DEV ENVIRONMENT!. Tests will create some resources on your environment, don't run tests on prod and prefer use tests on a sandbox env !

Then test all the app with jest (100% coverage), you need to run this command line:

$ yarn test

⚔️ Limitations

Be careful about dates given by Everest, the format is timestamp based on unix system (in seconds) and the JS timestamp format is based on milliseconds format. From all timestamps received from Everest, you can apply this code (consider in this example everestUnixTimestamp is a date from everest):

console.log(everestUnixTimestamp); // 1672531200 (as Sunday 1 January 2023 00:00:00 GMT+01:00)
const date = new Date(everestUnixTimestamp * 1000); // Converted in a JS datetime (based on milliseconds timestamp)

License

This package is MIT licensed.