LLIu33 / node-primetrust

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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: "example@example.org",
    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: "example@example.org",
    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: "info@example.org",
    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);

About

License:Apache License 2.0