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

primetrust-v2

v1.1.5

Published

Primetrust V2 API client

Downloads

6

Readme

PrimeTrustV2 Node

PrimeTrust V2 Node Client.

API Documentation

Installation

primetrust-v2 is available on NPM.

npm i primetrust-v2 --save

API Resources

Check the complete list of common use cases for the Primetrust API.

Getting started

var Client = require("primetrust-v2").Client;

const primetrust = new Client({
    userId: process.env.PRIMETRUST_SERVICE_USER_UUID, // optional UUIDv4 use as X-Idempotent-ID
    username: process.env.PRIMETRUST_SERVICE_USERNAME,
    password: process.env.PRIMETRUST_SERVICE_PASSWORD,
    environment: "sandbox" // defaults to 'sandbox'
});

The previous code allows you to integrate with Primetrust solutions and does the following actions:

  • Creates a service user.
  • Creates a JWT for the user authentication.
  • Creates a class abstraction that allows you to call the API.

Making requests

Once you've created a Client, you can make requests using the #get, #post, and #delete methods. These methods return promises containing a response object detailed in the Responses section.

// GET Method
primetrust
  .get("/v2/users")
  .then((res) => console.log(res));

// POST Method
primetrust
  .post("/v2/users",
    {
      "data": {
        "type": "users",
        "attributes": {
          "name": "api_test",
          "email": "[email protected]",
          "password": "api_Test11"  //must contain at least one lowercase letter, uppercase letter, and digit and must be at least eight characters in length.
        }
      }
    })
  .then((res) => console.log(res));

// PATCH Method
Primetrust
  .patch(`/v2/accounts/${account_UUID}/sandbox`,
    {
      "data": {
        "type": "accounts",
        "attributes": {
          "name": "updated_company_name"
        }
      }
    })
  .then((res) => console.log(res));

// DELETE Method
primetrust.delete(`/v2/contacts/${contact_UUID}`);

Setting headers

To set additional headers on a request you can pass an object as the 3rd argument.

For example:

primetrust
    .post(
        "/v2/agreement-previews",
        { 
            data: {
            type: "account",
            "attributes": {...account_attributes}
            } 
        },
        { "X-Idempotent-ID-V2": "a52fcf63-0730-41c3-96e8-7147b5d1fb01" }
    );

Responses

primetrust.get("/v2/users").then(
  function(res) {
    // res.status   => 200
    // res.headers  => Headers { ... }
    // res.body     => Object or String depending on response type
  },
  function(error) {
    // when the server return a status >= 400
    // error.status   => 400
    // error.headers  => Headers { ... }
    // error.body     => Object or String depending on response type
  }
);

Contributing

Bug reports and pull requests are welcome on Github.

Changelog

  • 1.1.5 Headers method expose due to the use case of uploaded documents form.
  • 1.1.4 Patch method added.
  • 1.1.1 Expiration token can be set using process.env.PRIMETRUST_TOKEN_EXPIRATION or set to 1hr by default.
  • 1.1.0 Token Manager Function reference fixed, pagination, filering and querying parse not working in query objects for get requests.