Code Monkey home page Code Monkey logo

node-primetrust's Introduction

PrimeTrust API NodeJS Client

Installation

npm install node-primetrust

Usage

Client initialization

import { PrimeTrustAPIClient } from "primetrust";

const username = "";
const password = "";
const sandbox = false;

const client = new PrimeTrustAPIClient(
    { username, password, sandbox }
);
const response = await client.CreateUser({
    email: "[email protected]",
    name: "Example Example",
    password: "Password-Password",
});

console.log("User created. PrimeTrust ID: %s", response.id);
// GET /v2/users
const response = await client.GetUsers();

console.log("All Users: %o", response);
// GET /v2/users/current
const response = await client.GetCurrentUser();

console.log("Current User: %o", response);
// POST /v2/accounts
const contactPhoneNoSMS: PTContactPhone = {
    country: "US",
    number: "1231234567",
    sms: false
}

const contactPhoneWithSMS: PTContactPhone = {
    country: "US",
    number: "1231234567",
    sms: true
}

const contactAddressCorporate: PTContactAddress = {
    street1: "Example Street",
    street2: "Example Building",
    postalCode: "12345-1234",
    city: "Las Vegas",
    region: "Nevada",
    country: "US"
}

const contactAddressPersonal: PTContactAddress = {
    street1: "Example Street",
    street2: "Example Building, Suite 123",
    postalCode: "12345-1234",
    city: "Las Vegas",
    region: "Nevada",
    country: "US"
}

const contactPerson1: PTContactNaturalPerson = {
    name: "Example Person 1",
    email: "[email protected]",
    taxIdNumber: "123-123-123",
    taxCountry: "US",
    dateOfBirth: "1900-01-01",
    sex: "male",
    label: "CEO",
    primaryPhoneNumber: contactPhoneWithSMS,
    primaryAddress: contactAddressPersonal,
}

const acccountOwner: PTAccountOwner = {
    type: "company",
    name: "Example Company LTD",
    email: "[email protected]",
    taxIdNumber: "1234567890",
    taxCountry: "US", // ISO 3166-1 alpha-2 code (https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2)
    regionOfFormation: "Nevada",
    primaryPhoneNumber: contactPhoneNoSMS,
    primaryAddress: contactAddressCorporate,
    relatedContacts: [
        {...contactPerson1}
    ]
}

const response = await client.CreateAccount({
    type: "custodial",
    name: "Example Company Account",
    authorizedSignature: "Example Person",
    owner: acccountOwner,
    
});

console.log("Account created. PrimeTrust ID: %s", response.id);
// GET /v2/accounts
const response = await client.GetAccounts();

console.log("All Accounts: %o", response);
// GET v2/account-cash-totals?account.id=<accountId>
const account = "0f89212d-1578-4e3e-a865-dc77a6f2a505";
const response = await client.GetAccountFiatBalance({ account });

console.log("Account Balance: %o", response);
// GET /v2/account-asset-totals?account.id=<accountId>
const account = "0f89212d-1578-4e3e-a865-dc77a6f2a505";
const response = await client.GetAccountCryptoBalance({ account });

console.log("Account Balance: %o", response);
// POST v2/uploaded-documents
import fs from "fs";

const response = await client.UploadDocument({
    contactId: "1234-123456-1234545656456456456",
    label: "Example Document",
    description: "Optional Description",
    fileData: fs.readFileSync('/path/to/file'),
});

console.log("User created. PrimeTrust ID: %s", response.id);

node-primetrust's People

Contributors

xtovski avatar

Watchers

James Cloos avatar

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.